FileDocCategorySizeDatePackage
JAXRPCEndpointImpl.javaAPI DocGlassfish v2 API6544Fri May 04 22:36:16 BST 2007com.sun.enterprise.webservice.monitoring

JAXRPCEndpointImpl

public class JAXRPCEndpointImpl extends EndpointImpl implements com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate
Implementation of the JAXRPC endpoint interface and JAXRPC System Handler Delegate
author
Jerome Dochez

Fields Summary
com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate
parent
Constructors Summary
JAXRPCEndpointImpl(String endpointSelector, EndpointType type)
Creates a new instance of EndpointImpl

    
           
        
        super(endpointSelector, type);
    
Methods Summary
public booleanprocessRequest(com.sun.xml.rpc.spi.runtime.SOAPMessageContext messageContext)


	boolean status = true;

        if (parent!=null) {
            status = parent.processRequest(messageContext);
        }

        // let's get our thread local context
        WebServiceEngineImpl wsEngine = WebServiceEngineImpl.getInstance();
        try {
            if (!listeners.isEmpty() || wsEngine.hasGlobalMessageListener()) {
                
                // someone is listening
                ThreadLocalInfo config = 
                        (ThreadLocalInfo) wsEngine.getThreadLocal().get();

                // do we have a global listener ?
                if (config!=null && config.getMessageId()!=null) {
                    HttpRequestInfoImpl info = new HttpRequestInfoImpl(config.getRequest());
                    wsEngine.processRequest(config.getMessageId(), messageContext, info);
                } 
                
                // any local listeners ?
                if (!listeners.isEmpty()) {
                    if (config==null) {
                        config = new ThreadLocalInfo(null, null);
                    }
                    // create the message trace and save it to our thread local
                    MessageTraceImpl request = new MessageTraceImpl();
                    request.setEndpoint(this);
                    request.setMessageContext(messageContext);
                    if (config.getRequest()!=null) {
                        request.setTransportInfo(new HttpRequestInfoImpl(config.getRequest()));
                    }
                    
                    config.setRequestMessageTrace(request);
                }
                
            }
	} catch(Throwable t) {
            wsEngine.sLogger.warning("Exception while tracing request : " + t.getMessage());
	    RuntimeException re;
	    if (t instanceof RuntimeException) {
		re = (RuntimeException) t;
	    } else {
		re = new RuntimeException(t);
	    }
	    throw re;
        }
        
        return status;
    
public voidprocessResponse(com.sun.xml.rpc.spi.runtime.SOAPMessageContext messageContext)

   

        // let's get our thread local context
        WebServiceEngineImpl wsEngine = WebServiceEngineImpl.getInstance();
        try {
            
            if (wsEngine.hasGlobalMessageListener() || !listeners.isEmpty()) {
                
                // someone is listening
                ThreadLocalInfo config = 
                        (ThreadLocalInfo) wsEngine.getThreadLocal().get();

                if (config!=null) {                    
                    // do we have a global listener ?
                    if (config.getMessageId()!=null) {
                        wsEngine.processResponse(config.getMessageId(),  messageContext);
                    }

                    // local listeners
                    if (!listeners.isEmpty()) {
                        MessageTraceImpl response = new MessageTraceImpl();
                        response.setEndpoint(this);
                        response.setMessageContext(messageContext);
                        for (MessageListener listener : listeners) {                    
                            listener.invocationProcessed(config.getRequestMessageTrace(), response);
                        }   
                    }
                }
            }
            // cleanup
            wsEngine.getThreadLocal().remove();
            
	    // do security after tracing
	    if (parent!=null) {
		parent.processResponse(messageContext);
	    }
        
        } catch(Throwable t) {
            wsEngine.sLogger.warning("Exception while tracing response : " + t.getMessage());
	    RuntimeException re;
	    if (t instanceof RuntimeException) {
		re = (RuntimeException) t;
	    } else {
		re = new RuntimeException(t);
	    }
	    throw re;
        }                 

    
public voidsetParent(com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate parent)

        this.parent = parent;