本文整理汇总了Java中com.wm.lang.ns.NSName类的典型用法代码示例。如果您正苦于以下问题:Java NSName类的具体用法?Java NSName怎么用?Java NSName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSName类属于com.wm.lang.ns包,在下文中一共展示了NSName类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:19,代码来源:StubManager.java
示例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));
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:17,代码来源:StubManagerTest.java
示例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"));
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:25,代码来源:AOPChainProcessorTest.java
示例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);
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:21,代码来源:AOPChainProcessorTest.java
示例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);
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:20,代码来源:AOPChainProcessorTest.java
示例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);
}
}
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:28,代码来源:ServiceHelper.java
示例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;
}
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:27,代码来源:ServiceHelper.java
示例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;
}
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:30,代码来源:ServiceHelper.java
示例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;
}
开发者ID:Permafrost,项目名称:TundraHTTP.java,代码行数:25,代码来源:HTTPRoute.java
示例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;
}
开发者ID:Permafrost,项目名称:TundraTN.java,代码行数:33,代码来源:CallableGuaranteedJob.java
示例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);
}
}
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:12,代码来源:StubManager.java
示例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));
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:10,代码来源:StubManagerTest.java
示例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;
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:11,代码来源:StubManagerTest.java
示例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);
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:37,代码来源:AOPChainProcessorTest.java
示例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();
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:37,代码来源:AOPChainProcessorTest.java
示例16: ReactiveServiceThread
import com.wm.lang.ns.NSName; //导入依赖的package包/类
public ReactiveServiceThread(NSName service, Session session, IData input,
int threadPriority, boolean interruptable) {
super(service, session, input);
this.cancel = false;
this.run = false;
this.id = null;
this.threadPriority = threadPriority;
this.interruptable = interruptable;
}
开发者ID:teivah,项目名称:reactiveWM,代码行数:10,代码来源:ReactiveServiceThread.java
示例17: invoke_thread
import com.wm.lang.ns.NSName; //导入依赖的package包/类
public static final void invoke_thread (IData pipeline)
throws ServiceException
{
// --- <<IS-START(invoke_thread)>> ---
// @sigtype java 3.5
// [i] field:0:required service
// [i] field:0:required data
// [i] record:0:required in
// [i] object:0:required obj
IDataHashCursor idc = pipeline.getHashCursor();
idc.first( "service" );
String svc_name = (String) idc.getValue();
try
{
NSName nsName = NSName.create(svc_name);
ServiceThread thrd = Service.doThreadInvoke(nsName, pipeline);
thrd.getData();
}
catch (Exception e)
{
throw new ServiceException(e.getMessage());
}
idc.destroy();
// --- <<IS-END>> ---
}
开发者ID:iandrosov,项目名称:SimpleToolBox,代码行数:29,代码来源:service.java
示例18: isRegisteredService
import com.wm.lang.ns.NSName; //导入依赖的package包/类
protected boolean isRegisteredService(String svcName) {
NSName name = NSName.create(svcName);
return Namespace.getService(name) != null;
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:5,代码来源:StubManager.java
示例19: getBaseService
import com.wm.lang.ns.NSName; //导入依赖的package包/类
private BaseService getBaseService(String svcName) {
BaseService baseService = mock(BaseService.class);
when(baseService.getNSName()).thenReturn(NSName.create(svcName));
return baseService;
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:6,代码来源:BddInterceptorTest.java
示例20: shouldMatchCorrectNamespacePackage
import com.wm.lang.ns.NSName; //导入依赖的package包/类
@Test
public void shouldMatchCorrectNamespacePackage() {
NSName nsnTestService = NSName.create("org.wmaop.pub:testService");
NSName nsnBarService = NSName.create(PUB_FOO_BAR);
Package pkg1 = mock(Package.class);
when(pkg1.getName()).thenReturn("pkg1");
Package pkg2 = mock(Package.class);
when(pkg2.getName()).thenReturn("pkg2");
PowerMockito.mockStatic(InvokeState.class);
InvokeState mockInvokeState = mock(InvokeState.class);
when(InvokeState.getCurrentState()).thenReturn(mockInvokeState);
NSService svcTest = mock(NSService.class);
when(svcTest.getNSName()).thenReturn(nsnTestService);
when(svcTest.getPackage()).thenReturn(pkg1);
NSService svcBar = mock(NSService.class);
when(svcBar.getNSName()).thenReturn(nsnBarService);
when(svcBar.getPackage()).thenReturn(pkg2);
Stack<NSService> callStack = new Stack<>();
callStack.push(svcTest);
callStack.push(svcBar);
when(mockInvokeState.getCallStack()).thenReturn(callStack);
FlowPosition fp = new FlowPosition(InterceptPoint.INVOKE, PUB_FOO_BAR);
assertFalse(new CallingServicePositionMatcher("id", PUB_FOO_BAR, null).match(null).isMatch());
assertFalse(new CallingServicePositionMatcher("id", PUB_FOO_BAR, null).match( new FlowPosition(InterceptPoint.INVOKE, "nother:service")).isMatch());
// Check for none or partial namespace and service match
assertTrue(new CallingServicePositionMatcher("id", PUB_FOO_BAR, null).match(fp).isMatch());
assertTrue(new CallingServicePositionMatcher("id", PUB_FOO_BAR, "org.wmaop").match(fp).isMatch());
assertTrue(new CallingServicePositionMatcher("id", PUB_FOO_BAR, "org.wmaop.pub").match(fp).isMatch());
assertTrue(new CallingServicePositionMatcher("id", PUB_FOO_BAR, "org.wmaop.pub:testService").match(fp).isMatch());
// Match on the calling package
assertTrue(new CallingServicePositionMatcher("id", PUB_FOO_BAR, "pkg1").match(fp).isMatch());
// Package for this call which is irrelevant
assertFalse(new CallingServicePositionMatcher("id", PUB_FOO_BAR, "pkg2").match(fp).isMatch());
// Matching on some arbitary service
assertFalse(new CallingServicePositionMatcher("id", PUB_FOO_BAR, "org.wmaop.pub:anotherService").match(fp).isMatch());
CallingServicePositionMatcher cspm = new CallingServicePositionMatcher("id", PUB_FOO_BAR, "org.wmaop.pub:anotherService");
cspm.toString();
assertEquals(PUB_FOO_BAR, cspm.toMap().get("serviceName"));
assertEquals(PUB_FOO_BAR, cspm.getServiceName());
}
开发者ID:wmaop,项目名称:wm-aop,代码行数:52,代码来源:CallingServicePositionMatcherTest.java
注:本文中的com.wm.lang.ns.NSName类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论