Search in sources :

Example 6 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class EjbJarHandler method getClassLoader.

public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) {
    ASURLClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<ASURLClassLoader>() {

        @Override
        public ASURLClassLoader run() {
            return new ASURLClassLoader(parent);
        }
    });
    try {
        String compatProp = context.getAppProps().getProperty(DeploymentProperties.COMPATIBILITY);
        // let's see if it's defined in glassfish-ejb-jar.xml
        if (compatProp == null) {
            GFEjbJarXMLParser gfEjbJarXMLParser = new GFEjbJarXMLParser(context.getSource());
            compatProp = gfEjbJarXMLParser.getCompatibilityValue();
            if (compatProp != null) {
                context.getAppProps().put(DeploymentProperties.COMPATIBILITY, compatProp);
            }
        }
        // let's see if it's defined in sun-ejb-jar.xml
        if (compatProp == null) {
            SunEjbJarXMLParser sunEjbJarXMLParser = new SunEjbJarXMLParser(context.getSourceDir());
            compatProp = sunEjbJarXMLParser.getCompatibilityValue();
            if (compatProp != null) {
                context.getAppProps().put(DeploymentProperties.COMPATIBILITY, compatProp);
            }
        }
        // compatibility of v2 jar visibility
        if (compatProp != null && compatProp.equals("v2")) {
            List<URL> moduleRootLibraries = ASClassLoaderUtil.getURLsAsList(null, new File[] { context.getSourceDir() }, true);
            for (URL url : moduleRootLibraries) {
                cloader.addURL(url);
            }
        }
        cloader.addURL(context.getSource().getURI().toURL());
        cloader.addURL(context.getScratchDir("ejb").toURI().toURL());
        // add libraries referenced from manifest
        for (URL url : getManifestLibraries(context)) {
            cloader.addURL(url);
        }
        try {
            final DeploymentContext dc = context;
            final ClassLoader cl = cloader;
            AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.ejb, dc, cl));
        } catch (PrivilegedActionException e) {
            throw new SecurityException(e.getException());
        }
    } catch (Exception e) {
        _logger.log(Level.SEVERE, e.getMessage());
        throw new RuntimeException(e);
    }
    return cloader;
}
Also used : PermsArchiveDelegate(com.sun.enterprise.security.perms.PermsArchiveDelegate) PrivilegedActionException(java.security.PrivilegedActionException) URL(java.net.URL) XMLStreamException(javax.xml.stream.XMLStreamException) PrivilegedActionException(java.security.PrivilegedActionException) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ASURLClassLoader(com.sun.enterprise.loader.ASURLClassLoader) ASURLClassLoader(com.sun.enterprise.loader.ASURLClassLoader)

Example 7 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class ResourceValidator method event.

@Override
public void event(Event event) {
    if (event.is(Deployment.AFTER_APPLICATION_CLASSLOADER_CREATION)) {
        dc = (DeploymentContext) event.hook();
        Application application = dc.getModuleMetaData(Application.class);
        DeployCommandParameters commandParams = dc.getCommandParameters(DeployCommandParameters.class);
        target = commandParams.target;
        if (System.getProperty("deployment.resource.validation", "true").equals("false")) {
            deplLogger.log(Level.INFO, SKIP_RESOURCE_VALIDATION);
            return;
        }
        if (application == null) {
            return;
        }
        AppResources appResources = new AppResources();
        // Puts all resouces found in the application via annotation or xml into appResources
        parseResources(application, appResources);
        // Ensure we have a valid component invocation before triggering lookups
        String componentId = null;
        for (BundleDescriptor bundleDescriptor : application.getBundleDescriptors()) {
            if (bundleDescriptor instanceof JndiNameEnvironment) {
                componentId = DOLUtils.getComponentEnvId((JndiNameEnvironment) bundleDescriptor);
                if (componentId != null) {
                    break;
                }
            }
        }
        contextUtil.setInstanceComponentId(componentId);
        try (Context ctx = contextUtil.pushContext()) {
            validateResources(application, appResources);
        }
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) Context(org.glassfish.internal.api.JavaEEContextUtil.Context) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) InitialContext(javax.naming.InitialContext) Application(com.sun.enterprise.deployment.Application)

Example 8 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class ServerConfigLookup method calculateWebAvailabilityEnabledFromConfig.

/**
 * Get the availability-enabled from domain.xml.
 * This takes into account:
 * global
 * web-container-availability
 * web-module (if stand-alone)
 * return false if not found
 */
public boolean calculateWebAvailabilityEnabledFromConfig(WebModule ctx) {
    boolean waEnabled = calculateWebAvailabilityEnabledFromConfig();
    boolean webModuleAvailability = false;
    DeploymentContext dc = ctx.getWebModuleConfig().getDeploymentContext();
    if (dc != null) {
        DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
        if (params != null) {
            webModuleAvailability = params.availabilityenabled;
        }
    }
    if (_logger.isLoggable(Level.FINEST)) {
        _logger.log(Level.FINEST, LogFacade.WEB_MODULE_AVAILABILITY, webModuleAvailability);
    }
    return waEnabled && webModuleAvailability;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) DeploymentContext(org.glassfish.api.deployment.DeploymentContext)

Example 9 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class DynamicWebServletRegistrationImpl method configureAlternateDD.

/**
 * Determines and sets the alternate deployment descriptor for
 * this web module.
 */
void configureAlternateDD(WebBundleDescriptor wbd) {
    String altDDName = wbd.getModuleDescriptor().getAlternateDescriptor();
    if (altDDName == null) {
        return;
    }
    com.sun.enterprise.deployment.Application app = wbd.getApplication();
    if (app == null || app.isVirtual()) {
        // WAR files embedded inside EAR files
        return;
    }
    DeploymentContext dc = getWebModuleConfig().getDeploymentContext();
    if (dc == null) {
        return;
    }
    altDDName = altDDName.trim();
    if (altDDName.startsWith("/")) {
        altDDName = altDDName.substring(1);
    }
    String appLoc = dc.getSource().getParentArchive().getURI().getPath();
    altDDName = appLoc + altDDName;
    if (logger.isLoggable(Level.FINE)) {
        Object[] objs = { altDDName, wmInfo.getName() };
        logger.log(Level.FINE, LogFacade.ALT_DD_NAME, objs);
    }
    setAltDDName(altDDName);
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext)

Example 10 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class DynamicWebServletRegistrationImpl method start.

/**
 * Starts this web module.
 */
@Override
public synchronized void start() throws LifecycleException {
    // Get interestList of ServletContainerInitializers present, if any.
    List<Object> orderingList = null;
    boolean hasOthers = false;
    Map<String, String> webFragmentMap = Collections.emptyMap();
    if (webBundleDescriptor != null) {
        AbsoluteOrderingDescriptor aod = ((WebBundleDescriptorImpl) webBundleDescriptor).getAbsoluteOrderingDescriptor();
        if (aod != null) {
            orderingList = aod.getOrdering();
            hasOthers = aod.hasOthers();
        }
        webFragmentMap = webBundleDescriptor.getJarNameToWebFragmentNameMap();
    }
    boolean servletInitializersEnabled = true;
    if (webBundleDescriptor != null) {
        servletInitializersEnabled = webBundleDescriptor.getServletInitializersEnabled();
    }
    Iterable<ServletContainerInitializer> allInitializers = ServletContainerInitializerUtil.getServletContainerInitializers(webFragmentMap, orderingList, hasOthers, wmInfo.getAppClassLoader(), servletInitializersEnabled);
    setServletContainerInitializerInterestList(allInitializers);
    DeploymentContext dc = getWebModuleConfig().getDeploymentContext();
    if (dc != null) {
        directoryDeployed = Boolean.valueOf(dc.getAppProps().getProperty(ServerTags.DIRECTORY_DEPLOYED));
    }
    if (webBundleDescriptor != null) {
        showArchivedRealPathEnabled = webBundleDescriptor.isShowArchivedRealPathEnabled();
        servletReloadCheckSecs = webBundleDescriptor.getServletReloadCheckSecs();
        String reqEncoding = webBundleDescriptor.getRequestCharacterEncoding();
        if (reqEncoding != null) {
            setRequestCharacterEncoding(reqEncoding);
        }
        String resEncoding = webBundleDescriptor.getResponseCharacterEncoding();
        if (resEncoding != null) {
            setResponseCharacterEncoding(resEncoding);
        }
    }
    // Start and register Tomcat mbeans
    super.start();
    // Configure catalina listeners and valves. This can only happen
    // after this web module has been started, in order to be able to
    // load the specified listener and valve classes.
    configureValves();
    configureCatalinaProperties();
    webModuleStartedEvent();
    if (directoryListing) {
        setDirectoryListing(directoryListing);
    }
    hasStarted = true;
}
Also used : ServletContainerInitializer(javax.servlet.ServletContainerInitializer) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) WebBundleDescriptorImpl(org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl) AbsoluteOrderingDescriptor(org.glassfish.web.deployment.descriptor.AbsoluteOrderingDescriptor)

Aggregations

DeploymentContext (org.glassfish.api.deployment.DeploymentContext)27 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)11 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)6 URL (java.net.URL)5 ParameterMap (org.glassfish.api.admin.ParameterMap)5 PermsArchiveDelegate (com.sun.enterprise.security.perms.PermsArchiveDelegate)4 URI (java.net.URI)4 PrivilegedActionException (java.security.PrivilegedActionException)4 Container (com.sun.ejb.Container)3 AbstractSingletonContainer (com.sun.ejb.containers.AbstractSingletonContainer)3 Application (com.sun.enterprise.deployment.Application)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 ActionReport (org.glassfish.api.ActionReport)3 ApplicationContainer (org.glassfish.api.deployment.ApplicationContainer)3 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)3 ParameterMapExtractor (org.glassfish.common.util.admin.ParameterMapExtractor)3 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)3 VersioningException (org.glassfish.deployment.versioning.VersioningException)3