On 3/12/02 2:12 PM, "Nathan Bubna" <[EMAIL PROTECTED]> wrote:
> Gabriel Sidler wrote:
> [snip]
>> I'd like to propose the addition of two new methods to ContextTool
>> that will further improve the handling of context tools.
>
> hmm. i'm not a fan of complicating interfaces if it can be avoided, and
> i've never been thrilled with the current ContextTool interface either.
> more below...
>
> [snip]
>> /**
>> * ContextTool defines a set of methods that allows a context tool
>> * manager to efficiently handle context tools.
>> */
>> public interface ContextTool
>> {
>> /**
>> * Returns an instance of the context tool. Some tools may simply
> return
>> * themselves from this method others may instantiate new objects
>> * to hold the per-request state.
>> */
>> public Object init(ViewContext context);
>
> -1
> you know, i've never really been comfortable with this. To me "init"
> implies that we are using the method to configure the object the method is
> called on, but at present, this method is being used as a factory method to
> create new instances of the implementing class. That is to me a misnomer.
> I would prefer calling such a method "getInstance" or something similar.
+1 your -1 - I agree that a name change would be a good thing
>
>> /**
>> * Allows a tool manager to pass a logger to the context tool.
>> * If a logger is set, it will be used for all instances of
>> * this class. If no logger is set, no logging will occur.
>> *
>> * @param logger A logger.
>> */
>> public static void setLogger(ContextToolLogger logger);
>
> +0
> hmm. yes, we should provide some hook for tools that output log messages to
> use a common log system, but i'm not convinced that this is the best way.
> however, neither do i have an alternative suggestion at the moment. i need
> to chew on this one.
>
>> /**
>> * Allows a tool manager to check if a tool is all static or
>> * not. If a tool is not all static, a new instance *must* be
>> * created for every template that is processed. If a tool is
>> * all static the tool manager *may* optimize the tool handling
>> * by working with a single instance for the entire runtime.
>> *
>> */
>> public static boolean isStatic()
>
> -1
> ick! i don't see the point of this. if a tool is completely static, it
> shouldn't be implementing the ContextTool interface. my understanding is
> that ContextTool is for tools that are request/session/application
> sensitive. if a tool is static, it has no use for such stateful objects and
> therefore it is a waste of time to implement ContextTool or anything else.
> the view servlet should just use the same instance of static tools for all
> requests.
You are right - I didn't think about it that way - my thoughts surrounding
this really had to do with lifecycle - and I think the right name here is
'single instance' (note I avoided the word 'singleton')
When you list your tools in the configuration, you can indicate if the tool
is a single instance or not, -> the toolmanager reuses a single instance in
each context, or must make a fresh instance for each.
That's the important aspect here, or believe so, because it means if you
have some heavy tools that do an incredible amount of stuff once, then you
can denote them as 'single instance' in the config, and not worry that you
get hammered with each use.
Geir
>
> [snip]
>
> Nathan Bubna
> [EMAIL PROTECTED]
>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
Geir Magnusson Jr. [EMAIL PROTECTED]
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>