public void inject(BeanContext ctx, Object instance) { try { field.set(instance, ctx.getEJBContext()); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
/** * * @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()); }
private InvocationContext getInvocationContext(LifecycleMethodInterceptorsInvocation invocation) { BeanContext<?> beanContext = (BeanContext<?>) invocation.getBeanContext(); InvocationContext invocationContext = beanContext.createLifecycleInvocation(); invocationContext.setEJBContext(beanContext.getEJBContext()); return invocationContext; } }
public Object getTarget() { return beanContext.getInstance(); }
public void inject(BeanContext ctx, Object instance) { property.set(instance, ctx.getEJBContext()); }
@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; } }
protected EJBContextImpl(B beanContext) { assert beanContext != null : "beanContext is null"; this.beanContext = beanContext; this.container = beanContext.getContainer(); this.rm = container.getSecurityManager(RealmMapping.class); this.ejbContextHelper = new EJBContextHelper(); }
public Object invoke(Invocation invocation) throws Throwable { EJBContainerInvocation inv = (EJBContainerInvocation) invocation; //We need to do this every time to make sure we have interceptor instances corresponding //to the bean instance //TODO Cache this for non-stateful beans? Object[] interceptors = inv.getBeanContext().getInterceptorInstances(interceptorInfos); if (interceptors != null && interceptors.length == 0 && beanAroundInvokes != null && beanAroundInvokes.length == 0) return invocation.invokeNext(); InvocationContextImpl ctx = new InvocationContextImpl(inv, interceptorInfos, interceptors, beanAroundInvokes); return ctx.proceed(); }
public void inject(BeanContext ctx) { Object instance = ctx.getInstance(); inject(instance); }
public void inject(BeanContext ctx, Object instance) { Object[] args = {ctx.getEJBContext()}; try { setMethod.invoke(instance, args); } catch (IllegalAccessException e) { throw new RuntimeException(e); //To change body of catch statement use Options | File Templates. } catch (IllegalArgumentException e) { throw new RuntimeException("Failed in setting EntityManager on setter method: " + setMethod.toString()); } catch (InvocationTargetException e) { throw new RuntimeException(e.getCause()); //To change body of catch statement use Options | File Templates. } }
return beanContext.getContainer().getEjbName();
/** * EJB3 spec states that if a session bean implements the {@link SessionBean} interface then the * container should invoke {@link SessionBean#setSessionContext(javax.ejb.SessionContext)} to associate * a session context with the bean instance. The container calls this {@link #invokeSetSessionContext(BeanContext)} * method when a new {@link BeanContext} is created (typically via {@link #createBeanContext()}). * * @param beanCtx The {@link BeanContext} * @throws EJBException * @throws RemoteException */ protected void invokeSetSessionContext(BeanContext beanCtx) throws EJBException, RemoteException { Object beanInstance = beanCtx.getInstance(); if (beanInstance instanceof SessionBean) { ((SessionBean) beanInstance).setSessionContext((javax.ejb.SessionContext) beanCtx.getEJBContext()); } }
public void inject(BeanContext ctx) { inject(ctx, ctx.getInstance()); }
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()); }
return beanContext.getContainer().getEjbName();
/** * EJB3 spec states that if a message driven bean implements the {@link MessageDrivenBean} interface then the * container should invoke {@link MessageDrivenBean#setMessageDrivenContext(javax.ejb.MessageDrivenContext)} * to associate the {@link MessageDrivenContext} context with the bean instance. * The container calls this {@link #invokeSetMessageDrivenContext(BeanContext)} * method when a new {@link BeanContext} is created (typically via {@link #createBeanContext()}) * * @param beanCtx The {@link BeanContext} * @throws EJBException * @throws RemoteException */ protected void invokeSetMessageDrivenContext(BeanContext beanCtx) throws EJBException, RemoteException { Object beanInstance = beanCtx.getInstance(); if (beanInstance instanceof MessageDrivenBean) { ((MessageDrivenBean) beanInstance).setMessageDrivenContext((MessageDrivenContext) beanCtx.getEJBContext()); } } }
public void inject(BeanContext bctx) { inject(bctx, bctx.getInstance()); }
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { Reference ref = (Reference) obj; String containerGuid = (String) ref.get("containerGuid").getContent(); boolean isClustered = Boolean.getBoolean((String)ref.get("isClustered").getContent()); EJBContainer container = (EJBContainer)Ejb3Registry.getContainer(containerGuid); if (container == null && isClustered) { String containerClusterUid = (String) ref.get("containerClusterUid").getContent(); container = (EJBContainer)Ejb3Registry.getClusterContainer(containerClusterUid); } return container.peekContext().getEJBContext(); } }
public void attached(BeanContext beanCtx) { // JAX-RPC MessageContext StatelessBeanContext sbc = (StatelessBeanContext)beanCtx; sbc.setMessageContextJAXRPC(jaxrpcMessageContext); // JAX-WS MessageContext BeanProperty beanProp = sbc.getWebServiceContextProperty(); if (beanProp != null) { EJBContext ejbCtx = beanCtx.getEJBContext(); jaxwsContext.addAttachment(EJBContext.class, ejbCtx); beanProp.set(beanCtx.getInstance(), jaxwsContext); } }
public void inject(BeanContext ctx) { inject(ctx.getInstance()); }