FAQ
I'm trying to make a standalone toolbox loader and I have a question.

is necessary in a standalone application to create a new instance of
each Velocity Tool each time a Context is created?

is a good idea to add a "singleton" parameter to toolbox.xml and thus
create instances only if necessary?

Regards
Edgar

Mike Kienenberger wrote:
What's the best practice for adding a Velocity Tool to the context in
a standalone app?
is it manually with something like "context.put("tool", new *Tool())" or
there's a configuration setting I'm missing?

Shinobu Kawai wrote:
I guess that's the normal method. Or, you can use the toolbox
strategy like VelocityViewServlet and DVSL.
## It's not built into Velocity, so you'll have to implement if
yourself, though.

If you came up with a standalone toolbox loader using the same format as
toolbox.xml and posted it, it might end up in the next version of velocity
tools :)

XMLToolboxManager probably does most if not all of what you need already.

-Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org

Search Discussions

  • Nathan Bubna at Dec 9, 2004 at 6:05 am

    On Thu, 09 Dec 2004 01:12:32 -0300, Edgar Poce wrote:
    I'm trying to make a standalone toolbox loader and I have a question.

    is necessary in a standalone application to create a new instance of
    each Velocity Tool each time a Context is created?
    it depends on the application and the tools.
    is a good idea to add a "singleton" parameter to toolbox.xml and thus
    create instances only if necessary?
    hmm. again, i'd say it probably depends. if you've looked at the
    ServletToolboxManager (which extends XMLToolboxManager), you'll see it
    extends the toolbox.xml format to support a "scope" element that
    allows you to put singleton-ish tools in the application scope and
    thus only be instantiated once.

    if it suits your application's purposes, then adding a "singleton"
    parameter shouldn't be too hard and could be quite useful.
    Regards
    Edgar

    Mike Kienenberger wrote:
    What's the best practice for adding a Velocity Tool to the context in
    a standalone app?
    is it manually with something like "context.put("tool", new *Tool())" or
    there's a configuration setting I'm missing?

    Shinobu Kawai wrote:
    I guess that's the normal method. Or, you can use the toolbox
    strategy like VelocityViewServlet and DVSL.
    ## It's not built into Velocity, so you'll have to implement if
    yourself, though.

    If you came up with a standalone toolbox loader using the same format as
    toolbox.xml and posted it, it might end up in the next version of velocity
    tools :)

    XMLToolboxManager probably does most if not all of what you need already.

    -Mike

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-user-help@jakarta.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
  • Edgar Poce at Dec 9, 2004 at 8:51 pm
    I made a StandaloneContext which contains a set of tools defined in
    the toolbox.xml format and I extended a couple of ViewTool classes for
    adding a property called singleton. The usage is: VelocityContext ctx =
    new StandaloneContext().

    Uploading a patch to bugzilla is the proper way to propose contributions?

    Nathan Bubna wrote:
    On Thu, 09 Dec 2004 01:12:32 -0300, Edgar Poce wrote:

    I'm trying to make a standalone toolbox loader and I have a question.

    is necessary in a standalone application to create a new instance of
    each Velocity Tool each time a Context is created?

    it depends on the application and the tools.

    is a good idea to add a "singleton" parameter to toolbox.xml and thus
    create instances only if necessary?

    hmm. again, i'd say it probably depends. if you've looked at the
    ServletToolboxManager (which extends XMLToolboxManager), you'll see it
    extends the toolbox.xml format to support a "scope" element that
    allows you to put singleton-ish tools in the application scope and
    thus only be instantiated once.

    if it suits your application's purposes, then adding a "singleton"
    parameter shouldn't be too hard and could be quite useful.

    Regards
    Edgar

    Mike Kienenberger wrote:
    What's the best practice for adding a Velocity Tool to the context in
    a standalone app?
    is it manually with something like "context.put("tool", new *Tool())" or
    there's a configuration setting I'm missing?

    Shinobu Kawai wrote:

    I guess that's the normal method. Or, you can use the toolbox
    strategy like VelocityViewServlet and DVSL.
    ## It's not built into Velocity, so you'll have to implement if
    yourself, though.

    If you came up with a standalone toolbox loader using the same format as
    toolbox.xml and posted it, it might end up in the next version of velocity
    tools :)

    XMLToolboxManager probably does most if not all of what you need already.

    -Mike

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-user-help@jakarta.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
  • Shinobu Kawai at Dec 9, 2004 at 11:12 pm
    Hi Edgar,
    I made a StandaloneContext which contains a set of tools defined in
    the toolbox.xml format and I extended a couple of ViewTool classes for
    adding a property called singleton. The usage is: VelocityContext ctx =
    new StandaloneContext().

    Uploading a patch to bugzilla is the proper way to propose contributions?
    Or, you can post it to the wiki page.
    http://wiki.apache.org/jakarta-velocity/
    http://wiki.apache.org/jakarta-velocity/VelocityTools

    ## I like the wiki page because it's easier to modify the code afterwards. :)

    Best regards,
    -- Shinobu Kawai

    --
    Shinobu Kawai <shinobu.kawai@gmail.com>

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
  • Edgar Poce at Dec 10, 2004 at 9:16 pm
    >
    Or, you can post it to the wiki page.
    http://wiki.apache.org/jakarta-velocity/
    http://wiki.apache.org/jakarta-velocity/VelocityTools >
    ## I like the wiki page because it's easier to modify the code
    afterwards. :)
    >
    I tried to post it but I get "You are not allowed to edit this page.".
    So, I attach the patch. If anyone want to give it a try apply it on
    org.apache.velocity.tools.

    In order to work the engine runtime property "standalone.toolbox.path"
    must return the path to the file with toolbox.xml format. The
    toolbox.xml format is slightly modified to accept singleton lifecycle
    for tools.

    Usage:
    // Velocity Singleton model
    VelocityContext ctx = new StandaloneContext() ;

    // Velocity separate instance
    VelocityEngine engine = new VelocityEngine();
    engine.addProperty(StandaloneContext.PATH_KEY, "path");
    engine.init();
    StandaloneContext ctx = new StandaloneContext() ;
    ctx.setToolbox(StandaloneToolboxManager.getToolbox(engine));

    I also made a simple test case but I guess the subscribers won't be very
    happy if I send many attachments.

    Thanks
    Edgar



    Shinobu Kawai wrote:
    Hi Edgar,

    I made a StandaloneContext which contains a set of tools defined in
    the toolbox.xml format and I extended a couple of ViewTool classes for
    adding a property called singleton. The usage is: VelocityContext ctx =
    new StandaloneContext().

    Uploading a patch to bugzilla is the proper way to propose contributions?

    Or, you can post it to the wiki page.
    http://wiki.apache.org/jakarta-velocity/
    http://wiki.apache.org/jakarta-velocity/VelocityTools

    ## I like the wiki page because it's easier to modify the code afterwards. :)

    Best regards,
    -- Shinobu Kawai

    --
    Shinobu Kawai <shinobu.kawai@gmail.com>

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
  • Mike Kienenberger at Dec 10, 2004 at 9:21 pm

    Edgar Poce wrote:
    I tried to post it but I get "You are not allowed to edit this page.".
    Click on "UserPreferences" in the upper-right-hand corner to log in.
    Once you've done that, you can edit and add pages.

    -Mike

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
  • Edgar Poce at Dec 13, 2004 at 1:19 pm

    Click on "UserPreferences" in the upper-right-hand corner to log in.
    Once you've done that, you can edit and add pages.
    Now I know how to upload it to the wiki. Thanks, mike.
    ## I like the wiki page because it's easier to modify the code
    afterwards. :)
    >
    The patch I sent contains 6 classes. How should I upload this to the
    wiki? one class per page?

    Sorry about the unexperience but it's my first attempt to contribute and
    I don't want to mess up the wiki.

    Best regards
    Edgar

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
  • Shinobu Kawai at Dec 14, 2004 at 4:22 pm
    Hi Edgar,
    The patch I sent contains 6 classes. How should I upload this to the
    wiki? one class per page?
    I think you can put it all in one page, using separate source code blocks.
    {{{
    class 1
    }}}

    {{{
    class 2
    }}}

    and so on.
    You can also attach the file to the page (though I've never tried it before).
    Sorry about the unexperience but it's my first attempt to contribute and
    I don't want to mess up the wiki.
    If you mess things up, you can put it back again. After all, it's a wiki. :)
    ## or is it impossible to delete a page?

    Best regards,
    -- Shinobu Kawai

    --
    Shinobu Kawai <shinobu.kawai@gmail.com>

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: velocity-dev-help@jakarta.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriesvelocity
postedDec 9, '04 at 4:13a
activeDec 14, '04 at 4:22p
posts8
users5
websitevelocity.apache.org

People

Translate

site design / logo © 2021 Grokbase