Search in sources :

Example 1 with ConfigBeansUtilities

use of com.sun.enterprise.config.serverbeans.ConfigBeansUtilities in project Payara by payara.

the class VirtualServer method getDefaultWebModule.

protected WebModuleConfig getDefaultWebModule(Domain domain, WebArchivist webArchivist, ApplicationRegistry appRegistry) {
    WebModuleConfig webModuleConfig = null;
    String defaultWebModuleId = getDefaultWebModuleID();
    if (defaultWebModuleId != null) {
        // Check if the default-web-module is part of an ee-application
        webModuleConfig = findWebModuleInJ2eeApp(domain.getApplications(), defaultWebModuleId, appRegistry);
        if (webModuleConfig == null) {
            String contextRoot = null;
            String location = null;
            ConfigBeansUtilities configBeansUtilities = getConfigBeansUtilities();
            if (configBeansUtilities != null) {
                contextRoot = configBeansUtilities.getContextRoot(defaultWebModuleId);
                location = configBeansUtilities.getLocation(defaultWebModuleId);
            }
            if (contextRoot != null && location != null) {
                WebBundleDescriptorImpl webBundleDescriptorImpl = webArchivist.getDefaultWebXmlBundleDescriptor();
                webBundleDescriptorImpl.setName(DEFAULT_WEB_MODULE_NAME);
                webBundleDescriptorImpl.setContextRoot(contextRoot);
                webModuleConfig = new WebModuleConfig();
                webModuleConfig.setLocation(new File(location));
                webModuleConfig.setDescriptor(webBundleDescriptorImpl);
                webModuleConfig.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                webModuleConfig.setAppClassLoader(privileged(() -> new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader(), webBundleDescriptorImpl.getApplication())));
            }
        }
        if (webModuleConfig == null) {
            _logger.log(SEVERE, VS_DEFAULT_WEB_MODULE_NOT_FOUND, new Object[] { defaultWebModuleId, getID() });
        }
    }
    return webModuleConfig;
}
Also used : WebappClassLoader(org.glassfish.web.loader.WebappClassLoader) WebBundleDescriptorImpl(org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl) ConfigBeansUtilities(com.sun.enterprise.config.serverbeans.ConfigBeansUtilities) File(java.io.File)

Example 2 with ConfigBeansUtilities

use of com.sun.enterprise.config.serverbeans.ConfigBeansUtilities in project Payara by payara.

the class VirtualServer method getDefaultContextPath.

// ------------------------------------------------------ Protected Methods
/**
 * Gets the context root of the web module that the user/configuration has designated as the default-web-module for this
 * virtual server.
 *
 * The default-web-module for a virtual server is specified via the 'default-web-module' attribute of the
 * 'virtual-server' element in server.xml. This is an optional attribute and if the configuration does not specify
 * another web module (standalone or part of a j2ee-application) that is configured at a context-root="", then a default
 * web module will be created and loaded. The value for this attribute is either "${standalone-web-module-name}" or
 * "${j2ee-app-name}:${web-module-uri}".
 *
 * @param domain
 * @param appRegistry
 * @return null if the default-web-module has not been specified or if the web module specified either could not be
 * found or is disabled or does not specify this virtual server (if it specifies a value for the virtual-servers
 * attribute) or if there was an error loading its deployment descriptors.
 */
protected String getDefaultContextPath(Domain domain, ApplicationRegistry appRegistry) {
    String contextRoot = null;
    String defaultWebModuleId = getDefaultWebModuleID();
    if (defaultWebModuleId != null) {
        // Check if the default-web-module is part of a
        // j2ee-application
        Applications appsBean = domain.getApplications();
        WebModuleConfig webModuleConfig = findWebModuleInJ2eeApp(appsBean, defaultWebModuleId, appRegistry);
        if (webModuleConfig == null) {
            ConfigBeansUtilities configBeansUtilities = getConfigBeansUtilities();
            if (configBeansUtilities == null) {
                contextRoot = null;
            } else {
                contextRoot = configBeansUtilities.getContextRoot(defaultWebModuleId);
            }
        } else {
            contextRoot = webModuleConfig.getContextPath();
        }
        if (contextRoot == null) {
            _logger.log(SEVERE, VS_DEFAULT_WEB_MODULE_NOT_FOUND, new Object[] { defaultWebModuleId, getID() });
        }
    }
    return contextRoot;
}
Also used : Applications(com.sun.enterprise.config.serverbeans.Applications) ConfigBeansUtilities(com.sun.enterprise.config.serverbeans.ConfigBeansUtilities)

Example 3 with ConfigBeansUtilities

use of com.sun.enterprise.config.serverbeans.ConfigBeansUtilities in project Payara by payara.

the class NotDuplicateTargetNameValidator method initialize.

@Override
public void initialize(NotDuplicateTargetName constraintAnnotation) {
    ServiceLocator locator = ServiceLocatorFactory.getInstance().find("default");
    if (locator == null)
        return;
    ConfigBeansUtilities cbu = locator.getService(ConfigBeansUtilities.class);
    if (cbu == null)
        return;
    domain = cbu.getDomain();
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ConfigBeansUtilities(com.sun.enterprise.config.serverbeans.ConfigBeansUtilities)

Aggregations

ConfigBeansUtilities (com.sun.enterprise.config.serverbeans.ConfigBeansUtilities)3 Applications (com.sun.enterprise.config.serverbeans.Applications)1 File (java.io.File)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1 WebBundleDescriptorImpl (org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl)1 WebappClassLoader (org.glassfish.web.loader.WebappClassLoader)1