Search in sources :

Example 1 with WebServicesDeploymentMBean

use of org.glassfish.webservices.deployment.WebServicesDeploymentMBean 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)

Example 2 with WebServicesDeploymentMBean

use of org.glassfish.webservices.deployment.WebServicesDeploymentMBean in project Payara by payara.

the class ListWebServicesCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    WebServicesContainer container = containerProvider.get();
    if (container == null) {
        return;
    }
    WebServicesDeploymentMBean bean = container.getDeploymentBean();
    if (appName != null && moduleName != null && endpointName != null) {
        Map<String, Map<String, Map<String, DeployedEndpointData>>> endpoints = bean.getEndpoint(appName, moduleName, endpointName);
        fillEndpoints(report, endpoints);
    } else if (appName != null && moduleName != null) {
        Map<String, Map<String, Map<String, DeployedEndpointData>>> endpoints = bean.getEndpoints(appName, moduleName);
        fillEndpoints(report, endpoints);
    } else if (appName != null) {
        Map<String, Map<String, Map<String, DeployedEndpointData>>> endpoints = bean.getEndpoints(appName);
        fillEndpoints(report, endpoints);
    } else {
        Map<String, Map<String, Map<String, DeployedEndpointData>>> endpoints = bean.getEndpoints();
        fillEndpoints(report, endpoints);
    }
}
Also used : DeployedEndpointData(org.glassfish.webservices.deployment.DeployedEndpointData) WebServicesContainer(org.glassfish.webservices.WebServicesContainer) ActionReport(org.glassfish.api.ActionReport) WebServicesDeploymentMBean(org.glassfish.webservices.deployment.WebServicesDeploymentMBean) Map(java.util.Map)

Example 3 with WebServicesDeploymentMBean

use of org.glassfish.webservices.deployment.WebServicesDeploymentMBean in project Payara by payara.

the class WebServicesDeployer method clean.

@Override
public void clean(DeploymentContext dc) {
    super.clean(dc);
    WebServicesContainer container = habitat.getService(WebServicesContainer.class);
    WebServicesDeploymentMBean bean = container.getDeploymentBean();
    UndeployCommandParameters params = dc.getCommandParameters(UndeployCommandParameters.class);
    if (params != null) {
        bean.undeploy(params.name);
    }
}
Also used : UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) WebServicesDeploymentMBean(org.glassfish.webservices.deployment.WebServicesDeploymentMBean)

Aggregations

WebServicesDeploymentMBean (org.glassfish.webservices.deployment.WebServicesDeploymentMBean)3 Map (java.util.Map)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ActionReport (org.glassfish.api.ActionReport)1 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)1 DeploymentException (org.glassfish.deployment.common.DeploymentException)1 JAXRPCCodeGenFacade (org.glassfish.internal.api.JAXRPCCodeGenFacade)1 WebServicesContainer (org.glassfish.webservices.WebServicesContainer)1 DeployedEndpointData (org.glassfish.webservices.deployment.DeployedEndpointData)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1