Search in sources :

Example 61 with DeployCommandParameters

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);
        }
    }
}
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) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) Application(com.sun.enterprise.deployment.Application)

Example 62 with DeployCommandParameters

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;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties)

Example 63 with DeployCommandParameters

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);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException)

Example 64 with DeployCommandParameters

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);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) OpsParams(org.glassfish.api.deployment.OpsParams) DeploymentException(org.glassfish.deployment.common.DeploymentException) StaticRmiStubGenerator(com.sun.ejb.codegen.StaticRmiStubGenerator) DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 65 with DeployCommandParameters

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);
        }
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties)

Aggregations

DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)69 IOException (java.io.IOException)25 File (java.io.File)24 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)24 ActionReport (org.glassfish.api.ActionReport)23 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)16 Application (com.sun.enterprise.deployment.Application)14 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)13 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)13 Logger (java.util.logging.Logger)12 Properties (java.util.Properties)10 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)10 DeploymentException (org.glassfish.deployment.common.DeploymentException)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)9 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)9 Deployment (org.glassfish.internal.deployment.Deployment)9 PropertyVetoException (java.beans.PropertyVetoException)8 URI (java.net.URI)8 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)8