saif-hmk / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Allow developper to set remoteUser name #277

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I have an ear and a war.
The ear contains the javamelody war and some EJBs
The war contains servlet and the servlet calls EJBS. This war contains 
javamelody too.

What is the expected output? What do you see instead?
When i launch  "URL://host:80/myWebApp/monitoring" i see current sql requests 
with the remoteUserName
When i launch  "URL://host:80/myEARApp/monitoring" i see current sql requests 
without the remoteUserName

In constructor:
private CounterRequestContext(Counter parentCounter, CounterRequestContext 
parentContext,String requestName, String completeRequestName, String 
remoteUser, long threadId,long startTime, long startCpuTime) the remoteUser is 
null when i call it from an EJB.

I think that it can be usefull to add ability to set the remoteUser.

In class Parameter:
add REMOTE_USER_PROVIDER_CLASS("remote-user-provider-class")

Create new Interface:
public Interface RemoteUserProvider {
  String getRemoteUser();
}

In constructor CounterRequestContext, add:

if(remoteUser==null) {
 final String remoteUserProvider = getParameter(Parameter.REMOTE_USER_PROVIDER_CLASS);
 if (remoteUserProvider!= null) {
  Class remoteUserProviderClass = Class.forName(remoteUserProvider);
  RemoteUserProvider remoteUserProvider = remoteUserProviderClass.getConstructor().newInstance();
  remoteUser = remoteUserProvider.getRemoteUser();
 }
}

Original issue reported on code.google.com by lastm...@yahoo.fr on 9 Jan 2013 at 1:26