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;
}
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);
}
}
}
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;
}
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);
}
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;
}
Aggregations