FileDocCategorySizeDatePackage
MonitoringPipe.javaAPI DocGlassfish v2 API7148Mon Jul 30 08:28:46 BST 2007com.sun.enterprise.webservice

MonitoringPipe

public class MonitoringPipe extends com.sun.xml.ws.api.pipe.helper.AbstractFilterPipeImpl
This pipe is used to do app server monitoring

Fields Summary
private final com.sun.xml.ws.api.model.SEIModel
seiModel
private final com.sun.xml.ws.api.model.wsdl.WSDLPort
wsdlModel
private final com.sun.xml.ws.api.server.WSEndpoint
owner
private final com.sun.enterprise.deployment.WebServiceEndpoint
endpoint
private final com.sun.enterprise.webservice.monitoring.WebServiceEngineImpl
wsEngine
Constructors Summary
public MonitoringPipe(com.sun.xml.ws.api.pipe.ServerPipeAssemblerContext ctxt, com.sun.xml.ws.api.pipe.Pipe tail, com.sun.enterprise.deployment.WebServiceEndpoint ep)

        super(tail);
        this.endpoint = ep;
        this.seiModel = ctxt.getSEIModel();
        this.wsdlModel = ctxt.getWsdlModel();
        this.owner = ctxt.getEndpoint();
        wsEngine = WebServiceEngineImpl.getInstance();
    
public MonitoringPipe(MonitoringPipe that, com.sun.xml.ws.api.pipe.PipeCloner cloner)

        super(that, cloner);
        this.endpoint = that.endpoint;
        this.seiModel = that.seiModel;
        this.wsdlModel = that.wsdlModel;
        this.owner = that.owner;
        wsEngine = WebServiceEngineImpl.getInstance();
    
Methods Summary
public final com.sun.xml.ws.api.pipe.Pipecopy(com.sun.xml.ws.api.pipe.PipeCloner cloner)

        return new MonitoringPipe(this, cloner);
    
public com.sun.xml.ws.api.message.Packetprocess(com.sun.xml.ws.api.message.Packet request)

        // if it is a JBI request then skip the monitoring logic. This is done 
        // as HTTPServletRequest/Response is not available when the invocation 
        // is from JavaEE service engine.
        if(ServiceEngineUtil.isJBIRequest(request.webServiceContextDelegate.getClass().getName())) {
            return next.process(request);
        }
        // No monitoring available for restful services
        if(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())) {
            return next.process(request);
        }
        SOAPMessageContext ctxt = new SOAPMessageContextImpl(request);
        HttpServletRequest httpRequest = 
                (HttpServletRequest) request.get(javax.xml.ws.handler.MessageContext.SERVLET_REQUEST);
        HttpServletResponse httpResponse = 
                (HttpServletResponse) request.get(javax.xml.ws.handler.MessageContext.SERVLET_RESPONSE);

        String messageId=null;
        if (wsEngine.getGlobalMessageListener()!=null) {
            Endpoint endpt;
            if(endpoint.implementedByWebComponent()) {
                endpt = wsEngine.getEndpoint(httpRequest.getServletPath());
            } else {
                endpt = wsEngine.getEndpoint(httpRequest.getRequestURI());
            }             
            messageId = wsEngine.preProcessRequest(endpt);  
            if (messageId!=null) {
                ctxt.put(EndpointImpl.MESSAGE_ID, messageId);
                ThreadLocalInfo config = new ThreadLocalInfo(messageId, httpRequest);
                wsEngine.getThreadLocal().set(config);
            }
        }
                                
        JAXWSEndpointImpl endpt = null;
        try {
            if (wsEngine.getGlobalMessageListener()!=null) {
                if(endpoint.implementedByWebComponent()) {
                    endpt = 
                        (JAXWSEndpointImpl)wsEngine.getEndpoint(httpRequest.getServletPath());
                } else {
                    endpt = 
                        (JAXWSEndpointImpl)wsEngine.getEndpoint(httpRequest.getRequestURI());
                }             
                endpt.processRequest(ctxt);
            }
        } catch (Exception e) {
            // temporary - need to send back SOAP fault message
        }

	Packet pipeResponse = next.process(request);
       
        //Make the response packet available in the MessageContext
        ((SOAPMessageContextImpl)ctxt).setPacket(pipeResponse);
        
        
        try {
            if (endpt != null) {
                endpt.processResponse(ctxt);
            }
    
        } catch (Exception e) {
            // temporary - need to send back SOAP fault message
        }
 
        if (messageId!=null) {
            HttpResponseInfoImpl info = new HttpResponseInfoImpl(httpResponse);
            wsEngine.postProcessResponse(messageId, info);
        }        
        return pipeResponse;