FileDocCategorySizeDatePackage
AdminEventListenerRegistry.javaAPI DocGlassfish v2 API17007Fri May 04 22:33:34 BST 2007com.sun.enterprise.admin.event

AdminEventListenerRegistry

public class AdminEventListenerRegistry extends Object
Event Listener registry for admin events. This is a singleton object that tracks all registered event handlers.

Fields Summary
static final String
notificationEventType
Constant used to refer to Notification Event listenerMap
private static HashMap
listenerMap
private static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
Methods Summary
public static voidaddApplicationDeployEventListener(ApplicationDeployEventListener listener)
Add an event listener of type ApplicationDeployEventListener to the registry. Once registered using this method, an ApplicationDeployEventListener receives all subsequent ApplicationDeployEvents.

        AdminEventMulticaster.addListener(ApplicationDeployEvent.eventType, listener);
    
public static voidaddAuditModuleEventListener(AuditModuleEventListener listener)
Add a listener for AuditModuleEvent

see
com.sun.enterprise.admin.event.AuditModuleEvent

        AdminEventMulticaster.addListener(
                AuditModuleEvent.eventType, listener);
    
public static voidaddAuthRealmEventListener(AuthRealmEventListener listener)
Add a listener for AuthRealmEvent

see
com.sun.enterprise.admin.event.AuthRealmEvent

        AdminEventMulticaster.addListener(
                AuthRealmEvent.eventType, listener);
    
public static voidaddBaseDeployEventListener(BaseDeployEventListener listener)
Add an event listener of type BaseDeployEventListener to the registry. Once registered using this method, a BaseDeployEventListener receives all subsequent BaseDeployEvents.


                              
       
              
        AdminEventMulticaster.addListener(BaseDeployEvent.eventType, listener);
    
public static voidaddConfigChangeEventListener(ConfigChangeEventListener listener)
Add an event listener of type ConfigChangeEventListener to the registry. Once registered using this method, a ConfigChangeEventListener receives all subsequent ConfigChangeEvents.

        AdminEventMulticaster.addListener(ConfigChangeEvent.eventType, listener);
    
public static voidaddConfigChangeEventListener(ConfigChangeCategory category, ConfigChangeEventListener listener)
Add a listener for ConfigChangeEvent that is invoked only if any of the config attributes as defined by ConfigChangeCategory have been changed.

see
com.sun.enterprise.admin.event.ConfigChangeCategory

        AdminEventMulticaster.addListener(ConfigChangeEvent.eventType, category,
                listener);
    
public static voidaddEjbTimerEventListener(EjbTimerEventListener listener)
Add a listener for EjbTimerEvent

see
com.sun.enterprise.admin.event.EjbTimerEvent

        AdminEventMulticaster.addListener(
                EjbTimerEvent.eventType, listener);
    
public static voidaddElementChangeEventListener(ElementChangeEventListener listener)
Add a listener for ElementChangeEvent

see
com.sun.enterprise.admin.event.ElementChangeEvent

        AdminEventMulticaster.addListener(
                ElementChangeEvent.eventType, listener);
    
public static voidaddEventListener(java.lang.String eventType, AdminEventListener listener)
Add a listener for AdminEvent

see
com.sun.enterprise.admin.event.AdminEvent
param
eventType type of the event
param
listener listener implemention for notifications
throws
IllegalArgumentException if event type and listener type are not compatible


        validateRegistration(eventType, listener);

        AdminEventMulticaster.addListener(
                eventType, listener);
    
public static voidaddLogLevelChangeEventListener(LogLevelChangeEventListener listener)
Add a listener for LogLevelChangeEvent

see
com.sun.enterprise.admin.event.LogLevelChangeEvent

        AdminEventMulticaster.addListener(
                LogLevelChangeEvent.eventType, listener);
    
public static voidaddModuleDeployEventListener(ModuleDeployEventListener listener)
Add an event listener of type ModuleDeployEventListener to the registry. Once registered using this method, a ModuleDeployEventListener receives all subsequent ModuleDeployEvents.

        AdminEventMulticaster.addListener(ModuleDeployEvent.eventType, listener);
    
public static voidaddMonitoringEventListener(MonitoringEventListener listener)
Add an event listener of type MonitoringEventListener to the registry. Once registered using this method, a MonitoringEventListener receives all subsequent MonitoringEvents.

        AdminEventMulticaster.addListener(MonitoringEvent.eventType, listener);
    
public static voidaddMonitoringLevelChangeEventListener(MonitoringLevelChangeEventListener listener)
Add a listener for MonitoringLevelChangeEvent

see
com.sun.enterprise.admin.event.MonitoringLevelChangeEvent

        AdminEventMulticaster.addListener(
                MonitoringLevelChangeEvent.eventType, listener);
    
public static voidaddResourceDeployEventListener(ResourceDeployEventListener listener)
Add an event listener of type ResourceDeployEventListener to the registry. Once registered using this method, a ResourceDeployEventListener receives all subsequent ResourceDeployEvents.

        AdminEventMulticaster.addListener(ResourceDeployEvent.eventType, listener);
    
public static voidaddSecurityServiceEventListener(SecurityServiceEventListener listener)
Add a listener for SecurityServiceEvent

see
com.sun.enterprise.admin.event.SecurityServiceEvent

        AdminEventMulticaster.addListener(
                SecurityServiceEvent.eventType, listener);
    
public static voidaddShutdownEventListener(ShutdownEventListener listener)
Add a listener for ShutdownEvent

see
com.sun.enterprise.admin.event.ShutdownEvent

        AdminEventMulticaster.addListener(ShutdownEvent.eventType, listener);
    
public static voidaddUserMgmtEventListener(UserMgmtEventListener listener)
Add a listener for UserMgmtEvent

see
com.sun.enterprise.admin.event.UserMgmtEvent

        AdminEventMulticaster.addListener(
                UserMgmtEvent.eventType, listener);
    
public static voidremoveEventListener(AdminEventListener listener)
Remove specified event listener from event registry.

param
listener the event listener to remove

        AdminEventMulticaster.removeListener(listener);
    
private static voidvalidateRegistration(java.lang.String eventType, AdminEventListener listener)


        if ( (eventType == null) || (listener == null)) {
            String msg = localStrings.getString("admin.null_not_supported");
            throw new IllegalArgumentException(msg);
        }

        // Expected listener interface class
        Class listenerImplClass = (Class) listenerMap.get(eventType);
        if (listenerImplClass == null) {
            // event type is not valid or not supported.
            String msg = localStrings.getString("admin.event.invalid_event_type"                                , eventType);
            throw new IllegalArgumentException(msg);
        }
        
        // get the interfaces of the passed in class
        Class[] classes = listener.getClass().getInterfaces();

        if (classes == null) {
            String msg = localStrings.getString("admin.event.does_not_implement"                            ,listener.getClass().getName());
            throw new IllegalArgumentException(msg);
        }

        boolean found = false;
        // go through all interface names
        for(int i=0; i< classes.length; i++) {
          String cName = classes[i].getName(); 
          if (cName != null ) {
            // compare interface name to expected interface name
            if (cName.equals(listenerImplClass.getName() )){
                found = true;
                break;
            }
          }
        }
        if(!found) {
            String msg = localStrings.getString("admin.event.not_compatible",
                    eventType,listenerImplClass.getName(),
                        listener.getClass().getName())  ;
            throw new IllegalArgumentException();
        }