Package org.apache.tapestry.ioc

Examples of org.apache.tapestry.ioc.ObjectCreator


    public Object createService(ServiceResources resources, final ObjectCreator creator)
    {
        Class proxyClass = createProxyClass(resources);

        ObjectCreator perThreadCreator = new PerThreadServiceCreator(_threadCleanupHub, creator);

        try
        {
            Constructor ctor = proxyClass.getConstructors()[0];
View Full Code Here


        if (constructor == null)
            throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz));

        String description = _classFactory.getConstructorLocation(constructor).toString();

        ObjectCreator creator = new ConstructorServiceCreator(this, description, constructor);

        return clazz.cast(creator.createObject());
    }
View Full Code Here

                    _classFactory, log);

            // Build up a stack of operations that will be needed to realize the service
            // (by the proxy, at a later date).

            ObjectCreator creator = def.createServiceCreator(resources);

            Class serviceInterface = def.getServiceInterface();

            // For non-proxyable services, we immediately create the service implementation
            // and return it. There's no interface to proxy, which throws out the possibility of
            // deferred instantiation, service lifecycles, and decorators.

            if (!serviceInterface.isInterface()) return creator.createObject();

            creator = new LifecycleWrappedServiceCreator(_registry, def.getServiceScope(),
                    resources, creator);

            // Don't allow the core IOC services services to be decorated.
View Full Code Here

                    return _context.getBean(beanName);
                }

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

                public String getServiceId()
                {
                    return beanName;
                }

                public Class getServiceInterface()
                {
                    return getBean().getClass();
                }

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

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

            _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()
                {
                    public Object createObject()
                    {
                        return _context;
                    }
View Full Code Here

        train_isDebugEnabled(log, false);

        replay();

        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_noargs"),
                resources, getClassFactory());

        Object actual = sc.createObject();

        assertSame(actual, fixture._fie);

        verify();
    }
View Full Code Here

        log.debug(IOCMessages.invokingMethod(InternalUtils.asString(method, getClassFactory())));

        replay();

        ObjectCreator sc = new ServiceBuilderMethodInvoker(method, resources, getClassFactory());

        Object actual = sc.createObject();

        assertSame(actual, fixture._fie);

        verify();
    }
View Full Code Here

        train_isDebugEnabled(log, false);

        replay();

        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_injected"),
                resources, getClassFactory());

        Object actual = sc.createObject();

        assertSame(actual, fixture._fie);

        verify();
    }
View Full Code Here

        train_isDebugEnabled(log, false);

        replay();

        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(
                fixture,
                "buildWithOrderedConfiguration"), resources, getClassFactory());

        Object actual = sc.createObject();

        assertSame(actual, fixture._fie);

        verify();
View Full Code Here

        train_isDebugEnabled(log, false);

        replay();

        ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(
                fixture,
                "buildWithUnorderedConfiguration"), resources, getClassFactory());

        Object actual = sc.createObject();

        assertSame(actual, fixture._fie);

        verify();
    }
View Full Code Here

        train_isDebugEnabled(log, false);

        replay();

        ObjectCreator sc = new ServiceBuilderMethodInvoker(method, resources, getClassFactory());

        try
        {
            sc.createObject();
            unreachable();
        }
        catch (RuntimeException ex)
        {
            Assert.assertEquals(ex.getMessage(), "Builder method " + methodId
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ioc.ObjectCreator

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.