Example usage for java.beans.beancontext BeanContextSupport add

List of usage examples for java.beans.beancontext BeanContextSupport add

Introduction

In this page you can find the example usage for java.beans.beancontext BeanContextSupport add.

Prototype

public boolean add(Object targetChild) 

Source Link

Document

Adds/nests a child within this BeanContext .

Usage

From source file:MembershipTest.java

public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // the context
    MyMembershipListener listener = new MyMembershipListener();
    BeanContextChildSupport bean = new BeanContextChildSupport(); // a JavaBean
    context.addBeanContextMembershipListener(listener); // now listening!
    context.add(bean);
    context.remove(bean);//  ww w .ja va2  s  . c o m
}

From source file:MembershipTest.java

public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // the context
    MyMembershipListener listener = new MyMembershipListener();
    BeanContextChildSupport bean = new BeanContextChildSupport(); // a
    // JavaBean/*from ww w.  j  av a 2  s  .c o  m*/
    context.addBeanContextMembershipListener(listener); // now listening!
    context.add(bean);
    context.remove(bean);
}

From source file:Example2.java

public static void main(String[] args) {

    // A BeanContext
    BeanContextSupport context = new BeanContextSupport();

    // Many JavaBeans
    BeanContextChildSupport[] beans = new BeanContextChildSupport[100];

    System.out.println("Number of children in the context: " + context.size());

    // Create the beans and add them to the context
    for (int i = 0; i < beans.length; i++) {
        beans[i] = new BeanContextSupport();
        context.add(beans[i]);
    }//  w ww  . jav  a 2 s  .  c  om
    System.out.println("Number of children in the context: " + context.size());

    // Context now has 100 beans in it, get references to them all
    Object[] children = context.toArray();
    System.out.println("Number of objects retrieved from the context: " + children.length);
}