FileDocCategorySizeDatePackage
ApplicationMediator.javaAPI DocGlassfish v2 API6932Fri May 04 22:24:42 BST 2007com.sun.enterprise.admin.wsmgmt.msg

ApplicationMediator

public class ApplicationMediator extends Object
Keeps track of SOAP messages per application or stand alone module.

Fields Summary
private Map
_endpoints
private String
_applicationId
private static final Logger
_logger
private static final com.sun.enterprise.util.i18n.StringManager
_stringMgr
Constructors Summary
ApplicationMediator(String id)
Constructor.

param
id name of the application


        _applicationId = id;
        _endpoints     = new Hashtable();

        // initializes the endpoint handler
        try {
            ConfigFactory cf = ConfigFactory.getConfigFactory();
            ConfigProvider cp = cf.getConfigProvider();
            WebServiceConfig[] wsc = cp.getWebserviceConfigs(id);

            for (int i=0; i<wsc.length; i++) {
                String mLevel = wsc[i].getMonitoringLevel();

                // SOAP message visualization is only enabled for level HIGH
                if (Constants.HIGH.equals(mLevel)) {
                    EndpointHandler eph = new EndpointHandler(wsc[i], id);
                    _endpoints.put(eph.getEndpointName(), eph);
                }
            }
        } catch (Exception e) {
            String msg=_stringMgr.getString("ApplicationMediator_ConfigEx",id);
            throw new MessageTraceException(msg, e);
        }
    
Methods Summary
voiddestroy()
Stops message visualization for this application.

        Collection endpoints = _endpoints.values();
        for (Iterator iter=endpoints.iterator(); iter.hasNext();) {
            EndpointHandler eph = (EndpointHandler) iter.next();
            if (eph != null) {
                eph.destroy();
            }
        }
        _endpoints.clear();
        _endpoints = null;
        _logger.finer("Message trace mediator destroyed for " + _applicationId);
    
voiddisable(java.lang.String wsEndpoint)
Disables monitoring for the endpoint.

param
wsEndpoint name of the webservice endpoint

        EndpointHandler eph = (EndpointHandler) _endpoints.remove(wsEndpoint);
        if (eph != null) {
            eph.destroy();
        }
    
voidenable(java.lang.String wsEndpoint, int size)
Enables monitoring for the endpoint.

param
wsEndpoint name of the webservice endpoint
param
size max size of the messages in history

        EndpointHandler eph = 
            new EndpointHandler(wsEndpoint, size, _applicationId);
        _endpoints.put(wsEndpoint, eph);
    
java.util.CollectiongetMessages(java.lang.String wsEndpoint)
Returns messages for the given endpoint.

param
wsEndpoint web service endpoint
return
messages for the given endpoint

        EndpointHandler eph = (EndpointHandler) _endpoints.get(wsEndpoint);
        if (eph != null) {
            return eph.getMessages();
        }
        return null;
    
java.util.CollectiongetMessages()
Returns all messages for this application.

return
messages associated for this application


        Collection c = new ArrayList();
        Collection endpoints = _endpoints.values();
        for (Iterator iter=endpoints.iterator(); iter.hasNext();) {
            EndpointHandler eph = (EndpointHandler) iter.next();
            if (eph != null) {
                c.addAll( eph.getMessages() );
            }
        }

        return c;
    
booleanisEmpty()
Returns true if there are no endpoints in this application mediator.

return
true if mediator is empty

        Collection c = _endpoints.values();
        return c.isEmpty();
    
voidsetMessageHistorySize(java.lang.String wsEndpoint, int size)
Sets the number of messages stored in memory for this application. This method is called to dynamically reconfigure the size.

param
wsEndpoint name of the webservice endpoint
param
size number of message stored in memory

        EndpointHandler eph = (EndpointHandler) _endpoints.get(wsEndpoint);
        if (eph != null) {
            eph.setMessageHistorySize(size);
        }