From: Christian R. <lq...@us...> - 2002-06-28 12:22:43
|
User: lqd Date: 02/06/28 05:22:43 Modified: src/main/org/jboss/management/mejb Tag: Branch_3_0 ListenerRegistration.java Log: - evil DOS cr/lf be gone Revision Changes Path No revision No revision 1.1.2.2 +204 -204 jboss-management/src/main/org/jboss/management/mejb/ListenerRegistration.java Index: ListenerRegistration.java =================================================================== RCS file: /cvsroot/jboss/jboss-management/src/main/org/jboss/management/mejb/ListenerRegistration.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- ListenerRegistration.java 25 May 2002 02:30:34 -0000 1.1.2.1 +++ ListenerRegistration.java 28 Jun 2002 12:22:42 -0000 1.1.2.2 @@ -1,204 +1,204 @@ -/* - * JBoss, the OpenSource J2EE webOS - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.management.mejb; - -import java.security.InvalidParameterException; -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.List; - -import javax.ejb.CreateException; -import javax.management.InstanceNotFoundException; -import javax.management.ListenerNotFoundException; -import javax.management.NotificationFilter; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import javax.management.j2ee.ManagementHome; - -import org.jboss.management.mejb.MEJB; - -/** - * Root class of the JBoss JSR-77 implementation of - * {@link javax.management.j2ee.ListenerRegistration ListenerRegistration}. - * - * @author <a href="mailto:an...@jb...">Andreas Schaefer</a>. - * @version $Revision: 1.1.2.1 $ - * - * <p><b>Revisions:</b> - * - * <p><b>20011205 Andreas Schaefer:</b> - * <ul> - * <li> Creation - * </ul> - **/ -public class ListenerRegistration - implements javax.management.j2ee.ListenerRegistration -{ - // Constants ----------------------------------------------------- - - public static final int NOTIFICATION_TYPE_RMI = 0; - public static final int NOTIFICATION_TYPE_JMS = 1; - public static final int NOTIFICATION_TYPE_POLLING = 2; - - // Attributes ---------------------------------------------------- - - private ManagementHome mHome; - private int mEventType = NOTIFICATION_TYPE_RMI; - private String[] mOptions; - private List mListeners = new ArrayList(); - - // Static -------------------------------------------------------- - - // Constructors -------------------------------------------------- - - public ListenerRegistration( ManagementHome pHome, String[] pOptions ) { - if( pHome == null ) { - throw new InvalidParameterException( "Home Interface must be specified" ); - } - mHome = pHome; - mOptions = pOptions; - } - - // Public -------------------------------------------------------- - - // javax.management.j2ee.ListenerRegistration implementation ----- - - public void addNotificationListener( - ObjectName pName, - NotificationListener pListener, - NotificationFilter pFilter, - Object pHandback - ) - throws - InstanceNotFoundException, - RemoteException - { - MEJB lManagement = null; - // Create the remote MBean and register it - try { - // Get EJB - lManagement = getMEJB(); - ClientNotificationListener lListener = null; - switch( mEventType ) { - case NOTIFICATION_TYPE_RMI: - lListener = new RMIClientNotificationListener( - pName, - pListener, - pHandback, - pFilter, - lManagement - ); - break; - case NOTIFICATION_TYPE_JMS: - lListener = new JMSClientNotificationListener( - pName, - pListener, - pHandback, - pFilter, - mOptions[ 0 ], - mOptions[ 1 ], // JNDI-Server name - lManagement - ); - break; - case NOTIFICATION_TYPE_POLLING: - lListener = new PollingClientNotificationListener( - pName, - pListener, - pHandback, - pFilter, - 5000, // Sleeping Period - 2500, // Maximum Pooled List Size - lManagement - ); - } - // Add this listener on the client to remove it when the client goes down - mListeners.add( lListener ); - } - catch( Exception e ) { - if( e instanceof RuntimeException ) { - throw (RuntimeException) e; - } - if( e instanceof InstanceNotFoundException ) { - throw (InstanceNotFoundException) e; - } - throw new RuntimeException( "Remote access to perform this operation failed: " + e.getMessage() ); - } - finally { - if( lManagement != null ) { - try { - lManagement.remove(); - } - catch( Exception e ) { - // Ignore It - } - } - } - } - - public void removeNotificationListener( - ObjectName pName, - NotificationListener pListener - ) - throws - InstanceNotFoundException, - ListenerNotFoundException, - RemoteException - { - MEJB lManagement = null; - try { - // Get EJB - lManagement = getMEJB(); - - ClientNotificationListener lCheck = new SearchClientNotificationListener( pName, pListener ); - int i = mListeners.indexOf( lCheck ); - if( i >= 0 ) { - ClientNotificationListener lListener = (ClientNotificationListener) mListeners.get( i ); - lListener.removeNotificationListener( lManagement ); - } - } - catch( Exception e ) { - if( e instanceof RuntimeException ) { - throw (RuntimeException) e; - } - if( e instanceof InstanceNotFoundException ) { - throw (InstanceNotFoundException) e; - } - throw new RuntimeException( "Remote access to perform this operation failed: " + e.getMessage() ); - } - finally { - if( lManagement != null ) { - try { - lManagement.remove(); - } - catch( Exception e ) { - // Ignore It - } - } - } - } - - // Y overrides --------------------------------------------------- - - // Package protected --------------------------------------------- - - // Protected ----------------------------------------------------- - - // Private ------------------------------------------------------- - - private MEJB getMEJB() - throws - CreateException, - RemoteException - { - Object lTemp = mHome.create(); - MEJB lReturn = (MEJB) lTemp; - return lReturn; - } - - // Inner classes ------------------------------------------------- - -} +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.management.mejb; + +import java.security.InvalidParameterException; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.List; + +import javax.ejb.CreateException; +import javax.management.InstanceNotFoundException; +import javax.management.ListenerNotFoundException; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; +import javax.management.ObjectName; +import javax.management.j2ee.ManagementHome; + +import org.jboss.management.mejb.MEJB; + +/** + * Root class of the JBoss JSR-77 implementation of + * {@link javax.management.j2ee.ListenerRegistration ListenerRegistration}. + * + * @author <a href="mailto:an...@jb...">Andreas Schaefer</a>. + * @version $Revision: 1.1.2.2 $ + * + * <p><b>Revisions:</b> + * + * <p><b>20011205 Andreas Schaefer:</b> + * <ul> + * <li> Creation + * </ul> + **/ +public class ListenerRegistration + implements javax.management.j2ee.ListenerRegistration +{ + // Constants ----------------------------------------------------- + + public static final int NOTIFICATION_TYPE_RMI = 0; + public static final int NOTIFICATION_TYPE_JMS = 1; + public static final int NOTIFICATION_TYPE_POLLING = 2; + + // Attributes ---------------------------------------------------- + + private ManagementHome mHome; + private int mEventType = NOTIFICATION_TYPE_RMI; + private String[] mOptions; + private List mListeners = new ArrayList(); + + // Static -------------------------------------------------------- + + // Constructors -------------------------------------------------- + + public ListenerRegistration( ManagementHome pHome, String[] pOptions ) { + if( pHome == null ) { + throw new InvalidParameterException( "Home Interface must be specified" ); + } + mHome = pHome; + mOptions = pOptions; + } + + // Public -------------------------------------------------------- + + // javax.management.j2ee.ListenerRegistration implementation ----- + + public void addNotificationListener( + ObjectName pName, + NotificationListener pListener, + NotificationFilter pFilter, + Object pHandback + ) + throws + InstanceNotFoundException, + RemoteException + { + MEJB lManagement = null; + // Create the remote MBean and register it + try { + // Get EJB + lManagement = getMEJB(); + ClientNotificationListener lListener = null; + switch( mEventType ) { + case NOTIFICATION_TYPE_RMI: + lListener = new RMIClientNotificationListener( + pName, + pListener, + pHandback, + pFilter, + lManagement + ); + break; + case NOTIFICATION_TYPE_JMS: + lListener = new JMSClientNotificationListener( + pName, + pListener, + pHandback, + pFilter, + mOptions[ 0 ], + mOptions[ 1 ], // JNDI-Server name + lManagement + ); + break; + case NOTIFICATION_TYPE_POLLING: + lListener = new PollingClientNotificationListener( + pName, + pListener, + pHandback, + pFilter, + 5000, // Sleeping Period + 2500, // Maximum Pooled List Size + lManagement + ); + } + // Add this listener on the client to remove it when the client goes down + mListeners.add( lListener ); + } + catch( Exception e ) { + if( e instanceof RuntimeException ) { + throw (RuntimeException) e; + } + if( e instanceof InstanceNotFoundException ) { + throw (InstanceNotFoundException) e; + } + throw new RuntimeException( "Remote access to perform this operation failed: " + e.getMessage() ); + } + finally { + if( lManagement != null ) { + try { + lManagement.remove(); + } + catch( Exception e ) { + // Ignore It + } + } + } + } + + public void removeNotificationListener( + ObjectName pName, + NotificationListener pListener + ) + throws + InstanceNotFoundException, + ListenerNotFoundException, + RemoteException + { + MEJB lManagement = null; + try { + // Get EJB + lManagement = getMEJB(); + + ClientNotificationListener lCheck = new SearchClientNotificationListener( pName, pListener ); + int i = mListeners.indexOf( lCheck ); + if( i >= 0 ) { + ClientNotificationListener lListener = (ClientNotificationListener) mListeners.get( i ); + lListener.removeNotificationListener( lManagement ); + } + } + catch( Exception e ) { + if( e instanceof RuntimeException ) { + throw (RuntimeException) e; + } + if( e instanceof InstanceNotFoundException ) { + throw (InstanceNotFoundException) e; + } + throw new RuntimeException( "Remote access to perform this operation failed: " + e.getMessage() ); + } + finally { + if( lManagement != null ) { + try { + lManagement.remove(); + } + catch( Exception e ) { + // Ignore It + } + } + } + } + + // Y overrides --------------------------------------------------- + + // Package protected --------------------------------------------- + + // Protected ----------------------------------------------------- + + // Private ------------------------------------------------------- + + private MEJB getMEJB() + throws + CreateException, + RemoteException + { + Object lTemp = mHome.create(); + MEJB lReturn = (MEJB) lTemp; + return lReturn; + } + + // Inner classes ------------------------------------------------- + +} |