james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <n...@devtech.com>
Subject RE: CommandMap for Handlers
Date Wed, 07 Aug 2002 00:00:51 GMT
My view is that the Method class is too heavyweight in most cases to expose
to normal client code (and developers).  As for creating additional objects,
Method instances are objects, so instantiation still occurs.  Furthermore,
you have to wrap your arguments to call Method.invoke(Object, Object[]), so
there is the additional instantiation of an Object array.  So rather than
expose a naked Method instance, I'd just as soon have a more direct mapping.

My prototype looks like:

  cmds.perform(name, argument-list);
  cmds.watchPerform(timeout, name, argument-list);

In the case of our handlers, since all of the methods are of the form:

  doX(String, String, String);

the HandlerCommandMap exposes exactly that interface.

Anyhow, we can beat this subject to death.

	--- Noel

-----Original Message-----
From: Harmeet Bedi [mailto:harmeet@kodemuse.com]
Sent: Tuesday, August 06, 2002 21:36
To: James Developers List
Subject: Re: CommandMap for Handlers


From: "Noel J. Bergman" <noel@devtech.com>
> If I understood your point, the reflection idea can be built by adding a
> specialized subclass of my CommandMap with a method that populates the

A little more than that, methods can be treated as objects and a method can
invoked from another method based on reflection and command name. The idea
was to have the benfits of command map pattern, without any need of creating
additional objects.

so instead of
if ( command.equals("DATA") )
  doData(arg1....)
else if ( command.equals("USER") )
  doUSER(arg1....)
etc. etc.

do
----
Method cmd = methodMap.get(<command>);
cmd.invoke(this,< args..>);
---

methodMap can be built in static initializer or lazily built once, based on
class reflection.

Harmeet
----- Original Message -----
From: "Noel J. Bergman" <noel@devtech.com>


> I addressed the timeout handling addressed in a separate thread.
>
> If I understood your point, the reflection idea can be built by adding a
> specialized subclass of my CommandMap with a method that populates the
> command map with command objects based upon inspecting the class for
> methods matching a convention.  The command objects would simply invoke
> the target method on the target object using the specified calling
convention.
>
> --- Noel


--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message