Package org.picocontainer.defaults

Examples of org.picocontainer.defaults.ConstructorInjectionComponentAdapter


    protected int getComponentAdapterNature() {
        return super.getComponentAdapterNature() & ~(RESOLVING | VERIFYING | INSTANTIATING);
    }

    private ComponentAdapter createComponentAdapterWithTouchable() {
        return new AssimilatingComponentAdapter(Touchable.class, new ConstructorInjectionComponentAdapter(
                CompatibleTouchable.class, CompatibleTouchable.class));
    }
View Full Code Here


    /**
     * Important! Nanning really, really depends on this!
     */
    public void testComponentAdapterRegistrationOrderIsMaintained() {

        ConstructorInjectionComponentAdapter c1 = new ConstructorInjectionComponentAdapter("1", Object.class);
        ConstructorInjectionComponentAdapter c2 = new ConstructorInjectionComponentAdapter("2", String.class);

        MutablePicoContainer picoContainer = createPicoContainer(null);
        picoContainer.registerComponent(c1);
        picoContainer.registerComponent(c2);
        assertEquals("registration order should be maintained",
View Full Code Here

    }

    public void testAcceptImplementsBreadthFirstStrategy() {
        final MutablePicoContainer parent = createPicoContainer(null);
        final MutablePicoContainer child = parent.makeChildContainer();
        ComponentAdapter hashMapAdapter = parent.registerComponent(new ConstructorInjectionComponentAdapter(HashMap.class, HashMap.class));
        ComponentAdapter hashSetAdapter = parent.registerComponent(new ConstructorInjectionComponentAdapter(HashSet.class, HashSet.class));
        ComponentAdapter stringAdapter = parent.registerComponent(new InstanceComponentAdapter(String.class, "foo"));
        ComponentAdapter arrayListAdapter = child.registerComponent(new ConstructorInjectionComponentAdapter(ArrayList.class, ArrayList.class));
        Parameter componentParameter = BasicComponentParameter.BASIC_DEFAULT;
        Parameter throwableParameter = new ConstantParameter(new Throwable("bar"));
        ComponentAdapter exceptionAdapter = child.registerComponent(new ConstructorInjectionComponentAdapter(Exception.class, Exception.class, new Parameter[]{
            componentParameter,
            throwableParameter
        }));

        List expectedList = Arrays.asList(new Object[]{
View Full Code Here

    protected int getComponentAdapterNature() {
        return super.getComponentAdapterNature() & ~(RESOLVING | VERIFYING | INSTANTIATING);
    }

    private ComponentAdapter createComponentAdapterWithSimpleTouchable() {
        return new ThreadLocalComponentAdapter(new ConstructorInjectionComponentAdapter(
                Touchable.class, SimpleTouchable.class, null));
    }
View Full Code Here

import java.awt.event.MouseListener;

public class ImplementationHidingComponentAdapterTestCase extends TestCase {

    public void testMultipleInterfacesCanBeHidden() {
        ComponentAdapter ca = new ConstructorInjectionComponentAdapter(new Class[]{ActionListener.class, MouseListener.class}, Footle.class);
        ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);
        Object comp = ihca.getComponentInstance(null);
        assertNotNull(comp);
        assertTrue(comp instanceof ActionListener);
        assertTrue(comp instanceof MouseListener);
View Full Code Here

    protected ComponentAdapter prepDEF_visitable() {
        return createComponentAdapterWithSimpleTouchable();
    }

    protected ComponentAdapter prepDEF_isAbleToTakeParameters(MutablePicoContainer picoContainer) {
        return new ThreadLocalComponentAdapter(new ConstructorInjectionComponentAdapter(
                List.class, ArrayList.class, new Parameter[]{new ConstantParameter(new Integer(10))}));
    }
View Full Code Here

     * @throws InterruptedException
     */
    public final void testInstancesUsedFromMultipleThreads() throws InterruptedException {
        final Set set = Collections.synchronizedSet(new HashSet());
        final List list = Collections.synchronizedList(new ArrayList());
        final ComponentAdapter componentAdapter = new ThreadLocalComponentAdapter(new ConstructorInjectionComponentAdapter(
                Touchable.class, SimpleTouchable.class, null));
        final Touchable touchable = (Touchable)componentAdapter.getComponentInstance(null);

        final Thread[] threads = {
                new Thread(new Runner(touchable, list, set), "junit-1"), new Thread(new Runner(touchable, list, set), "junit-2"),
View Full Code Here

        assertTrue(comp instanceof ActionListener);
        assertTrue(comp instanceof MouseListener);
    }

    public void testNonInterfaceInArrayCantBeHidden() {
        ComponentAdapter ca = new ConstructorInjectionComponentAdapter(new Class[]{String.class}, Footle.class);
        ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);
        try {
            ihca.getComponentInstance(null);
            fail("Oh no.");
        } catch (PicoIntrospectionException e) {
View Full Code Here

        } catch (PicoIntrospectionException e) {
        }
    }

    public void testShouldThrowExceptionWhenAccessingNonInterfaceKeyedComponentInStrictMode() {
        ComponentAdapter ca = new ConstructorInjectionComponentAdapter("ww", Footle.class);
        ImplementationHidingComponentAdapter ihca = new ImplementationHidingComponentAdapter(ca, true);
        try {
            ihca.getComponentInstance(null);
            fail("Oh no.");
        } catch (PicoIntrospectionException e) {
View Full Code Here

     * Test instances from different containers.
     */
    public final void testInstancesAreNotSharedBetweenContainers() {
        final MutablePicoContainer picoA = new DefaultPicoContainer();
        final MutablePicoContainer picoB = new DefaultPicoContainer();
        picoA.registerComponent(new ThreadLocalComponentAdapter(new ConstructorInjectionComponentAdapter(
                List.class, ArrayList.class, null)));
        picoB.registerComponent(new ThreadLocalComponentAdapter(new ConstructorInjectionComponentAdapter(
                List.class, ArrayList.class, null)));
        final List hello1 = (List)picoA.getComponentInstance(List.class);
        final List hello2 = (List)picoA.getComponentInstance(List.class);
        hello1.add("foo");
        assertEquals(hello1, hello2);
View Full Code Here

TOP

Related Classes of org.picocontainer.defaults.ConstructorInjectionComponentAdapter

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.