Search in sources :

Example 51 with ServiceName

use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.

the class DefaultThreadLocalInterceptorChainTest method test4.

public void test4() throws Throwable {
    final ChainStack stack = new ChainStack();
    final TestInterceptorInvoker interceptor1 = new TestInterceptorInvoker(stack);
    final TestInterceptorInvoker interceptor2 = new TestInterceptorInvoker(stack);
    final TestInterceptorInvoker invoker = new TestInterceptorInvoker(stack, "hoge");
    final InterceptorChainList chainList = new DefaultInterceptorChainList(new Interceptor[] { interceptor1, interceptor2 });
    final DefaultThreadLocalInterceptorChain chain = new DefaultThreadLocalInterceptorChain(new ServiceName("Test", "ChainList"), new ServiceName("Test", "Invoker"));
    ServiceManagerFactory.registerManager("Test");
    ServiceManagerFactory.registerService("Test", "ChainList", chainList);
    ServiceManagerFactory.registerService("Test", "Invoker", invoker);
    ServiceManagerFactory.findManager("Test").createAllService();
    ServiceManagerFactory.findManager("Test").startAllService();
    try {
        Runnable runnable = new Runnable() {

            public void run() {
                stack.clear();
                Object result = null;
                try {
                    result = chain.invokeNext(new DefaultInvocationContext());
                } catch (Throwable th) {
                    fail();
                }
                assertEquals("hoge", result);
                assertEquals(3, stack.upList().size());
                assertEquals(interceptor1, stack.upList().get(0));
                assertEquals(interceptor2, stack.upList().get(1));
                assertEquals(invoker, stack.upList().get(2));
                assertEquals(3, stack.downList().size());
                assertEquals(invoker, stack.downList().get(0));
                assertEquals(interceptor2, stack.downList().get(1));
                assertEquals(interceptor1, stack.downList().get(2));
                assertEquals(0, stack.catchList().size());
            }
        };
        Thread[] threads = new Thread[5];
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new Thread(runnable);
        }
        for (int i = 0; i < threads.length; i++) {
            threads[i].start();
        }
        for (int i = 0; i < threads.length; i++) {
            threads[i].join();
        }
    } finally {
        ServiceManagerFactory.findManager("Test").stopAllService();
        ServiceManagerFactory.findManager("Test").destroyAllService();
        ServiceManagerFactory.unregisterManager("Test");
    }
}
Also used : ServiceName(jp.ossc.nimbus.core.ServiceName)

Example 52 with ServiceName

use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.

the class ServiceNameEditorTest method testSetAsText3.

public void testSetAsText3() throws Exception {
    ServiceNameEditor editor = new ServiceNameEditor();
    editor.setServiceManagerName("Manager1");
    editor.setAsText("Manager2#Service1");
    assertEquals(new ServiceName("Manager2", "Service1"), editor.getValue());
}
Also used : ServiceName(jp.ossc.nimbus.core.ServiceName)

Example 53 with ServiceName

use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.

the class ServiceNameRefArrayEditorTest method testSetValue2.

public void testSetValue2() throws Exception {
    ServiceNameRefArrayEditor editor = new ServiceNameRefArrayEditor();
    editor.setValue(new ServiceNameRef[] { new ServiceNameRef("Service1", new ServiceName("Manager1", "Service1")), new ServiceNameRef("Service2", new ServiceName("Manager2", "Service2")) });
    assertEquals("Service1=Manager1#Service1" + System.getProperty("line.separator") + "Service2=Manager2#Service2", editor.getAsText());
}
Also used : ServiceName(jp.ossc.nimbus.core.ServiceName) ServiceNameRef(jp.ossc.nimbus.core.ServiceNameRef)

Example 54 with ServiceName

use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.

the class ServiceNameRefArrayEditorTest method testSetAsText3.

public void testSetAsText3() throws Exception {
    ServiceNameRefArrayEditor editor = new ServiceNameRefArrayEditor();
    editor.setServiceManagerName("Manager1");
    editor.setAsText("Service1=#Service1\nService2=Manager2#Service2");
    Object val = editor.getValue();
    assertEquals(2, Array.getLength(val));
    assertEquals(new ServiceNameRef("Service1", new ServiceName("Manager1", "Service1")), Array.get(val, 0));
    assertEquals(new ServiceNameRef("Service2", new ServiceName("Manager2", "Service2")), Array.get(val, 1));
}
Also used : ServiceName(jp.ossc.nimbus.core.ServiceName) ServiceNameRef(jp.ossc.nimbus.core.ServiceNameRef)

Example 55 with ServiceName

use of jp.ossc.nimbus.core.ServiceName in project nimbus by nimbus-org.

the class ServiceNameRefArrayEditorTest method testSetValue1.

public void testSetValue1() throws Exception {
    ServiceNameRefArrayEditor editor = new ServiceNameRefArrayEditor();
    editor.setValue(new ServiceNameRef[] { new ServiceNameRef("Service1", new ServiceName("Manager1", "Service1")) });
    assertEquals("Service1=Manager1#Service1", editor.getAsText());
}
Also used : ServiceName(jp.ossc.nimbus.core.ServiceName) ServiceNameRef(jp.ossc.nimbus.core.ServiceNameRef)

Aggregations

ServiceName (jp.ossc.nimbus.core.ServiceName)66 ServiceNameRef (jp.ossc.nimbus.core.ServiceNameRef)13 ServiceNameEditor (jp.ossc.nimbus.beans.ServiceNameEditor)12 DefaultInterceptorChainList (jp.ossc.nimbus.service.aop.DefaultInterceptorChainList)9 DefaultMethodInvocationContext (jp.ossc.nimbus.service.aop.DefaultMethodInvocationContext)8 Interceptor (jp.ossc.nimbus.service.aop.Interceptor)8 InvocationContext (jp.ossc.nimbus.service.aop.InvocationContext)8 FilterChain (javax.servlet.FilterChain)7 InterceptorChain (jp.ossc.nimbus.service.aop.InterceptorChain)7 Map (java.util.Map)6 Properties (java.util.Properties)6 DefaultInterceptorChain (jp.ossc.nimbus.service.aop.DefaultInterceptorChain)6 HashMap (java.util.HashMap)5 ServiceMetaData (jp.ossc.nimbus.core.ServiceMetaData)5 Invoker (jp.ossc.nimbus.service.aop.Invoker)5 Iterator (java.util.Iterator)4 Method (java.lang.reflect.Method)3 ServletConfig (javax.servlet.ServletConfig)3 DefaultThreadLocalInterceptorChain (jp.ossc.nimbus.service.aop.DefaultThreadLocalInterceptorChain)3 DefaultSemaphoreService (jp.ossc.nimbus.service.semaphore.DefaultSemaphoreService)3