Search in sources :

Example 1 with SystemHandlerDelegate

use of com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate in project Payara by payara.

the class ServletWebServiceDelegate method postInit.

@Override
public void postInit(ServletConfig servletConfig) throws ServletException {
    String servletName = "unknown";
    try {
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
        JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
        WebBundleDescriptor webBundle = null;
        if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
            webBundle = ((WebBundleDescriptor) jndiNameEnv);
        } else {
            throw new WebServiceException("Cannot intialize the JAXRPCServlet for " + jndiNameEnv);
        }
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        servletName = servletConfig.getServletName();
        WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
        if (webComponent != null) {
            WebServicesDescriptor webServices = webBundle.getWebServices();
            Collection endpoints = webServices.getEndpointsImplementedBy(webComponent);
            // Only 1 endpoint per servlet is supported, even though
            // data structure implies otherwise.
            endpoint_ = (WebServiceEndpoint) endpoints.iterator().next();
            registerEndpoint(classLoader);
            // security
            if (secServ != null) {
                SystemHandlerDelegate securityHandlerDelegate = secServ.getSecurityHandler(endpoint_);
                if (securityHandlerDelegate != null) {
                    rpcDelegate_.setSystemHandlerDelegate(securityHandlerDelegate);
                    // need to invoke the endpoint lifecylcle
                    endpointImpl_ = JAXRPCEndpointImpl.class.cast(wsEngine_.createHandler(securityHandlerDelegate, endpoint_));
                    rpcDelegate_.setSystemHandlerDelegate(endpointImpl_);
                }
            }
        } else {
            throw new ServletException(servletName + " not found");
        }
    } catch (Throwable t) {
        String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
        logger.log(Level.WARNING, msg, t);
        throw new ServletException(t);
    }
}
Also used : WebServicesDescriptor(com.sun.enterprise.deployment.WebServicesDescriptor) WebServiceException(javax.xml.ws.WebServiceException) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) SystemHandlerDelegate(com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) JAXRPCEndpointImpl(org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)

Aggregations

ComponentEnvManager (com.sun.enterprise.container.common.spi.util.ComponentEnvManager)1 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)1 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 WebServicesDescriptor (com.sun.enterprise.deployment.WebServicesDescriptor)1 SystemHandlerDelegate (com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate)1 WebServiceException (javax.xml.ws.WebServiceException)1 JAXRPCEndpointImpl (org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)1