本文整理汇总了Java中com.wm.lang.ns.NSName类的典型用法代码示例。如果您正苦于以下问题:Java NSName类的具体用法?Java NSName怎么用?Java NSName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSName类属于com.wm.lang.ns包,在下文中一共展示了NSName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerStubService
import com.wm.lang.ns.NSName; //导入依赖的package包/类
public void registerStubService(String... svcNames) {
if (isStubPackageMissing()) {
createStubPackage();
}
for (String svcName : svcNames) {
if (isRegisteredService(svcName)) {
continue; // existing service so no stub required
}
try {
NSName name = NSName.create(svcName);
NSServiceType serviceType = NSServiceType.create("flow", "unknown");
ServerAPI.registerService(SUPPORTING_PKG, name, true, serviceType , null, null, null);
stubbedServices.add(svcName);
} catch (ServiceSetupException e) {
throw new StubLifecycleException("Error creating stub service for " + svcName, e);
}
}
}
示例2: shouldClearStubs
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldClearStubs() throws NSException {
Package pkg = mockPackage();
Namespace ns = mock(Namespace.class);
Vector<NSNode> nodes = new Vector<NSNode>();
nodes.add(mock(NSNode.class));
when(ns.getNodes(pkg)).thenReturn(nodes);
PowerMockito.mockStatic(Namespace.class);
PowerMockito.when(Namespace.current()).thenReturn(ns);
stubManager.clearStubs();
verify(ns, times(1)).deleteNode((NSName) any(), eq(true), eq(pkg));
}
示例3: shouldExecuteAlwaysTrueReponse
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldExecuteAlwaysTrueReponse() throws Exception {
ClassLoader classLoader = this.getClass().getClassLoader();
AOPChainProcessor cp = new AOPChainProcessor(new AdviceManager(), mock(StubManager.class));
cp.setEnabled(true);
FlowPositionMatcherImpl serviceNameMatcher = new FlowPositionMatcherImpl("my id", "pre:foo");
CannedResponseInterceptor interceptor = new CannedResponseInterceptor(classLoader.getResourceAsStream("cannedResponse.xml"));
ServicePipelinePointCut pointCut = new ServicePipelinePointCut(serviceNameMatcher, new AlwaysTrueMatcher<IData>("my id"), InterceptPoint.INVOKE);
Advice advice = new Advice("intercept", new GlobalRemit(), pointCut, interceptor);
cp.getAdviceManager().registerAdvice(advice);
// Pipeline mocking
IData idata = new IDataXMLCoder().decode(classLoader.getResourceAsStream("pipeline.xml"));
BaseService baseService = mock(BaseService.class);
when(baseService.getNSName()).thenReturn(NSName.create("pre:foo"));
ServiceStatus ss = mock(ServiceStatus.class);
Iterator<InvokeChainProcessor> chainIterator = new ArrayList<InvokeChainProcessor>().iterator();
// Execute
cp.process(chainIterator, baseService, idata, ss);
assertTrue(new String(new IDataXMLCoder().encodeToBytes(idata)).contains("\"apple\">alpha"));
}
示例4: shouldExecuteNextChainStepWhenNotInvoked
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldExecuteNextChainStepWhenNotInvoked() throws Exception {
ClassLoader classLoader = this.getClass().getClassLoader();
AOPChainProcessor cp = new AOPChainProcessor();
cp.setEnabled(true);
// Pipeline mocking
IData idata = new IDataXMLCoder().decode(classLoader.getResourceAsStream("pipeline.xml"));
BaseService baseService = mock(BaseService.class);
when(baseService.getNSName()).thenReturn(NSName.create("pre:foo"));
ServiceStatus ss = mock(ServiceStatus.class);
InvokeChainProcessor icp = mock(InvokeChainProcessor.class);
Iterator<InvokeChainProcessor> chainIterator = Arrays.asList(icp).iterator();
// Execute
cp.process(chainIterator, baseService, idata, ss);
verify(icp, times(1)).process(chainIterator, baseService, idata, ss);
}
示例5: shouldExecuteNextChainStepWhenDisabled
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldExecuteNextChainStepWhenDisabled() throws Exception {
ClassLoader classLoader = this.getClass().getClassLoader();
AOPChainProcessor cp = new AOPChainProcessor();
// Pipeline mocking
IData idata = new IDataXMLCoder().decode(classLoader.getResourceAsStream("pipeline.xml"));
BaseService baseService = mock(BaseService.class);
when(baseService.getNSName()).thenReturn(NSName.create("pre:foo"));
ServiceStatus ss = mock(ServiceStatus.class);
InvokeChainProcessor icp = mock(InvokeChainProcessor.class);
Iterator<InvokeChainProcessor> chainIterator = Arrays.asList(icp).iterator();
// Execute
cp.process(chainIterator, baseService, idata, ss);
verify(icp, times(1)).process(chainIterator, baseService, idata, ss);
}
示例6: create
import com.wm.lang.ns.NSName; //导入依赖的package包/类
/**
* Creates a new service in the given package with the given name.
*
* @param packageName The name of the package to create the service in.
* @param serviceName The fully-qualified name of the service to be created.
* @param type The type of service to be created.
* @param subtype The subtype of service to be created.
* @throws ServiceException If an error creating the service occurs.
*/
private static void create(String packageName, String serviceName, String type, String subtype) throws ServiceException {
if (!PackageHelper.exists(packageName)) {
throw new IllegalArgumentException("package does not exist: " + packageName);
}
if (NodeHelper.exists(serviceName)) throw new IllegalArgumentException("node already exists: " + serviceName);
NSName service = NSName.create(serviceName);
if (type == null) type = NSServiceType.SVC_FLOW;
if (subtype == null) subtype = NSServiceType.SVCSUB_UNKNOWN;
NSServiceType serviceType = NSServiceType.create(type, subtype);
try {
ServerAPI.registerService(packageName, service, true, serviceType, null, null, null);
} catch (ServiceSetupException ex) {
ExceptionHelper.raise(ex);
}
}
示例7: reflect
import com.wm.lang.ns.NSName; //导入依赖的package包/类
/**
* Returns information about the service with the given name.
*
* @param serviceName The name of the service to be reflected on.
* @return An IData document containing information about the service.
*/
public static IData reflect(String serviceName) {
if (serviceName == null) return null;
BaseService service = Namespace.getService(NSName.create(serviceName));
if (service == null) return null;
IData output = IDataFactory.create();
IDataCursor cursor = output.getCursor();
IDataUtil.put(cursor, "name", serviceName);
IDataUtil.put(cursor, "type", service.getServiceType().getType());
IDataUtil.put(cursor, "package", service.getPackageName());
IDataHelper.put(cursor, "description", service.getComment(), false);
IDataUtil.put(cursor, "references", getReferences(service.getNSName().getFullName()));
IDataUtil.put(cursor, "dependents", getDependents(service.getNSName().getFullName()));
cursor.destroy();
return output;
}
示例8: invoke
import com.wm.lang.ns.NSName; //导入依赖的package包/类
/**
* Invokes the given service with the given pipeline synchronously.
*
* @param service The service to be invoked.
* @param pipeline The input pipeline used when invoking the service.
* @param raise If true will rethrow exceptions thrown by the invoked service.
* @param clone If true the pipeline will first be cloned before being used by the invocation.
* @param logError Logs a caught exception if true and raise is false, otherwise exception is not logged.
* @return The output pipeline returned by the service invocation.
* @throws ServiceException If raise is true and the service throws an exception while being invoked.
*/
public static IData invoke(String service, IData pipeline, boolean raise, boolean clone, boolean logError) throws ServiceException {
if (service != null) {
if (pipeline == null) pipeline = IDataFactory.create();
try {
IDataUtil.merge(Service.doInvoke(NSName.create(service), normalize(pipeline, clone)), pipeline);
} catch (Exception exception) {
if (raise) {
ExceptionHelper.raise(exception);
} else {
pipeline = addExceptionToPipeline(pipeline, exception);
if (logError) ServerAPI.logError(exception);
}
}
}
return pipeline;
}
示例9: initialize
import com.wm.lang.ns.NSName; //导入依赖的package包/类
/**
* Initializes a new routing instruction.
*
* @param method The HTTP method for the instruction.
* @param uri The URI for the instruction.
* @param target The target for the instruction.
* @param description The description of the instruction.
* @param source The source file of the instruction.
*/
protected void initialize(HTTPMethod method, UriTemplate uri, String target, String description, File source) {
this.method = method;
this.uri = uri;
this.target = target;
java.util.regex.Matcher matcher = SERVICE_PATTERN.matcher(target);
isInvoke = matcher.matches();
if (isInvoke) {
service = NSName.create(target);
}
this.description = description;
this.source = source;
}
示例10: CallableGuaranteedJob
import com.wm.lang.ns.NSName; //导入依赖的package包/类
/**
* Creates a new CallableGuaranteedJob which when called invokes the given service against the given job.
*
* @param queue The delivery queue on which the job queued.
* @param job The job to be processed.
* @param service The service to be invoked to process the given job.
* @param session The session used when invoking the given service.
* @param pipeline The input pipeline used when invoking the given service.
* @param retryLimit The number of retries this job should attempt.
* @param retryFactor The factor used to extend the time to wait on each retry.
* @param timeToWait The time to wait between each retry.
* @param suspend Whether to suspend the delivery queue on job retry exhaustion.
* @param exhaustedStatus The status set on the related bizdoc when all retries of the job are exhaused.
*/
public CallableGuaranteedJob(DeliveryQueue queue, GuaranteedJob job, NSName service, Session session, IData pipeline, int retryLimit, float retryFactor, Duration timeToWait, boolean suspend, String exhaustedStatus) {
if (queue == null) throw new NullPointerException("queue must not be null");
if (job == null) throw new NullPointerException("job must not be null");
if (service == null) throw new NullPointerException("service must not be null");
if (retryFactor < 1.0f) throw new IllegalArgumentException("retryFactor must not be less than one");
this.queue = queue;
this.job = job;
this.service = service;
this.session = session;
this.pipeline = pipeline == null ? IDataFactory.create() : IDataHelper.duplicate(pipeline);
this.retryLimit = retryLimit;
this.retryFactor = retryFactor;
this.timeToWait = timeToWait;
this.suspend = suspend;
this.statusSilence = DeliveryQueueHelper.getStatusSilence(queue);
this.exhaustedStatus = exhaustedStatus;
}
示例11: unregisterStubService
import com.wm.lang.ns.NSName; //导入依赖的package包/类
public void unregisterStubService(String svcName) throws NSException {
Package pkg = PackageManager.getPackage(SUPPORTING_PKG);
if (pkg != null) {
NSName name = NSName.create(svcName);
BaseService svc = Namespace.getService(name);
if (svc != null && SUPPORTING_PKG.equals(svc.getPackageName())) {
Namespace.current().deleteNode(name, true, pkg);
stubbedServices.remove(svcName);
}
}
}
示例12: shouldUnregisterStubService
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldUnregisterStubService() throws NSException {
Namespace ns = mockNamespace();
Package pkg = mockPackage();
stubManager.unregisterStubService(SERVICE_NAME);
verify(ns, times(1)).deleteNode((NSName) any(), eq(true), eq(pkg));
}
示例13: mockNamespace
import com.wm.lang.ns.NSName; //导入依赖的package包/类
private Namespace mockNamespace() {
BaseService svc = mock(BaseService.class);
when(svc.getPackageName()).thenReturn(StubManager.SUPPORTING_PKG);
Namespace ns = mock(Namespace.class);
PowerMockito.mockStatic(Namespace.class);
PowerMockito.when(Namespace.getService((NSName) any())).thenReturn(svc);
PowerMockito.when(Namespace.current()).thenReturn(ns);
return ns;
}
示例14: shouldSetException
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldSetException() throws Exception{
ClassLoader classLoader = this.getClass().getClassLoader();
AOPChainProcessor cp = new AOPChainProcessor(new AdviceManager(), mock(StubManager.class));
cp.setEnabled(true);
FlowPositionMatcherImpl serviceNameMatcher = new FlowPositionMatcherImpl("my id", "pre:foo");
Exception exception = new Exception();
Interceptor interceptor = new ExceptionInterceptor(exception );
ServicePipelinePointCut pointCut = new ServicePipelinePointCut(serviceNameMatcher, new AlwaysTrueMatcher<IData>("my id"), InterceptPoint.INVOKE);
Advice advice = new Advice("intercept", new GlobalRemit(), pointCut, interceptor);
cp.getAdviceManager().registerAdvice(advice);
// Pipeline mocking
IData idata = new IDataXMLCoder().decode(classLoader.getResourceAsStream("pipeline.xml"));
BaseService baseService = mock(BaseService.class);
when(baseService.getNSName()).thenReturn(NSName.create("pre:foo"));
ServiceStatus ss = mock(ServiceStatus.class);
Iterator<InvokeChainProcessor> chainIterator = new ArrayList<InvokeChainProcessor>().iterator();
// Execute
cp.process(chainIterator, baseService, idata, ss);
verify(ss, times(1)).setException(exception);
cp.getAdviceManager().unregisterAdvice(advice);
pointCut = new ServicePipelinePointCut(serviceNameMatcher, new AlwaysTrueMatcher<IData>("my id"), InterceptPoint.BEFORE);
advice = new Advice("intercept", new GlobalRemit(), pointCut, interceptor);
cp.getAdviceManager().registerAdvice(advice);
// Execute
cp.process(chainIterator, baseService, idata, ss);
verify(ss, times(2)).setException(exception);
}
示例15: shouldFireMultiBeforeAfterAndSingleInvoke
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldFireMultiBeforeAfterAndSingleInvoke() throws ServerException, IOException {
AOPChainProcessor cp = new AOPChainProcessor(new AdviceManager(), mock(StubManager.class));
cp.getAdviceManager().registerAdvice(getCannedAdvice("err1", InterceptPoint.INVOKE, "a == 99"));
cp.getAdviceManager().registerAdvice(getCannedAdvice("pre1", InterceptPoint.BEFORE, null));
cp.getAdviceManager().registerAdvice(getCannedAdvice("pre2", InterceptPoint.BEFORE, null));
cp.getAdviceManager().registerAdvice(getCannedAdvice("inv1", InterceptPoint.INVOKE, "a == 1"));
cp.getAdviceManager().registerAdvice(getCannedAdvice("inv2", InterceptPoint.INVOKE, "a == 2"));
cp.getAdviceManager().registerAdvice(getCannedAdvice("inv3", InterceptPoint.INVOKE, "a == 3"));
cp.getAdviceManager().registerAdvice(getCannedAdvice("post1", InterceptPoint.AFTER, null));
cp.getAdviceManager().registerAdvice(getCannedAdvice("err2", InterceptPoint.INVOKE, "a == 99"));
cp.getAdviceManager().registerAdvice(getCannedAdvice("post2", InterceptPoint.AFTER, null));
IData idata = IDataFactory.create();
IDataUtil.put(idata.getCursor(), "a", 2);
BaseService baseService = mock(BaseService.class);
when(baseService.getNSName()).thenReturn(NSName.create("pre:foo"));
ServiceStatus ss = mock(ServiceStatus.class);
Iterator<InvokeChainProcessor> chainIterator = new ArrayList<InvokeChainProcessor>().iterator();
// Execute
cp.setEnabled(true);
cp.process(chainIterator, baseService, idata, ss);
assertEquals(1, getInvokeCount(cp, "pre1"));
assertEquals(1, getInvokeCount(cp, "pre2"));
assertEquals(0, getInvokeCount(cp, "inv1"));
assertEquals(1, getInvokeCount(cp, "inv2"));
assertEquals(0, getInvokeCount(cp, "inv3"));
assertEquals(1, getInvokeCount(cp, "post1"));
assertEquals(1, getInvokeCount(cp, "post2"));
cp.getAdviceManager().clearAdvice();
}