Package org.apache.tapestry.ioc.def

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


            _modules.add(module);

            for (String serviceId : def.getServiceIds())
            {
                ServiceDef serviceDef = module.getServiceDef(serviceId);

                Module existing = _serviceIdToModule.get(serviceId);

                if (existing != null)
                    throw new RuntimeException(IOCMessages.serviceIdConflict(serviceId, existing
                            .getServiceDef(serviceId), serviceDef));

                _serviceIdToModule.put(serviceId, module);

                // The service is defined but will not have gone further than that.
                _tracker.define(serviceDef, Status.DEFINED);

                Class marker = serviceDef.getMarker();

                if (marker != null)
                    InternalUtils.addToMapList(_markerToServiceDef, marker, serviceDef);

            }
View Full Code Here


        _builtinServices.put(serviceId, service);

        // Make sure each of the builtin services is also available via the Builtin annotation
        // marker.

        ServiceDef serviceDef = new ServiceDef()
        {
            public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
            {
                return null;
            }

            public Class getMarker()
            {
                return Builtin.class;
            }

            public String getServiceId()
            {
                return serviceId;
            }

            public Class getServiceInterface()
            {
                return serviceInterface;
            }

            public String getServiceScope()
            {
                return IOCConstants.DEFAULT_SCOPE;
            }

            public boolean isEagerLoad()
            {
                return false;
            }
        };

        InternalUtils.addToMapList(_markerToServiceDef, serviceDef.getMarker(), serviceDef);

        _tracker.define(serviceDef, Status.BUILTIN);
    }
View Full Code Here

            switch (matches.size())
            {

                case 1:

                    ServiceDef def = matches.get(0);

                    return getService(def.getServiceId(), objectType);

                case 0:

                    // It's no accident that the user put the marker annotation at the injection
                    // point, since it matches a known marker annotation, it better be there for
View Full Code Here

            {
                return _classFactory.getConstructorLocation(constructor).toString();
            }
        };

        ServiceDef serviceDef = new ServiceDefImpl(_serviceInterface, _serviceId, _marker, _scope,
                _eagerLoad, source);

        _accumulator.addServiceDef(serviceDef);

        _serviceId = null;
View Full Code Here

    {
        _context = context;

        for (final String beanName : BeanFactoryUtils.beanNamesIncludingAncestors(_context))
        {
            ServiceDef serviceDef = new ServiceDef()
            {
                private Object getBean()
                {
                    return _context.getBean(beanName);
                }

                private Class getBeanType()
                {
                    return _context.getType(beanName);
                }

                public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
                {
                    return new ObjectCreator()
                    {
                        public Object createObject()
                        {
                            return getBean();
                        }
                    };
                }

                public String getServiceId()
                {
                    return beanName;
                }

                public Class getServiceInterface()
                {
                    return getBeanType();
                }

                public String getServiceScope()
                {
                    return IOCConstants.DEFAULT_SCOPE;
                }

                public boolean isEagerLoad()
                {
                    return false;
                }

                /** Returns null, Spring has no concept of a marker annotation. */
                public Class getMarker()
                {
                    return null;
                }

            };

            _serviceDefs.put(beanName, serviceDef);
        }

        // And add one service that is the Spring WebApplicationContext.

        ServiceDef serviceDef = new ServiceDef()
        {

            public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
            {
                return new ObjectCreator()
View Full Code Here

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

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

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

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

        assertEquals(sd.toString(), className + ".buildFred()");
        assertEquals(sd.getServiceLifeycle(), IOCConstants.DEFAULT_LIFECYCLE);
        assertEquals(sd.isPrivate(), false);
        assertEquals(sd.isEagerLoad(), false);

        sd = md.getServiceDef("ioc.Barney");

        assertEquals(sd.getServiceId(), "ioc.Barney");

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

        assertEquals(sd.toString(), className + ".buildBarney()");
        assertEquals(sd.getServiceLifeycle(), "threaded");
        assertEquals(sd.isPrivate(), true);

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

        // Now the decorator method.

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

        Set<String> ids = md.getServiceIds();

        assertEquals(ids.size(), 1);
        assertTrue(ids.contains("ioc.Fred"));

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

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

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

        // The methods are considered in ascending order, by name, then descending order, by
        // parameter count. So the grinder will latch onto the method that takes a parameter,
        // and consider the other method (with no parameters) the conflict.

        assertEquals(sd.toString(), expectedMethod.toString());

        verify();
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void find_decorator_defs_for_service()
    {
        InternalRegistry registry = newInternalRegistry();
        ServiceDef serviceDef = newServiceDef();
        DecoratorDef def1 = newDecoratorDef();
        DecoratorDef def2 = newDecoratorDef();
        Set<DecoratorDef> rawDefs = newMock(Set.class);
        Log log = newLog();
View Full Code Here

        Method method = getClass().getMethod("buildMyService");

        ObjectCreator delegate = newObjectCreator();
        Object service = new Object();

        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false, false);

        train_createObject(delegate, service);

        replay();
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

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.