}
return obj;
} catch (NamingException ex) {
ServiceLocator services = Globals.getDefaultHabitat();
ProcessEnvironment processEnv = services.getService(ProcessEnvironment.class);
if( fullName.startsWith("java:app/") &&
processEnv.getProcessType() == ProcessType.ACC ) {
// This could either be an attempt by an app client to access a portable
// remote session bean JNDI name via the java:app namespace or a lookup of
// an application-defined java:app environment dependency. Try them in
// that order.
Context ic = namingManager.getInitialContext();
String appName = (String) namingManager.getInitialContext().lookup("java:app/AppName");
Object obj = null;
if( !fullName.startsWith("java:app/env/")) {
try {
// Translate the java:app name into the equivalent java:global name so that
// the lookup will be resolved by the server.
String newPrefix = "java:global/" + appName + "/";
int javaAppLength = "java:app/".length();
String globalLookup = newPrefix + fullName.substring(javaAppLength);
obj = ic.lookup(globalLookup);
} catch(NamingException javaappenvne) {
logger.log(Level.FINE, "Trying global version of java:app ejb lookup", javaappenvne);
}
}
if( obj == null ) {
ComponentNamingUtil compNamingUtil = services.getService(ComponentNamingUtil.class);
String internalGlobalJavaAppName =
compNamingUtil.composeInternalGlobalJavaAppName(appName, fullName);
obj = ic.lookup(internalGlobalJavaAppName);
}