FileDocCategorySizeDatePackage
Ejb3MessageDispatcher.javaAPI DocGlassfish v2 API6898Fri May 04 22:36:10 BST 2007com.sun.enterprise.webservice

Ejb3MessageDispatcher

public class Ejb3MessageDispatcher extends Object implements EjbMessageDispatcher
Implementation of the Ejb Message Dispatcher for EJB3 endpoints.
author
Jerome Dochez

Fields Summary
private static Logger
logger
private static WsUtil
wsUtil
private com.sun.enterprise.webservice.monitoring.WebServiceEngineImpl
wsEngine
Constructors Summary
public Ejb3MessageDispatcher()
Creates a new instance of Ejb3MessageDispatcher

    
           
      
        wsEngine = WebServiceEngineImpl.getInstance();
    
Methods Summary
private voidhandleGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, javax.servlet.ServletContext ctxt, EjbRuntimeEndpointInfo endpointInfo)

        try {
            ServletAdapter adapter = 
                    (ServletAdapter) endpointInfo.prepareInvocation(false);
            if (adapter != null) {                    
                adapter.publishWSDL(ctxt, req, resp);
            } else {
                String message = "Invalid wsdl request " +  req.getRequestURL();
                (new WsUtil()).writeInvalidMethodType(resp, message);
            }
        } catch (Throwable e) {
            String errorMessage = "invocation error on ejb endpoint " +
            endpointInfo.getEndpoint().getEndpointName() + " at " +
            endpointInfo.getEndpointAddressUri() + " : " + e.getMessage();
            logger.log(Level.WARNING, errorMessage, e);
            String binding = endpointInfo.getEndpoint().getProtocolBinding();
            WsUtil.raiseException(resp, binding, errorMessage);
        }
    
private voidhandlePost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, EjbRuntimeEndpointInfo endpointInfo)

        
        try {            
            try {
                ServletAdapter adapter = 
                        (ServletAdapter) endpointInfo.prepareInvocation(true);
                
                if (adapter != null) {                    
                    adapter.handle(null, req, resp);
                } else {
                    logger.log(Level.SEVERE, 
                            "Unable to find adpater for endpoint " + endpointInfo.getEndpoint().getName());
                }
            } finally {
                // Always call release, even if an error happened
                // during getImplementor(), since some of the
                // preInvoke steps might have occurred.  It's ok
                // if implementor is null.
                endpointInfo.releaseImplementor();
            }    
        } catch (Throwable e) {
            String errorMessage = "invocation error on ejb endpoint " +
            endpointInfo.getEndpoint().getEndpointName() + " at " +
            endpointInfo.getEndpointAddressUri() + " : " + e.getMessage();
            logger.log(Level.WARNING, errorMessage, e);
            String binding = endpointInfo.getEndpoint().getProtocolBinding();
            WsUtil.raiseException(resp, binding, errorMessage);
        }
    
public voidinvoke(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, javax.servlet.ServletContext ctxt, EjbRuntimeEndpointInfo endpointInfo)

        
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "JAXWS WebServiceDispatcher " + req.getMethod() + 
                   " entering for " + req.getRequestURI() + " and query string " + req.getQueryString());
        }       
        String method = req.getMethod();
        try {
            if( method.equals("POST") ) {
                handlePost(req, resp, endpointInfo);
            } else if( method.equals("GET") ) {
                handleGet(req, resp, ctxt, endpointInfo);
            } else {
                String errorMessage =  "Unsupported method request = [" 
                    + method + "] for endpoint " + 
                    endpointInfo.getEndpoint().getEndpointName() + " at " + 
                    endpointInfo.getEndpointAddressUri();
                logger.warning(errorMessage);
                wsUtil.writeInvalidMethodType(resp, errorMessage);
            }
        } catch(Exception e) {
            logger.log(Level.WARNING, "ejb endpoint exception", e);
        }