Examples of BeanContextChild


Examples of java.beans.beancontext.BeanContextChild

    }

    public void testGetChildBeanContextChild_BeanContextProxy() {
        MockBeanContextChild child = new MockBeanContextChild();
        MockBeanContextProxy proxy = new MockBeanContextProxy(child);
        BeanContextChild result = MockBeanContextSupport
                .publicGetChildBeanContextChild(proxy);
        assertSame(child, result);
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        assertSame(child, result);
    }

    public void testGetChildBeanContextChild_Neither() {
        Integer child = new Integer(129);
        BeanContextChild result = MockBeanContextSupport
                .publicGetChildBeanContextChild(child);
        assertNull(result);
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    public void testRemoveObject_BCC() {
        MockBeanContextSupport support = new MockBeanContextSupport();
        MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
        support.addBeanContextMembershipListener(l1);

        BeanContextChild child = new MockBeanContextChild();
        support.add(child);
        support.records.assertRecord("initialize", null);
        support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
        support.records.assertRecord("createBCSChild", child, null, support
                .children().get(child));
        support.records.assertRecord("childJustAddedHook", child, support
                .children().get(child), null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventAdd);
        assertMembershipEvent(l1.lastEvent, support, null, child);
        support.records.clear();
        l1.clearLastEvent();

        Object bcsChild = support.children().get(child);
        support.remove(child);
        support.records.assertRecord("validatePendingRemove", child,
                Boolean.TRUE);
        support.records.assertRecord("childJustRemovedHook", child, bcsChild,
                null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventRemove);
        assertMembershipEvent(l1.lastEvent, support, null, child);

        assertNull(child.getBeanContext());
        assertEquals(0, support.size());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        MockBeanContextSupport support = new MockBeanContextSupport();
        support.waitOnChildInHooks = false;
        MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
        support.addBeanContextMembershipListener(l1);

        BeanContextChild childPeer = new MockBeanContextChild();
        BeanContextProxy child = new MockBeanContextProxy(childPeer);
        support.add(child);
        support.records.assertRecord("initialize", null);
        support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
        support.records.assertRecord("createBCSChild", child, childPeer,
                support.children().get(child));
        support.records.assertRecord("createBCSChild", childPeer, child,
                support.children().get(childPeer));
        support.records.assertRecord("childJustAddedHook", child, support
                .children().get(child), null);
        support.records.assertRecord("childJustAddedHook", childPeer, support
                .children().get(childPeer), null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventAdd);
        assertMembershipEvent(l1.lastEvent, support, null, Arrays
                .asList(new Object[] { child, childPeer }));
        support.records.clear();
        l1.clearLastEvent();

        Object bcsChild = support.children().get(child);
        Object bcsChildPeer = support.children().get(childPeer);
        support.remove(child);
        support.records.assertRecord("validatePendingRemove", child,
                Boolean.TRUE);
        support.records.assertRecord("childJustRemovedHook", child, bcsChild,
                null);
        support.records.assertRecord("childJustRemovedHook", childPeer,
                bcsChildPeer, null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventRemove);
        assertMembershipEvent(l1.lastEvent, support, null, Arrays
                .asList(new Object[] { child, childPeer }));

        assertNull(childPeer.getBeanContext());
        assertEquals(0, support.size());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        MockBeanContextSupport support = new MockBeanContextSupport();
        support.waitOnChildInHooks = false;
        MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
        support.addBeanContextMembershipListener(l1);

        BeanContextChild childPeer = new MockBeanContextChild();
        BeanContextProxy child = new MockBeanContextProxy(childPeer);
        support.add(child);
        support.records.assertRecord("initialize", null);
        support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
        support.records.assertRecord("createBCSChild", child, childPeer,
                support.children().get(child));
        support.records.assertRecord("createBCSChild", childPeer, child,
                support.children().get(childPeer));
        support.records.assertRecord("childJustAddedHook", child, support
                .children().get(child), null);
        support.records.assertRecord("childJustAddedHook", childPeer, support
                .children().get(childPeer), null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventAdd);
        assertMembershipEvent(l1.lastEvent, support, null, Arrays
                .asList(new Object[] { child, childPeer }));
        support.records.clear();
        l1.clearLastEvent();

        Object bcsChild = support.children().get(child);
        Object bcsChildPeer = support.children().get(childPeer);
        support.remove(childPeer);
        support.records.assertRecord("validatePendingRemove", childPeer,
                Boolean.TRUE);
        support.records.assertRecord("childJustRemovedHook", childPeer,
                bcsChildPeer, null);
        support.records.assertRecord("childJustRemovedHook", child, bcsChild,
                null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventRemove);
        assertMembershipEvent(l1.lastEvent, support, null, Arrays
                .asList(new Object[] { child, childPeer }));

        assertNull(childPeer.getBeanContext());
        assertEquals(0, support.size());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    public void testRemoveObject_Veto() {
        MockBeanContextSupport support = new MockBeanContextSupport();
        MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
        support.addBeanContextMembershipListener(l1);

        BeanContextChild child = new MockBeanContextChild();
        support.add(child);
        support.records.assertRecord("initialize", null);
        support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
        support.records.assertRecord("createBCSChild", child, null, support
                .children().get(child));
        support.records.assertRecord("childJustAddedHook", child, support
                .children().get(child), null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventAdd);
        assertMembershipEvent(l1.lastEvent, support, null, child);
        support.records.clear();
        l1.clearLastEvent();

        support.children().get(child);
        support.vetoAddRemove = true;
        try {
            support.remove(child);
            fail("IllegalStateException expected");
        } catch (IllegalStateException e) {
            // expected
        }
        support.records.assertRecord("validatePendingRemove", child,
                Boolean.FALSE);
        support.records.assertEndOfRecords();
        assertNull(l1.lastEvent);

        assertSame(support, child.getBeanContext());
        assertEquals(1, support.size());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    public void testRemoveObjectboolean() {
        MockBeanContextSupport support = new MockBeanContextSupport();
        MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener();
        support.addBeanContextMembershipListener(l1);

        BeanContextChild child = new MockBeanContextChild();
        support.add(child);
        support.records.assertRecord("initialize", null);
        support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE);
        support.records.assertRecord("createBCSChild", child, null, support
                .children().get(child));
        support.records.assertRecord("childJustAddedHook", child, support
                .children().get(child), null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventAdd);
        assertMembershipEvent(l1.lastEvent, support, null, child);
        support.records.clear();
        l1.clearLastEvent();

        Object bcsChild = support.children().get(child);
        support.publicRemove(child, false); // don't call child's setBeanContext
        support.records.assertRecord("validatePendingRemove", child,
                Boolean.TRUE);
        support.records.assertRecord("childJustRemovedHook", child, bcsChild,
                null);
        support.records.assertEndOfRecords();
        assertTrue(l1.lastEventRemove);
        assertMembershipEvent(l1.lastEvent, support, null, child);

        assertSame(support, child.getBeanContext());
        assertEquals(0, support.size());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

     * @throws IOException
     * @throws ClassNotFoundException if the class identified
     *                                by the beanName parameter is not found
     */
    public Object instantiateChild(String beanName) throws IOException, ClassNotFoundException {
        BeanContextChild bcc = getPeer();
        return Beans.instantiate(bcc.getClass().getClassLoader(), beanName, (BeanContext) bcc);
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

     *
     * @return True if the bean absolutely needs a GUI available in
     *         order to get its work done.
     */
    public boolean needsGui() {
        BeanContextChild bcc = getPeer();
        if (bcc != this && bcc instanceof Visibility) {
            return ((Visibility) bcc).needsGui();
        }

        // check children
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        if (contains(o)) return false;

        // todo: for multithreaded usage this block needs to be synchronized
        // spec: if the object being added implements BeanContextChild or BeanContextProxy
        // need to set the bean context of the object to this bean context.
        BeanContextChild bcc = null;
        BeanContextProxy bcp = null;

        if (o instanceof BeanContextProxy) {
            if (o instanceof BeanContext) {
                throw new IllegalArgumentException("May not implement both BeanContextProxy and BeanContext!!");
            }
            bcp = (BeanContextProxy) o;
            bcc = bcp.getBeanContextProxy();
        }
        else if (o instanceof BeanContextChild) {
            bcc = (BeanContextChild) o;
        }

        if (bcc != null) {
            try {
                bcc.setBeanContext((BeanContext) getPeer());
            }
            catch (PropertyVetoException e) {
                throw new IllegalStateException(e);
            }

            bcc.addPropertyChangeListener("beanContext", _childPcl);
            bcc.addVetoableChangeListener("beanContext", _childVcl);
        }

        if (publicApi) {
            if (o instanceof Visibility) {
                if (_mayUseGui) {
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.