FileDocCategorySizeDatePackage
WebServiceEndpointEventListenerImpl.javaAPI DocGlassfish v2 API11638Fri May 04 22:24:42 BST 2007com.sun.enterprise.admin.wsmgmt.lifecycle.reconfig

WebServiceEndpointEventListenerImpl

public class WebServiceEndpointEventListenerImpl extends Object implements com.sun.enterprise.admin.event.wsmgmt.WebServiceEndpointEventListener
Listener impl to handle web-service-endpoint element events.

Fields Summary
Constructors Summary
Methods Summary
private java.lang.StringgetApplicationId(com.sun.enterprise.config.serverbeans.WebServiceEndpoint bean)
Returns application registration name for this endpoing.

param
bean web service endpint config bean
return
application registration name

        String name = null;

        if (bean != null) {
            ConfigBean parent = (ConfigBean) bean.parent();
            if (parent instanceof J2eeApplication) {
                J2eeApplication app = (J2eeApplication) parent;
                name = app.getName();
            } else if (parent instanceof WebModule) {
                WebModule wm = (WebModule) parent;
                name = wm.getName();
            } else if (parent instanceof EjbModule) {
                EjbModule em = (EjbModule) parent;
                name = em.getName();
            }
        }
        return name;
    
private com.sun.enterprise.config.ConfigBeangetWSEPBean(com.sun.enterprise.admin.event.wsmgmt.WebServiceEndpointEvent event, boolean old)
Returns the web-service-endpoint config bean for this event.

param
event web service endpoint event
param
old true when old config context is used
return
web service endpoing config bean


        if (event == null) {
            throw new IllegalArgumentException();
        }

        ConfigBean bean = null;
        ConfigContext ctx = null;
        String xpath = event.getElementXPath();
        if (old) {
            ctx = event.getOldConfigContext();
        } else {
            ctx = event.getConfigContext();
        }
        if (ctx != null) {
            bean = ctx.exactLookup(xpath);
        }

        return bean;
    
public voidhandleCreate(com.sun.enterprise.admin.event.wsmgmt.WebServiceEndpointEvent event)
Handles element additions.

param
event Event to be processed.
throws
AdminEventListenerException when the listener is unable to process the event.


        try {
            ConfigBean bean = getWSEPBean(event, false);
            if (bean instanceof WebServiceEndpoint) {
                WebServiceEndpoint wsep = (WebServiceEndpoint) bean;
                int historySize = 25;
                String epName = wsep.getName();
                String appId = getApplicationId(wsep);

                String hs = wsep.getMaxHistorySize();
                if (hs != null) {
                    historySize = Integer.parseInt(hs);
                }

                // monitoring level
                String newMonitoring = wsep.getMonitoring();

                if ("HIGH".equalsIgnoreCase(newMonitoring)) {
                    // enables message trace for this endpoint
                    MessageTraceMgr traceMgr = MessageTraceMgr.getInstance();
                    traceMgr.enable(appId, epName, historySize);
                }

                AppServWSMonitorLifeCycleProvider aplifeProv = 
                    new AppServWSMonitorLifeCycleProvider(); 
                aplifeProv.reconfigureMonitoring(wsep, appId, 
                MonitoringLevel.instance("OFF"),
                MonitoringLevel.instance(wsep.getMonitoring())); 
            } 
        } catch (Exception e) {
            throw new AdminEventListenerException(e);
        }
    
public voidhandleDelete(com.sun.enterprise.admin.event.wsmgmt.WebServiceEndpointEvent event)
Handles web-service-endpoint element removal.

param
event Event to be processed.
throws
AdminEventListenerException when the listener is unable to process the event.


        try { 
            ConfigBean bean = getWSEPBean(event, true);
            if (bean instanceof WebServiceEndpoint) {
                WebServiceEndpoint wsep = (WebServiceEndpoint) bean;
                String epName = wsep.getName();
                String appId = getApplicationId(wsep);

                // disables message trace for this endpoint
                MessageTraceMgr traceMgr = MessageTraceMgr.getInstance();
                traceMgr.disable(appId, epName);

                AppServWSMonitorLifeCycleProvider aplifeProv = 
                    new AppServWSMonitorLifeCycleProvider(); 
                aplifeProv.reconfigureMonitoring(wsep, appId, 
                MonitoringLevel.instance(wsep.getMonitoring()), 
                MonitoringLevel.instance("OFF"));

            } 
        } catch (Exception e) {
            throw new AdminEventListenerException(e);
        }
    
public voidhandleUpdate(com.sun.enterprise.admin.event.wsmgmt.WebServiceEndpointEvent event)
Handles web-service-endpoint element modification (attributes/properties values changed).

param
event Event to be processed.
throws
AdminEventListenerException when the listener is unable to process the event.


        try {
            // set message in history size
            ConfigBean bean = getWSEPBean(event, false);
            if (bean instanceof WebServiceEndpoint) {
                WebServiceEndpoint wsep = (WebServiceEndpoint) bean;
                WebServiceEndpoint oWsep = 
                    (WebServiceEndpoint) getWSEPBean(event, true);

                // monitoring level
                String newMonitoring = wsep.getMonitoring();
                String oldMonitoring = oWsep.getMonitoring();

                // history size
                int historySize = 25;

                // end point name
                String epName = wsep.getName();

                String hs = wsep.getMaxHistorySize();
                if (hs != null) {
                    historySize = Integer.parseInt(hs);
                }

                // application id
                String appId = getApplicationId(wsep);

                // message trace manager
                MessageTraceMgr traceMgr = MessageTraceMgr.getInstance();

                // monitoring level changed
                if ( (newMonitoring != null) && (oldMonitoring != null) 
                        && (!newMonitoring.equals(oldMonitoring)) ) {

                    // monitoring level is changed to HIGH
                    if ("HIGH".equalsIgnoreCase(newMonitoring)) {
                        traceMgr.enable(appId, epName, historySize);

                    // monitoirng level is changed from HIGH to LOW or OFF
                    } else if ("HIGH".equalsIgnoreCase(oldMonitoring)) {
                        traceMgr.disable(appId, epName);
                    }
                } else {
                    // old history size
                    String oldHs = oWsep.getMaxHistorySize();
                    int oldHistorySize = 0;
                    if (oldHs != null) {
                        oldHistorySize = Integer.parseInt(oldHs);
                    }

                    // history size has changed and monitoring level is HIGH
                    if ((historySize != oldHistorySize) 
                            && ("HIGH".equalsIgnoreCase(newMonitoring))) {

                        traceMgr.setMessageHistorySize(appId, epName, 
                                                        historySize);
                    }
                }
                    
                AppServWSMonitorLifeCycleProvider aplifeProv = 
                    new AppServWSMonitorLifeCycleProvider(); 
                aplifeProv.reconfigureMonitoring(wsep, appId, 
                MonitoringLevel.instance(oldMonitoring), 
                MonitoringLevel.instance(newMonitoring));
                
                // Check for jbiEnabled Flag
                boolean jbiEnabledFlag = wsep.isJbiEnabled();
                boolean oldJbiEnabledSetting =oWsep.isJbiEnabled(); 
                if(jbiEnabledFlag  != oldJbiEnabledSetting) {
                    String endpointURI = WebServiceMgrBackEnd.getManager().
                              getEndpointURI(getApplicationId(wsep) + "#" + epName);
                    if(endpointURI != null && (ServiceEngineRtObjectFactory.getInstance().getFacade() != null)) {
                        ServiceEngineRtObjectFactory.getInstance().
                              getFacade().handleWebServiceEndpointEvent(
                              endpointURI,jbiEnabledFlag);
                    }
                } 
            }
        } catch (Exception e) {
            throw new AdminEventListenerException(e);
        }