Announcement Announcement Module
No announcement yet.
How to add arguments to a MethodInvocation object ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to add arguments to a MethodInvocation object ?


    I'm actually using Spring to access an EJB service.

    I have overloaded the Class SimpleRemoteStatelessSessionProxyFactoryBean to intercept every remote invocation.

    Indeed, I'd like to add a new argument to the method invoked, but I don't know how to modify arguments of the Object MethodInvocation: the method setArguments doesn't exist for this interface.

    Protected Object invoke(MethodInvocation invocation) throws Throwable
    	return super.invoke(invocation);
    Can anyone help me ?

    Thanks in advance.

  • #2
    I don't believe you can add a parameter to a MethodInvocation. It has a few methods which can get you some information about the method, signature, parameters passed in etc. and to proceed with the invocation.

    Also when you are adding parameters to the invocation it means that another method is going to be called. One which also has the method signature with the added parameter.

    If you want to change the method called, I guess you will have to intercept it before it is being called/intercepted. Lookup the other method, create a new array of objects 1 larger then the passed in types, copy the objects to the array, add your object/parameter to the array and execute that method.


    • #3
      I second Marten here. Transparently adding parameters can be done only with Spring's RMI- and HttpInvoker-handlers.

      Intercepting EJB methods themselves (i.e. before the container processes them) is not specified and therefore not supported (at any rate not portably). As of a workaround that resembles the approach Marten describes see here. I propose there a solution for passing an acegi security context via EJB without polluting the business interface. It should be capable of transferring other data as well. Implementation is available.