tags:

views:

71

answers:

1

I'm working on modifying an existing application implemented as a 2.1 stateless EJB. I'd like to put in some kind of generic, detailed, logging of all calls made to the EJB.

Stuff I'd like to log:

  • Name of method being called
  • Serialized copy of all passed parameters
  • Serialized copy of return value

I implemented something like that for an asp.net REST web service before by simply putting in a hook before the request is processed and one right before the response is sent back. It produces a lot of data, but it's well worth it for debugging a long running system.

I'm not sure how the same can be done for an EJB. I'd like to avoid AOP since the application doesn't currently use AOP. Interceptors won't work because it's not EJB 3.0.

Does anyone know of a way to hook into the EJB processing pipeline to look at request as they come in? Is there another approach to doing this?

Thanks

+1  A: 

I think there are only two ways two ways to know when a method of an EJB (or any other class) is called:

  • Bad solution: using the Java Debug Interface (JDI) you can know which line is executed, as you know it when you are debugging Java with your IDE. It's complicated and there are some problems when you are debugging an application in the same JVM where JDI runs.

  • Good solution: as Thomas Owens says, AOP is the recommended solution. If you are not using it in your project now, this is a good reason for using it.

Sinuhe
If there aren't any more suggestions, I'll mark this as the answer and start looking into AspectJ.
jthg