public static EJBContext get() { return CurrentInvocationContext.get().getEJBContext(); }
protected InvocationContext getCurrentInvocationContext() { InvocationContext current = CurrentInvocationContext.get(InvocationContext.class); assert current.getEJBContext() == this; return current; }
@Override public EnterpriseBeanEffigy getEffigy() { // you've got to love the compiler InvocationContext ctx = ((org.jboss.ejb3.core.context.EJBInvocation) this).getInvocationContext(); return ((EJBContainer) ctx.getEJBContext().getManager()).getEffigy(); }
/** * Returns {@link TimerService} for the current {@link EJBContext} */ @Override public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { // get hold of EJBContext EJBContext currentEJBContext = CurrentInvocationContext.get().getEJBContext(); // now get hold of the BeanManager from the EJBContext. // Note that we could have directly used EJBContext.getTimerService(), but that // won't work in all cases, because the EJBContext.getTimerService() is an user API // and the spec mandates that this API throw an exception when invoked during injection. // Internal implementation (like injectors) of EJB3 will require to get hold of the // TimerService during injection (to actually do the injection). Hence we bypass the user // API and instead use the BeanManager.getTimerService() which doesn't have a restriction // on using it during injection. BeanManager beanManager = currentEJBContext.getManager(); // now finally get hold of the timerservice return beanManager.getTimerService(); }