Package org.apache.tapestry.ioc.def

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


        replay();

        ModuleDef md = new DefaultModuleDefImpl(EagerLoadViaAnnotationModule.class, logger, _classFactory);

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

        assertTrue(sd.isEagerLoad());

        verify();
    }
View Full Code Here


        replay();

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

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

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

        verify();
    }
View Full Code Here

        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

        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

        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

    @SuppressWarnings("unchecked")
    @Test
    public void find_decorator_defs_for_service()
    {
        InternalRegistry registry = mockInternalRegistry();
        ServiceDef serviceDef = mockServiceDef();
        DecoratorDef def1 = mockDecoratorDef();
        DecoratorDef def2 = mockDecoratorDef();
        Set<DecoratorDef> rawDefs = newMock(Set.class);
        Logger logger = mockLogger();
View Full Code Here

        Logger logger = mockLogger();
        ObjectCreatorSource source = mockObjectCreatorSource();
        ObjectCreator delegate = mockObjectCreator();
        Object service = new Object();

        ServiceDef def = new ServiceDefImpl(Runnable.class, "Bar", null, "singleton", false, source);

        train_createObject(delegate, service);

        train_getDescription(source, SOURCE_DESCRIPTION);
View Full Code Here

        Logger logger = mockLogger();
        ObjectCreatorSource source = mockObjectCreatorSource();
        ObjectCreator delegate = mockObjectCreator();
        Object service = new Object();

        ServiceDef def = new ServiceDefImpl(Runnable.class, "Bar", null, "singleton", false, source);

        expect(delegate.createObject()).andThrow(failure);

        logger.error("Construction of service Bar failed: Just cranky.", failure);
View Full Code Here

    private void addServiceDef(Method method)
    {
        // TODO: Methods named just "build"
        String serviceId = _moduleId + "." + stripMethodPrefix(method, BUILD_METHOD_NAME_PREFIX);

        ServiceDef existing = _serviceDefs.get(serviceId);
        if (existing != null)
        {
            _log.warn(buildMethodConflict(method, existing.toString()), null);
            return;
        }

        // Any number of parameters is fine, we'll adapt. Eventually we have to check
        // that we can satisfy the parameters requested. Thrown exceptions of the method
View Full Code Here

    {
        notBlank(serviceId, "serviceId");
        notNull(serviceInterface, "serviceInterface");
        // module may be null.

        ServiceDef def = _moduleDef.getServiceDef(serviceId);

        if (def == null)
            throw new IllegalArgumentException(IOCMessages.missingService(serviceId));

        if (notVisible(def, module))
            throw new RuntimeException(IOCMessages.serviceIsPrivate(serviceId));

        Object service = findOrCreate(def);

        try
        {
            return serviceInterface.cast(service);
        }
        catch (ClassCastException ex)
        {
            // This may be overkill: I don't know how this could happen
            // given that the return type of the method determines
            // the service interface.

            throw new RuntimeException(IOCMessages.serviceWrongInterface(serviceId, def
                    .getServiceInterface(), serviceInterface));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ioc.def.ServiceDef

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.