Results 1 to 5 of 5

Thread: What is the Bean Context : Containment Only?

  1. #1
    Join Date
    Aug 2006
    Posts
    121

    What is the Bean Context : Containment Only?

    Hi friends,
    I have done little bit of things in Java Beans. But I am confused in Bean Context. There are some types of the Bean Contexts. I have recently started learning about it, so don't have enough idea about it. So thought posting here would help me..!! Please tell me what is the Bean Context : Containment Only? Hope that someone would help me as soon as possible.!!
    Whats my name again? I spend so much time looking at code i fogot my own name ahhh!

  2. #2
    Join Date
    Jul 2006
    Posts
    286

    Re: What is the Bean Context : Containment Only?

    The "containment" portion of the Extensible Runtime Containment and Services Protocol is defined by the BeanContext interface. We basically use a BeanContext to logically group a set of related java beans, bean contexts, or arbitrary objects. JavaBeans nested into a BeanContext are known as "child" beans. Once nested, a child bean can query its BeanContext for various membership information.
    IF you hate me, please don't mention it. I know who hates me and who doesn't. You really do not have to make fun of people....

  3. #3
    Join Date
    Aug 2006
    Posts
    235

    Re: What is the Bean Context : Containment Only?

    With a BeanContextSupport instance, it is possible to :
    • You can add an object, bean, or BeanContext: boolean add(Object o).
    • You can remove an object, bean, or BeanContext: boolean remove(Object o).
    • You can also add a BeanContextMembershipListener: void addBeanContextMembershipListener(BeanContextMembershipListener bcml).
    • You can also remove a BeanContextMembershipListener: void removeBeanContextMembershipListener(BeanContextMembershipListener bcml).
    • You can get the number of children currently nested in this BeanContext: int size().
    • Determine whether or not the BeanContext currently has zero children: boolean isEmpty().
    3.2 (northwood)
    2gig ram
    ATI AIW X800xt 256mb
    Gigabyte GA-8knxp 875p Chipset
    Optiwrite 8X DVD Burner
    Win XP PRO Sp2 (Works Perfectly)
    2 SATA Raptor 74gig Raid 0
    2 7200 IDE 320gig HD

  4. #4
    Join Date
    Jul 2006
    Posts
    442

    Re: What is the Bean Context : Containment Only?

    After looking at the coding, I think that you can understand more better, so i have provided you with an example :
    Code:
    import java.beans.beancontext.*;
    
    public class BeansEx {
        private static BeanContextSupport context = new BeanContextSupport(); 
        private static BeanContextChildSupport bean = new BeanContextChildSupport();
      
        public static void main(String[] args) {
            report();  
    
            System.out.println("Adding bean to context...");
            context.add(bean);
    
            report();
        }
    
        private static void report() {
            System.out.println("-------------");
    
            System.out.println("Is the context empty? " + context.isEmpty());
    
            boolean result = (bean.getBeanContext()!=null);
            System.out.println("Does the bean have a context yet? " + result);
    
            System.out.println("Number of children in the context: " + context.size());
    
            System.out.println("Is the bean a member of the context? " + context.contains(bean));
    
            if (bean.getBeanContext() != null) {
                boolean isEqual = (bean.getBeanContext()==context); // true means both references point to the same object
                System.out.println("Contexts are the same? " + isEqual);
            }
            System.out.println("-----------------");   
        }
    }
    "When they give you ruled paper, write the other way..." J.R.J.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: What is the Bean Context : Containment Only?

    I also have given an example that may help you :
    Code:
    import java.beans.beancontext.*;
    
    public class BeansTrial {
        public static void main(String[] args) {
    
            BeanContextSupport context = new BeanContextSupport(); 
    
            BeanContextChildSupport[] beans = new BeanContextChildSupport[100];
    
            System.out.println("Number of children in the context: " + context.size());
    
            for (int i = 0; i < beans.length; i++) {
                beans[i] = new BeanContextSupport();
                context.add(beans[i]);
            }
            System.out.println("Number of children in the context: " + context.size());
    
            Object[] children = context.toArray();
            System.out.println("Number of objects retrieved from the context: " + children.length);
        }
    }

Similar Threads

  1. Will HTC EVO 4G LTE get Android 4.1 Jelly Bean
    By Somatra in forum Portable Devices
    Replies: 4
    Last Post: 30-06-2012, 05:44 PM
  2. What are the Bean Persistence?
    By hatred in forum Software Development
    Replies: 5
    Last Post: 17-02-2010, 05:57 AM
  3. Differentiation between Containment and Inheritance
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 09:59 AM
  4. Don't know how to run the java bean program
    By Reema_n in forum Software Development
    Replies: 5
    Last Post: 23-12-2009, 11:01 AM
  5. newfolder.exe containment procedure
    By Derek in forum Windows Security
    Replies: 2
    Last Post: 03-12-2009, 04:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,275,750.03349 seconds with 17 queries