You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gary L Peskin <ga...@firstech.com> on 2000/12/14 17:21:37 UTC

Re: Xalan Extensions: using a single instance rather than new instantiation

Bassi Suk wrote:
> 
> I have a JAVA class which is acting as a database factory. I only want to
> use one instance of this.
> 
> Is there a way in Xalan xslt java extensions to use this factory as i would
> through normal java calls.
> ie.
> 
> myDBFactory dbFac = myDBFactory.getInstance();
> 
> dbFac.getOrder(int orderID)
> dbFac.getDept(int depID)
> 
> etc...
> 
> At present, when l reference a java class, Xalan creates a new instance of
> that class each time a new stylesheet references it.
> 
> I would like it so that each time a stylesheet references the code, Xalan
> refers to the same myDBFactory instance.

Suk --

I'm a little confused as to what you're trying to do.  I assume that
getInstance() is a static method in myDBFactory.  When you call it, it
returns an object of type myDBFactory called dbFac.  Is it this dbFac
that you want to use everywhere?  Are you passing a reference to dbFac
to your various stylesheets or what?

If I understand you correctly, perhaps you want to have a "default
instance" of myDBFactory.  In this case, you'd just store the instance
as a static field in myDBFactory and get it with either getInstance() or
a new getDefaultInstance() method.

Not sure what you're trying to do.  If my explanation doesn't help,
perhaps you could explain further and we can go from there.

Gary