loginContext = ContextManager.login(realmName, callbackHandler);
clientSubject = loginContext.getSubject();
}
ContextManager.setCallers(clientSubject, clientSubject);
Class mainClass = classLoader.loadClass(mainClassName);
ObjectRecipe objectRecipe = new ObjectRecipe(mainClass);
objectRecipe.allow(Option.FIELD_INJECTION);
objectRecipe.allow(Option.PRIVATE_PROPERTIES);
objectRecipe.allow(Option.STATIC_PROPERTIES);
List<Injection> injections = new ArrayList<Injection>();
while (mainClass != null && mainClass != Object.class) {
List<Injection> perClass = holder.getInjections(mainClass.getName());
if (perClass != null) {
injections.addAll(perClass);
}
mainClass = mainClass.getSuperclass();
}
if (injections != null) {
List<NamingException> problems = new ArrayList<NamingException>();
for (Injection injection : injections) {
try {
String jndiName = injection.getJndiName();
//our componentContext is attached to jndi at "java:comp" so we remove that when looking stuff up in it
Object object = componentContext.lookup("env/" + jndiName);
if (object instanceof String) {
String string = (String) object;
// Pass it in raw so it could be potentially converted to
// another data type by an xbean-reflect property editor
objectRecipe.setProperty(injection.getTargetName(), string);
} else {
objectRecipe.setProperty(injection.getTargetName(), new StaticRecipe(object));
}
} catch (NamingException e) {
problems.add(e);
}
}
if (!problems.isEmpty()) {
throw new Exception("Some objects to be injected were not found in jndi: " + problems);
}
}
Class clazz = objectRecipe.setStaticProperties();
if (holder.getPostConstruct() != null) {
Holder.apply(null, clazz, holder.getPostConstruct());
}
if (clientSubject == null) {