Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 /*
  * TracingSystemHandlerFactory.java
  *
  * Created on August 12, 2004, 4:04 PM
  */
 
 package org.glassfish.webservices.monitoring;
 
 
 
 import java.util.*;
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(s):
Jerome Dochez
 
 public final class WebServiceEngineImpl implements WebServiceEngine {
     
     private final Map<StringEndpointendpoints = new HashMap<StringEndpoint>();
     private final List<EndpointLifecycleListenerlifecycleListeners =
             new ArrayList<EndpointLifecycleListener>();
     private final List<AuthenticationListenerauthListeners =
             new ArrayList<AuthenticationListener>();
     private volatile GlobalMessageListener globalMessageListener = null;
            
     static final ThreadLocal servletThreadLocal = new ThreadLocal();
     public static final Logger sLogger = LogUtils.getLogger();
    
    
    
Creates a new instance of TracingSystemHandlerFactory
 
     private WebServiceEngineImpl() {
         // 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.
         addAuthListenernew LogAuthenticationListener() );
     }
     
     private static final WebServiceEngineImpl INSTANCE    = new WebServiceEngineImpl();
     
     public static  WebServiceEngineImpl getInstance() {
         return ;
     }
     
     public EndpointImpl createHandler(WebServiceEndpoint endpointDesc)  {
         
         EndpointImpl newEndpoint = createEndpointInfo(endpointDesc);
         if (newEndpoint==null) {
             return null;
        }
        String key = newEndpoint.getEndpointSelector();
        .put(keynewEndpoint); 
        
        // notify listeners
        for (EndpointLifecycleListener listener : ) {
            listener.endpointAdded(newEndpoint);
        }
        
        return newEndpoint;
    }
    
        WebServiceEndpoint endpointDesc)  {
        EndpointImpl newEndpoint = createHandler(endpointDesc);
        ((JAXRPCEndpointImpl)newEndpoint).setParent(parent);
        return newEndpoint;
    }
    public Endpoint getEndpoint(String uri) {    
        return .get(uri);
    }
    
    public Iterator<EndpointgetEndpoints() {
        return .values().iterator();
    }
    
    public void removeHandler(WebServiceEndpoint endpointDesc) {
        EndpointImpl endpoint = (EndpointImplendpointDesc.getExtraAttribute(.);
        if (endpoint==null
            return;
                
        // remove this endpoint from our list of endpoints
        .remove(endpoint.getEndpointSelector());
        // notify listeners
        for (EndpointLifecycleListener listener : ) {
            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 void addLifecycleListener(EndpointLifecycleListener listener) {
        .add(listener);
    }
    
    public void removeLifecycleListener(EndpointLifecycleListener listener) {
        .remove(listener);
    }
    
    public void addAuthListener(AuthenticationListener listener) {
        .add(listener);
    }
    
    public void removeAuthListener(AuthenticationListener listener) {
        .remove(listener);
    }
    
        return ;
    }
    
        return ;
    }
    
    public void setGlobalMessageListener(GlobalMessageListener listener) {
         = listener;
    }
    
    
    public boolean hasGlobalMessageListener() {
        return !=null;
    }
                
    private EndpointImpl createEndpointInfo(WebServiceEndpoint endpoint) {
        
        try { 
            String endpointURL = endpoint.getEndpointAddressUri();
            EndpointType endpointType;            
            ArchiveType moduleType = endpoint.getWebService().getWebServicesDescriptor().getModuleType();
            if (moduleType != null && moduleType.equals(DOLUtils.ejbType())) {
                endpointType = .;
            } else {
                endpointType = .;
            }
            EndpointImpl newEndpoint;
            // At this point, we can depend on presence of mapping file to distinguish between JAXRPC and JAXWS
            // service
            if(endpoint.getWebService().hasMappingFile()) {
                newEndpoint = new JAXRPCEndpointImpl(endpointURLendpointType);
            } else {
                newEndpoint = new JAXWSEndpointImpl(endpointURLendpointType);
            }
            newEndpoint.setDescriptor(endpoint);
            return newEndpoint;
        
        } catch(Exception e) {
        }                         
        return null;
    }    
        
    
Callback when a web service request entered the web service container before any processing is done.

Parameters:
endpoint the Endpoint
Returns:
a message ID to trace the request in the subsequent callbacks
    public String preProcessRequest(Endpoint endpoint) {
        
        if (==null)
            return null;
        
        return .preProcessRequest(endpoint);
    }
    
    
Callback when a web service request is received on the endpoint.

Parameters:
messageID returned by preProcessRequest call
context the jaxrpc message trace, transport dependent.
    public void processRequest(String messageIDcom.sun.xml.rpc.spi.runtime.SOAPMessageContext context,
            TransportInfo info) {
        if (==null)
            return;
        .processRequest(messageIDcontextinfo);
    }

    
Callback when a web service response is received on the endpoint.

Parameters:
messageID returned by the preProcessRequest call
context jaxrpc message context
    public void processResponse(String messageIDcom.sun.xml.rpc.spi.runtime.SOAPMessageContext context) {
        if (==null)
            return;
        .processResponse(messageIDcontext);
    }
    
    
Callback when a 2.0 web service request is received on the endpoint.

Parameters:
messageID returned by preProcessRequest call
context the jaxws message trace, transport dependent.
info the transport info
    public void processRequest(String messageIDSOAPMessageContext context,
            TransportInfo info) {
        
        if (==null
            return;
        .processRequest(messageIDcontextinfo);
    }
    
    
Callback when a 2.0 web service response is received on the endpoint.

Parameters:
messageID returned by the preProcessRequest call
context jaxws message context
    public void processResponse(String messageIDSOAPMessageContext context) {
        
        if (==null)
            return;
        .processResponse(messageIDcontext);
    }
    
    
Callback when a web service response has finished being processed by the container and was sent back to the client

Parameters:
messageID returned by the preProcessRequest call
    public void postProcessResponse(String messageIDTransportInfo info) {
        
        if (==null)
            return;
        
        .postProcessResponse(messageIDinfo);        
    }
    
    public ThreadLocal getThreadLocal() {
        return ;
    }    
New to GrepCode? Check out our FAQ X