Package org.nanocontainer.aop

Examples of org.nanocontainer.aop.Identifiable


        assertEquals(before, log.toString());
    }

    private void verifyMixin(Object component) {
        assertTrue(component instanceof Identifiable);
        Identifiable identifiable = (Identifiable) component;
        identifiable.setId("id");
        assertEquals("id", identifiable.getId());
    }
View Full Code Here


        pico.registerComponentImplementation("order2", OrderEntityImpl.class);

        // register mixin dependency:
        pico.registerComponentImplementation(IdGenerator.class, IdGeneratorImpl.class);

        Identifiable order1 = (Identifiable) pico.getComponentInstance("order1");
        Identifiable order2 = (Identifiable) pico.getComponentInstance("order2");

        assertEquals(new Integer(1), order1.getId());
        assertEquals(new Integer(2), order2.getId());

        // order1 and order2 do NOT share the same mixin instance (usually a
        // good thing),
        // although their mixin instances do share the same IdGenerator
        order1.setId(new Integer(42));
        assertEquals(new Integer(42), order1.getId());
        assertEquals(new Integer(2), order2.getId());
    }
View Full Code Here

        aspects.registerMixin(cuts.instancesOf(OrderEntity.class), IdentifiableMixin.class);
        pico.registerComponentImplementation(IdentifiableMixin.class);
        pico.registerComponentImplementation("order1", OrderEntityImpl.class);
        pico.registerComponentImplementation("order2", OrderEntityImpl.class);

        Identifiable order1 = (Identifiable) pico.getComponentInstance("order1");
        Identifiable order2 = (Identifiable) pico.getComponentInstance("order2");

        assertEquals(new Integer(1), order1.getId());
        assertEquals(new Integer(1), order2.getId());

        // order1 and order2 share the same IdentifiableMixin object (not
        // usually what you want!)
        order1.setId(new Integer(42));
        assertEquals(new Integer(42), order1.getId());
        assertEquals(new Integer(42), order2.getId());
    }
View Full Code Here

        pico.registerComponentImplementation("hasMixin1", OrderEntityImpl.class);
        pico.registerComponentImplementation("hasMixin2", OrderEntityImpl.class);
        pico.registerComponentImplementation("noMixin", OrderEntityImpl.class);
        pico.registerComponentImplementation(IdGenerator.class, IdGeneratorImpl.class);

        Identifiable hasMixin1 = (Identifiable) pico.getComponentInstance("hasMixin1");
        Identifiable hasMixin2 = (Identifiable) pico.getComponentInstance("hasMixin1");
        OrderEntity noMixin = (OrderEntity) pico.getComponentInstance("noMixin");

        assertFalse(noMixin instanceof Identifiable);
        assertEquals(new Integer(1), hasMixin1.getId());
        assertEquals(new Integer(2), hasMixin2.getId());

        hasMixin1.setId(new Integer(42));
        assertEquals(new Integer(42), hasMixin1.getId());
        assertEquals(new Integer(2), hasMixin2.getId());
    }
View Full Code Here

        pico.registerComponentImplementation("order1", OrderEntityImpl.class);
        pico.registerComponentImplementation("order2", OrderEntityImpl.class);
        pico.registerMixin(cuts.instancesOf(OrderEntity.class), new Class[]{Identifiable.class},
                IdentifiableMixin.class);

        Identifiable i1 = (Identifiable) pico.getComponentInstance("order1");
        Identifiable i2 = (Identifiable) pico.getComponentInstance("order2");

        assertEquals(new Integer(1), i1.getId());
        assertEquals(new Integer(2), i2.getId());

        i1.setId(new Integer(3));
        assertEquals(new Integer(3), i1.getId());
        assertEquals(new Integer(2), i2.getId());
    }
View Full Code Here

TOP

Related Classes of org.nanocontainer.aop.Identifiable

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.