Ok, following the post that I reference, I was able to implement a client interceptor to capture the client's IP address and add it to the invocation object using setValue(). Then I was able to create a server interceptor, modeled after the LogInterceptor (i.e., extends from AbstractInterceptor), which can retrieve the IP address from the invocation object using getValue(). So far, so good.
Now, how does that help me? I need to get that value into something that the EJB business method can access, which then needs to pass it on to a corresponding MBean method, again in some transparent fashion. That is, I don't want to modify the 60 business methods in the stateless session EJB or the corresponding 60 business methods in the MBean. Ideally, the MBean could get hold of the invocation object, but I don't know if that is possible.
Ok, I finally got this figured out. For those who may stumble upon this thread, here is a quick summary of what I had to do to get this to work. If someone can tell me where to post a code sample, I'll do that when I get some time:
(1) Implement a client interceptor that captures the client IP address in a static initialization block:
aIpAddr = InetAddress.getLocalHost().getHostAddress();
Then, in the invoke method, add this value to the invocation object:
This code runs in the client VM.
(2) Implement a container interceptor to copy the captured value into the server VM. In order to have this value retrievable by an EJB and then by MBeans called by that EJB, you'll need a ThreadLocal variable. In the code below ClientIpAddress manages a ThreadLocal variable.
String aIpAddr = (String) mi.getValue("client_ip_addr"); ClientIPAddress.set(aIpAddr);
(3) ThreadLocal variables are managed as class static variables, at least in my simple case (and in the Sun Java documentation.) So, to use the value in an EJB or MBean, you just reference it. This assumes the EJB and the MBean are running in the same VM. If not, I suppose you'll have to figure out some way to pass along the value to the target VM, I imagine through another pair of invokers.
I'd like to say a sincere thanks to myself for helping me through this ;).
If someone can tell me where to post a code sample, I'll do that when I get some time:
The JBoss Wiki http://wiki.jboss.org/wiki is a good place.
I guess, you can add this to the "Why do I" section at http://wiki.jboss.org/wiki/JBossFrequentlyAskedQuestions