Search in sources :

Example 26 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class PipeHelper method getHandlerContext.

@Override
protected HandlerContext getHandlerContext(Map map) {
    String realmName = null;
    WebServiceEndpoint wSE = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
    if (wSE != null) {
        Application app = wSE.getBundleDescriptor().getApplication();
        if (app != null) {
            realmName = app.getRealm();
        }
        if (realmName == null) {
            realmName = wSE.getRealm();
        }
    }
    final String fRealmName = realmName;
    return new HandlerContext() {

        @Override
        public String getRealmName() {
            return fRealmName;
        }
    };
}
Also used : WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) HandlerContext(com.sun.enterprise.security.jmac.config.HandlerContext) Application(com.sun.enterprise.deployment.Application)

Example 27 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class RealmAdapter method computeRealmName.

// ### Private methods
private void computeRealmName(WebBundleDescriptor webDescriptor, String realmName) {
    Application application = webDescriptor.getApplication();
    LoginConfiguration loginConfig = webDescriptor.getLoginConfiguration();
    this.realmName = application.getRealm();
    if (this.realmName == null && loginConfig != null) {
        this.realmName = loginConfig.getRealmName();
    }
    if (realmName != null && (this.realmName == null || this.realmName.equals(""))) {
        this.realmName = realmName;
    }
}
Also used : LoginConfiguration(com.sun.enterprise.deployment.web.LoginConfiguration) Application(com.sun.enterprise.deployment.Application)

Example 28 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class EjbApplication method resolveKeepStateOptions.

/**
 * Returns a consolidated keepstate value.  keepstate only takes effect for
 * redeploy operations where the app is already registered.  If the app is
 * not already registered, keepstate always resolves to false even if
 * keepstate is true in CLI or descriptors.  For redeploy operations, CLI
 * --keepstate option has precedence over descriptor keep-state element.
 * @param deployContext
 * @param isDeploy
 * @param bundleDesc
 * @return true if keepstate is true after consolidating --keepstate CLI option
 * and keep-state element in descriptors; false otherwise.
 */
private boolean resolveKeepStateOptions(DeploymentContext deployContext, boolean isDeploy, EjbBundleDescriptorImpl bundleDesc) {
    Boolean isredeploy = Boolean.FALSE;
    Boolean keepState = null;
    if (isDeploy) {
        DeployCommandParameters dcp = deployContext.getCommandParameters(DeployCommandParameters.class);
        if (dcp != null) {
            isredeploy = dcp.isredeploy;
            keepState = dcp.keepstate;
        }
    } else {
        UndeployCommandParameters ucp = deployContext.getCommandParameters(UndeployCommandParameters.class);
        if (ucp != null) {
            isredeploy = ucp.isredeploy;
            keepState = ucp.keepstate;
        }
    }
    if (!isredeploy) {
        return false;
    }
    if (keepState == null) {
        Application app = bundleDesc.getApplication();
        keepState = app.getKeepState();
    }
    return keepState;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) Application(com.sun.enterprise.deployment.Application)

Example 29 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class EjbDeployer method event.

@Override
public void event(Event event) {
    if (event.is(Deployment.APPLICATION_PREPARED) && isDas()) {
        ExtendedDeploymentContext context = (ExtendedDeploymentContext) event.hook();
        OpsParams opsparams = context.getCommandParameters(OpsParams.class);
        DeployCommandParameters dcp = context.getCommandParameters(DeployCommandParameters.class);
        ApplicationInfo appInfo = appRegistry.get(opsparams.name());
        Application app = appInfo.getMetaData(Application.class);
        if (app == null) {
            // Not a Java EE application
            return;
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "EjbDeployer in APPLICATION_PREPARED for origin: " + opsparams.origin + ", target: " + dcp.target + ", name: " + opsparams.name());
        }
        boolean createTimers = true;
        if (!(opsparams.origin.isDeploy() || opsparams.origin.isCreateAppRef()) || env.getInstanceName().equals(dcp.target)) {
            // Timers will be created by the BaseContainer if it's a single instance deploy
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "EjbDeployer ... will only set the timeout application flag if any");
            }
            // But is-timed-app needs to be set in AppInfo in any case
            createTimers = false;
        }
        String target = dcp.target;
        if (createTimers && dcp.isredeploy != null && dcp.isredeploy && DeploymentUtils.isDomainTarget(target)) {
            List<String> targets = (List<String>) context.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class);
            for (String ref : targets) {
                target = ref;
                if (domain.getClusterNamed(target) != null || domain.getDeploymentGroupNamed(target) != null) {
                    // prefer cluster target
                    break;
                }
            }
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "EjbDeployer using target for event as " + target);
        }
        boolean isTimedApp = false;
        for (EjbBundleDescriptorImpl ejbBundle : app.getBundleDescriptors(EjbBundleDescriptorImpl.class)) {
            if (checkEjbBundleForTimers(ejbBundle, createTimers, target)) {
                isTimedApp = true;
            }
        }
        if (isTimedApp && (opsparams.origin.isDeploy() || opsparams.origin.isLoad())) {
            // Mark application as a timeout application, so that the clean() call removes the timers.
            appInfo.addTransientAppMetaData(IS_TIMEOUT_APP_PROP, Boolean.TRUE);
        }
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) OpsParams(org.glassfish.api.deployment.OpsParams) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) List(java.util.List) ArrayList(java.util.ArrayList) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) Application(com.sun.enterprise.deployment.Application) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Example 30 with Application

use of com.sun.enterprise.deployment.Application in project Payara by payara.

the class EjbDeployer method prepare.

@Override
public boolean prepare(DeploymentContext dc) {
    EjbBundleDescriptorImpl ejbBundle = dc.getModuleMetaData(EjbBundleDescriptorImpl.class);
    if (ejbBundle == null) {
        String errMsg = localStrings.getLocalString("context.contains.no.ejb", "DeploymentContext does not contain any EJB", dc.getSourceDir());
        throw new RuntimeException(errMsg);
    }
    // Get application-level properties (*not* module-level)
    Properties appProps = dc.getAppProps();
    long uniqueAppId;
    if (!appProps.containsKey(APP_UNIQUE_ID_PROP)) {
        // This is the first time load is being called for any ejb module in an
        // application, so generate the unique id.
        uniqueAppId = getNextEjbAppUniqueId();
        appProps.setProperty(APP_UNIQUE_ID_PROP, uniqueAppId + "");
    } else {
        uniqueAppId = Long.parseLong(appProps.getProperty(APP_UNIQUE_ID_PROP));
    }
    OpsParams params = dc.getCommandParameters(OpsParams.class);
    if (params.origin.isDeploy()) {
        // KEEP_STATE is saved to AppProps in EjbApplication.stop
        String keepStateVal = (String) dc.getAppProps().get(EjbApplication.KEEP_STATE);
        if (keepStateVal != null) {
            // save KEEP_STATE to Application so subsequent to make it available
            // to subsequent deploy-related methods.
            ejbBundle.getApplication().setKeepStateResolved(keepStateVal);
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "EjbDeployer.prepare set keepstate to {0} for application.", ejbBundle.getApplication().getKeepStateResolved());
            }
        }
    }
    Application app = ejbBundle.getApplication();
    if (!app.isUniqueIdSet()) {
        // This will set the unique id for all EJB components in the application.
        // If there are multiple ejb modules in the app, we'll only call it once
        // for the first ejb module load().  All the old
        // .xml processing for unique-id in the sun-* descriptors is removed so
        // this is the only place where Application.setUniqueId() should be called.
        app.setUniqueId(uniqueAppId);
    }
    return super.prepare(dc);
}
Also used : OpsParams(org.glassfish.api.deployment.OpsParams) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) Properties(java.util.Properties) Application(com.sun.enterprise.deployment.Application) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

Application (com.sun.enterprise.deployment.Application)66 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)17 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)10 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 IOException (java.io.IOException)9 File (java.io.File)8 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)8 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)7 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)7 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)5 DeploymentException (org.glassfish.deployment.common.DeploymentException)5 SAXParseException (org.xml.sax.SAXParseException)5 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)4 ArrayList (java.util.ArrayList)4 WebappClassLoader (org.glassfish.web.loader.WebappClassLoader)4 OpsParams (org.glassfish.api.deployment.OpsParams)3 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)3 Applications (com.sun.enterprise.config.serverbeans.Applications)2 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)2