commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Curdt <tcu...@apache.org>
Subject Re: [javaflow] MethodLookup
Date Wed, 27 Jul 2005 08:43:30 GMT

On 27.07.2005, at 07:11, Kohsuke Kawaguchi wrote:

> I'm bit confused with MethodLookup. I could be just missing  
> something, but here it goes...
>

The MethodLookup was introduced when I added the
serialization support. Beforehand the Method was
passed in directly. But now the Method that is
stored inside the Continuation is marked transient.
After the resume the Method is null and must be
looked up.

> I wonder if it would be better if the startWith method is:
>
> Continuation startWith( Runnable target, ContinuationContext context )

I've been thinking about that, too ...but for the
use inside Cocoon I don't really want to restrict
it to the "void run()" method only.

Besides for the serialization support we would
need to pass in the Runnable/Method also for
"continueWith(Runnable/Method, Continuation)"

IIRC there were even more reasons ...will try
to remember :)

> I think developers relates to Runnable more easily, as  
> java.lang.Thread uses it. I also think there isn't any loss in the  
> expressiveness of the library, as we can emulate the old  
> functionality by using a Runnable that looks up a method name from  
> String and create a new instance.

Uh... that sounds ugly :)

...but how about the other way around. We could
also provide

  Continuation startWith(ContinuationContext) // means: use method "run"
  Continuation startWith(String, ContinuationContext)

with a standard ContinuationContext that explicitly
supports a Runnable by providing a default implementation.
So a bit simplified you could do:

   startWith(new DefaultContinuationContext(Runnable))

That would give us all the flexibility and the simplified
interface

WDYT?


> It also has some other minor benefits, like simplifying the  
> implementation and improving the performance by avoiding reflection.

As the reflection calls are cached the performance impact
is really minor.

cheers
--
Torsten

Mime
View raw message