Search in sources :

Example 6 with ApplicationRegistry

use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.

the class AppServRegistry method getWebModule.

/*
     * This function is called once for every endpoint registration.
     * and the WebModule corresponding to that endpoint is stored.
     */
static WebModule getWebModule(WebServiceEndpoint wsep) {
    ApplicationRegistry appRegistry = org.glassfish.internal.api.Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
    String appName = wsep.getBundleDescriptor().getApplication().getAppName();
    ApplicationInfo appInfo = appRegistry.get(appName);
    WebApplication webApp = null;
    if (appInfo != null) {
        Collection<ModuleInfo> moduleInfos = appInfo.getModuleInfos();
        Set<EngineRef> engineRefs = null;
        WebBundleDescriptor requiredWbd = (WebBundleDescriptor) wsep.getBundleDescriptor();
        for (ModuleInfo moduleInfo : moduleInfos) {
            engineRefs = moduleInfo.getEngineRefs();
            for (EngineRef engineRef : engineRefs) {
                if (engineRef.getApplicationContainer() instanceof WebApplication) {
                    webApp = (WebApplication) engineRef.getApplicationContainer();
                    WebBundleDescriptor wbd = webApp.getDescriptor();
                    if (wbd.equals(requiredWbd)) {
                        // WebApp corresponding to wsep is found.
                        break;
                    } else {
                        webApp = null;
                    }
                }
            }
        }
    }
    // get the required WebModule from the webApp.
    if (webApp != null) {
        String requiredModule = ((WebBundleDescriptor) wsep.getBundleDescriptor()).getModuleName();
        Set<WebModule> webModules = webApp.getWebModules();
        for (WebModule wm : webModules) {
            if (wm.getModuleName().equalsIgnoreCase(requiredModule)) {
                return wm;
            }
        }
    }
    return null;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ModuleInfo(org.glassfish.internal.data.ModuleInfo) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WebModule(com.sun.enterprise.web.WebModule) WebApplication(com.sun.enterprise.web.WebApplication) EngineRef(org.glassfish.internal.data.EngineRef)

Example 7 with ApplicationRegistry

use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.

the class ASClassLoaderUtil method addDeployParamLibrariesForModule.

private static void addDeployParamLibrariesForModule(StringBuilder sb, String moduleId, String deploymentLibs, ServiceLocator habitat) {
    if (moduleId.indexOf("#") != -1) {
        moduleId = moduleId.substring(0, moduleId.indexOf("#"));
    }
    if (deploymentLibs == null) {
        ApplicationInfo appInfo = habitat.<ApplicationRegistry>getService(ApplicationRegistry.class).get(moduleId);
        if (appInfo == null) {
            // like _default_web_app, ignore.
            return;
        }
        deploymentLibs = appInfo.getLibraries();
    }
    final URL[] libs = getDeployParamLibrariesAsURLs(deploymentLibs, habitat);
    if (libs != null) {
        for (final URL u : libs) {
            sb.append(u.getPath());
            sb.append(File.pathSeparator);
        }
    }
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) URL(java.net.URL)

Example 8 with ApplicationRegistry

use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.

the class RegistrationSupport method processApplicationRef.

/**
 *        Examine the MBean to see if it is a ResourceRef that should be manifested under this server,
 *        and if so, register a JSR 77 MBean for it.
 */
public ObjectName processApplicationRef(final ApplicationRef ref) {
    // find all applications
    final ApplicationRegistry appRegistry = J2EEInjectedValues.getInstance().getApplicationRegistry();
    final MetadataImpl meta = new MetadataImpl();
    meta.setCorrespondingRef(getObjectName(ref));
    final String appName = ref.getRef();
    final ApplicationInfo appInfo = appRegistry.get(appName);
    if (appInfo == null) {
        mLogger.fine("Unable to get ApplicationInfo for application: " + appName);
        return null;
    }
    final Application app = appInfo.getMetaData(Application.class);
    if (app == null) {
        if (appInfo.isJavaEEApp()) {
            mLogger.log(Level.WARNING, AMXEELoggerInfo.nullAppinfo, appName);
        }
        return null;
    }
    final com.sun.enterprise.config.serverbeans.Application appConfig = getDomain().getApplications().getApplication(appName);
    if (appConfig == null) {
        mLogger.log(Level.WARNING, AMXEELoggerInfo.errorGetappconfig, appName);
        return null;
    }
    meta.setCorrespondingConfig(getObjectName(appConfig));
    final ObjectName mbean77 = createAppMBeans(appConfig, app, meta);
    synchronized (mConfigRefTo77) {
        mConfigRefTo77.put(getObjectName(ref), mbean77);
    }
    return mbean77;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo)

Example 9 with ApplicationRegistry

use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.

the class RoleMapper method getAppDefaultRoleMapping.

private boolean getAppDefaultRoleMapping() {
    if (appDefaultMapping != null) {
        return appDefaultMapping;
    }
    appDefaultMapping = false;
    if (secService != null) {
        appDefaultMapping = Boolean.parseBoolean(secService.getActivateDefaultPrincipalToRoleMapping());
        if (appDefaultMapping) {
            // if set explicitly in the security service allow default mapping
            return appDefaultMapping;
        }
    }
    ApplicationRegistry appRegistry = Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
    ApplicationInfo appInfo = appRegistry.get(appName);
    if (appInfo == null) {
        return appDefaultMapping;
    }
    Application app = appInfo.getMetaData(Application.class);
    BundleDescriptor bd = app.getModuleByUri(appName);
    appDefaultMapping = bd == null ? app.isDefaultGroupPrincipalMapping() : app.getModuleByUri(appName).isDefaultGroupPrincipalMapping();
    return appDefaultMapping;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.deployment.Application)

Example 10 with ApplicationRegistry

use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.

the class EjbApplication method stop.

public boolean stop(ApplicationContext stopContext) {
    DeploymentContext depc = (DeploymentContext) stopContext;
    OpsParams params = depc.getCommandParameters(OpsParams.class);
    boolean keepState = false;
    // keepstate remains the default value (false).
    if (params.origin.isUndeploy()) {
        keepState = resolveKeepStateOptions(depc, false, ejbBundle);
        if (keepState) {
            Properties appProps = depc.getAppProps();
            Object appId = appProps.get(EjbDeployer.APP_UNIQUE_ID_PROP);
            Properties actionReportProps = null;
            if (ejbBundle.getApplication().isVirtual()) {
                actionReportProps = depc.getActionReport().getExtraProperties();
            } else {
                // the application is EAR
                ExtendedDeploymentContext exdc = (ExtendedDeploymentContext) depc;
                actionReportProps = exdc.getParentContext().getActionReport().getExtraProperties();
            }
            actionReportProps.put(EjbDeployer.APP_UNIQUE_ID_PROP, appId);
            actionReportProps.put(EjbApplication.KEEP_STATE, String.valueOf(true));
            _logger.log(Level.INFO, "keepstate options resolved to true, saving appId {0} for application {1}.", new Object[] { appId, params.name() });
        }
    }
    // If true we're shutting down b/c of an undeploy or a fatal error during
    // deployment.  If false, it's a shutdown where the application will remain
    // deployed.
    boolean undeploy = (params.origin.isUndeploy() || params.origin.isDeploy());
    // and Application.  For failed deploy, keepstate is the default value (false).
    if (undeploy) {
        // store keepstate in ApplicationInfo to make it available to
        // EjbDeployer.clean().  A different instance of DeploymentContext
        // is passed to EjbDeployer.clean so we cannot use anything in DC (e.g.
        // appProps, transientData) to store keepstate.
        ApplicationRegistry appRegistry = services.getService(ApplicationRegistry.class);
        ApplicationInfo appInfo = appRegistry.get(params.name());
        appInfo.addTransientAppMetaData(KEEP_STATE, keepState);
        // store keepState in Application to make it available to subsequent
        // undeploy-related methods.
        ejbBundle.getApplication().setKeepStateResolved(String.valueOf(keepState));
    }
    // First, shutdown any singletons that were initialized based
    // on a particular ordering dependency.
    // TODO Make sure this covers both eagerly and lazily initialized
    // Singletons.
    singletonLCM.doShutdown();
    for (Container container : containers) {
        if (undeploy) {
            container.undeploy();
        } else {
            container.onShutdown();
        }
        if (container.getSecurityManager() != null) {
            container.getSecurityManager().destroy();
        }
    }
    containers.clear();
    return true;
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) Container(com.sun.ejb.Container) AbstractSingletonContainer(com.sun.ejb.containers.AbstractSingletonContainer) ApplicationContainer(org.glassfish.api.deployment.ApplicationContainer) OpsParams(org.glassfish.api.deployment.OpsParams) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Properties(java.util.Properties) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext)

Aggregations

ApplicationRegistry (org.glassfish.internal.data.ApplicationRegistry)13 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)12 Application (com.sun.enterprise.config.serverbeans.Application)2 Applications (com.sun.enterprise.config.serverbeans.Applications)2 Application (com.sun.enterprise.deployment.Application)2 ApplicationLoaderService (com.sun.enterprise.v3.server.ApplicationLoaderService)2 WebModule (com.sun.enterprise.web.WebModule)2 URL (java.net.URL)2 TreeSet (java.util.TreeSet)2 Container (com.sun.ejb.Container)1 AbstractSingletonContainer (com.sun.ejb.containers.AbstractSingletonContainer)1 EjbContainerUtil (com.sun.ejb.containers.EjbContainerUtil)1 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)1 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 SecurityContext (com.sun.enterprise.security.SecurityContext)1 WebApplication (com.sun.enterprise.web.WebApplication)1 WSBinding (com.sun.xml.ws.api.WSBinding)1 InstanceResolver (com.sun.xml.ws.api.server.InstanceResolver)1 Invoker (com.sun.xml.ws.api.server.Invoker)1