Examples of DefaultPicoContainer


Examples of org.picocontainer.defaults.DefaultPicoContainer

        helperCAs_ = helpers;
    }

    public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException
    {
        final MutablePicoContainer _helperContainer = new DefaultPicoContainer(container);
        for (int i = 0; i < helperCAs_.length; ++i)
        {
            _helperContainer.registerComponent(helperCAs_[i]);
        }

        return super.getComponentInstance(_helperContainer);
    }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

      disposed.set(true);
   }

   public MutablePicoContainer makeChildContainer()
   {
      DefaultPicoContainer pc = new DefaultPicoContainer(componentAdapterFactory, this);
      addChildContainer(pc);
      return pc;
   }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

      disposed.set(true);
   }

   public MutablePicoContainer makeChildContainer()
   {
      DefaultPicoContainer pc = new DefaultPicoContainer(componentAdapterFactory, this);
      addChildContainer(pc);
      return pc;
   }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

    /**
     * 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());
        assertTrue(Proxy.isProxyClass(touchable.getClass()));
    }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

   
    /**
     * 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());
        assertTrue(Proxy.isProxyClass(touchable.getClass()));
    }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

    /**
     * Test if proxy generation is omitted, if types are compatible.
     */
    public void testAvoidUnnecessaryProxy() {
        final MutablePicoContainer mpc = new DefaultPicoContainer();
        mpc.registerComponent(new AssimilatingComponentAdapter(TestCase.class, new InstanceComponentAdapter(TestCase.class, this)));
        final TestCase self = (TestCase) mpc.getComponentInstanceOfType(TestCase.class);
        assertFalse(Proxy.isProxyClass(self.getClass()));
        assertSame(this, self);
    }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

    /**
     * Test if proxy generation is omitted, if types are compatible and that the component key is not changed.
     */
    public void testAvoidedProxyDoesNotChangeComponentKey() {
        final MutablePicoContainer mpc = new DefaultPicoContainer();
        mpc.registerComponent(new AssimilatingComponentAdapter(TestCase.class, new InstanceComponentAdapter(getClass(), this)));
        final TestCase self = (TestCase) mpc.getComponentInstance(getClass());
        assertNotNull(self);
        assertSame(this, self);
    }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

        final MutablePicoContainer pico = createPicoContainer(null);
        assertNull(pico.getComponentInstanceOfType(List.class));
    }

    public void testShouldReturnNonMutableParent() {
        DefaultPicoContainer parent = new DefaultPicoContainer();
        final MutablePicoContainer picoContainer = createPicoContainer(parent);
        assertNotSame(parent, picoContainer.getParent());
        assertFalse(picoContainer.getParent() instanceof MutablePicoContainer);
    }
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

    /**
     * Test automatic assimilation of registered components.
     */
    public void testAutomaticAssimilation() {
        picoContainer = new DefaultPicoContainer(createComponentAdapterFactory());
        picoContainer.registerComponentImplementation(SimpleTouchable.class);
        picoContainer.registerComponentImplementation(AlternativeTouchable.class);
        picoContainer.registerComponentImplementation(CompatibleTouchable.class);
        final List list = picoContainer.getComponentInstancesOfType(Touchable.class);
        assertEquals(3, list.size());
View Full Code Here

Examples of org.picocontainer.defaults.DefaultPicoContainer

    /**
     * Creates a new container with a parent container.
     */
    public ImplementationHidingPicoContainer(ComponentAdapterFactory caf, PicoContainer parent, LifecycleManager lifecycleManager) {
        super(new DefaultPicoContainer(caf, parent, lifecycleManager));
        this.caf = caf;
        this.lifecycleManager = lifecycleManager;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.