Search in sources :

Example 1 with ApplicationRegistry

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");
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) Applications(com.sun.enterprise.config.serverbeans.Applications) TreeSet(java.util.TreeSet) NamingException(javax.naming.NamingException) Application(com.sun.enterprise.config.serverbeans.Application)

Example 2 with ApplicationRegistry

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.");
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef) ApplicationLoaderService(com.sun.enterprise.v3.server.ApplicationLoaderService)

Example 3 with ApplicationRegistry

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();
        }
    }
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) SecurityContext(com.sun.enterprise.security.SecurityContext) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Subject(javax.security.auth.Subject)

Example 4 with ApplicationRegistry

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());
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) EjbContainerUtil(com.sun.ejb.containers.EjbContainerUtil) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject)

Example 5 with ApplicationRegistry

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;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) Applications(com.sun.enterprise.config.serverbeans.Applications) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Application(com.sun.enterprise.deployment.Application)

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