use of org.glassfish.internal.data.ApplicationRegistry in project jersey by jersey.
the class EjbComponentProvider method getApplicationInfo.
private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingException {
ApplicationRegistry appRegistry = ejbUtil.getServices().getService(ApplicationRegistry.class);
Applications applications = ejbUtil.getServices().getService(Applications.class);
String appNamePrefix = (String) initialContext.lookup("java:app/AppName");
Set<String> appNames = appRegistry.getAllApplicationNames();
Set<String> disabledApps = new TreeSet<>();
for (String appName : appNames) {
if (appName.startsWith(appNamePrefix)) {
Application appDesc = applications.getApplication(appName);
if (appDesc != null && !ejbUtil.getDeployment().isAppEnabled(appDesc)) {
// skip disabled version of the app
disabledApps.add(appName);
} else {
return ejbUtil.getDeployment().get(appName);
}
}
}
// grab the latest one, there is no way to make
// sure which one the user is actually enabling,
// so use the best case, i.e. upgrade
Iterator<String> it = disabledApps.iterator();
String lastDisabledApp = null;
while (it.hasNext()) {
lastDisabledApp = it.next();
}
if (lastDisabledApp != null) {
return ejbUtil.getDeployment().get(lastDisabledApp);
}
throw new NamingException("Application Information Not Found");
}
use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.
the class RestMonitoringLoader method loadApplication.
/**
* Loads the application
*/
private void loadApplication() {
ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
ApplicationInfo appInfo = appRegistry.get(applicationName);
if (appInfo != null && appInfo.isLoaded()) {
LOGGER.log(Level.FINE, "Rest Monitoring Application already loaded.");
return;
}
Application config = null;
if (dynamicStart) {
config = restMonitoringAdapter.getSystemApplicationConfig(contextRoot);
} else {
config = restMonitoringAdapter.getSystemApplicationConfig();
}
if (config == null) {
throw new IllegalStateException("The Rest Monitoring application has no system app entry!");
}
// Load the Rest Monitoring Application
String instanceName = serverEnv.getInstanceName();
ApplicationRef ref = domain.getApplicationRefInServer(instanceName, applicationName);
habitat.getService(ApplicationLoaderService.class).processApplication(config, ref);
// Mark as registered
restMonitoringAdapter.setAppRegistered(true);
LOGGER.log(Level.FINE, "Rest Monitoring Application Loaded.");
}
use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.
the class InvocationContext method readObject.
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
useTransactionOfExecutionThread = in.readBoolean();
// reconstruct invocation
String componentId = (String) in.readObject();
String appName = (String) in.readObject();
String moduleName = (String) in.readObject();
invocation = createComponentInvocation(componentId, appName, moduleName);
// reconstruct securityContext
String principalName = (String) in.readObject();
boolean defaultSecurityContext = in.readBoolean();
Subject subject = (Subject) in.readObject();
if (principalName != null) {
if (defaultSecurityContext) {
securityContext = SecurityContext.getDefaultSecurityContext();
} else {
securityContext = new SecurityContext(principalName, subject, null);
}
}
// reconstruct contextClassLoader
ApplicationRegistry applicationRegistry = ConcurrentRuntime.getRuntime().getApplicationRegistry();
if (appName != null) {
ApplicationInfo applicationInfo = applicationRegistry.get(appName);
if (applicationInfo != null) {
contextClassLoader = applicationInfo.getAppClassLoader();
}
}
}
use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.
the class SunContainerHelper method getContainer.
/**
* Get a Container helper instance that will be passed unchanged to the
* required methods.
* This is SunContainerHelper specific code.
*
* The info argument is an Object array that consistes of a class to use
* for the class loader and concreteImpl bean class name.
* @see getEJBObject(Object, Object)
* @see getEJBLocalObject(Object, Object)
* @see getEJBLocalObject(Object, Object, EJBObject)
* @see removeByEJBLocalObject(EJBLocalObject, Object)
* @see removeByPK(Object, Object)
* @param info Object with the request information that is application server
* specific.
* @return a Container helper instance as an Object.
*/
public Object getContainer(Object info) {
Object[] params = (Object[]) info;
String appName = (String) params[0];
ServiceLocator habitat = Globals.getDefaultHabitat();
ApplicationRegistry reg = habitat.getService(ApplicationRegistry.class);
ApplicationInfo appInfo = reg.get(appName);
Application app = appInfo.getMetaData(Application.class);
EjbDescriptor desc = app.getEjbByName((String) params[1]);
return habitat.<EjbContainerUtil>getService(EjbContainerUtil.class).getContainer(desc.getUniqueId());
}
use of org.glassfish.internal.data.ApplicationRegistry in project Payara by payara.
the class DOLUtils method isRAConnectionFactory.
/**
* Returns true if there is a resource connection definition of the type with the application
* @param habitat
* @param type
* @param thisApp
* @return
*/
public static boolean isRAConnectionFactory(ServiceLocator habitat, String type, Application thisApp) {
// adapter in this application
if (isRAConnectionFactory(type, thisApp)) {
return true;
}
// then check if this is a connection factory defined in a standalone
// resource adapter
Applications applications = habitat.getService(Applications.class);
if (applications != null) {
List<com.sun.enterprise.config.serverbeans.Application> raApps = applications.getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true);
ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class);
for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) {
ApplicationInfo appInfo = appRegistry.get(raApp.getName());
if (appInfo == null)
continue;
if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) {
return true;
}
}
}
return false;
}
Aggregations