public Object processInvocation(final InterceptorContext context) throws Exception { ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); if (componentInstance == null) { throw EeLogger.ROOT_LOGGER.noComponentInstance(); } Method oldMethod = context.getMethod(); try { context.setMethod(componentMethod); context.setTarget(componentInstance.getInstance()); return componentInstance.getInterceptor(componentMethod).processInvocation(context); } finally { context.setMethod(oldMethod); context.setTarget(null); } } }
/** {@inheritDoc} */ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { final Interceptor interceptor = interceptors.get(method); if (interceptor == null) { throw new NoSuchMethodError(method.toString()); } final InterceptorContext context = new InterceptorContext(); // special location for original proxy context.putPrivateData(Object.class, proxy); context.putPrivateData(Component.class, componentView.getComponent()); context.putPrivateData(ComponentView.class, componentView); context.putPrivateData(SecurityDomain.class, WildFlySecurityManager.isChecking() ? AccessController.doPrivileged((PrivilegedAction<SecurityDomain>) SecurityDomain::getCurrent) : SecurityDomain.getCurrent()); instance.prepareInterceptorContext(context); context.setParameters(args); context.setMethod(method); // setup the public context data context.setContextData(new HashMap<String, Object>()); context.setBlockingCaller(true); return interceptor.processInvocation(context); } }
@Override public void callTimeout(final TimerImpl timer, final Method timeoutMethod) throws Exception { final Interceptor interceptor; synchronized (this) { if (!started) { //this can happen if an invocation has been triggered as the deployment is shutting down throw EjbLogger.EJB3_TIMER_LOGGER.timerInvocationFailedDueToInvokerNotBeingStarted(); } interceptor = timeoutInterceptors.get(timeoutMethod); } if(interceptor == null) { throw EjbLogger.EJB3_TIMER_LOGGER.failToInvokeTimeout(timeoutMethod); } final InterceptorContext context = new InterceptorContext(); context.setContextData(new HashMap<String, Object>()); context.setMethod(timeoutMethod); if(timeoutMethod.getParameterTypes().length == 0) { context.setParameters(new Object[0]); } else { final Object[] params = new Object[1]; params[0] = timer; context.setParameters(params); } context.setTimer(timer); context.putPrivateData(Component.class, ejbComponent.getValue()); context.putPrivateData(MethodIntf.class, MethodIntf.TIMER); context.putPrivateData(InvocationType.class, InvocationType.TIMER); interceptor.processInvocation(context); }
private void prepareInterceptorContext(final SkeletonStrategy op, final Object[] params, final InterceptorContext interceptorContext) throws IOException, ClassNotFoundException { if (!home) { if (componentView.getComponent() instanceof StatefulSessionComponent) { final SessionID sessionID = (SessionID) unmarshalIdentifier(); interceptorContext.putPrivateData(SessionID.class, sessionID); } } interceptorContext.setContextData(new HashMap<>()); interceptorContext.setParameters(params); interceptorContext.setMethod(op.getMethod()); interceptorContext.putPrivateData(ComponentView.class, componentView); interceptorContext.putPrivateData(Component.class, componentView.getComponent()); interceptorContext.putPrivateData(InvocationType.class, InvocationType.REMOTE); interceptorContext.setTransaction(inboundTxCurrent == null ? null : inboundTxCurrent.getCurrentTransaction()); }
static Object invokeMethod(final ComponentView componentView, final Method method, final InvocationRequest incomingInvocation, final InvocationRequest.Resolved content, final CancellationFlag cancellationFlag, Map<String, Object> contextDataHolder) throws Exception { final InterceptorContext interceptorContext = new InterceptorContext(); interceptorContext.setParameters(content.getParameters()); interceptorContext.setMethod(method); interceptorContext.putPrivateData(Component.class, componentView.getComponent()); interceptorContext.putPrivateData(ComponentView.class, componentView);
private Object execute(final Interceptor interceptor, final Method method, final Object... parameters) { if (interceptor == null) return null; final InterceptorContext interceptorContext = new InterceptorContext(); //we need the method so this does not count as a lifecycle invocation interceptorContext.setMethod(method); interceptorContext.putPrivateData(Component.class, getComponent()); interceptorContext.putPrivateData(ComponentInstance.class, this); interceptorContext.putPrivateData(InvokeMethodOnTargetInterceptor.PARAMETERS_KEY, parameters); interceptorContext.setContextData(new HashMap<String, Object>()); interceptorContext.setTarget(getInstance()); final AbstractTransaction transaction = ContextTransactionManager.getInstance().getTransaction(); interceptorContext.setTransactionSupplier(() -> transaction); try { return interceptor.processInvocation(interceptorContext); } catch (Error e) { throw e; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new EJBException(e); } }
interceptorContext.setMethod(method); interceptorContext.setTransaction(invocation.getTransaction()); interceptorContext.setTarget(invocation.getInvokedProxy());
/** * Handle a proxy method invocation. * * @param proxy the proxy instance * @param method the invoked method * @param args the method arguments * @return the result of the method call * @throws Throwable the exception to thrown from the method invocation on the proxy instance, if any */ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { InterceptorContext context = new InterceptorContext(); context.setParameters(args); context.setMethod(method); return interceptor.processInvocation(context); }
public void reload() { try { final EntityBeanComponent component = getComponent(); final InterceptorContext loadContext = prepareInterceptorContext(); loadContext.putPrivateData(InvocationType.class, InvocationType.ENTITY_EJB_EJB_LOAD); loadContext.setMethod(component.getEjbLoadMethod()); ejbLoad.processInvocation(loadContext); reloadRequired = false; } catch (Exception e) { throw new RuntimeException(e); } }
/** {@inheritDoc} */ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { final Interceptor interceptor = interceptors.get(method); if (interceptor == null) { throw new NoSuchMethodError(method.toString()); } final InterceptorContext context = new InterceptorContext(); // special location for original proxy context.putPrivateData(Object.class, proxy); context.putPrivateData(Component.class, component); context.putPrivateData(ComponentView.class, componentView); context.setParameters(args); context.setMethod(method); // setup the public context data context.setContextData(new HashMap()); return interceptor.processInvocation(context); } }
protected Object invokeFind(final InterceptorContext context, final EntityBeanComponentInstance instance) throws Exception { Method oldMethod = context.getMethod(); try { context.putPrivateData(ComponentInstance.class, instance); context.setMethod(finderMethod); context.setTarget(instance.getInstance()); return instance.getInterceptor(finderMethod).processInvocation(context); } finally { context.setMethod(oldMethod); context.setTarget(null); context.putPrivateData(ComponentInstance.class, null); } }
protected void invokeEjbStore() throws Exception { final InterceptorContext context = prepareInterceptorContext(); final EntityBeanComponent component = getComponent(); context.setMethod(component.getEjbStoreMethod()); ejbStore.processInvocation(context); }
public Object processInvocation(final InterceptorContext context) throws Exception { ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); if (componentInstance == null) { throw EeLogger.ROOT_LOGGER.noComponentInstance(); } Method oldMethod = context.getMethod(); try { context.setMethod(componentMethod); context.setTarget(componentInstance.getInstance()); return componentInstance.getInterceptor(componentMethod).processInvocation(context); } finally { context.setMethod(oldMethod); context.setTarget(null); } } }
public Object processInvocation(final InterceptorContext context) throws Exception { ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); if (componentInstance == null) { throw MESSAGES.noComponentInstance(); } Method oldMethod = context.getMethod(); try { context.setMethod(componentMethod); context.setTarget(componentInstance.getInstance()); return componentInstance.getInterceptor(componentMethod).processInvocation(context); } finally { context.setMethod(oldMethod); context.setTarget(null); } } }
public Object processInvocation(final InterceptorContext context) throws Exception { ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); if (componentInstance == null) { throw EeLogger.ROOT_LOGGER.noComponentInstance(); } Method oldMethod = context.getMethod(); try { context.setMethod(componentMethod); context.setTarget(componentInstance.getInstance()); return componentInstance.getInterceptor(componentMethod).processInvocation(context); } finally { context.setMethod(oldMethod); context.setTarget(null); } } }
protected void invokeUnsetEntityContext() throws Exception { final InterceptorContext context = prepareInterceptorContext(); final EntityBeanComponent component = getComponent(); context.setMethod(component.getUnsetEntityContextMethod()); context.putPrivateData(InvocationType.class, InvocationType.UNSET_ENTITY_CONTEXT); unsetEntityContext.processInvocation(context); }
/** {@inheritDoc} */ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { final Interceptor interceptor = interceptors.get(method); if (interceptor == null) { throw new NoSuchMethodError(method.toString()); } final InterceptorContext context = new InterceptorContext(); // special location for original proxy context.putPrivateData(Object.class, proxy); context.putPrivateData(Component.class, componentView.getComponent()); context.putPrivateData(ComponentView.class, componentView); context.putPrivateData(SecurityDomain.class, WildFlySecurityManager.isChecking() ? AccessController.doPrivileged((PrivilegedAction<SecurityDomain>) SecurityDomain::getCurrent) : SecurityDomain.getCurrent()); instance.prepareInterceptorContext(context); context.setParameters(args); context.setMethod(method); // setup the public context data context.setContextData(new HashMap<String, Object>()); context.setBlockingCaller(true); return interceptor.processInvocation(context); } }
private Object execute(final Interceptor interceptor, final Method method, final Object... parameters) { if (interceptor == null) return null; final InterceptorContext interceptorContext = new InterceptorContext(); //we need the method so this does not count as a lifecycle invocation interceptorContext.setMethod(method); interceptorContext.putPrivateData(Component.class, getComponent()); interceptorContext.putPrivateData(ComponentInstance.class, this); interceptorContext.putPrivateData(InvokeMethodOnTargetInterceptor.PARAMETERS_KEY, parameters); interceptorContext.setContextData(new HashMap<String, Object>()); interceptorContext.setTarget(getInstance()); try { return interceptor.processInvocation(interceptorContext); } catch (Error e) { throw e; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new EJBException(e); } }
private void prepareInterceptorContext(final SkeletonStrategy op, final Object[] params, final InterceptorContext interceptorContext) throws IOException, ClassNotFoundException { if (!home) { if (componentView.getComponent() instanceof StatefulSessionComponent) { final SessionID sessionID = (SessionID) unmarshalIdentifier(); interceptorContext.putPrivateData(SessionID.class, sessionID); } else if (componentView.getComponent() instanceof EntityBeanComponent) { final Object pk = unmarshalIdentifier(); interceptorContext.putPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, pk); } } interceptorContext.setContextData(new HashMap<String, Object>()); interceptorContext.setParameters(params); interceptorContext.setMethod(op.getMethod()); interceptorContext.putPrivateData(ComponentView.class, componentView); interceptorContext.putPrivateData(Component.class, componentView.getComponent()); }