Package org.picocontainer.defaults

Examples of org.picocontainer.defaults.CachingComponentAdapter


    public void testCachedServiceObject()
        throws Exception
    {
        // Put DummyServiceThatCounts and its dependency into the pico. Its
        // going to be cached, just one instance for container.
        getPico().registerComponent(new CachingComponentAdapter(
                new ConstructorInjectionComponentAdapter(DummyServiceThatCounts.class,
                        DummyServiceThatCounts.class)));
        getPico().registerComponentInstance(this);

        // Execute it 3 times.
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

    {
        super(channelServant, orb, poa, config, messageFactory, offerManager, subscriptionManager);

        thisCorbaRef_ = SupplierAdminHelper.narrow(activate());

        container_.registerComponent(new CachingComponentAdapter(new CORBAObjectComponentAdapter(
                SupplierAdmin.class, thisCorbaRef_)));

        registerDisposable(new Disposable()
        {
            public void dispose()
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

    /**
     * Test if an instance can be assimilated.
     */
    public void testInstanceIsBorged() {
        final MutablePicoContainer mpc = new DefaultPicoContainer();
        final ComponentAdapter componentAdapter = new CachingComponentAdapter(new ConstructorInjectionComponentAdapter(
                CompatibleTouchable.class, CompatibleTouchable.class));
        mpc.registerComponent(new AssimilatingComponentAdapter(Touchable.class, componentAdapter));
        final CompatibleTouchable compatibleTouchable = (CompatibleTouchable) componentAdapter
                .getComponentInstance(mpc);
        final Touchable touchable = (Touchable) mpc.getComponentInstanceOfType(Touchable.class);
        assertFalse(compatibleTouchable.wasTouched());
        touchable.touch();
        assertTrue(compatibleTouchable.wasTouched());
View Full Code Here

    /**
     * Test if the component key is preserved if it is not a class type.
     */
    public void testComponentKeyIsPreserved() {
        final MutablePicoContainer mpc = new DefaultPicoContainer();
        final ComponentAdapter componentAdapter = new CachingComponentAdapter(new ConstructorInjectionComponentAdapter(
                "Touchy", CompatibleTouchable.class));
        mpc.registerComponent(new AssimilatingComponentAdapter(Touchable.class, componentAdapter));
        final CompatibleTouchable compatibleTouchable = (CompatibleTouchable) componentAdapter
                .getComponentInstance(mpc);
        final Touchable touchable = (Touchable) mpc.getComponentInstance("Touchy");
        assertFalse(compatibleTouchable.wasTouched());
        touchable.touch();
        assertTrue(compatibleTouchable.wasTouched());
View Full Code Here

    public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException {
        if (componentKey instanceof Class) {
            Class clazz = (Class) componentKey;
            if (clazz.isInterface()) {
                ComponentAdapter delegate = caf.createComponentAdapter(componentKey, componentImplementation, null);
                return getDelegate().registerComponent(new CachingComponentAdapter(new ImplementationHidingComponentAdapter(delegate, true)));
            }
        }
        return getDelegate().registerComponentImplementation(componentKey, componentImplementation);
    }
View Full Code Here

        if (componentKey instanceof Class) {
            Class clazz = (Class) componentKey;
            if (clazz.isInterface()) {
                ComponentAdapter delegate = caf.createComponentAdapter(componentKey, componentImplementation, parameters);
                ImplementationHidingComponentAdapter ihDelegate = new ImplementationHidingComponentAdapter(delegate, true);
                return getDelegate().registerComponent(new CachingComponentAdapter(ihDelegate));
            }
        }
        return getDelegate().registerComponentImplementation(componentKey, componentImplementation, parameters);
    }
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.