Package org.apache.tapestry5.ioc.def

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


            Set<ServiceDef2> moduleServiceDefs = CollectionFactory.newSet();

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

                moduleServiceDefs.add(serviceDef);
                allServiceDefs.add(serviceDef);

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

                for (Class marker : serviceDef.getMarkers())
                    InternalUtils.addToMapList(markerToServiceDef, marker, serviceDef);
            }

            moduleToServiceDefs.put(module, moduleServiceDefs);
        }
View Full Code Here


        builtinServices.put(serviceId, service);

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

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

            public Set<Class> getMarkers()
            {
                return BUILTIN;
            }

            public String getServiceId()
            {
                return serviceId;
            }

            public Class getServiceInterface()
            {
                return serviceInterface;
            }

            public String getServiceScope()
            {
                return ScopeConstants.DEFAULT;
            }

            public boolean isEagerLoad()
            {
                return false;
            }

            public boolean isPreventDecoration()
            {
                return true;
            }
        };

        for (Class marker : serviceDef.getMarkers())
        {
            InternalUtils.addToMapList(markerToServiceDef, marker, serviceDef);
            allServiceDefs.add(serviceDef);
        }
View Full Code Here

        for (String id : moduleDef.getServiceIds())
        {
            ServiceDef sd = moduleDef.getServiceDef(id);

            ServiceDef2 sd2 = InternalUtils.toServiceDef2(sd);

            serviceDefs.put(id, sd2);
        }
    }
View Full Code Here

    public <T> T getService(String serviceId, Class<T> serviceInterface)
    {
        assert InternalUtils.isNonBlank(serviceId);
        assert serviceInterface != null;
        ServiceDef2 def = getServiceDef(serviceId);

        // RegistryImpl should already have checked that the service exists.
        assert def != null;

        Object service = findOrCreate(def, null);

        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

    public static ServiceDef2 toServiceDef2(final ServiceDef sd)
    {
        if (sd instanceof ServiceDef2)
            return (ServiceDef2) sd;

        return new ServiceDef2()
        {
            public boolean isPreventDecoration()
            {
                return false;
            }
View Full Code Here

            }
        };

        replay();

        ServiceDef2 sd2 = InternalUtils.toServiceDef2(sd);

        assertSame(sd2.createServiceCreator(null), oc);
        assertSame(sd2.getServiceId(), serviceId);
        assertSame(sd2.getMarkers(), markers);
        assertSame(sd2.getServiceInterface(), serviceInterface);
        assertSame(sd2.getServiceScope(), ScopeConstants.PERTHREAD);
        assertTrue(sd2.isEagerLoad());
        assertFalse(sd2.isPreventDecoration());

        verify();
    }
View Full Code Here

            }
        };

        replay();

        ServiceDef2 sd2 = InternalUtils.toServiceDef2(sd);

        assertSame(sd2.createServiceCreator(null), oc);
        assertSame(sd2.getServiceId(), serviceId);
        assertSame(sd2.getMarkers(), markers);
        assertSame(sd2.getServiceInterface(), serviceInterface);
        assertSame(sd2.getServiceScope(), ScopeConstants.PERTHREAD);
        assertTrue(sd2.isEagerLoad());
        assertFalse(sd2.isPreventDecoration());

        verify();
    }
View Full Code Here

     * Invoked at object creation, or when there are updates to class files (i.e., invalidation), to create a new set of
     * Javassist class pools and loaders.
     */
    private void initializeService()
    {
        ClassFactoryClassPool classPool = new ClassFactoryClassPool(parent);

        // For TAPESTRY-2561, we're introducing a class loader between the parent (i.e., the
        // context class loader), and the component class loader, to try and prevent the deadlocks
        // that we've been seeing.

        ClassLoader threadDeadlockBuffer = new URLClassLoader(new URL[0], parent);

        loader = new PackageAwareLoader(threadDeadlockBuffer, classPool);

        ClassPath path = new LoaderClassPath(loader);

        classPool.appendClassPath(path);

        classSource = new CtClassSourceImpl(classPool, loader);

        try
        {
View Full Code Here

        catch (Exception ex)
        {
            throw new RuntimeException(ex);
        }

        classFactory = new ClassFactoryImpl(loader, classPool, classSource, logger);

        classToPriorTransformException.clear();
    }
View Full Code Here

        ClassPath path = new LoaderClassPath(loader);

        classPool.appendClassPath(path);

        classSource = new CtClassSourceImpl(classPool, loader);

        try
        {
            loader.addTranslator(classPool, this);
        }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ioc.def.ServiceDef2

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.