Functions are always cloned, regardless of whether or not they're used
globally or locally.  This can be a bit of a pain when you're going to
include instance data, but you can always manage it by not cloning the
instance data if it's not appropriate.  Think of the function instance you
provide as a factory for the instances you want Xalan to use.  That means
you can call any constructor for your implementation class when it gets
cloned, not just the copy constructor on the instance that's being cloned.
You can also use a different constructor for the factory function instance,
or even use a different class that "clones" the appropriate class (not that
I would recommend the last option...).  I hope that makes sense.  If not, I
can elaborate a bit more with an example.

The lifetime of a global function is from the time you install it, until
the time your process ends, unless you explicitly uninstall it.  The
lifetime of local functions varies depending upon the Xalan classes you're
using.  If you're using the XalanTransformer class, then local functions
are cloned when the transformation starts, and destroyed after the
transformation is finished.

If you're doing things the old way, using individual implementation classes
to build all of the objects you need for a transform, then things are
different.  In that case, you must install your local function(s) into an
instance of XSLTProcessorEnvSupport.  Any local functions you install will
be destroyed when that instances goes out of scope.  So if you use one
instance of XSLTProcessorEnvSupport for multiple transforms, then one
instance of your function will be used for multiple transforms.

Hope that helps...

Dave



                                                                                
                                                      
                      Wolfgang Schell                                           
                                                      
                      <wolfgang.schell         To:      
[email protected]                                                  
                      @gmx.de>                 cc:                              
                                                      
                                               Subject: Re: how to create nodes 
from an external function                             
                      02/13/2002 02:14                                          
                                                      
                      AM                                                        
                                                      
                                                                                
                                                      
                                                                                
                                                      




Hi Dave!

Thanks for your advice!

> I don't know your exact design/architecture, but I would urge you to
> consider giving each function instance its own XalanSourceTreeDocument
> instance and installing multiple instances.  It's much cleaner, and you
> avoid the problem of using one XalanSourceTreeDocument instance for all
> threads.

Hm, you're probably right. I'll try this approach.

> It's much easier to give each function instance its own
> XalanSourceTreeDocument instance, and let the function instance be
> destroyed after the transformation is complete.

What is the livecycle of an extension function? Will a new instance be
created (via clone()?) for each transformation and destroyed right
afterwards? Are
there significant difference in handling for globally and locally installed
extensions?

Thanks in advance for your time
Cheers,


Wolfgang

--
Wolfgang Schell
[EMAIL PROTECTED]

GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net





Reply via email to