Search in sources :

Example 21 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class ApplicationRuntimeNode method setElementValue.

/**
 * receives notification of the value for a particular tag
 *
 * @param element the xml element
 * @param value it's associated value
 */
public void setElementValue(XMLElement element, String value) {
    if (element.getQName().equals(RuntimeTagNames.PASS_BY_REFERENCE)) {
        descriptor.setPassByReference("true".equalsIgnoreCase(value));
    } else if (element.getQName().equals(RuntimeTagNames.UNIQUE_ID)) {
        DOLUtils.getDefaultLogger().finer("Ignoring unique id");
        return;
    } else if (element.getQName().equals(RuntimeTagNames.ARCHIVE_NAME)) {
        descriptor.setArchiveName(value);
    } else if (element.getQName().equals(RuntimeTagNames.COMPATIBILITY)) {
        descriptor.setCompatibility(value);
    } else if (element.getQName().equals(RuntimeTagNames.PAYARA_CLASSLOADING_DELEGATE)) {
        descriptor.setClassLoadingDelegate(value);
    } else if (element.getQName().equals(RuntimeTagNames.PAYARA_ENABLE_IMPLICIT_CDI)) {
    // ignore, handled in EarHandler.java
    } else if (element.getQName().equals(RuntimeTagNames.PAYARA_SCANNING_EXCLUDE)) {
        descriptor.addScanningExclusions(ImmutableList.of(value));
    } else if (element.getQName().equals(RuntimeTagNames.PAYARA_SCANNING_INCLUDE)) {
        descriptor.addScanningInclusions(ImmutableList.of(value));
    } else if (element.getQName().equals(RuntimeTagNames.PAYARA_WHITELIST_PACKAGE)) {
        descriptor.addWhitelistPackage(value);
    } else if (element.getQName().equals(RuntimeTagNames.WEB_URI)) {
        currentWebUri = value;
    } else if (element.getQName().equals(RuntimeTagNames.CONTEXT_ROOT)) {
        if (currentWebUri != null) {
            ModuleDescriptor md = descriptor.getModuleDescriptorByUri(currentWebUri);
            if (md == null) {
                throw new RuntimeException("No bundle in application with uri " + currentWebUri);
            }
            currentWebUri = null;
            if (md.getModuleType().equals(DOLUtils.warType())) {
                md.setContextRoot(value);
            } else {
                throw new RuntimeException(currentWebUri + " uri does not point to a web bundle");
            }
        } else {
            throw new RuntimeException("No uri provided for this context-root " + value);
        }
    } else if (element.getQName().equals(RuntimeTagNames.KEEP_STATE)) {
        descriptor.setKeepState(value);
    } else if (element.getQName().equals(RuntimeTagNames.VERSION_IDENTIFIER)) {
    } else
        super.setElementValue(element, value);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 22 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class CheckMgr method getAbstractArchiveUri.

protected String getAbstractArchiveUri(Descriptor descriptor) {
    String archBase = context.getAbstractArchive().getURI().toString();
    if (descriptor instanceof Application)
        return archBase;
    ModuleDescriptor mdesc = getBundleDescriptor(descriptor).getModuleDescriptor();
    if (mdesc.isStandalone()) {
        return archBase;
    } else {
        return archBase + "/" + FileUtils.makeFriendlyFilename(mdesc.getArchiveUri());
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 23 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class PersistenceUnitCheckMgrImpl method getAbstractArchiveUri.

/**
 * This method returns the path to the module.
 * @param descriptor is a PersistenceUnitDescriptor
 * @return the path to the module
 */
protected String getAbstractArchiveUri(Descriptor descriptor) {
    String archBase = context.getAbstractArchive().getURI().toString();
    RootDeploymentDescriptor rootDD = PersistenceUnitDescriptor.class.cast(descriptor).getParent().getParent();
    if (rootDD.isApplication()) {
        return archBase;
    } else {
        ModuleDescriptor mdesc = BundleDescriptor.class.cast(rootDD).getModuleDescriptor();
        if (mdesc.isStandalone()) {
            return archBase;
        } else {
            return archBase + "/" + FileUtils.makeFriendlyFilename(mdesc.getArchiveUri());
        }
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Example 24 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class WsUtil method handleGet.

/**
 * Serve up the FINAL wsdl associated with this web service.
 * @return true for success, false for failure
 */
public boolean handleGet(HttpServletRequest request, HttpServletResponse response, WebServiceEndpoint endpoint) throws IOException {
    MimeHeaders headers = getHeaders(request);
    if (hasSomeTextXmlContent(headers)) {
        String message = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.GET_RECEIVED), endpoint.getEndpointName(), endpoint.getEndpointAddressUri());
        writeInvalidMethodType(response, message);
        logger.info(message);
        return false;
    }
    URL wsdlUrl = null;
    String requestUriRaw = request.getRequestURI();
    String requestUri = (requestUriRaw.charAt(0) == '/') ? requestUriRaw.substring(1) : requestUriRaw;
    String queryString = request.getQueryString();
    WebService webService = endpoint.getWebService();
    if (queryString == null) {
        // Get portion of request uri representing location within a module
        String wsdlPath = endpoint.getWsdlContentPath(requestUri);
        if (wsdlPath != null) {
            ModuleDescriptor module = webService.getBundleDescriptor().getModuleDescriptor();
            if (wsdlPath.equals(webService.getWsdlFileUri())) {
                // If the request is for the main wsdl document, return
                // the final wsdl instead of the wsdl from the module.
                wsdlUrl = webService.getWsdlFileUrl();
            } else if (isWsdlContent(wsdlPath, webService.getBundleDescriptor())) {
                // For relative document imports. These documents do not
                // require modification during deployment, so serve them
                // up directly from the packaged module.  isWsdlContent()
                // check ensures we don't serve up arbitrary content from
                // the module.
                URL finalWsdlUrl = webService.getWsdlFileUrl();
                String finalWsdlPath = finalWsdlUrl.getPath();
                // remove the final wsdl uri from the above path
                String wsdlDirPath = finalWsdlPath.substring(0, finalWsdlPath.length() - webService.getWsdlFileUri().length());
                File wsdlDir = new File(wsdlDirPath);
                File wsdlFile = new File(wsdlDir, wsdlPath.replace('/', File.separatorChar));
                try {
                    wsdlUrl = wsdlFile.toURL();
                } catch (MalformedURLException mue) {
                    String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.FAILURE_SERVING_WSDL), webService.getName());
                    logger.log(Level.INFO, msg, mue);
                }
            }
        }
    } else if (queryString.equalsIgnoreCase("WSDL")) {
        wsdlUrl = webService.getWsdlFileUrl();
    }
    boolean success = false;
    if (wsdlUrl != null) {
        InputStream is = null;
        try {
            response.setContentType("text/xml");
            response.setStatus(HttpServletResponse.SC_OK);
            // than the one they were deployed on (DAS).
            if (wsdlUrl.toURI().equals(webService.getWsdlFileUrl().toURI())) {
                // get the application module ID
                try {
                    WebServerInfo wsi = getWebServerInfoForDAS();
                    URL url = webService.getWsdlFileUrl();
                    File originalWsdlFile = new File(url.getPath() + "__orig");
                    if (!originalWsdlFile.exists()) {
                        originalWsdlFile = new File(url.getPath());
                    }
                    generateFinalWsdl(originalWsdlFile.toURL(), webService, wsi, response.getOutputStream());
                } catch (Exception e) {
                    // if this fail, we revert to service the untouched
                    // repository item.
                    URLConnection urlCon = wsdlUrl.openConnection();
                    urlCon.setUseCaches(false);
                    is = urlCon.getInputStream();
                    copyIsToOs(is, response.getOutputStream());
                }
            } else {
                // Copy bytes into output. Disable caches to avoid jar URL
                // caching problem.
                URLConnection urlCon = wsdlUrl.openConnection();
                urlCon.setUseCaches(false);
                is = urlCon.getInputStream();
                copyIsToOs(is, response.getOutputStream());
            }
            success = true;
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, LogUtils.SERVING_FINAL_WSDL, new Object[] { wsdlUrl, request.getRequestURL() + (queryString != null ? ("?" + queryString) : "") });
            }
        } catch (Exception e) {
            String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.FAILURE_SERVING_WSDL), webService.getName());
            logger.log(Level.INFO, msg, e);
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException ex) {
                }
            }
        }
    }
    if (!success) {
        String message = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.INVALID_WSDL_REQUEST), request.getRequestURL() + (queryString != null ? ("?" + queryString) : ""), webService.getName());
        logger.info(message);
        writeInvalidMethodType(response, message);
    }
    return success;
}
Also used : WebServerInfo(org.glassfish.web.deployment.util.WebServerInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) SAXException(org.xml.sax.SAXException) PrivilegedActionException(java.security.PrivilegedActionException) SOAPFaultException(javax.xml.rpc.soap.SOAPFaultException) InjectionException(com.sun.enterprise.container.common.spi.util.InjectionException) SAXParseException(org.xml.sax.SAXParseException) ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Example 25 with ModuleDescriptor

use of org.glassfish.deployment.common.ModuleDescriptor in project Payara by payara.

the class Application method addBundleDescriptor.

/**
 * Add a bundle descriptor to this application.
 *
 * @param bundleDescriptor the bundle descriptor to add
 */
@Override
public void addBundleDescriptor(BundleDescriptor bundleDescriptor) {
    ModuleDescriptor newModule = bundleDescriptor.getModuleDescriptor();
    addModule(newModule);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor)

Aggregations

ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)44 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)13 Application (com.sun.enterprise.deployment.Application)8 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)6 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)6 DOLUtils.setExtensionArchivistForSubArchivist (com.sun.enterprise.deployment.util.DOLUtils.setExtensionArchivistForSubArchivist)5 File (java.io.File)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)4 InputStream (java.io.InputStream)4 ApplicationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ApplicationDeploymentDescriptorFile)3 ConfigurationDeploymentDescriptorFile (com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile)3 DeploymentDescriptorFile (com.sun.enterprise.deployment.io.DeploymentDescriptorFile)3 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 Enumeration (java.util.Enumeration)2 Vector (java.util.Vector)2