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

WebServiceEngineImpl

public final class WebServiceEngineImpl extends Object implements WebServiceEngine
This class acts as a factory to create TracingSystemHandler instances. It also provides an API to register listeners of SOAP messages.

NOT THREAD SAFE: mutable instance variable: globalMessageListener

author
Jerome Dochez

Fields Summary
protected final Map
endpoints
protected final List
lifecycleListeners
protected final List
authListeners
protected volatile GlobalMessageListener
globalMessageListener
static final ThreadLocal
servletThreadLocal
public static final Logger
sLogger
private static final WebServiceEngineImpl
INSTANCE
Constructors Summary
private WebServiceEngineImpl()
Creates a new instance of TracingSystemHandlerFactory

    
    
           
      
        // this is normally a bad idiom (see Java Concurrency 3.2), but 
        // this method is private, and can only be constructed in the static
        // constructor below *and* the listern maintains no reference to 'this.
        addAuthListener( new LogAuthenticationListener() );
    
Methods Summary
public voidaddAuthListener(AuthenticationListener listener)

        authListeners.add(listener);
    
public voidaddLifecycleListener(EndpointLifecycleListener listener)

        lifecycleListeners.add(listener);
    
private EndpointImplcreateEndpointInfo(com.sun.enterprise.deployment.WebServiceEndpoint endpoint)

        
        try { 
            String endpointURL = endpoint.getEndpointAddressUri();
            EndpointType endpointType;            
            ModuleType moduleType = endpoint.getWebService().getWebServicesDescriptor().getModuleType();
            if (moduleType.equals(ModuleType.EJB)) {
                endpointType = EndpointType.EJB_ENDPOINT;
            } else {
                endpointType = EndpointType.SERVLET_ENDPOINT;
            }

            EndpointImpl newEndpoint;
            // At this point, we can depend on presence of mapping file to distinguish between JAXRPC and JAXWS
            // service
            if(endpoint.getWebService().getMappingFileUri()==null) {
                newEndpoint = new JAXWSEndpointImpl(endpointURL, endpointType); 
            } else {
                newEndpoint = new JAXRPCEndpointImpl(endpointURL, endpointType); 
            }
            newEndpoint.setDescriptor(endpoint);
            return newEndpoint;
        
        } catch(Exception e) {
            e.printStackTrace();
        }                         
        return null;
    
public EndpointImplcreateHandler(com.sun.enterprise.deployment.WebServiceEndpoint endpointDesc)

        
        EndpointImpl newEndpoint = createEndpointInfo(endpointDesc);
        if (newEndpoint==null) {
            return null;
        }
        String key = newEndpoint.getEndpointSelector();
        endpoints.put(key, newEndpoint); 
        
        // notify listeners
        for (EndpointLifecycleListener listener : lifecycleListeners) {
            listener.endpointAdded(newEndpoint);
        }
        
        return newEndpoint;
    
public EndpointImplcreateHandler(com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate parent, com.sun.enterprise.deployment.WebServiceEndpoint endpointDesc)

        
        EndpointImpl newEndpoint = createHandler(endpointDesc);
        ((JAXRPCEndpointImpl)newEndpoint).setParent(parent);
        return newEndpoint;
    
public java.util.CollectiongetAuthListeners()

        return authListeners;
    
public EndpointgetEndpoint(java.lang.String uri)

    
        return endpoints.get(uri);
    
public java.util.IteratorgetEndpoints()

        return endpoints.values().iterator();
    
public GlobalMessageListenergetGlobalMessageListener()

        return globalMessageListener;
    
public static com.sun.enterprise.webservice.monitoring.WebServiceEngineImplgetInstance()

    
         
        return INSTANCE;
    
public java.lang.ThreadLocalgetThreadLocal()

        return servletThreadLocal;
    
public booleanhasGlobalMessageListener()

        return globalMessageListener!=null;
    
public voidpostProcessResponse(java.lang.String messageID, TransportInfo info)
Callback when a web service response has finished being processed by the container and was sent back to the client

param
messageID returned by the preProcessRequest call

        
        if (globalMessageListener==null)
            return;
        
        globalMessageListener.postProcessResponse(messageID, info);        
    
public java.lang.StringpreProcessRequest(Endpoint endpoint)
Callback when a web service request entered the web service container before any processing is done.

return
a message ID to trace the request in the subsequent callbacks

        
        if (globalMessageListener==null)
            return null;
        
        return globalMessageListener.preProcessRequest(endpoint);
    
public voidprocessRequest(java.lang.String messageID, com.sun.xml.rpc.spi.runtime.SOAPMessageContext context, TransportInfo info)
Callback when a web service request is received on the endpoint.

param
messageID returned by preProcessRequest call
param
msgContext the jaxrpc message trace, transport dependent.

        
        if (globalMessageListener==null) 
            return;
        
        globalMessageListener.processRequest(messageID, context, info);
    
public voidprocessRequest(java.lang.String messageID, com.sun.enterprise.webservice.SOAPMessageContext context, TransportInfo info)
Callback when a 2.0 web service request is received on the endpoint.

param
messageID returned by preProcessRequest call
param
msgContext the jaxrpc message trace, transport dependent.

        
        if (globalMessageListener==null) 
            return;

        globalMessageListener.processRequest(messageID, context, info);
    
public voidprocessResponse(java.lang.String messageID, com.sun.xml.rpc.spi.runtime.SOAPMessageContext context)
Callback when a web service response is received on the endpoint.

param
messageID returned by the preProcessRequest call
param
trace jaxrpc message context

        
        if (globalMessageListener==null)
            return;
        
        globalMessageListener.processResponse(messageID, context);
    
public voidprocessResponse(java.lang.String messageID, com.sun.enterprise.webservice.SOAPMessageContext context)
Callback when a 2.0 web service response is received on the endpoint.

param
messageID returned by the preProcessRequest call
param
trace jaxrpc message context

        
        if (globalMessageListener==null)
            return;
        globalMessageListener.processResponse(messageID, context);
    
public voidremoveAuthListener(AuthenticationListener listener)

        authListeners.remove(listener);
    
public voidremoveHandler(com.sun.enterprise.deployment.WebServiceEndpoint endpointDesc)


        EndpointImpl endpoint = (EndpointImpl) endpointDesc.getExtraAttribute(EndpointImpl.NAME);
        if (endpoint==null) 
            return;
                
        // remove this endpoint from our list of endpoints
        endpoints.remove(endpoint.getEndpointSelector());

        // notify listeners
        for (EndpointLifecycleListener listener : lifecycleListeners) {
            listener.endpointRemoved(endpoint);
        }
        
        // forcing the cleaning so we don't have DOL objects staying alive because
        // some of our clients have not released the endpoint instance.
        endpoint.setDescriptor(null);
    
public voidremoveLifecycleListener(EndpointLifecycleListener listener)

        lifecycleListeners.remove(listener);
    
public voidsetGlobalMessageListener(GlobalMessageListener listener)

        globalMessageListener = listener;