for (final Injection injection : context.getInjections()) {
if (QueryProxy.class.equals(injection.getTarget())) {
try {
em = (EntityManager) context.getJndiEnc().lookup(injection.getJndiName());
} catch (final NamingException e) {
throw new OpenEJBRuntimeException("a dynamic bean should reference at least one correct PersistenceContext", e);
}
}
}
if (em == null) {
throw new OpenEJBRuntimeException("can't find the entity manager to use for the dynamic bean " + context.getEjbName());
}
QueryProxy.class.cast(invocationHandler).setEntityManager(em);
}
try {
return ProxyManager.newProxyInstance(context.getBeanClass(), new Handler(invocationHandler));
} catch (final IllegalAccessException e) {
throw new OpenEJBRuntimeException("illegal access", e);
}
}