protected InvocationContext getCurrentInvocationContext() { InvocationContext current = CurrentInvocationContext.get(InvocationContext.class); assert current.getEJBContext() == this; return current; }
public Map<String, Object> getContextData() { return CurrentInvocationContext.get().getContextData(); }
public Principal getCallerPrincipal() { // per invocation return getCurrentInvocationContext().getCallerPrincipal(); }
public InjectionInvocation(BeanContext<?> ctx, InjectionManager injectionManager, Interceptor interceptors[]) { super(interceptors); if (ctx == null) { throw new IllegalArgumentException("BeanContext cannot be null while creating InjectionInvocation"); } if (injectionManager == null) { throw new IllegalArgumentException("InjectionManager cannot be null while creating InjectionInvocation"); } this.ctx = ctx; this.injectionManager = injectionManager; invocationContext.setEJBContext(ctx.getEJBContext()); }
public boolean getRollbackOnly() throws IllegalStateException { // to allow override per invocation return getCurrentInvocationContext().getRollbackOnly(); }
public UserTransaction getUserTransaction() throws IllegalStateException { // to allow override per invocation return getCurrentInvocationContext().getUserTransaction(); }
public TimerService getTimerService() throws IllegalStateException { // to allow override per invocation return getCurrentInvocationContext().getTimerService(); }
public boolean isCallerInRole(String roleName) { return getCurrentInvocationContext().isCallerInRole(roleName); }
@Override public Object invokeTarget() throws Throwable { // TODO: Once InjectionManager is fully integrated, // this should be removed. Injection should happen solely via InjectionManager.inject if (invocationContext != null) { invocationContext.proceed(); } // additional null safety check till InjectionManager is completely integrated if (this.injectionManager != null) { this.injectionManager.inject(ctx.getInstance()); } // now inject the interceptor instances this.ctx.initialiseInterceptorInstances(); // injection invocation doesn't have anything to return return null; } }
/** * * @param ctx * @param injectors * @param interceptors * @param injectionManager * * @deprecated Once InjectionManager is completely integrated, this constructor shouldn't be used. * Use {@link #InjectionInvocation(BeanContext, InjectionManager, Interceptor[])} instead. */ @Deprecated public InjectionInvocation(BeanContext<?> ctx, Iterable<Injector> injectors, Interceptor interceptors[], InjectionManager injectionManager) { super(interceptors); assert ctx != null : "ctx is null"; assert injectors != null : "injector is null"; this.ctx = ctx; this.invocationContext = ctx.createInjectionInvocation(injectors); this.injectionManager = injectionManager; invocationContext.setEJBContext(ctx.getEJBContext()); }
public static EJBContext get() { return CurrentInvocationContext.get().getEJBContext(); }
public Map<String, Object> getContextData() { return getCurrentInvocationContext().getContextData(); }
private InvocationContext getInvocationContext(LifecycleMethodInterceptorsInvocation invocation) { BeanContext<?> beanContext = (BeanContext<?>) invocation.getBeanContext(); InvocationContext invocationContext = beanContext.createLifecycleInvocation(); invocationContext.setEJBContext(beanContext.getEJBContext()); return invocationContext; } }
@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(); }