FileDocCategorySizeDatePackage
NotificationEventFactory.javaAPI DocGlassfish v2 API5364Fri May 04 22:33:44 BST 2007com.sun.enterprise.admin.selfmanagement.event

NotificationEventFactory

public class NotificationEventFactory extends EventAbstractFactory
This is the factory to build and configure Timer Event
author
Sun Micro Systems, Inc

Fields Summary
private static final NotificationEventFactory
instance
private static final String
instanceName
Constructors Summary
private NotificationEventFactory()
Creates a new instance of LogEventFactory

        super();
        EventBuilder.getInstance().addEventFactory(EVENT_NOTIFICATION, this);
    
Methods Summary
static com.sun.enterprise.admin.selfmanagement.event.NotificationEventFactorygetInstance()

        return instance;
    
public EventinstrumentEvent(com.sun.enterprise.config.serverbeans.ElementProperty[] properties, java.lang.String description)

        // sourcembean
        //String sourceMbean = null;
        String sourceMbeanObjName = null;
        String sourceMbeanName = null;
        for( int i = 0; i < properties.length; i++ ){
            ElementProperty property = properties[i];
            String propertyName = property.getName( ).toLowerCase( );
            if (propertyName.equals(PROPERTY_NOTIFICATION_SOURCE_OBJ_NAME)) {
                sourceMbeanObjName = property.getValue();
            } else if (propertyName.equals(PROPERTY_NOTIFICATION_SOURCEMBEAN)) {
                sourceMbeanName = property.getValue();
            }
        }
        if (sourceMbeanName ==  null && sourceMbeanObjName == null) {
            throw new IllegalArgumentException(
                    sm.getString("selfmgmt_event.invalid_event_property","sourceMBean","notification"));
        }
        String sourceMbean = null;
        if(sourceMbeanObjName != null) {
            //final String serverNameVal  = System.getProperty("com.sun.aas.instanceName");
            Pattern pat = Pattern.compile("\\$\\{instance.name\\}");
            Matcher m = pat.matcher(sourceMbeanObjName);
            if(m.find()) {
                sourceMbean = m.replaceAll(instanceName);
            } else {
                sourceMbean = sourceMbeanObjName;
            }
        } else if(sourceMbeanName != null) {
            sourceMbean = ManagementRulesMBeanHelper.getObjName(sourceMbeanName);
        }
        /*if (!(sourceMbean.endsWith(",server=" + instanceName))) {
            sourceMbean = sourceMbean + ",server=" + instanceName;
        }*/
 
        try {
            ObjectName oName = new ObjectName(sourceMbean);
            return new NotificationEvent(oName, description);
        } catch (MalformedObjectNameException ex) {
            throw new IllegalArgumentException(
                    sm.getString("selfmgmt_event.invalid_event_property","sourceMBean","notification"));
        }