1 23 package com.sun.enterprise.admin.wsmgmt.agent; 24 25 import com.sun.enterprise.webservice.monitoring.GlobalMessageListener; 26 import com.sun.enterprise.webservice.monitoring.Endpoint; 27 import com.sun.enterprise.webservice.monitoring.TransportInfo; 28 import com.sun.xml.rpc.spi.runtime.*; 29 import com.sun.enterprise.deployment.WebServiceEndpoint; 30 import com.sun.enterprise.deployment.BundleDescriptor; 31 import com.sun.enterprise.deployment.Application; 32 33 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterRegistry; 34 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterRouter; 35 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterContext; 36 import com.sun.enterprise.admin.wsmgmt.filter.spi.Filter; 37 38 import java.util.HashMap ; 39 40 import com.sun.enterprise.admin.wsmgmt.stats.spi.StatsProviderManager; 41 import com.sun.enterprise.admin.wsmgmt.stats.impl.WebServiceEndpointStatsProviderImpl; 42 import com.sun.enterprise.admin.wsmgmt.WebServiceMgrBackEnd; 43 import com.sun.enterprise.admin.monitor.callflow.Agent; 44 import com.sun.enterprise.admin.monitor.callflow.ThreadLocalData; 45 import com.sun.enterprise.Switch; 46 47 48 51 public class GlobalMessageListenerImpl implements GlobalMessageListener { 52 53 59 public void postProcessResponse(String messageID, TransportInfo info) { 60 FilterContext fc = (FilterContext) msgId2fc.get(messageID); 61 long startTime = fc.getExecutionTime(); 62 fc.setExecutionTime(System.currentTimeMillis() - startTime); 63 FilterRouter.getInstance().applyFilters(Filter.POST_PROCESS_RESPONSE, 64 fc); 65 msgId2fc.remove(messageID); 67 } 68 69 75 public String preProcessRequest(Endpoint endpoint) { 76 77 String ep = null; 78 WebServiceEndpoint wse = endpoint.getDescriptor(); 79 80 if ( wse != null) { 81 ep = wse.getEndpointName(); 82 } 83 85 BundleDescriptor bundle = wse.getBundleDescriptor(); 86 Application app = bundle.getApplication(); 87 88 String fqn = 89 WebServiceMgrBackEnd.getManager().getFullyQualifiedName( 90 app.getRegistrationName() , 91 bundle.getModuleDescriptor().getArchiveUri(), 92 bundle.getModuleDescriptor().isStandalone(), ep); 93 94 if (FilterRegistry.getInstance().isManaged(fqn) == false) { 95 return null; 96 } 97 String mId = null; 98 String cfId = null; 99 boolean isCallFlowEnabled = false; 100 101 Agent agent = Switch.getSwitch().getCallFlowAgent(); 103 if (agent != null) { 104 if (agent.isEnabled()) { 105 ThreadLocalData data = agent.getThreadLocalData(); 106 if (data != null) { 107 cfId = data.getRequestId(); 108 } 109 } 110 } 111 112 if ( (cfId == null) || ("".equals(cfId)) ) { 113 114 int newNumber = newSequenceNumber(); 116 mId = new Integer (newNumber).toString(); 117 118 } else { 119 mId = cfId; 121 isCallFlowEnabled = true; 122 } 123 FilterContext fc = new FilterContext(endpoint, isCallFlowEnabled, 124 (TransportInfo)null, 125 (com.sun.enterprise.admin.wsmgmt.SOAPMessageContext)null, mId, fqn); 126 127 FilterRouter.getInstance().applyFilters(Filter.PRE_PROCESS_REQUEST,fc); 128 129 msgId2fc.put(mId, fc); 131 132 return mId; 133 } 134 135 142 public void processRequest(String messageID, com.sun.xml.rpc.spi.runtime.SOAPMessageContext context, 143 TransportInfo info) { 144 com.sun.enterprise.admin.wsmgmt.SOAPMessageContext smc = 145 new com.sun.enterprise.admin.wsmgmt.SOAPMessageContext_1_0(context); 146 147 FilterContext fc = (FilterContext) msgId2fc.get(messageID); 148 fc.setTransportInfo(info); 149 fc.setMessageContext(smc); 150 FilterRouter.getInstance().applyFilters(Filter.PROCESS_REQUEST,fc); 151 } 152 153 160 public void processResponse(String messageID, com.sun.xml.rpc.spi.runtime.SOAPMessageContext context) { 161 String ep = null; 162 FilterContext fc = (FilterContext) msgId2fc.get(messageID); 163 FilterRouter.getInstance().applyFilters(Filter.PROCESS_RESPONSE,fc); 164 } 165 166 173 public void processRequest(String messageID, com.sun.xml.ws.spi.runtime.SOAPMessageContext context, 174 TransportInfo info) { 175 com.sun.enterprise.admin.wsmgmt.SOAPMessageContext smc = 176 new com.sun.enterprise.admin.wsmgmt.SOAPMessageContext_2_0(context); 177 178 FilterContext fc = (FilterContext) msgId2fc.get(messageID); 179 fc.setTransportInfo(info); 180 fc.setMessageContext(smc); 181 FilterRouter.getInstance().applyFilters(Filter.PROCESS_REQUEST,fc); 182 } 183 184 191 public void processResponse(String messageID, com.sun.xml.ws.spi.runtime.SOAPMessageContext context) { 192 String ep = null; 193 FilterContext fc = (FilterContext) msgId2fc.get(messageID); 194 FilterRouter.getInstance().applyFilters(Filter.PROCESS_RESPONSE,fc); 195 } 196 197 200 public static synchronized int newSequenceNumber() { 201 sequenceNumber++; 202 return sequenceNumber; 203 } 204 205 public static synchronized int getSequenceNumber() { 206 return sequenceNumber; 207 } 208 209 public static int sequenceNumber = 0; 210 211 213 static HashMap msgId2fc = new HashMap (); 214 } 215 | Popular Tags |