Skip to Content.
Sympa Menu

grouper-dev - better request/response handling code ?

Subject: Grouper Developers Forum

List archive

better request/response handling code ?


Chronological Thread 
  • From: Tom Zeller <>
  • To: Grouper Dev <>
  • Subject: better request/response handling code ?
  • Date: Thu, 25 Mar 2010 12:51:59 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; b=MJW+qrHDzKMuhzSbrsnyt5RVxudn+g2/ChUqcD0AgKO5VST+EgPtLomleYWCfSmFnx Snon481Zpmge6Iwv2TP9RO4gL9SkVqCGNcUaWF/Cu+2SWnX7tLaStGrlAvs2aZuk3MyH aB/5dbaF4RB0hwFc4OrzzyvV+V/sUj9ip4Ib8=

I'm looking for a better way to structure ldappc-ng request/response
handling code. I'd like to avoid casting and would like to include MDC
logging.

I defined an interface (based on the spml toolkit) for
request/response handling :

public interface SpmlProvider {
public Response execute(Request request);
}

The base implementation for handling common code :

public abstract class BaseSpmlProvider implements SpmlProvider {
public Response execute (Request request) {
... common code
MDC.put(...);
Method method = this.getClass().getMethod(methodName, new Class[] {
request.getClass() });
Response response = (Response) method.invoke(this, new Object[] { request
});
... common code
MDC.remove(...);
return response;
}
}

And ldappc-ng :

public class PSP extends BaseSpmlProvider {
private CalcResponse execute(CalcRequest request) ...
private DiffResponse execute(DiffRequest request) ...
...

The result is that casts are required in order to call the common code
and MDC, e.g. :

CalcResponse response = (CalcResponse) execute((Request) request);

I don't really like those casts, it's not a huge deal, but I'm looking
for a better way.

Suggestions ? Ideas ?

TomZ


  • better request/response handling code ?, Tom Zeller, 03/25/2010

Archive powered by MHonArc 2.6.16.

Top of Page