Search in sources :

Example 1 with ApplicationEnvironment

use of org.glassfish.api.invocation.ApplicationEnvironment in project Payara by payara.

the class JavaModuleNamingProxy method getAppName.

private String getAppName() throws NamingException {
    ComponentEnvManager namingMgr = habitat.getService(ComponentEnvManager.class);
    String appName = null;
    if (namingMgr != null) {
        JndiNameEnvironment env = namingMgr.getCurrentJndiNameEnvironment();
        BundleDescriptor bd = null;
        if (env instanceof EjbDescriptor) {
            bd = ((EjbDescriptor) env).getEjbBundleDescriptor();
        } else if (env instanceof BundleDescriptor) {
            bd = (BundleDescriptor) env;
        }
        if (bd != null) {
            Application app = bd.getApplication();
            appName = app.getAppName();
        } else {
            ApplicationEnvironment applicationEnvironment = namingMgr.getCurrentApplicationEnvironment();
            if (applicationEnvironment != null) {
                appName = applicationEnvironment.getName();
            }
        }
    }
    if (appName == null) {
        throw new NamingException("Could not resolve " + JAVA_APP_NAME);
    }
    return appName;
}
Also used : ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) NamingException(javax.naming.NamingException) ApplicationEnvironment(org.glassfish.api.invocation.ApplicationEnvironment)

Aggregations

ComponentEnvManager (com.sun.enterprise.container.common.spi.util.ComponentEnvManager)1 NamingException (javax.naming.NamingException)1 ApplicationEnvironment (org.glassfish.api.invocation.ApplicationEnvironment)1