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;
}
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);
}
}
}
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;
}
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;
}
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;
}
Aggregations