Package org.picocontainer.defaults

Examples of org.picocontainer.defaults.ComponentAdapterFactory


        properties_ = ConsoleMain.parseProperties(args);

        DynamicMBeanProvider _decoratedProvider = new UnregisterObjectNameProviderDecorator(
                mbeanServer, mbeanProvider);

        ComponentAdapterFactory _defaultCAF = new JMXExposingComponentAdapterFactory(
                new ConstructorInjectionComponentAdapterFactory(), mbeanServer,
                new DynamicMBeanProvider[] { _decoratedProvider });

        ComponentAdapterFactory _cachingCAF = new CachingComponentAdapterFactory(
                _defaultCAF);

        container_ = new DefaultPicoContainer(_cachingCAF);
        container_.registerComponentInstance(ComponentAdapterFactory.class, _defaultCAF);
    }
View Full Code Here


    }

    private static MutablePicoContainer createContainer(final Logger logger)
    {
        final ConstructorInjectionComponentAdapterFactory _nonCachingCAFactory = new ConstructorInjectionComponentAdapterFactory(); //false, new ConsoleComponentMonitor(System.out));
        final ComponentAdapterFactory _cachingCAFactory = new CachingComponentAdapterFactory(_nonCachingCAFactory);
        final MutablePicoContainer _container = new DefaultPicoContainer(_cachingCAFactory);

        _container.registerComponentInstance(ComponentAdapterFactory.class,
                _nonCachingCAFactory);
View Full Code Here

    /**
     * Test creation of a CA ensuring ThreadLocal-behaviour.
     * @throws InterruptedException
     */
    public final void testCreateComponentAdapterEnsuringThreadLocal() throws InterruptedException {
        final ComponentAdapterFactory componentAdapterFactory = new ThreadLocalComponentAdapterFactory(
                new ConstructorInjectionComponentAdapterFactory());
        final ComponentAdapter componentAdapter = componentAdapterFactory.createComponentAdapter(
                List.class, ArrayList.class, new Parameter[]{});
        final List list = (List)componentAdapter.getComponentInstance(null);
        list.add(this);
        final List list2 = new ArrayList();
        final Thread thread = new Thread(new Runnable() {
View Full Code Here

    /**
     * Test creation of a CA failing ThreadLocal-behaviour.
     * @throws InterruptedException
     */
    public final void testCreateComponentAdapterFailingThreadLocal() throws InterruptedException {
        final ComponentAdapterFactory componentAdapterFactory = new ThreadLocalComponentAdapterFactory(
                new ConstructorInjectionComponentAdapterFactory(), ThreadLocalComponentAdapterFactory.THREAD_ENSURES_LOCALITY);
        final ComponentAdapter componentAdapter = componentAdapterFactory.createComponentAdapter(
                List.class, ArrayList.class, new Parameter[]{});
        final List list = (List)componentAdapter.getComponentInstance(null);
        list.add(this);
        final List list2 = new ArrayList();
        final Thread thread = new Thread(new Runnable() {
View Full Code Here

    /**
     * Test creation of a CA with ThreadLocal-behaviour works if the thread ensures creation.
     * @throws InterruptedException
     */
    public final void testCreateComponentAdapterWorksForDifferentThreads() throws InterruptedException {
        final ComponentAdapterFactory componentAdapterFactory = new ThreadLocalComponentAdapterFactory(
                new ConstructorInjectionComponentAdapterFactory(), ThreadLocalComponentAdapterFactory.THREAD_ENSURES_LOCALITY);
        final ComponentAdapter componentAdapter = componentAdapterFactory.createComponentAdapter(
                List.class, ArrayList.class, new Parameter[]{});
        final List list = (List)componentAdapter.getComponentInstance(null);
        list.add(this);
        final List list2 = new ArrayList();
        final Thread thread = new Thread(new Runnable() {
View Full Code Here

            return partner;
        }
    }

    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);
View Full Code Here

        if (notSet(className)) {
            throw new NanoContainerMarkupException("'" + CLASS + "' attribute not specified for " + element.getNodeName());
        }
        Class implementationClass = getClassLoader().loadClass(className);
        Parameter[] parameters = createChildParameters(container, element);
        ComponentAdapterFactory componentAdapterFactory = createComponentAdapterFactory(factoryName);
        container.getPico().registerComponent(componentAdapterFactory.createComponentAdapter(key, implementationClass, parameters));
    }
View Full Code Here

public class DynaopAspectablePicoContainerFactory implements AspectablePicoContainerFactory {

    public AspectablePicoContainer createContainer(Class containerClass, AspectsManager aspectsManager,
                                                   ComponentAdapterFactory componentAdapterFactory, PicoContainer parent) {

        ComponentAdapterFactory aspectsComponentAdapterFactory = new AspectsComponentAdapterFactory(aspectsManager,
                componentAdapterFactory);
        MutablePicoContainer pico = createMutablePicoContainer(containerClass, aspectsComponentAdapterFactory, parent);
        return mixinAspectablePicoContainer(aspectsManager, pico);
    }
View Full Code Here

        ClassLoader parentClassLoader = null;
        MutablePicoContainer childContainer = null;
        if (parent != null) {
            parentClassLoader = parent.getComponentClassLoader();
            if ( isAttribute(attributes, COMPONENT_ADAPTER_FACTORY) ) {
                ComponentAdapterFactory componentAdapterFactory = createComponentAdapterFactory(attributes);
                childContainer = new DefaultPicoContainer(
                        decorationDelegate.decorate(componentAdapterFactory, attributes), parent.getPico());
                if ( isAttribute(attributes, COMPONENT_MONITOR) ) {
                    changeComponentMonitor(childContainer, createComponentMonitor(attributes));
                }
                parent.getPico().addChildContainer(childContainer);
            } else if ( isAttribute(attributes, COMPONENT_MONITOR) ) {
                ComponentAdapterFactory componentAdapterFactory = new DefaultComponentAdapterFactory(
                                                    createComponentMonitor(attributes));
                childContainer = new DefaultPicoContainer(
                        decorationDelegate.decorate(componentAdapterFactory, attributes), parent.getPico());
            } else {
                childContainer = parent.getPico().makeChildContainer();
            }
        } else {
            parentClassLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                    return PicoContainer.class.getClassLoader();
                }
            });
            ComponentAdapterFactory componentAdapterFactory = createComponentAdapterFactory(attributes);
            childContainer = new DefaultPicoContainer(
                    decorationDelegate.decorate(componentAdapterFactory, attributes));
            if ( isAttribute(attributes, COMPONENT_MONITOR) ) {
                changeComponentMonitor(childContainer, createComponentMonitor(attributes));
            }
View Full Code Here

    private boolean isAttribute(Map attributes, String key) {
        return attributes.containsKey(key) && attributes.get(key) != null;
    }

    private ComponentAdapterFactory createComponentAdapterFactory(Map attributes) {
        final ComponentAdapterFactory factory = (ComponentAdapterFactory) attributes.remove(COMPONENT_ADAPTER_FACTORY);
        if ( factory == null ){
            return new DefaultComponentAdapterFactory();
        }
        return factory;
    }
View Full Code Here

TOP

Related Classes of org.picocontainer.defaults.ComponentAdapterFactory

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.