Examples of BeanContextChild


Examples of java.beans.beancontext.BeanContextChild

    private boolean internalRemove(Object o, boolean publicApi) {

        if (!contains(o)) return false;

        // todo: for multithreaded usage this block needs to be synchronized
        BeanContextChild bcc = null;
        if (o instanceof BeanContextProxy) {
            bcc = ((BeanContextProxy) o).getBeanContextProxy();
        }
        else if (o instanceof BeanContextChild) {
            bcc = (BeanContextChild) o;
        }

        if (bcc != null) {

            /*
             If remove invoked as a result of the BeanContext receiving an unexpected PropertyChangeEvent
             notification as a result of a 3rd party invoking setBeanContext() then the remove implementation
             shall not invoke setBeanContext(null) on that child as part of the remove() semantics, since
             doing so would overwrite the value previously set by the 3rd party.
            */
            if (publicApi) {

                // remove the property/veto listeners -- we know we want to remove the bean
                // and don't need to be notified if we have initiated the removal
                bcc.removePropertyChangeListener("beanContext", _childPcl);
                bcc.removeVetoableChangeListener("beanContext", _childVcl);

                try {
                    bcc.setBeanContext(null);
                }
                catch (PropertyVetoException e) {
                    // rewire the listeners we removed above then except
                    bcc.addPropertyChangeListener("beanContext", _childPcl);
                    bcc.addVetoableChangeListener("beanContext", _childVcl);
                    throw new IllegalStateException(e);
                }
            }
        }

View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    /*
     * Class under test for void
     * BeanContextChildSupport(java.beans.beancontext.BeanContextChild)
     */
    public void testBeanContextChildSupportBeanContextChild() {
        BeanContextChild c = new MockBeanContextChild();
        BeanContextChildSupport support = new MockBeanContextChildSupport(c);
        assertSame(c, support.getBeanContextChildPeer());
        assertSame(c, support.beanContextChildPeer);
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    public void testGetBeanContextChildPeer() throws Exception {
        BeanContextChildSupport support = new MockBeanContextChildSupport();
        assertSame(support, support.beanContextChildPeer);
        assertSame(support, support.getBeanContextChildPeer());

        BeanContextChild mockChild = new MockBeanContextChild();
        support = new MockBeanContextChildSupport(mockChild);
        assertSame(mockChild, support.beanContextChildPeer);
        assertSame(mockChild, support.getBeanContextChildPeer());

        BeanContextChildSupport sup = new BeanContextChildSupport();
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    public void testIsDelegated() throws Exception {
        BeanContextChildSupport support = new MockBeanContextChildSupport();
        assertFalse(support.isDelegated());

        BeanContextChild mockChild = new MockBeanContextChild();
        support = new MockBeanContextChildSupport(mockChild);
        assertTrue(support.isDelegated());

        support.beanContextChildPeer = support;
        assertFalse(support.isDelegated());
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        BeanContextChildSupport support = new MockBeanContextChildSupport();
        support.serviceRevoked(null);
    }

    public void testSetBeanContext() throws PropertyVetoException {
        BeanContextChild peer = new MockBeanContextChild();
        MockBeanContextChildSupport support = new MockBeanContextChildSupport(
                peer);
        MockPropertyChangeListener l1 = new MockPropertyChangeListener();
        MockVetoableChangeListener l2 = new MockVetoableChangeListener();
        support.addPropertyChangeListener("beanContext", l1);
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        MockVetoableChangeListener l3 = new MockVetoableChangeListener();
        support.addBeanContextMembershipListener(l1);
        support.addPropertyChangeListener("children", l2);
        support.addVetoableChangeListener("children", l3);

        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);
        assertNull(l2.lastEvent);
        assertNull(l3.lastEvent);

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

Examples of java.beans.beancontext.BeanContextChild

        MockVetoableChangeListener l3 = new MockVetoableChangeListener();
        support.addBeanContextMembershipListener(l1);
        support.addPropertyChangeListener("children", l2);
        support.addVetoableChangeListener("children", l3);

        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 }));
        assertNull(l2.lastEvent);
        assertNull(l3.lastEvent);

        assertSame(support, childPeer.getBeanContext());
        assertEquals(2, support.size());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        support.addBeanContextMembershipListener(l1);
        support.addPropertyChangeListener("children", l2);
        support.addVetoableChangeListener("children", l3);

        support.vetoAddRemove = true;
        BeanContextChild child = new MockBeanContextChild();
        try {
            support.add(child);
            fail();
        } catch (IllegalStateException e) {
            // expected
        }
        support.records.assertRecord("initialize", null);
        support.records
                .assertRecord("validatePendingAdd", child, Boolean.FALSE);
        support.records.assertEndOfRecords();
        assertNull(l1.lastEvent);
        assertNull(l2.lastEvent);
        assertNull(l3.lastEvent);

        assertNull(child.getBeanContext());
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

    public void testGetBeanContextPeer() {
        // covered by testConstructor
    }

    public void testGetChildBeanContextChild_NullParam() {
        BeanContextChild result = MockBeanContextSupport
                .publicGetChildBeanContextChild(null);
        assertNull(result);
    }
View Full Code Here

Examples of java.beans.beancontext.BeanContextChild

        assertNull(result);
    }

    public void testGetChildBeanContextChild_BeanContextChild() {
        MockBeanContextChild child = new MockBeanContextChild();
        BeanContextChild result = MockBeanContextSupport
                .publicGetChildBeanContextChild(child);
        assertSame(child, result);

        // Regression for HARMONY-1393
        class TestBeanException extends BeanContextChildSupport implements
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.