Package org.picocontainer.defaults

Examples of org.picocontainer.defaults.CachingComponentAdapter


    public void testLowLevelCheating() {
        ComponentAdapterFactory caf = createComponentAdapterFactory();
        DefaultPicoContainer pico = new DefaultPicoContainer(caf);

        CachingComponentAdapter wifeAdapter = (CachingComponentAdapter) caf.createComponentAdapter("wife", Wife.class, null);
        CachingComponentAdapter husbandAdapter = (CachingComponentAdapter) caf.createComponentAdapter("husband", Husband.class, null);

        pico.registerComponent(wifeAdapter);
        pico.registerComponent(husbandAdapter);

        Woman wife = (Woman) wifeAdapter.getComponentInstance(pico);
        Man wifesMan = wife.getMan();
        wifesMan.kiss();
        Man man = (Man) husbandAdapter.getComponentInstance(pico);
        assertTrue(man.wasKissed());

        assertSame(man, wife.getMan());
        assertSame(wife, man.getWoman());
View Full Code Here


     * @throws PicoIntrospectionException Thrown if the component does not implement any
     *                     interface.
     */
    public ThreadLocalComponentAdapter(final ComponentAdapter delegate, final ProxyFactory proxyFactory)
            throws PicoIntrospectionException {
        super(new CachingComponentAdapter(delegate, new ThreadLocalReference()));
        this.proxyFactory = proxyFactory;
        interfaces = getInterfaces();
    }
View Full Code Here

     * @param delegate The {@link ComponentAdapter}to delegate.
     * @throws PicoIntrospectionException Thrown if the component does not implement any
     *                     interface.
     */
    public ThreadLocalComponentAdapter(final ComponentAdapter delegate) throws PicoIntrospectionException {
        this(new CachingComponentAdapter(delegate, new ThreadLocalReference()), new StandardProxyFactory());
    }
View Full Code Here

        final ComponentAdapter componentAdapter;
        if (ensureThreadLocal) {
            componentAdapter = new ThreadLocalComponentAdapter(super.createComponentAdapter(
                    componentKey, componentImplementation, parameters), proxyFactory);
        } else {
            componentAdapter = new CachingComponentAdapter(super.createComponentAdapter(
                    componentKey, componentImplementation, parameters), new ThreadLocalReference());
        }
        return componentAdapter;
    }
View Full Code Here

        return _container;
    }

    private static void registerCoreServices(final MutablePicoContainer container)
    {
        container.registerComponent(new CachingComponentAdapter(
                new PushTaskExecutorFactoryComponentAdapter(
                        new ConstructorInjectionComponentAdapter(PushTaskExecutorFactory.class, ConfigurablePushTaskExecutorFactory.class))));

        // etcl evaluator
        container.registerComponentImplementation(DefaultETCLEvaluator.class);
View Full Code Here

        final LocalParameterComponentAdapter _localParamCA =
            new LocalParameterComponentAdapter(_poolingServiceCA, new ComponentAdapter[] {_serviceCA});

        final ComponentAdapter _cachingCA =
            new CachingComponentAdapter(_localParamCA);

        container.registerComponent(_cachingCA);
    }
View Full Code Here

    private static void registerORBServices(final MutablePicoContainer container)
    {
        // register services that need to be looked up via orb using custom componentadapter

        // POA
        container.registerComponent(new CachingComponentAdapter(new BiDirGiopPOAComponentAdapter(new POAComponentAdapter())));

        // DynAnyFactory
        container.registerComponent(new CachingComponentAdapter(new DynAnyFactoryComponentAdapter()));

        // Configuration
        container.registerComponent(new CachingComponentAdapter(new ConfigurationComponentAdapter()));

        // FilterFactory
        container.registerComponent(new CachingComponentAdapter(new FilterFactoryComponentAdapter()));

        // IFR
        container.registerComponent(new CachingComponentAdapter(new RepositoryComponentAdapter()));

        // CurrentTimeUtil
        container.registerComponent(new CurrentTimeUtilComponentAdapter());
    }
View Full Code Here

        addProxyEventListener(this);

        ConsumerAdmin _thisRef = ConsumerAdminHelper.narrow(activate());

        container_.registerComponent(new CachingComponentAdapter(new CORBAObjectComponentAdapter(
                ConsumerAdmin.class, _thisRef)));

        registerDisposable(new Disposable()
        {
            public void dispose()
View Full Code Here

        return _container;
    }

    private static void registerCoreServices(final MutablePicoContainer container)
    {
        container.registerComponent(new CachingComponentAdapter(
                new PushTaskExecutorFactoryComponentAdapter(
                        new ConstructorInjectionComponentAdapter(PushTaskExecutorFactory.class, ConfigurablePushTaskExecutorFactory.class))));

        // etcl evaluator
        container.registerComponentImplementation(DefaultETCLEvaluator.class);
View Full Code Here

        final LocalParameterComponentAdapter _localParamCA =
            new LocalParameterComponentAdapter(_poolingServiceCA, new ComponentAdapter[] {_serviceCA});

        final ComponentAdapter _cachingCA =
            new CachingComponentAdapter(_localParamCA);

        container.registerComponent(_cachingCA);
    }
View Full Code Here

TOP

Related Classes of org.picocontainer.defaults.CachingComponentAdapter

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.