private List<ReadableArchive> getExternalLibraries( DeploymentContext context) throws IOException { List<ReadableArchive> externalLibArchives = new ArrayList<ReadableArchive>(); String skipScanExternalLibProp = context.getAppProps().getProperty( DeploymentProperties.SKIP_SCAN_EXTERNAL_LIB); if (Boolean.valueOf(skipScanExternalLibProp)) { // if we skip scanning external libraries, we should just // return an empty list here return Collections.EMPTY_LIST; } List<URI> externalLibs = DeploymentUtils.getExternalLibraries(context.getSource()); for (URI externalLib : externalLibs) { externalLibArchives.add(archiveFactory.openArchive(new File(externalLib.getPath()))); } return externalLibArchives; }
@Override public DummyApplication load(SecurityContainer container, DeploymentContext context) { DeployCommandParameters dparams = context.getCommandParameters(DeployCommandParameters.class); Application app = context.getModuleMetaData(Application.class); handleCNonceCacheBSInit(app.getAppName(), app.getBundleDescriptors(WebBundleDescriptor.class), dparams.availabilityenabled); return new DummyApplication(); }
/** * Returns a collection of sniffers that recognized some parts of the * passed archive as components their container handle. * * If no sniffer recognize the passed archive, an empty collection is * returned. * * @param context the deployment context * @return possibly empty collection of sniffers that handle the passed * archive. */ public Collection<Sniffer> getSniffers(DeploymentContext context) { ReadableArchive archive = context.getSource(); ArchiveHandler handler = context.getArchiveHandler(); List<URI> uris = handler.getClassPathURIs(archive); Types types = context.getTransientAppMetaData(Types.class.getName(), Types.class); return getSniffers(context, uris, types); }
/** * Loads a previously prepared application in its execution environment and * return a ContractProvider instance that will identify this environment in * future communications with the application's container runtime. * @param container in which the application will reside * @param context of the deployment * @return an ApplicationContainer instance identifying the running application */ public U load(T container, DeploymentContext context) { // reset classloader on DOL object before loading so we have a // valid classloader set on DOL Application app = context.getModuleMetaData(Application.class); if (app != null) { app.setClassLoader(context.getClassLoader()); } return null; }
/** * Returns true if the passed file or directory is recognized by this * composite sniffer. * @param context deployment context * @return true if the location is recognized by this sniffer */ public boolean handles(DeploymentContext context) { return handles(context.getSource(), context.getClassLoader()); } }
@Override public ClassLoader getFinalClassLoader() { try { EarClassLoader finalEarCL = (EarClassLoader) context.getFinalClassLoader(); return finalEarCL.getModuleClassLoader(moduleUri); } catch (ClassCastException e) { return context.getClassLoader(); } } @Override
private boolean loadOnCurrentInstance(DeploymentContext context) { final DeployCommandParameters commandParams = context.getCommandParameters(DeployCommandParameters.class); final Properties appProps = context.getAppProps(); if (commandParams.enabled) { // if the current instance match with the target if (domain.isCurrentInstanceMatchingTarget(commandParams.target, commandParams.name(), server.getName(), context.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class))) { return true; } if (server.isDas()) { String objectType = appProps.getProperty(ServerTags.OBJECT_TYPE); if (objectType != null) { // if it's a system application needs to be loaded on DAS if (objectType.equals(DeploymentProperties.SYSTEM_ADMIN) || objectType.equals(DeploymentProperties.SYSTEM_ALL)) { return true; } } } } return false; }
private void validateDeploymentProperties(Properties properties, DeploymentContext context) { String compatProp = properties.getProperty( DeploymentProperties.COMPATIBILITY); if (compatProp != null && !compatProp.equals("v2")) { // this only allowed value for property compatibility is v2 String warningMsg = localStrings.getLocalString("compat.value.not.supported", "{0} is not a supported value for compatibility property.", compatProp); ActionReport subReport = context.getActionReport().addSubActionsReport(); subReport.setActionExitCode(ActionReport.ExitCode.WARNING); subReport.setMessage(warningMsg); context.getLogger().log(Level.WARNING, warningMsg); } }
public static boolean useV2Compatibility(DeploymentContext context) { return V2_COMPATIBILITY.equals(context.getAppProps().getProperty(DeploymentProperties.COMPATIBILITY)); }
private boolean isKeepState(DeploymentContext deployContext, boolean isDeploy) { Boolean keepState = null; if (isDeploy) { DeployCommandParameters dcp = deployContext.getCommandParameters(DeployCommandParameters.class); if (dcp != null) { keepState = dcp.keepstate; } } else { UndeployCommandParameters ucp = deployContext.getCommandParameters(UndeployCommandParameters.class); if (ucp != null) { keepState = ucp.keepstate; } } if (keepState == null) { String keepSessionsString = deployContext.getAppProps().getProperty(DeploymentProperties.KEEP_SESSIONS); if (keepSessionsString != null && keepSessionsString.trim().length() > 0) { keepState = Boolean.valueOf(keepSessionsString); } else { keepState = getDescriptor().getApplication().getKeepState(); } } return ((keepState != null) ? keepState : false); }
private WebModuleConfig loadWebModuleConfig(DeploymentContext dc) { WebModuleConfig wmInfo = new WebModuleConfig(); try { DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class); wmInfo.setDescriptor(dc.getModuleMetaData(WebBundleDescriptor.class)); wmInfo.setVirtualServers(params.virtualservers); wmInfo.setLocation(dc.getSourceDir()); wmInfo.setObjectType(dc.getAppProps().getProperty(ServerTags.OBJECT_TYPE)); } catch (Exception ex) { String msg = rb.getString("webdeployer.loadWebModuleConfig"); msg = MessageFormat.format(msg, wmInfo.getName()); logger.log(Level.WARNING, msg, ex); } return wmInfo; }
@Override void visitPUD(PersistenceUnitDescriptor pud, DeploymentContext context) { if(referencedPus.contains(pud)) { boolean isDas = isDas(); // While running in embedded mode, it is not possible to guarantee that entity classes are not loaded by the app classloader before transformers are installed // If that happens, weaving will not take place and EclipseLink will throw up. Provide users an option to disable weaving by passing the flag. // Note that we enable weaving if not explicitly disabled by user boolean weavingEnabled = Boolean.valueOf(sc.getArguments().getProperty("org.glassfish.persistence.embedded.weaving.enabled", "true")); ProviderContainerContractInfo providerContainerContractInfo = weavingEnabled ? new ServerProviderContainerContractInfo(context, connectorRuntime, isDas) : new EmbeddedProviderContainerContractInfo(context, connectorRuntime, isDas); try { ((ExtendedDeploymentContext) context).prepareScratchDirs(); } catch (IOException e) { // There is no way to recover if we are not able to create the scratch dirs. Just rethrow the exception. throw new RuntimeException(e); } PersistenceUnitLoader puLoader = new PersistenceUnitLoader(pud, providerContainerContractInfo); // Store the puLoader in context. It is retrieved to execute java2db and to // store the loaded emfs in a JPAApplicationContainer object for cleanup context.addTransientAppMetaData(getUniquePuIdentifier(pud), puLoader ); } } };
public Collection<? extends Sniffer> getSniffers(final ArchiveHandler handler, Collection<? extends Sniffer> sniffers, DeploymentContext context) { if (handler == null) { return Collections.EMPTY_LIST; } if (sniffers==null) { if (handler instanceof CompositeHandler) { ((CompositeHandler)handler).initCompositeMetaData(context); context.getAppProps().setProperty(ServerTags.IS_COMPOSITE, "true"); } sniffers = snifferManager.getSniffers(context); } context.addTransientAppMetaData(DeploymentProperties.SNIFFERS, sniffers); snifferManager.validateSniffers(sniffers, context); return sniffers; }
public <V> V loadMetaData(Class<V> type, DeploymentContext dc) { WebBundleDescriptor wbd = dc.getModuleMetaData(WebBundleDescriptor.class); DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class); String contextRoot = params.contextroot; if(contextRoot==null) { contextRoot = wbd.getModuleDescriptor().getModuleName(); if(contextRoot==null) contextRoot = dc.getSource().getName(); dc.getAppProps().setProperty(ServerTags.CONTEXT_ROOT, contextRoot);
/** * Returns true if the passed file or directory is recognized by this * composite sniffer. * @param context deployment context * @return true if the location is recognized by this sniffer */ @Override public boolean handles(DeploymentContext context) { ArchiveType archiveType = habitat.getService(ArchiveType.class, context.getArchiveHandler().getArchiveType()); if (archiveType != null && !supportsArchiveType(archiveType)) { return false; } return DeploymentUtils.isArchiveOfType(context.getSource(), earType, context, locator); }
protected Collection<EngineInfo> setupContainer(Sniffer sniffer, Logger logger, DeploymentContext context) { ActionReport report = context.getActionReport(); ContainerStarter starter = habitat.getService(ContainerStarter.class); Collection<EngineInfo> containersInfo = starter.startContainer(sniffer); if (containersInfo == null || containersInfo.size()==0) { report.failure(logger, "Cannot start container(s) associated to application of type : " + sniffer.getModuleType(), null); return null; } return containersInfo; }
/** * Decides whether we have any pu roots at ear level */ public boolean handles(DeploymentContext context) { ArchiveType archiveType = habitat.getService(ArchiveType.class, context.getArchiveHandler().getArchiveType()); if (archiveType != null && !supportsArchiveType(archiveType)) { return false; } // Scans for pu roots in the "lib" dir of an application. // We do not scan for PU roots in root of .ear. JPA 2.0 spec will clarify that it is not a portable use case. // It is not portable use case because JavaEE spec implies that jars in root of ears are not visible by default // to components (Unless an explicit Class-Path manifest entry is present) and can potentially be loaded by // different class loaders (corresponding to each component that refers to it) thus residing in different name // space. It does not make sense to make them visible at ear level (and thus in a single name space) boolean isJPAApplication = false; ApplicationHolder holder = context.getModuleMetaData(ApplicationHolder.class); ReadableArchive appRoot = context.getSource(); if (holder != null && holder.app != null) { isJPAApplication = scanForPURootsInLibDir(appRoot, holder.app.getLibraryDirectory()); if(!isJPAApplication) { if(DeploymentUtils.useV2Compatibility(context) ) { //Scan for pu roots in root of ear isJPAApplication = scanForPURRootsInEarRoot(context, holder.app.getModules()); } } } return isJPAApplication; }
/** * Returns true if the passed file or directory is recognized by this * composite sniffer. * @param context deployment context * @return true if the location is recognized by this sniffer */ public boolean handles(DeploymentContext context) { ArchiveType archiveType = habitat.getService(ArchiveType.class, context.getArchiveHandler().getArchiveType()); if (archiveType != null && !supportsArchiveType(archiveType)) { return false; } return handles(context.getSource()); }
_logger.log( Level.FINE, "EjbDeployer Loading app from: " + dc.getSourceDir()); RegisteredComponentInvocationHandler handler = habitat.getService(RegisteredComponentInvocationHandler.class,"ejbSecurityCIH"); handler.register(); EjbBundleDescriptorImpl ejbBundle = dc.getModuleMetaData(EjbBundleDescriptorImpl.class); " Check archive to ensure correct packaging for " + dc.getSourceDir()); ejbBundle.setClassLoader(dc.getClassLoader()); ejbBundle.setupDataStructuresForRuntime(); dc.getClassLoader(), habitat);
private <T extends Sniffer> List<T> getApplicableSniffers(DeploymentContext context, List<URI> uris, Types types, Collection<T> sniffers, boolean checkPath) { ArchiveType archiveType = habitat.getService(ArchiveType.class, context.getArchiveHandler().getArchiveType());