use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class JPADeployer method event.
@Override
public void event(Event event) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("JpaDeployer.event():" + event.name());
}
if (event.is(Deployment.APPLICATION_PREPARED)) {
ExtendedDeploymentContext context = (ExtendedDeploymentContext) event.hook();
DeployCommandParameters deployCommandParameters = context.getCommandParameters(DeployCommandParameters.class);
if (logger.isLoggable(Level.FINE)) {
logger.fine("JpaDeployer.event(): Handling APPLICATION_PREPARED origin is:" + deployCommandParameters.origin);
}
// an application-ref is being created on DAS. Process the app
if (!deployCommandParameters.origin.isCreateAppRef() || isTargetDas(deployCommandParameters)) {
Map<String, ExtendedDeploymentContext> deploymentContexts = context.getModuleDeploymentContexts();
for (DeploymentContext deploymentContext : deploymentContexts.values()) {
// bundle level pus
iterateInitializedPUsAtApplicationPrepare(deploymentContext);
}
// app level pus
iterateInitializedPUsAtApplicationPrepare(context);
}
} else if (event.is(Deployment.APPLICATION_DISABLED)) {
logger.fine("JpaDeployer.event(): APPLICATION_DISABLED");
// APPLICATION_DISABLED will be generated when an app is disabled/undeployed/appserver goes down.
// close all the emfs created for this app
ApplicationInfo appInfo = (ApplicationInfo) event.hook();
closeEMFs(appInfo);
}
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class MEJBNamingObjectProxy method deployMEJB.
private void deployMEJB() throws IOException {
_logger.info("Loading MEJB app on JNDI look up");
ServerContext serverContext = habitat.getService(ServerContext.class);
File mejbArchive = new File(serverContext.getInstallRoot(), "lib/install/applications/mejb.jar");
DeployCommandParameters deployParams = new DeployCommandParameters(mejbArchive);
String targetName = habitat.<Server>getService(Server.class, ServerEnvironment.DEFAULT_INSTANCE_NAME).getName();
deployParams.target = targetName;
deployParams.name = "mejb";
ActionReport report = habitat.getService(ActionReport.class, "plain");
Deployment deployment = habitat.getService(Deployment.class);
ExtendedDeploymentContext dc = deployment.getBuilder(_logger, deployParams, report).source(mejbArchive).build();
deployment.deploy(dc);
if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS) {
throw new RuntimeException("Failed to deploy MEJB app: " + report.getFailureCause());
}
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class DOLUtils method getCurrentBundleForContext.
/**
* Gets the associated descriptor with the context
* @param context
* @return null if there is no associated application
*/
public static BundleDescriptor getCurrentBundleForContext(DeploymentContext context) {
ExtendedDeploymentContext ctx = (ExtendedDeploymentContext) context;
Application application = context.getModuleMetaData(Application.class);
// this can happen for non-JavaEE type deployment. e.g., issue 15869
if (application == null)
return null;
if (ctx.getParentContext() == null) {
if (application.isVirtual()) {
// standalone module
return application.getStandaloneBundleDescriptor();
} else {
// top level
return application;
}
} else {
// a sub module of ear
return application.getModuleByUri(ctx.getModuleUri());
}
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class DOLUtils method getSniffersForModule.
/**
* get sniffer list for sub modules of an ear application
*/
private static Collection<Sniffer> getSniffersForModule(ServiceLocator habitat, ReadableArchive archive, ModuleDescriptor md, Application app) throws Exception {
ArchiveHandler handler = habitat.getService(ArchiveHandler.class, md.getModuleType().toString());
SnifferManager snifferManager = habitat.getService(SnifferManager.class);
List<URI> classPathURIs = handler.getClassPathURIs(archive);
classPathURIs.addAll(getLibraryJarURIs(app, archive));
Types types = archive.getParentArchive().getExtraData(Types.class);
DeployCommandParameters parameters = archive.getParentArchive().getArchiveMetaData(DeploymentProperties.COMMAND_PARAMS, DeployCommandParameters.class);
Properties appProps = archive.getParentArchive().getArchiveMetaData(DeploymentProperties.APP_PROPS, Properties.class);
ExtendedDeploymentContext context = new DeploymentContextImpl(null, archive, parameters, habitat.<ServerEnvironment>getService(ServerEnvironment.class));
if (appProps != null) {
context.getAppProps().putAll(appProps);
}
context.setArchiveHandler(handler);
context.addTransientAppMetaData(Types.class.getName(), types);
Collection<Sniffer> sniffers = snifferManager.getSniffers(context, classPathURIs, types);
context.postDeployClean(true);
String type = getTypeFromModuleType(md.getModuleType());
Sniffer mainSniffer = null;
for (Sniffer sniffer : sniffers) {
if (sniffer.getModuleType().equals(type)) {
mainSniffer = sniffer;
}
}
// to add the appropriate sniffer
if (mainSniffer == null) {
mainSniffer = snifferManager.getSniffer(type);
sniffers.add(mainSniffer);
}
String[] incompatibleTypes = mainSniffer.getIncompatibleSnifferTypes();
List<String> allIncompatTypes = addAdditionalIncompatTypes(mainSniffer, incompatibleTypes);
List<Sniffer> sniffersToRemove = new ArrayList<Sniffer>();
for (Sniffer sniffer : sniffers) {
for (String incompatType : allIncompatTypes) {
if (sniffer.getModuleType().equals(incompatType)) {
deplLogger.log(Level.WARNING, INCOMPATIBLE_TYPE, new Object[] { type, md.getArchiveUri(), incompatType });
sniffersToRemove.add(sniffer);
}
}
}
sniffers.removeAll(sniffersToRemove);
// store the module sniffer information so we don't need to
// recalculate them later
Hashtable sniffersTable = archive.getParentArchive().getExtraData(Hashtable.class);
if (sniffersTable == null) {
sniffersTable = new Hashtable<String, Collection<Sniffer>>();
archive.getParentArchive().setExtraData(Hashtable.class, sniffersTable);
}
sniffersTable.put(md.getArchiveUri(), sniffers);
return sniffers;
}
use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.
the class Verifier method verify.
public void verify(DeploymentContext context) {
com.sun.enterprise.tools.verifier.VerifierFrameworkContext verifierFrameworkContext = new com.sun.enterprise.tools.verifier.VerifierFrameworkContext();
verifierFrameworkContext.setArchive(context.getSource());
verifierFrameworkContext.setApplication(context.getModuleMetaData(com.sun.enterprise.deployment.Application.class));
verifierFrameworkContext.setJarFileName(context.getSourceDir().getAbsolutePath());
verifierFrameworkContext.setJspOutDir(context.getScratchDir("jsp"));
verifierFrameworkContext.setIsBackend(true);
verifierFrameworkContext.setOutputDirName(env.getDomainRoot().getAbsolutePath() + "/logs/verifier-results");
com.sun.enterprise.tools.verifier.ResultManager rm = verifierFrameworkContext.getResultManager();
try {
init(verifierFrameworkContext);
verify();
} catch (Exception e) {
LogRecord logRecord = new LogRecord(Level.SEVERE, "Could not verify successfully.");
logRecord.setThrown(e);
verifierFrameworkContext.getResultManager().log(logRecord);
}
try {
generateReports();
} catch (IOException ioe) {
context.getLogger().log(Level.WARNING, "Can not generate verifier report: {0}", ioe.getMessage());
}
int failedCount = rm.getFailedCount() + rm.getErrorCount();
if (failedCount != 0) {
((ExtendedDeploymentContext) context).clean();
throw new DeploymentException(smh.getLocalString("deploy.failverifier", "Some verifier tests failed. Aborting deployment"));
}
}
Aggregations