Java Code Examples for javax.interceptor.InvocationContext#setParameters()

The following examples show how to use javax.interceptor.InvocationContext#setParameters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EjbMethodInvoker.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
protected Object performInvocation(final Exchange exchange, final Object serviceObject,
                                   final Method m, final Object[] paramArray) throws Exception {
    InvocationContext invContext = exchange.get(InvocationContext.class);
    invContext.setParameters(paramArray);
    Object res = invContext.proceed();

    EjbMessageContext ctx = (EjbMessageContext) invContext.getContextData();

    Map<String, Object> handlerProperties = (Map<String, Object>) exchange
        .get(HANDLER_PROPERTIES);
    addHandlerProperties(ctx, handlerProperties);

    updateWebServiceContext(exchange, ctx);

    return res;
}
 
Example 2
Source File: JaxRpcInvocationTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@AroundInvoke
public Object invoke(final InvocationContext invocationContext) throws Exception {
    // The interceptor of the web serivce must set the
    // arguments it marshalls from the soap message into
    // the InvocationContext so we can invoke the bean.
    invocationContext.setParameters(args);

    final Object returnValue;
    try {

        // Track this call so we can assert proper interceptor order
        calls.add(Call.WebServiceProvider_Invoke_BEFORE);

        // handler chain "before advice" would happen here
        returnValue = invocationContext.proceed();
        // handler chain "after advice" would happen here

        // Track this call so we can assert proper interceptor order
        calls.add(Call.WebServiceProvider_Invoke_AFTER);

    } catch (final Exception e) {
        // handler chain fault processing would happen here
        throw e;
    }
    return returnValue;
}
 
Example 3
Source File: JaxWsInvocationTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
@AroundInvoke
public Object invoke(final InvocationContext invocationContext) throws Exception {
    // The interceptor of the web serivce must set the
    // arguments it marshalls from the soap message into
    // the InvocationContext so we can invoke the bean.
    invocationContext.setParameters(args);

    final Object returnValue;
    try {

        // Track this call so we can assert proper interceptor order
        calls.add(Call.WebServiceProvider_Invoke_BEFORE);

        // handler chain "before advice" would happen here
        returnValue = invocationContext.proceed();
        // handler chain "after advice" would happen here

        // Track this call so we can assert proper interceptor order
        calls.add(Call.WebServiceProvider_Invoke_AFTER);

    } catch (final Exception e) {
        // handler chain fault processing would happen here
        throw e;
    }
    return returnValue;
}
 
Example 4
Source File: PaymentManipulationInterceptor.java    From blog-tutorials with MIT License 5 votes vote down vote up
@AroundInvoke
public Object manipulatePayment(InvocationContext invocationContext) throws Exception {

    if (invocationContext.getParameters()[0] instanceof String) {
        if (((String) invocationContext.getParameters()[0]).equalsIgnoreCase("duke")) {
            paymentManipulator.manipulatePayment();
            invocationContext.setParameters(new Object[]{
                    "Duke", new BigDecimal(999.99).setScale(2, RoundingMode.HALF_UP)
            });
        }
    }

    return invocationContext.proceed();
}
 
Example 5
Source File: MdbInterceptor.java    From tomee with Apache License 2.0 5 votes vote down vote up
@AroundInvoke
public Object mdbInterceptor(final InvocationContext ctx) throws Exception {
    final Object[] objArr = ctx.getParameters();
    final Message msg = (Message) objArr[0];
    msg.clearProperties();
    msg.setBooleanProperty("ClassLevelBusinessMethodInterception", true);
    ctx.setParameters(objArr);
    return ctx.proceed();
}
 
Example 6
Source File: InterceptorMdbBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
@AroundInvoke
public Object aroundInvoke(final InvocationContext ctx) throws Exception {
    final Object[] objArr = ctx.getParameters();
    final Message msg = (Message) objArr[0];
    msg.setBooleanProperty("MethodLevelBusinessMethodInterception", true);
    ctx.setParameters(objArr);
    return ctx.proceed();
}