Example usage for java.beans.beancontext BeanContextSupport size

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

Introduction

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

Prototype

public int size() 

Source Link

Document

Gets the number of children currently nested in this BeanContext.

Usage

From source file:Example3.java

public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport();
    System.out.println("Number of children nested into the context: " + context.size());

    BeanContextChildSupport child = null;
    try {// w  w  w .jav a  2  s  .co m
        child = (BeanContextChildSupport) context
                .instantiateChild("java.beans.beancontext.BeanContextChildSupport");
    } catch (IOException e) {
        System.out.println("IOException occurred: " + e.getMessage());
    } catch (ClassNotFoundException e) {
        System.out.println("Class not found: " + e.getMessage());
    }
    System.out.println("Number of children nested into the context: " + context.size());
}

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  w w  .jav  a 2  s .co m
    }
    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);
}