You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Ka...@tietoenator.com on 2002/06/25 09:32:19 UTC

Extension elements and Java instance pooling

Hi!
(XalanJ 2.3.1)

<ext:doSomething val="x"/>

Suppose that doSomething() is a static method. Does Xalan still create a new
class instance?
If doSomething() is an instance method, does Xalan always use paramless ctor
for class creation?

Can I somehow (easily) force Xalan to use my pool instead of paramless ctor:

public static MyClass newInstance() {
  if (m_myClass != null) {
    return m_myClass;
  }
  else {
    ....
  }
}


Maybe "wrapper-pipe" is only easy way?

public class simpleClass {
  private static ComplexClass = new ComplexClass();

  public SimpleClass() {
    //Xalan invokes this...
  }

  public void doSomething(a,b) {
    //use shared cpx
    cpx.doSomething(a,b);
  }
}

When using extensions through <xsl:value-of .../> and <xsl:variable .../>,
I can somehow manage pool things, but... 


And at last, maybe worth consideration (only maybe):
Could Xalan be developed so that the decision on how to create instance is:
1. if class has a method: "static X newInstance()", use it to retrieve X.
2. else use new X();

X.newInstance(), as far as I know, is a kind of standard.

-Kai