Examples of InterceptorContext


Examples of org.jboss.invocation.InterceptorContext

    /**
     * Checks that the current method
     */
    public static void checkAllowed(final MethodType methodType) {

        final InterceptorContext context = CurrentInvocationContext.get();
        if (context == null) {
            return;
        }

        final Component component = context.getPrivateData(Component.class);
        if (!(component instanceof EJBComponent)) {
            return;
        }
        final InvocationType invocationType = context.getPrivateData(InvocationType.class);

        ((EJBComponent) component).getAllowedMethodsInformation().realCheckPermission(methodType, invocationType);

    }
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

            }
            final Interceptor preDestroyInterceptor = viewPreDestroy.create(factoryContext);

            final ComponentViewInstance instance = new ViewInstance(viewEntryPoints, preDestroyInterceptor);
            try {
                InterceptorContext context = new InterceptorContext();
                context.putPrivateData(ComponentView.class, this);
                context.putPrivateData(Component.class, component);
                postConstructInterceptor.processInvocation(context);
            } catch (Exception e) {
                // TODO: What is the best exception type to throw here?
                throw new RuntimeException("Failed to instantiate component view", e);
            }
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

                    clientEntryPoints.put(method, clientInterceptorFactories.get(method).create(factoryContext));
                }
                final Interceptor postConstructInterceptor = clientPostConstruct.create(factoryContext);
                try {
                    Object object = proxyFactory.newInstance(new ProxyInvocationHandler(clientEntryPoints, component, View.this, this));
                    InterceptorContext interceptorContext = new InterceptorContext();
                    interceptorContext.putPrivateData(ComponentView.class, View.this);
                    interceptorContext.putPrivateData(ComponentViewInstance.class, this);
                    interceptorContext.putPrivateData(Component.class, component);
                    try {
                        postConstructInterceptor.processInvocation(interceptorContext);
                    } catch (Exception e) {
                        InstantiationException exception = new InstantiationException("Post-construct lifecycle failed");
                        exception.initCause(e);
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

                return false;
            }

            public void destroy() {
                try {
                    InterceptorContext interceptorContext = new InterceptorContext();
                    interceptorContext.putPrivateData(ComponentView.class, View.this);
                    interceptorContext.putPrivateData(ComponentViewInstance.class, this);
                    interceptorContext.putPrivateData(Component.class, component);
                    preDestroyInterceptor.processInvocation(interceptorContext);
                } catch (Exception e) {
                    logger.warn("Exception while invoking pre-destroy interceptor for component class: " + this.getComponent().getComponentClass(), e);
                }
            }
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

        final SessionBeanComponent component = (SessionBeanComponent) context.getContextData().get(Component.class);

        return new Interceptor() {
            @Override
            public Object processInvocation(final InterceptorContext context) throws Exception {
                final InterceptorContext asyncInterceptorContext = context.clone();
                final CancellationFlag flag = new CancellationFlag();
                final AsyncInvocationTask task = new AsyncInvocationTask( flag) {

                    @Override
                    protected Object runInvocation() throws Exception {
                        return asyncInterceptorContext.proceed();
                    }
                };
                asyncInterceptorContext.putPrivateData(CancellationFlag.class, flag);
                component.getAsynchronousExecutor().execute(task);
                return task;
            }
        };
    }
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

    protected void assertTimerState() {
        if (timerState == TimerState.EXPIRED)
            throw MESSAGES.timerHasExpired();
        if (timerState == TimerState.CANCELED)
            throw MESSAGES.timerWasCanceled();
        final InterceptorContext ctx = CurrentInvocationContext.get();
        if(ctx != null) {
            if(ctx.getPrivateData(Component.class) instanceof StatefulSessionComponent) {
                if(ctx.getMethod() == null) {
                    throw new IllegalStateException("Timer methods may not be invoked from lifecycle methods of a stateful session bean");
                }
            }
        }
    }
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

     * </p>
     *
     * @return
     */
    protected boolean isLifecycleCallbackInvocation() {
        final InterceptorContext currentInvocationContext = CurrentInvocationContext.get();
        if(currentInvocationContext == null) {
            return false;
        }
        // If the method in current invocation context is null,
        // then it represents a lifecycle callback invocation
        Method invokedMethod = currentInvocationContext.getMethod();
        if (invokedMethod == null) {
            // it's a lifecycle callback
            return true;
        }
        // not an lifecycle callback
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

    }

    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>());
        try {
            return interceptor.processInvocation(interceptorContext);
        } catch (Error e) {
            throw e;
        } catch (RuntimeException e) {
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

        final Interceptor interceptor = timeoutInterceptors.get(method);
        if (interceptor == null) {
            throw MESSAGES.failToCallTimeOutMethod(method);
        }
        try {
            InterceptorContext context = prepareInterceptorContext();
            context.putPrivateData(MethodIntf.class, MethodIntf.TIMER);
            context.setMethod(method);
            context.setTimer(timer);
            context.setTarget(getInstance());
            final Object[] params;
            if (method.getParameterTypes().length == 1) {
                params = new Object[1];
                params[0] = timer;
            } else {
                params = EMPTY_OBJECT_ARRAY;
            }
            context.setParameters(params);
            interceptor.processInvocation(context);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of org.jboss.invocation.InterceptorContext

        }

    }

    private Object invokeMethod(final ComponentView componentView, final Method method, final Object[] args, final EJBLocator ejbLocator, final RemotingAttachments attachments) throws Throwable {
        final InterceptorContext interceptorContext = new InterceptorContext();
        interceptorContext.setParameters(args);
        interceptorContext.setMethod(method);
        interceptorContext.setContextData(new HashMap<String, Object>());
        interceptorContext.putPrivateData(Component.class, componentView.getComponent());
        interceptorContext.putPrivateData(ComponentView.class, componentView);
        if (attachments != null) {
            // attach the RemotingAttachments
            interceptorContext.putPrivateData(RemotingAttachments.class, attachments);
        }
        // add the session id to the interceptor context, if it's a stateful ejb locator
        if (ejbLocator instanceof StatefulEJBLocator) {
            interceptorContext.putPrivateData(SessionID.SESSION_ID_KEY, ((StatefulEJBLocator) ejbLocator).getSessionId());
        } else if (ejbLocator instanceof EntityEJBLocator) {
            final Object primaryKey = ((EntityEJBLocator) ejbLocator).getPrimaryKey();
            interceptorContext.putPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY, primaryKey);
        }
        if (componentView.isAsynchronous(method)) {
            final Component component = componentView.getComponent();
            if (!(component instanceof SessionBeanComponent)) {
                logger.warn("Asynchronous invocations are only supported on session beans. Bean class " + component.getComponentClass()
                        + " is not a session bean, invocation on method " + method + " will have no asynchronous semantics");
                // just invoke normally
                return componentView.invoke(interceptorContext);
            }
            // it's really a async method invocation on a session bean. So treat it accordingly
            final SessionBeanComponent sessionBeanComponent = (SessionBeanComponent) componentView.getComponent();
            final CancellationFlag cancellationFlag = new CancellationFlag();
            // add the cancellation flag to the interceptor context
            interceptorContext.putPrivateData(CancellationFlag.class, cancellationFlag);

            final AsyncInvocationTask asyncInvocationTask = new AsyncInvocationTask(cancellationFlag) {
                @Override
                protected Object runInvocation() throws Exception {
                    return componentView.invoke(interceptorContext);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.