Package org.apache.hivemind

Examples of org.apache.hivemind.ServiceImplementationFactory


        DataItem d = (DataItem) l.get(0);

        assertEquals("wesley", d.getName());
        assertEquals(15, d.getCount());

        ServiceImplementationFactory builderFactory =
            (ServiceImplementationFactory) r.getService(
                "hivemind.BuilderFactory",
                ServiceImplementationFactory.class);

        assertSame(builderFactory, d.getFactory());
View Full Code Here


        MockControl factoryPointControl = newControl(ServicePoint.class);
        ServicePoint factoryPoint = (ServicePoint) factoryPointControl.getMock();

        MockControl factoryControl = newControl(ServiceImplementationFactory.class);
        ServiceImplementationFactory factory =
            (ServiceImplementationFactory) factoryControl.getMock();

        MockControl pointControl = newControl(ServicePoint.class);
        ServicePoint point = (ServicePoint) pointControl.getMock();

        InvokeFactoryServiceConstructor c = new InvokeFactoryServiceConstructor();

        MockControl errorHandlerControl = newControl(ErrorHandler.class);
        ErrorHandler eh = (ErrorHandler) errorHandlerControl.getMock();

        // Training !

        point.getServiceLog();
        pointControl.setReturnValue(LOG);

        module.getServicePoint("foo.bar.Baz");
        moduleControl.setReturnValue(factoryPoint);

        factoryPoint.getParametersCount();
        factoryPointControl.setReturnValue(Occurances.REQUIRED);

        factoryPoint.getService(ServiceImplementationFactory.class);
        factoryPointControl.setReturnValue(factory);

        factoryPoint.getParametersSchema();
        factoryPointControl.setReturnValue(null);

        module.getErrorHandler();
        moduleControl.setReturnValue(eh);

        String message =
            ImplMessages.wrongNumberOfParameters("foo.bar.Baz", 0, Occurances.REQUIRED);

        eh.error(LOG, message, null, null);

        point.getExtensionPointId();
        pointControl.setReturnValue("bleep.Bloop");

        point.getServiceInterface();
        pointControl.setReturnValue(Runnable.class);

        factory.createCoreServiceImplementation(
            "bleep.Bloop",
            Runnable.class,
            LOG,
            module,
            Collections.EMPTY_LIST);
View Full Code Here

        DataItem d = (DataItem) l.get(0);

        assertEquals("builder", d.getName());
        assertEquals(5, d.getCount());

        ServiceImplementationFactory builderFactory =
            (ServiceImplementationFactory) r.getService(
                "hivemind.BuilderFactory",
                ServiceImplementationFactory.class);

        assertSame(builderFactory, d.getFactory());
View Full Code Here

        DataItem d = (DataItem) l.get(0);

        assertEquals("builder", d.getName());
        assertEquals(5, d.getCount());

        ServiceImplementationFactory builderFactory =
            (ServiceImplementationFactory) r.getService(
                "hivemind.BuilderFactory",
                ServiceImplementationFactory.class);

        assertSame(builderFactory, d.getFactory());
View Full Code Here

        DataItem d = (DataItem) l.get(0);

        assertEquals("underworld", d.getName());
        assertEquals(18, d.getCount());

        ServiceImplementationFactory builderFactory =
            (ServiceImplementationFactory) r.getService(
                "hivemind.BuilderFactory",
                ServiceImplementationFactory.class);

        assertSame(builderFactory, d.getFactory());
View Full Code Here

        DataItem d = (DataItem) l.get(0);

        assertEquals("lamb", d.getName());
        assertEquals(95, d.getCount());

        ServiceImplementationFactory builderFactory =
            (ServiceImplementationFactory) r.getService(
                "hivemind.BuilderFactory",
                ServiceImplementationFactory.class);

        assertSame(builderFactory, d.getFactory());
View Full Code Here

        DataItem d = (DataItem) l.get(0);

        assertEquals("wesley", d.getName());
        assertEquals(15, d.getCount());

        ServiceImplementationFactory builderFactory =
            (ServiceImplementationFactory) r.getService(
                "hivemind.BuilderFactory",
                ServiceImplementationFactory.class);

        assertSame(builderFactory, d.getFactory());
View Full Code Here

        MockControl factoryPointControl = newControl(ServicePoint.class);
        ServicePoint factoryPoint = (ServicePoint) factoryPointControl.getMock();

        MockControl factoryControl = newControl(ServiceImplementationFactory.class);
        ServiceImplementationFactory factory = (ServiceImplementationFactory) factoryControl
                .getMock();

        MockControl pointControl = newControl(ServicePoint.class);
        ServicePoint point = (ServicePoint) pointControl.getMock();

        InvokeFactoryServiceConstructor c = new InvokeFactoryServiceConstructor();

        ErrorLog log = (ErrorLog) newMock(ErrorLog.class);

        // Training !

        point.getErrorLog();
        pointControl.setReturnValue(log);

        module.getServicePoint("foo.bar.Baz");
        moduleControl.setReturnValue(factoryPoint);

        factoryPoint.getParametersCount();
        factoryPointControl.setReturnValue(Occurances.REQUIRED);

        factoryPoint.getService(ServiceImplementationFactory.class);
        factoryPointControl.setReturnValue(factory);

        factoryPoint.getParametersSchema();
        factoryPointControl.setReturnValue(null);

        String message = ImplMessages
                .wrongNumberOfParameters("foo.bar.Baz", 0, Occurances.REQUIRED);

        log.error(message, null, null);

        factory.createCoreServiceImplementation(new ServiceImplementationFactoryParametersImpl(
                point, module, Collections.EMPTY_LIST));
        factoryControl.setReturnValue("THE SERVICE");

        replayControls();
View Full Code Here

        expect(factoryParameters.getFirstParameter()).andReturn(factoryParametersList.get(0)).anyTimes();
        expect(factoryParameters.getParameters()).andReturn(factoryParametersList).anyTimes();
        expect(factoryParameters.getServiceInterface()).andReturn(SomeService.class).anyTimes();
        expect(factoryParameters.getServiceId()).andReturn("someService");
        replay(factoryParameters);
        ServiceImplementationFactory rootService = createMock(ServiceImplementationFactory.class);
        final SomeService realCreatedService = createMock(SomeService.class);
        expect(rootService.createCoreServiceImplementation(isA(ServiceImplementationFactoryParameters.class))).
            andAnswer(new IAnswer<Object>() {

                public Object answer() throws Throwable {
                    ServiceImplementationFactoryParameters object = (ServiceImplementationFactoryParameters) getCurrentArguments()[0];

                    // make sure being passed the proxy
                    assertTrue(Proxy.isProxyClass(object.getInvokingModule().getClass()), "Did not get passed a module proxy");
                    assertTrue(object.getInvokingModule().containsService(dependentServiceClass),
                            dependentServiceClass+": module does not have service with this interface");
//        TODO            List dependentService = (List) object.getInvokingModule().getService(dependentServiceClass);
                    return realCreatedService;
                }

            });
        replay(rootService, realCreatedService);

        InterceptorStack stack = new InterceptorStackImpl(log, servicePoint, rootService);

        // create the interceptor
        factory.createInterceptor(stack, invokingModule, parameters);
        ServiceImplementationFactory intercepted = (ServiceImplementationFactory) stack.peek();

        assertNotNull(intercepted);

        SomeService result = (SomeService) intercepted.createCoreServiceImplementation(factoryParameters);
        MockSwitcher switcher = (MockSwitcher) Proxy.getInvocationHandler(result);
        assertSame(switcher.getRealService(), realCreatedService);
        assertSame(switcher.getUnderlyingService(), realCreatedService);

        // now tell factory that we always want the mock.
View Full Code Here

     */
    @SuppressWarnings({ "unused", "unchecked" })
    public void createInterceptor(InterceptorStack stack, Module invokingModule, List parameters) {
        Log log = stack.getServiceLog();

        ServiceImplementationFactory delegate = (ServiceImplementationFactory) stack.peek();
        InvocationHandler handler = new ServiceImplementationFactoryInterceptor(log, delegate);

        Object interceptor =
            Proxy.newProxyInstance(
                invokingModule.getClassResolver().getClassLoader(),
View Full Code Here

TOP

Related Classes of org.apache.hivemind.ServiceImplementationFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.