"Lewis, Brent" wrote:
> Is there a way to retrieve calling chain information from the lowest
> level of a bean call?
Possibly (untested, but you can do this in normal Java); this gives you
stack information (sort of):
public class BogusSecurityManager extends SecurityManager {
// normally this is protected; we override it to make it public
public final Class[] getClassContext() {
return super.getClassContext();
}
}
// in your bean, perhaps
try {
BogusSecurityManager dontInstallMe =
new BogusSecurityManager();
Class[] context = dontInstallMe.getClassContext();
// examine the stack...
} catch (SecurityException cantCreate) {
// oh well; nice try
}
That gives you a stack of classes, but not the objects.
Now, having said all this the container may certainly block the
constructor call (even though the security manager is not being
installed; it's just being used and thrown away) in which case you're
out of luck.
Another approach which is stupendously hackish is to feed
Thread.currentThread().dumpStack() into a StringBuffer and parse it, but
that would be nonportable and just plain ugly.
Finally, your example mentions getCallerPrincipal(), which suggests to
me that perhaps you aren't looking to inspect the call stack but instead
want to look at the identity of the client invoking your bean method.
If that's true, then getCallerPrincipal() is all you've got--if your
bean's client is really another bean in another appserver, let's say,
that's been called by yet another bean in yet another app server,
there's no way to get the principal located two appservers away from
you. Does that make sense?
Hope I've addressed your question.
Cheers,
Laird
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".