Results 1 to 5 of 5

Thread: What is the BeanContextMembershipEvent Notification?

  1. #1
    Join Date
    Aug 2006
    Posts
    148

    What is the BeanContextMembershipEvent Notification?

    Hi friends,
    Last time you all guys helped me a lot for solving mu issue. So I thought that posting here my query would be helpful. I have recently started doing the Beans Context. In that I am unable to understand about the BeanContextMembershipEvent.!! So can anyone out there explain me what is the BeanContextMembershipEvent Notification.?? Expecting the needful solution sooner.!!
    The Gaming Machine:
    Processor: Core 2 Duo E6400
    Motherboard: Asus P5W DH Deluxe
    RAM: 2GB XMS2 Corsair PC2-6400
    Video: ATI Radeon X1900XT 512MB w/ Arctic Accellero
    Drive: 74GB "WD Raptor" 10000RPM
    Sound: Creative SoundBlaster X-Fi
    Watercooling: *Soon* Zalman Reserator

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

    Re: What is the BeanContextMembershipEvent Notification?

    The BeanContext API uses the standard Java event model to register listeners and deliver events. A BeanContextMembershipEvent encapsulates the list of children added to, or removed from, the membership of a particular BeanContext. An instance of this event is fired whenever a successful add(), remove(), retainAll(), removeAll(), or clear() is invoked on a given BeanContext instance. Objects interested in receiving events of this type must implement the BeanContextMembershipListener interface

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: What is the BeanContextMembershipEvent Notification?

    Compliant BeanContexts fire events on this interface when the state of the membership of the BeanContext changes. The method childrenAdded is called when a child or list of children is added to a BeanContext that this listener is registered with. The following shows an example of the same :
    Code:
    void childrenAdded(BeanContextMembershipEvent bcme)

  4. #4
    Join Date
    Nov 2008
    Posts
    996

    Re: What is the BeanContextMembershipEvent Notification?

    I thought that providing code would be useful for you to understand. So I have given the following code that is the sample code of BeanContextMembershipEvent Notification :
    Code:
    import java.beans.beancontext.*;
    
    public class MembershipDemo {
        public static void main(String[] args) {
            BeanContextSupport context = new BeanContextSupport(); 
            MyMembershipListener listener = new MyMembershipListener(); 
            BeanContextChildSupport bean = new BeanContextChildSupport(); 
            context.addBeanContextMembershipListener(listener); 
            context.add(bean);
            context.remove(bean);
        }
    }
    
    class MyMembershipListener implements BeanContextMembershipListener {
        public void childrenAdded(BeanContextMembershipEvent bcme) {
            System.out.println("Another bean has been added to the context.");
        }
    
        public void childrenRemoved(BeanContextMembershipEvent bcme) {
            System.out.println("A bean has been removed from the context.");
        }
    }

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: What is the BeanContextMembershipEvent Notification?

    I have given you the coding of the same example described by the 'CodGuru' but i have implemented using an anonymous inner class :
    Code:
    import java.beans.beancontext.*;
    
    public class MembershipDemo {
        public static void main(String[] args) {
            BeanContextSupport context = new BeanContextSupport();
            context.addBeanContextMembershipListener(new BeanContextMembershipListener() {
                public void childrenAdded(BeanContextMembershipEvent bcme) {
                    System.out.println("Another bean has been added to the context.");
                }
    
                public void childrenRemoved(BeanContextMembershipEvent bcme) {
                    System.out.println("A bean has been removed from the context.");
                }
            });
            BeanContextChildSupport bean = new BeanContextChildSupport();
            context.add(bean);
            context.remove(bean);
        }
    }

Similar Threads

  1. LED Notification in HTC One S?
    By $Doggy$ in forum Portable Devices
    Replies: 5
    Last Post: 16-04-2012, 03:33 PM
  2. Where is the notification light in HTC One X?
    By G.Mcgrath in forum Portable Devices
    Replies: 4
    Last Post: 26-03-2012, 06:26 PM
  3. No sms notification in Nokia N9?
    By G.Mcgrath in forum Portable Devices
    Replies: 3
    Last Post: 14-02-2012, 08:58 PM
  4. Facebook Notification won't go away
    By MadhaviS in forum Portable Devices
    Replies: 6
    Last Post: 25-07-2010, 12:16 AM
  5. mail notification
    By hippey in forum Windows Vista Mail
    Replies: 3
    Last Post: 30-10-2007, 12:42 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,235,983.80739 seconds with 17 queries