Search in sources :

Example 1 with JAXRPCCodeGenFacade

use of org.glassfish.internal.api.JAXRPCCodeGenFacade in project Payara by payara.

the class JavaEEDeployer method prepare.

/**
 * Prepares the application bits for running in the application server.
 * For certain cases, this is generating non portable
 * artifacts and other application specific tasks.
 * Failure to prepare should throw an exception which will cause the overall
 * deployment to fail.
 *
 * @param dc deployment context
 * @return true if the prepare phase was successful
 */
public boolean prepare(DeploymentContext dc) {
    try {
        ((ExtendedDeploymentContext) dc).prepareScratchDirs();
        // In jaxrpc it was required to run
        // Wscompile to generate the artifacts for clients too.
        // service-ref element can be in client in web.xml,  application-client.xml, sun-ejb-jar.xml
        // Fix for issue 16015
        BundleDescriptor bundleDesc = dc.getModuleMetaData(BundleDescriptor.class);
        if (bundleDesc.hasWebServiceClients()) {
            JAXRPCCodeGenFacade jaxrpcCodeGenFacade = jaxrpcCodeGenFacadeProvider.get();
            if (jaxrpcCodeGenFacade != null) {
                jaxrpcCodeGenFacade.run(habitat, dc, getModuleClassPath(dc), true);
            }
        }
        if (!dc.getCommandParameters(OpsParams.class).origin.isArtifactsPresent()) {
            // only generate artifacts when there is no artifacts present
            generateArtifacts(dc);
        }
        return true;
    } catch (Exception ex) {
        // re-throw all the exceptions as runtime exceptions
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JAXRPCCodeGenFacade(org.glassfish.internal.api.JAXRPCCodeGenFacade) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) IOException(java.io.IOException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 2 with JAXRPCCodeGenFacade

use of org.glassfish.internal.api.JAXRPCCodeGenFacade in project Payara by payara.

the class WebServicesDeployer method prepare.

/**
 * Prepares the application bits for running in the application server.
 * For certain cases, this is exploding the jar file to a format the
 * ContractProvider instance is expecting, generating non portable
 * artifacts and other application specific tasks.
 * Failure to prepare should throw an exception which will cause the overall
 * deployment to fail.
 *
 * @param dc deployment context
 * @return true if the prepare phase was successful
 */
@Override
public boolean prepare(DeploymentContext dc) {
    try {
        Application app = dc.getModuleMetaData(Application.class);
        if (app == null) {
            // hopefully the DOL gave a good message of the failure...
            logger.log(Level.SEVERE, LogUtils.FAILED_LOADING_DD);
            return false;
        }
        BundleDescriptor bundle = DOLUtils.getCurrentBundleForContext(dc);
        String moduleCP = getModuleClassPath(dc);
        final List<URL> moduleCPUrls = ASClassLoaderUtil.getURLsFromClasspath(moduleCP, File.pathSeparator, null);
        final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
        URLClassLoader newCl = AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() {

            @Override
            public URLClassLoader run() {
                return new URLClassLoader(ASClassLoaderUtil.convertURLListToArray(moduleCPUrls), oldCl);
            }
        });
        Thread.currentThread().setContextClassLoader(newCl);
        WebServicesDescriptor wsDesc = bundle.getWebServices();
        for (WebService ws : wsDesc.getWebServices()) {
            if ((new WsUtil()).isJAXWSbasedService(ws)) {
                setupJaxWSServiceForDeployment(dc, ws);
            } else {
                JAXRPCCodeGenFacade facade = habitat.getService(JAXRPCCodeGenFacade.class);
                if (facade != null) {
                    facade.run(habitat, dc, moduleCP, false);
                } else {
                    throw new DeploymentException(rb.getString(LogUtils.JAXRPC_CODEGEN_FAIL));
                }
            }
        }
        doWebServicesDeployment(app, dc);
        Thread.currentThread().setContextClassLoader(oldCl);
        WebServicesContainer container = habitat.getService(WebServicesContainer.class);
        WebServicesDeploymentMBean bean = container.getDeploymentBean();
        WebServiceDeploymentNotifier notifier = getDeploymentNotifier();
        bean.deploy(wsDesc, notifier);
        return true;
    } catch (Exception ex) {
        RuntimeException re = new RuntimeException(ex.getMessage());
        re.initCause(ex);
        throw re;
    }
}
Also used : JAXRPCCodeGenFacade(org.glassfish.internal.api.JAXRPCCodeGenFacade) WebServicesDeploymentMBean(org.glassfish.webservices.deployment.WebServicesDeploymentMBean) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DeploymentException(org.glassfish.deployment.common.DeploymentException) SAXException(org.xml.sax.SAXException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Aggregations

DeploymentException (org.glassfish.deployment.common.DeploymentException)2 JAXRPCCodeGenFacade (org.glassfish.internal.api.JAXRPCCodeGenFacade)2 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)1 WebServicesDeploymentMBean (org.glassfish.webservices.deployment.WebServicesDeploymentMBean)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1