velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sato tadayosi <s...@mogra.net>
Subject how to inherit ServletToolboxManager?
Date Tue, 04 Jan 2005 06:22:04 GMT
Hello everyone,

I'm using VelocityView and am very happy it's much easier creating
dynamic HTML than JSP and custom tags.

Now I need to use some my own implementation of ServletToolboxRuleSet
(which is in "org.apache.velocity.tools.view.servlet" package),
so I tried to extend ServletToolboxManager to overrride "getRuleSet()"
method in it. But I couldn't because ServletToolboxManager is singleton
and its only constructor is private.

ServletToolboxManager source (VelocityTools 1.1) is like this:
===
public class ServletToolboxManger extends XMLToolboxManager {
  ...
  private ServletToolboxManager(ServletContext servletContext) {
    ...
  }
  ...
  public static synchronized ServletToolboxManager getInstance(
    ServletContext servlet,
    String toolboxFile) {
    ...
  }
  ...
  protected RuleSet getRuleSet() { ... }
}
===

and I made subclass like this (it's bad solution. it fails to compile...):
===
public class MyServletToolboxManger extends ServletToolboxManager {
  public static synchronized ServletToolboxManger getInstance(
    ServletContext servlet,
    String toolboxFile) {
    ...
  }
  protected RuleSet getRuleSet() { /* return my own RuleSet */ }
}
===


If any good idea to extend ServletToolboxManager, please could you
tell me?

Thank you.

Sato

(*
 *  SATO TADAYOSI <sato@mogra.net>
 *)

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


Mime
View raw message