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

MessageTraceMgr

public class MessageTraceMgr extends Object
Backend facade for the SOAP message visualization.

Fields Summary
private Map
_applications
private static final MessageTraceMgr
_instance
private static final Logger
_logger
private static final com.sun.enterprise.util.i18n.StringManager
_stringMgr
Constructors Summary
private MessageTraceMgr()
Private constructor.

        _applications  = new Hashtable();

    
Methods Summary
public voiddisable(java.lang.String appId, java.lang.String endpoint)
Disables message trace for the given web service endpoint. This method is called to dynamically reconfigure the size.

param
appId name of the application
param
endpoint partially qualified endpoint name
throws
MessageTraceException if application id is invalid


        ApplicationMediator am = (ApplicationMediator) _applications.get(appId);
        if (am != null) {
            am.disable(endpoint);
            if (am.isEmpty()) {
                _applications.remove(appId);
            }
        } else {
            String msg = _stringMgr.getString("MessageTraceMgr_InvalidAppEx", 
                                    appId, endpoint);
            throw new MessageTraceException(msg);
        }
    
public voidenable(java.lang.String appId, java.lang.String endpoint, int size)
Enables message visualization for the given webservice endpoint.

param
appId name of the application
param
endpoint partially qualified endpoint name
param
size max size of messages in history
throws
MessageTraceException if a configuration initialization exception


        ApplicationMediator am = (ApplicationMediator) _applications.get(appId);
        if (am != null) {
            am.enable(endpoint, size);
        } else {
            am = new ApplicationMediator(appId);
            am.enable(endpoint, size);
            _applications.put(appId, am);
        }
    
public static com.sun.enterprise.admin.wsmgmt.msg.MessageTraceMgrgetInstance()
Returns the singleton instance of this class.

return
singleton instance of this class

        return _instance;
    
public com.sun.appserv.management.ext.wsmgmt.MessageTrace[]getMessages()
Returns the available messages.

return
array of message trace objects currently available

        Collection c = new ArrayList();

        Collection mediators = _applications.values();
        for (Iterator itr=mediators.iterator(); itr.hasNext();) {
            ApplicationMediator am = (ApplicationMediator) itr.next();
            c.addAll( am.getMessages() );
        }

        MessageTrace[] trace = new MessageTrace[c.size()];
        return ((MessageTrace[]) c.toArray(trace));
    
public com.sun.appserv.management.ext.wsmgmt.MessageTrace[]getMessages(java.lang.String appId, java.lang.String endpoint)
Returns messages for a web service endpoint.

param
appId name of the application
param
endpoint partially qualified endpoint name
return
messages for the given endpoint

        Collection c = null;
        ApplicationMediator am = (ApplicationMediator) _applications.get(appId);
        if (am != null) {
            c = am.getMessages(endpoint);
        }
        MessageTrace[] trace = null;
        if ( c != null) {
            trace = new MessageTrace[c.size()];
            return ((MessageTrace[]) c.toArray(trace));
        } else {
            return null;
        }
    
public voidinit()
Initializes the message visualization service.

        try {
            ConfigFactory cf = ConfigFactory.getConfigFactory();
            ConfigProvider cp = cf.getConfigProvider();
            List list = cp.getManagedWebserviceApplicationIds();
            for (Iterator iter=list.iterator(); iter.hasNext();) {
                String appId = (String) iter.next();
                try {
                    ApplicationMediator am = new ApplicationMediator(appId);
                    _applications.put(appId, am);
                } catch (MessageTraceException me) {
                    String msg="Initialization error for application: " + appId;
                    _logger.log(Level.FINE, msg, me);
                }
            }
        } catch (Exception e) {
            String msg="Configuration initialization error.";
            _logger.log(Level.FINE, msg, e);
        }
    
public voidsetMessageHistorySize(java.lang.String appId, java.lang.String endpoint, int size)
Sets the number of messages stored in memory. This method is called to dynamically reconfigure the size.

param
appId name of the application
param
endpoint partially qualified endpoint name
param
size number of message stored in memory
throws
MessageTraceException if an invalid application id


        ApplicationMediator am = (ApplicationMediator) _applications.get(appId);
        if (am != null) {
            am.setMessageHistorySize(endpoint, size);
        } else {
            String msg = _stringMgr.getString("MessageTraceMgr_InvalidAppEx", 
                                    appId, endpoint);
            throw new MessageTraceException(msg);
        }
    
public voidstop()
Shuts down message visualization.

        Collection mediators = _applications.values();
        for (Iterator itr=mediators.iterator(); itr.hasNext();) {
            ApplicationMediator am = (ApplicationMediator) itr.next();
            am.destroy();
        }
        _applications.clear();