Package org.picocontainer.defaults

Examples of org.picocontainer.defaults.ComponentParameter


    public void testMultiWithSatisfyingDependencyAndParametersWorks() throws PicoException, PicoRegistrationException {
        MutablePicoContainer pico = createPicoContainer();
        pico.registerComponentImplementation("MultiOneTwo", Multi.class, new Parameter[]{
            ComponentParameter.DEFAULT,
            new ComponentParameter("Two"),
        });
        pico.registerComponentImplementation("MultiTwoOne", Multi.class, new Parameter[]{
            new ComponentParameter("Two"),
            ComponentParameter.DEFAULT,
        });
        pico.registerComponentImplementation("MultiOneString", Multi.class, new Parameter[]{
            ComponentParameter.DEFAULT,
            new ConstantParameter(""),
View Full Code Here


    public void testTouchableDependencyWithComponentKeyParameter() {
        container.registerComponentImplementation(AlternativeTouchable.class);
        container.registerComponentImplementation(DecoratedTouchable.class,
                                                  DecoratedTouchable.class,
                                                  new Parameter[] { new ComponentParameter(SimpleTouchable.class) });

        Touchable t = (Touchable) container.getComponentInstance(DecoratedTouchable.class);
        assertNotNull(t);
    }
View Full Code Here

        //      START SNIPPET: usage

        pico.registerComponentImplementation(Shark.class);
        pico.registerComponentImplementation(Cod.class);
        pico.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
                new ComponentParameter(Fish.class, false), new ComponentParameter(Cod.class, false)});
        //      END SNIPPET: usage

        Shark shark = (Shark) pico.getComponentInstanceOfType(Shark.class);
        Cod cod = (Cod) pico.getComponentInstanceOfType(Cod.class);
        Bowl bowl = (Bowl) pico.getComponentInstanceOfType(Bowl.class);
View Full Code Here

        final Set set = new HashSet();
        pico.registerComponentImplementation(Shark.class);
        pico.registerComponentImplementation(Cod.class);
        pico.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
                new ComponentParameter(Fish.class, false), new ComponentParameter(Cod.class, false)});
        pico.registerComponentInstance(set);

        Bowl bowl = (Bowl) pico.getComponentInstance(Bowl.class);
        //      END SNIPPET: directUsage
View Full Code Here

    public void testShouldCreateBowlWithNoFishAtAll() {

        //      START SNIPPET: emptyCollection

        pico.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
                new ComponentParameter(Fish.class, true), new ComponentParameter(Cod.class, true)});

        Bowl bowl = (Bowl) pico.getComponentInstance(Bowl.class);
        //      END SNIPPET: emptyCollection

        Collection fishes = bowl.getFishes();
View Full Code Here

        //      START SNIPPET: useKeyType

        pico.registerComponentImplementation(Shark.class);
        pico.registerComponentImplementation("Nemo", Cod.class);
        pico.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
                new ComponentParameter(String.class, Fish.class, false), new ComponentParameter(Cod.class, false)});

        Bowl bowl = (Bowl) pico.getComponentInstanceOfType(Bowl.class);
        //      END SNIPPET: useKeyType

        //      START SNIPPET: ensureKeyType
View Full Code Here

        //      START SNIPPET: usage

        pico.registerComponentImplementation("Shark", Shark.class);
        pico.registerComponentImplementation("Cod", Cod.class);
        pico.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
            new ComponentParameter(Fish.class, false),
            new ComponentParameter(Cod.class, false)
        });
        //      END SNIPPET: usage

        Shark shark = (Shark) pico.getComponentInstanceOfType(Shark.class);
        Cod cod = (Cod) pico.getComponentInstanceOfType(Cod.class);
View Full Code Here

        //      START SNIPPET: useKeyType

        pico.registerComponentImplementation(Shark.class);
        pico.registerComponentImplementation("Nemo", Cod.class);
        pico.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
            new ComponentParameter(String.class, Fish.class, false),
            new ComponentParameter(Cod.class, false)
        });
       
        Bowl bowl = (Bowl) pico.getComponentInstanceOfType(Bowl.class);
        //      END SNIPPET: useKeyType
       
View Full Code Here

        parent.registerComponentImplementation("Tom", Cod.class);
        parent.registerComponentImplementation("Harry", Cod.class);
        MutablePicoContainer child = new DefaultPicoContainer(parent);
        child.registerComponentImplementation("Dick", Cod.class);
        child.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
            new ComponentParameter(Fish.class, false),
            new ComponentParameter(Cod.class, false)
        });
        Bowl bowl = (Bowl) child.getComponentInstance(Bowl.class);
        assertEquals(3, bowl.fishes.size());
        assertEquals(3, bowl.cods.size());
View Full Code Here

        parent.registerComponentImplementation("Dick", Cod.class);
        parent.registerComponentImplementation("Harry", Cod.class);
        MutablePicoContainer child = new DefaultPicoContainer(parent);
        child.registerComponentImplementation("Dick", Shark.class);
        child.registerComponentImplementation(Bowl.class, Bowl.class, new Parameter[]{
            new ComponentParameter(Fish.class, false),
            new ComponentParameter(Cod.class, false)
        });
        Bowl bowl = (Bowl) child.getComponentInstance(Bowl.class);
        assertEquals(3, bowl.fishes.size());
        assertEquals(2, bowl.cods.size());
View Full Code Here

TOP

Related Classes of org.picocontainer.defaults.ComponentParameter

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.