java类java.beans.beancontext.BeanContextSupport的实例源码

SerialDataNode.java 文件源码 项目:incubator-netbeans 阅读 23 收藏 0 点赞 0 评论 0
/** Create nodes for a given key.
 * @param key the key
 * @return child nodes for this key or null if there should be no
 *   nodes for this key
 */
protected Node[] createNodes(Object key) {
    Object ctx = bean;
    if (bean == null) return new Node[0];

    try {
        if (key instanceof BeanContextSupport) {
            BeanContextSupport bcs = (BeanContextSupport)key;

            if (((BeanContext) ctx).contains (bcs.getBeanContextPeer())) {
                // sometimes a BeanContextSupport occures in the list of
                // beans children even there is its peer. we think that
                // it is desirable to hide the context if the peer is
                // also present
                return new Node[0];
            }
        }

        return new Node[] { new BeanContextNode (key, task) };
    } catch (IntrospectionException ex) {
        // ignore the exception
        return new Node[0];
    }
}
SoloMapComponentRejectPolicy.java 文件源码 项目:passage 阅读 42 收藏 0 点赞 0 评论 0
/**
 * @throws a MultipleSoloMapComponentException if a duplicate
 *         instance of SoloMapComponent exists.
 * @return true if the object can be added to the MapHandler.
 */
public boolean canAdd(BeanContextSupport bc, Object obj)
        throws MultipleSoloMapComponentException {
    if (obj instanceof SoloMapComponent) {
        Class firstClass = obj.getClass();
        for (Iterator it = bc.iterator(); it.hasNext();) {
            Object someObj = it.next();
            if (someObj instanceof SoloMapComponent) {
                Class secondClass = someObj.getClass();

                if (firstClass == secondClass
                        || firstClass.isAssignableFrom(secondClass)
                        || secondClass.isAssignableFrom(firstClass)) {

                    throw new MultipleSoloMapComponentException(firstClass, secondClass);
                }
            }
        }
    }
    return true;
}
BeanContextSupportTest.java 文件源码 项目:cn1 阅读 27 收藏 0 点赞 0 评论 0
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextSupport support = new BeanContextSupport(null, Locale.ITALY,
            true, true);
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l2"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l3"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");
    support.add(new MockBeanContextProxyS("proxy",
            new MockBeanContextChildS("b child")));

    assertEqualsSerially(support, (BeanContextSupport) SerializationTester
            .getDeserilizedObject(support));
}
BeanContextSupportTest.java 文件源码 项目:freeVM 阅读 33 收藏 0 点赞 0 评论 0
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextSupport support = new BeanContextSupport(null, Locale.ITALY,
            true, true);
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l2"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l3"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");
    support.add(new MockBeanContextProxyS("proxy",
            new MockBeanContextChildS("b child")));

    assertEqualsSerially(support, (BeanContextSupport) SerializationTester
            .getDeserilizedObject(support));
}
BeanContextSupportTest.java 文件源码 项目:freeVM 阅读 24 收藏 0 点赞 0 评论 0
public void testSerialization_Compatibility() throws Exception {
    MockBeanContextDelegateS mock = new MockBeanContextDelegateS("main id");
    BeanContextSupport support = mock.support;
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListenerS("l2"));
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListenerS("l3"));
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");

    MockBeanContextDelegateS serMock = (MockBeanContextDelegateS) SerializationTester
            .readObject(mock, "serialization/java/beans/beancontext/BeanContextSupport.ser");
    assertEquals(mock.id, serMock.id);
    assertSame(mock, mock.support.beanContextChildPeer);
    assertSame(serMock, serMock.support.beanContextChildPeer);
    assertEqualsSerially(mock.support, serMock.support);
}
BeanContextSupportTest.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextSupport support = new BeanContextSupport(null, Locale.ITALY,
            true, true);
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l2"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l3"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");
    support.add(new MockBeanContextProxyS("proxy",
            new MockBeanContextChildS("b child")));

    assertEqualsSerially(support, (BeanContextSupport) SerializationTester
            .getDeserilizedObject(support));
}
TestCollectionBeanContext.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextSupport#retainAll(Collection)
 * @see java.beans.beancontext.BeanContextSupport#iterator()
 */
public Result testContainsAllBeanContext()throws Exception {

    bean = new BeanContextChildSupport();
    beanWithContext = new BeanWithBeanContext();
    subContext = new BeanContextSupport();

    vector = new Vector();

    // Adding the components
    context.add(bean);
    context.add(beanWithContext);
    context.add(subContext);

    // Adding the components from bean context to Vector
    for (int i = 0; i < context.size(); i++) {
        vector.add(context.iterator().next());
    }

    // It's verified that objects in the specified Vector are children of this bean context 
    if (context.containsAll(vector)) {
        return passed();
    } else {
        return failed("testCollectionContainsAll() - failed ");
    }
}
TestSizeBeanContext.java 文件源码 项目:freeVM 阅读 26 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextSupport#size()
 */
public Result testSize() throws Exception {

    // The BeanContext object to be checked by the test
    BeanContextSupport contextForSize = new BeanContextSupport(); 

    // Components that should be added to context
    BeanContextSupport subContext = new BeanContextSupport();                                                                  
    BeanWithBeanContext beanWithContext = new BeanWithBeanContext();        
    BeanContextChildSupport bean = new BeanContextChildSupport();

    // Adding the components
    contextForSize.add(subContext);
    contextForSize.add(beanWithContext);
    contextForSize.add(bean);

    // It's verified that the BeanContext contains 4 components
    if (contextForSize.size() == 4) {
        return passed();
    } else {
        return failed("testSize() - failed ");
    }
}
TestSizeBeanContext.java 文件源码 项目:freeVM 阅读 54 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextSupport#isEmpty()
 */
public Result testIsContextEmpty() throws Exception {

    // The BeanContext object to be checked by the test
    BeanContextSupport context = new BeanContextSupport(); 

    // Components that should be added to context
    BeanContextSupport subContext = new BeanContextSupport();                                                                  
    BeanWithBeanContext beanWithContext = new BeanWithBeanContext();        
    BeanContextChildSupport bean = new BeanContextChildSupport();

    // Adding the components
    context.add(subContext);
    context.add(beanWithContext);
    context.add(bean);

    // It's verified that the BeanContext isn't empty
    if (!context.isEmpty()) {
        return passed();
    } else {
        return failed("testIsContextEmpty() - failed ");
    }
}
TestBeanContextMembershipEvent.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent
 */
public Result testNullPointerException1() throws Exception {

    context = new BeanContextSupport();

    bean = new BeanContextChildSupport();

    // Adding the component
    context.add(bean);

    Object[] array = null;
    try {
        event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
    } catch (java.lang.NullPointerException e) {
        return passed();
    }
    return failed("testNullPointerException1");
}
TestBeanContextMembershipEvent.java 文件源码 项目:freeVM 阅读 27 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent
 */
public Result testNullPointerException2() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();

    // Adding the component
    context.add(bean);

    Collection[] array = null;
    try {
        event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
    } catch (java.lang.NullPointerException e) {

        return passed();
    }
    return failed("testNullPointerException2");
}
TestBeanContextMembershipEvent.java 文件源码 项目:freeVM 阅读 23 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent#contains()
 */
public Result testContainsBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());

    if ((event.contains(sBean)) || !(event.contains(context)))
        return passed();
    else
        return failed("testContainsBeanContextMembershipEvent");
}
TestBeanContextMembershipEvent.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextSupport#iterator()
 */
public Result testIteratorBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());

    if ((event.iterator() instanceof java.util.Iterator))
        return passed();
    else
        return failed("testIteratorBeanContextMembershipEvent");
}
TestBeanContextMembershipEvent.java 文件源码 项目:freeVM 阅读 30 收藏 0 点赞 0 评论 0
/**
 * @see java.beans.beancontext.BeanContextSupport#size()
 */
public Result testSizeBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());
    // System.out.println(event.size());
    if (event.size() == 2)
        return passed();
    else
        return failed("testSizeBeanContextMembershipEvent");
}
Test4233980.java 文件源码 项目:jdk8u-jdk 阅读 25 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:openjdk-jdk10 阅读 25 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:openjdk9 阅读 25 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:jdk8u_jdk 阅读 20 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 22 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
XMLBeans.java 文件源码 项目:repo.kmeanspp.silhouette_score 阅读 20 收藏 0 点赞 0 评论 0
/**
 * initializes the serialization for different types of data
 * 
 * @param layout the component that manages the layout
 * @param context the bean context support to use
 * @param datatype the type of data to read/write
 * @throws Exception if initialization fails
 */
public XMLBeans(JComponent layout, BeanContextSupport context, int datatype,
  int tab) throws Exception {
  super();

  m_vectorIndex = tab;
  m_BeanLayout = layout;
  m_BeanContextSupport = context;
  setDataType(datatype);
}
XMLBeans.java 文件源码 项目:autoweka 阅读 25 收藏 0 点赞 0 评论 0
/**
 * initializes the serialization for different types of data
 * 
 * @param layout      the component that manages the layout
 * @param context     the bean context support to use
 * @param datatype    the type of data to read/write
 * @throws Exception  if initialization fails
 */
public XMLBeans(JComponent layout, BeanContextSupport context, int datatype, 
    int tab) throws Exception {
  super();

  m_vectorIndex = tab;
  m_BeanLayout = layout;
  m_BeanContextSupport = context;
  setDataType(datatype);
}
XMLBeans.java 文件源码 项目:umple 阅读 22 收藏 0 点赞 0 评论 0
/**
 * initializes the serialization for different types of data
 * 
 * @param layout the component that manages the layout
 * @param context the bean context support to use
 * @param datatype the type of data to read/write
 * @throws Exception if initialization fails
 */
public XMLBeans(JComponent layout, BeanContextSupport context, int datatype,
  int tab) throws Exception {
  super();

  m_vectorIndex = tab;
  m_BeanLayout = layout;
  m_BeanContextSupport = context;
  setDataType(datatype);
}
Test4233980.java 文件源码 项目:infobip-open-jdk-8 阅读 20 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:jdk8u-dev-jdk 阅读 24 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:jdk7-jdk 阅读 22 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
Test4233980.java 文件源码 项目:openjdk-source-code-learn 阅读 26 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
SoloMapComponentReplacePolicy.java 文件源码 项目:passage 阅读 20 收藏 0 点赞 0 评论 0
/**
 * @return true if the object can be added to the MapHandler, and
 *         will have removed the previous duplicate from the
 *         MapHandler.
 */
public boolean canAdd(BeanContextSupport bc, Object obj)
        throws MultipleSoloMapComponentException {

    if (obj == null) {
        return false;
    }

    // At first we just added the new item, but we should remove
    // the previous one, too.
    if (obj instanceof SoloMapComponent) {
        Class firstClass = obj.getClass();
        for (Iterator it = bc.iterator(); it.hasNext();) {
            Object someObj = it.next();
            if (someObj instanceof SoloMapComponent) {
                Class secondClass = someObj.getClass();

                if (firstClass == secondClass
                        || firstClass.isAssignableFrom(secondClass)
                        || secondClass.isAssignableFrom(firstClass)) {

                    bc.remove(someObj);
                    break;
                }
            }
        }
    }

    return true;
}
Test4233980.java 文件源码 项目:OLD-OpenJDK8 阅读 22 收藏 0 点赞 0 评论 0
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
BeansTest.java 文件源码 项目:cn1 阅读 22 收藏 0 点赞 0 评论 0
public void testInstantiateClassLoaderStringBeanContext_Class()
        throws Exception {

    ClassLoader loader = new BinClassLoader();
    BeanContext context = new BeanContextSupport();
    Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);

    assertEquals("as_class", (String) bean.getClass().getMethod(
            "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
    assertSame(loader, bean.getClass().getClassLoader());
    assertTrue(context.contains(bean));
}
BeansTest.java 文件源码 项目:cn1 阅读 22 收藏 0 点赞 0 评论 0
public void testInstantiateClassLoaderStringBeanContext_Ser()
        throws Exception {
    ClassLoader loader = new SerClassLoader();
    BeanContext context = new BeanContextSupport();
    Object bean = Beans.instantiate(loader, MOCK_JAVA_BEAN2, context);

    assertEquals("as_object", (String) bean.getClass().getMethod(
            "getPropertyOne", (Class[]) null).invoke(bean, (Object[]) null));
    assertSame(loader, bean.getClass().getClassLoader());
    assertTrue(context.contains(bean));
}


问题


面经


文章

微信
公众号

扫码关注公众号