Results 1 to 3 of 3

Thread: How to add arguments to a MethodInvocation object ?

  1. #1
    Join Date
    Jul 2005
    Posts
    29

    Default How to add arguments to a MethodInvocation object ?

    Hello,

    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.

    Code:
    Protected Object invoke(MethodInvocation invocation) throws Throwable
    {
    	if(invocation.getMethod().getName().equals("executeOperation"))
    	{
    		...
    	}
    	
    	return super.invoke(invocation);
    }
    Can anyone help me ?

    Thanks in advance.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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.

    Regards,
    Andreas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •