Examples of ServiceDef


Examples of org.apache.tapestry5.ioc.def.ServiceDef

        replay();

        ModuleDef md = new DefaultModuleDefImpl(MarkerModule.class, logger, classFactory);

        ServiceDef sd = md.getServiceDef("RedGreeter");

        assertListsEquals(CollectionFactory.newList(sd.getMarkers()), RedMarker.class);

        verify();
    }
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        replay();

        ModuleDef md = new DefaultModuleDefImpl(MarkerModule.class, logger, classFactory);

        ServiceDef sd = md.getServiceDef("SecondRedGreeter");

        assertListsEquals(CollectionFactory.newList(sd.getMarkers()), RedMarker.class);

        verify();
    }
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        replay();

        ModuleDef md = new DefaultModuleDefImpl(MarkerModule.class, logger, classFactory);

        ServiceDef sd = md.getServiceDef("SurprisinglyBlueGreeter");

        // BlueMarker from ServiceBindingOptions, RedMarker from @Marker on class

        Set<Class> markers = sd.getMarkers();

        assertTrue(markers.contains(RedMarker.class));
        assertTrue(markers.contains(BlueMarker.class));
        assertEquals(markers.size(), 2);
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

                : null;

        if (compatibilityMode)
            addServiceDefsForSpringBeans(externalContext);

        ServiceDef applicationContextServiceDef = new ServiceDef()
        {
            public ObjectCreator createServiceCreator(final ServiceBuilderResources resources)
            {
                if (compatibilityMode)
                    return new StaticObjectCreator(externalContext,
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        replay();

        SpringModuleDef moduleDef = new SpringModuleDef(servletContext);

        ServiceDef serviceDef = moduleDef.getServiceDef(SpringModuleDef.SERVICE_ID);

        ObjectCreator serviceCreator = serviceDef.createServiceCreator(resources);

        assertSame(serviceCreator.createObject(), ac);

        verify();

        // Now, let's test for some of the services.

        ServiceDef sd = moduleDef.getServiceDef("ApplicationContext");

        assertEquals(sd.getServiceInterface(), ac.getClass());
        assertEquals(sd.createServiceCreator(null).toString(),
                     "<ObjectCreator for externally configured Spring ApplicationContext>");

        expect((Class)ac.getType("fred")).andReturn(Runnable.class);
        expect(ac.getBean("fred")).andReturn(fred);


        sd = moduleDef.getServiceDef("fred");

        replay();

        assertEquals(sd.getServiceId(), "fred");
        assertEquals(sd.getServiceInterface(), Runnable.class);
        assertEquals(sd.getServiceScope(), ScopeConstants.DEFAULT);
        assertSame(sd.createServiceCreator(null).createObject(), fred);
        assertTrue(sd.getMarkers().isEmpty());
        assertFalse(sd.isEagerLoad());
        assertEquals(sd.createServiceCreator(null).toString(), "ObjectCreator<Spring Bean 'fred'>");

        verify();

        expect((Class)ac.getType("barney")).andReturn(Runnable.class);
        expect(ac.getBean("barney")).andReturn(barney);

        replay();

        sd = moduleDef.getServiceDef("barney");

        assertSame(sd.createServiceCreator(null).createObject(), barney);
    }
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        // Combine service-specific markers with those inherited form the module.
        Set<Class> markers = CollectionFactory.newSet(defaultMarkers);
        markers.addAll(this.markers);

        ServiceDef serviceDef = new ServiceDefImpl(serviceInterface, serviceImplementation, serviceId, markers, scope,
                eagerLoad, preventDecoration, source);

        accumulator.addServiceDef(serviceDef);

        clear();
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        final ObjectCreator oc = mockObjectCreator();
        final String serviceId = "RocketLauncher";
        final Set<Class> markers = Collections.emptySet();
        final Class serviceInterface = Runnable.class;

        ServiceDef sd = new ServiceDef()
        {
            public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
            {
                return oc;
            }
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        assertEquals(ids.size(), 3);
        assertTrue(ids.contains("Fred"));
        assertTrue(ids.contains("Barney"));
        assertTrue(ids.contains("Wilma"));

        ServiceDef sd = md.getServiceDef("Fred");

        assertEquals(sd.getServiceId(), "Fred");

        assertEquals(sd.getServiceInterface(), FieService.class);

        assertTrue(sd.toString().contains(className + ".buildFred()"));
        assertEquals(sd.getServiceScope(), ScopeConstants.DEFAULT);
        assertEquals(sd.isEagerLoad(), false);
        assertTrue(sd.getMarkers().isEmpty());

        sd = md.getServiceDef("Wilma");
        assertEquals(sd.isEagerLoad(), true);

        // Now the decorator method.

        Set<DecoratorDef> defs = md.getDecoratorDefs();
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        ModuleDef def = new DefaultModuleDefImpl(ServiceIdViaAnnotationModule.class, logger, null);

        assertEquals(def.getServiceIds().size(), 2);

        ServiceDef sd = def.getServiceDef("FooService");

        assertEquals(sd.getServiceId(), "FooService");

        verify();
    }
View Full Code Here

Examples of org.apache.tapestry5.ioc.def.ServiceDef

        ModuleDef def = new DefaultModuleDefImpl(ServiceIdViaAnnotationModule.class, logger, null);

        assertEquals(def.getServiceIds().size(), 2);

        ServiceDef sd = def.getServiceDef("BarneyService");

        assertEquals(sd.getServiceId(), "BarneyService");

        verify();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.