use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ResourceValidator method event.
@Override
public void event(Event<?> event) {
if (event.is(Deployment.AFTER_APPLICATION_CLASSLOADER_CREATION)) {
DeploymentContext deploymentContext = (DeploymentContext) event.hook();
Application application = deploymentContext.getModuleMetaData(Application.class);
DeployCommandParameters commandParams = deploymentContext.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 resources found in the application via annotation or xml into appResources
parseResources(deploymentContext, application, appResources);
// Ensure we have a valid component invocation before triggering lookups
try (Context ctx = contextUtil.empty().pushContext()) {
validateResources(deploymentContext, application, appResources);
}
}
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ResourceValidator method loadOnCurrentInstance.
/**
* Copy from ApplicationLifeCycle.java
*/
private boolean loadOnCurrentInstance(DeploymentContext deploymentContext) {
final DeployCommandParameters commandParams = deploymentContext.getCommandParameters(DeployCommandParameters.class);
final Properties appProps = deploymentContext.getAppProps();
if (commandParams.enabled) {
// if the current instance match with the target
if (domain.isCurrentInstanceMatchingTarget(commandParams.target, commandParams.name(), server.getName(), deploymentContext.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;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ExpiredSessionsRemovalTask method buildComponents.
public void buildComponents(byte[] ipAddress, int port, DeploymentContext dc) throws Exception {
if (availabilityService != null) {
this.HAEnabled = Boolean.valueOf(availabilityService.getAvailabilityEnabled());
_logger.log(Level.FINE, SFSB_BUILDER_TOP_LEVEL_AVAILABILITY_SERVICE_ENABLED, this.HAEnabled);
if ((this.HAEnabled) && (ejbAvailability != null)) {
this.HAEnabled = Boolean.valueOf(ejbAvailability.getAvailabilityEnabled());
_logger.log(Level.FINE, SFSB_BUILDER_EJB_AVAILABILITY_SERVICE_ENABLED, this.HAEnabled);
}
boolean appLevelHAEnabled = false;
try {
if (HAEnabled) {
if (dc != null) {
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
if (params != null) {
appLevelHAEnabled = params.availabilityenabled;
asyncReplication = params.asyncreplication;
}
}
_logger.log(Level.FINE, SFSB_BUILDER_GLOBAL_AND_APP_AVAILABILITY_ENABLED, new Object[] { this.HAEnabled, appLevelHAEnabled });
}
} catch (Exception ex) {
_logger.log(Level.WARNING, SFSB_BUILDER_DETERMINE_AVAILABILITY_EXCEPTION, ex);
appLevelHAEnabled = false;
}
HAEnabled = HAEnabled && appLevelHAEnabled;
_logger.log(Level.FINE, SFSB_BUILDER_RESOLVED_AVAILABILITY_ENABLED, this.HAEnabled);
}
EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) ejbDescriptor;
// When passivation is disabled, we should also forbid ha.
if (!sessionDescriptor.isPassivationCapable() && HAEnabled) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, SFSB_HA_DISABLED_BY_PASSIVATION_SETTING, ejbDescriptor.getEjbClassName());
}
HAEnabled = false;
}
buildCheckpointPolicy(this.HAEnabled);
buildSFSBUUIDUtil(ipAddress, port);
// First build BackingStore before Cache is built
if (sessionDescriptor.isPassivationCapable()) {
buildStoreManager();
} else {
if (_logger.isLoggable(TRACE_LEVEL)) {
_logger.log(TRACE_LEVEL, "Stateful session bean passivation is disabled, so do not create store manger");
}
}
buildCache();
scheduleTimerTasks(sfsbContainer);
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class EjbDeployer method generateArtifacts.
/**
* Use this method to generate any ejb-related artifacts for the module
*/
@Override
protected void generateArtifacts(DeploymentContext dc) throws DeploymentException {
OpsParams params = dc.getCommandParameters(OpsParams.class);
if (!(params.origin.isDeploy() && isDas())) {
// Generate artifacts only when being deployed on DAS
return;
}
EjbBundleDescriptorImpl bundle = dc.getModuleMetaData(EjbBundleDescriptorImpl.class);
DeployCommandParameters dcp = dc.getCommandParameters(DeployCommandParameters.class);
boolean generateRmicStubs = dcp.generatermistubs;
dc.addTransientAppMetaData(CMPDeployer.MODULE_CLASSPATH, getModuleClassPath(dc));
if (generateRmicStubs) {
StaticRmiStubGenerator staticStubGenerator = new StaticRmiStubGenerator(habitat);
try {
staticStubGenerator.ejbc(dc);
} catch (Exception e) {
throw new DeploymentException("Static RMI-IIOP Stub Generation exception for " + dc.getSourceDir(), e);
}
}
if (bundle == null || !bundle.containsCMPEntity()) {
// bundle WAS null in a war file where we do not support CMPs
return;
}
initCMPDeployer();
if (cmpDeployer == null) {
throw new DeploymentException("No CMP Deployer is available to deploy this module");
}
cmpDeployer.deploy(dc);
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ResourcesDeployer method cleanupPreservedResources.
private void cleanupPreservedResources(DeploymentContext dc, Event event) {
if (Deployment.DEPLOYMENT_FAILURE.equals(event.type())) {
final DeployCommandParameters deployCommandParameters = dc.getCommandParameters(DeployCommandParameters.class);
if (deployCommandParameters.origin == OpsParams.Origin.deploy || deployCommandParameters.origin == OpsParams.Origin.deploy_instance || deployCommandParameters.origin == OpsParams.Origin.create_application_ref) {
Properties properties = deployCommandParameters.properties;
String appName = deployCommandParameters.name();
cleanupPreservedResources(appName, properties);
}
} else if (Deployment.UNDEPLOYMENT_FAILURE.equals(event.type())) {
final UndeployCommandParameters undeployCommandParameters = dc.getCommandParameters(UndeployCommandParameters.class);
if (undeployCommandParameters.origin == OpsParams.Origin.undeploy) {
Properties properties = undeployCommandParameters.properties;
String appName = undeployCommandParameters.name();
cleanupPreservedResources(appName, properties);
}
}
}
Aggregations