jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java
changeset 12458 d601e4bba306
parent 12457 c348e06f0e82
child 16953 a44e04deb948
equal deleted inserted replaced
12457:c348e06f0e82 12458:d601e4bba306
    40 import com.sun.org.apache.xalan.internal.xsltc.DOM;
    40 import com.sun.org.apache.xalan.internal.xsltc.DOM;
    41 import com.sun.org.apache.xalan.internal.xsltc.Translet;
    41 import com.sun.org.apache.xalan.internal.xsltc.Translet;
    42 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
    42 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
    43 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
    43 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
    44 import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
    44 import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
       
    45 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
    45 
    46 
    46 /**
    47 /**
    47  * @author Morten Jorgensen
    48  * @author Morten Jorgensen
    48  * @author G. Todd Millerj
    49  * @author G. Todd Millerj
    49  * @author Jochen Cordes <Jochen.Cordes@t-online.de>
    50  * @author Jochen Cordes <Jochen.Cordes@t-online.de>
   116      * A reference to the transformer factory that this templates
   117      * A reference to the transformer factory that this templates
   117      * object belongs to.
   118      * object belongs to.
   118      */
   119      */
   119     private transient TransformerFactoryImpl _tfactory = null;
   120     private transient TransformerFactoryImpl _tfactory = null;
   120 
   121 
       
   122     private boolean _useServicesMechanism;
       
   123 
   121     static final class TransletClassLoader extends ClassLoader {
   124     static final class TransletClassLoader extends ClassLoader {
   122         TransletClassLoader(ClassLoader parent) {
   125         TransletClassLoader(ClassLoader parent) {
   123             super(parent);
   126             super(parent);
   124         }
   127         }
   125 
   128 
   140     protected TemplatesImpl(byte[][] bytecodes, String transletName,
   143     protected TemplatesImpl(byte[][] bytecodes, String transletName,
   141         Properties outputProperties, int indentNumber,
   144         Properties outputProperties, int indentNumber,
   142         TransformerFactoryImpl tfactory)
   145         TransformerFactoryImpl tfactory)
   143     {
   146     {
   144         _bytecodes = bytecodes;
   147         _bytecodes = bytecodes;
   145         _name      = transletName;
   148         init(transletName, outputProperties, indentNumber, tfactory);
   146         _outputProperties = outputProperties;
       
   147         _indentNumber = indentNumber;
       
   148         _tfactory = tfactory;
       
   149     }
   149     }
   150 
   150 
   151     /**
   151     /**
   152      * Create an XSLTC template object from the translet class definition(s).
   152      * Create an XSLTC template object from the translet class definition(s).
   153      */
   153      */
   154     protected TemplatesImpl(Class[] transletClasses, String transletName,
   154     protected TemplatesImpl(Class[] transletClasses, String transletName,
   155         Properties outputProperties, int indentNumber,
   155         Properties outputProperties, int indentNumber,
   156         TransformerFactoryImpl tfactory)
   156         TransformerFactoryImpl tfactory)
   157     {
   157     {
   158         _class     = transletClasses;
   158         _class     = transletClasses;
       
   159         _transletIndex = 0;
       
   160         init(transletName, outputProperties, indentNumber, tfactory);
       
   161     }
       
   162 
       
   163     private void init(String transletName,
       
   164         Properties outputProperties, int indentNumber,
       
   165         TransformerFactoryImpl tfactory) {
   159         _name      = transletName;
   166         _name      = transletName;
   160         _transletIndex = 0;
       
   161         _outputProperties = outputProperties;
   167         _outputProperties = outputProperties;
   162         _indentNumber = indentNumber;
   168         _indentNumber = indentNumber;
   163         _tfactory = tfactory;
   169         _tfactory = tfactory;
   164     }
   170         _useServicesMechanism = tfactory.useServicesMechnism();
   165 
   171     }
   166 
       
   167     /**
   172     /**
   168      * Need for de-serialization, see readObject().
   173      * Need for de-serialization, see readObject().
   169      */
   174      */
   170     public TemplatesImpl() { }
   175     public TemplatesImpl() { }
   171 
   176 
   205         else {
   210         else {
   206             os.writeBoolean(false);
   211             os.writeBoolean(false);
   207         }
   212         }
   208     }
   213     }
   209 
   214 
       
   215     /**
       
   216      * Return the state of the services mechanism feature.
       
   217      */
       
   218     public boolean useServicesMechnism() {
       
   219         return _useServicesMechanism;
       
   220     }
   210 
   221 
   211      /**
   222      /**
   212      * Store URIResolver needed for Transformers.
   223      * Store URIResolver needed for Transformers.
   213      */
   224      */
   214     public synchronized void setURIResolver(URIResolver resolver) {
   225     public synchronized void setURIResolver(URIResolver resolver) {
   355             // The translet needs to keep a reference to all its auxiliary
   366             // The translet needs to keep a reference to all its auxiliary
   356             // class to prevent the GC from collecting them
   367             // class to prevent the GC from collecting them
   357             AbstractTranslet translet = (AbstractTranslet) _class[_transletIndex].newInstance();
   368             AbstractTranslet translet = (AbstractTranslet) _class[_transletIndex].newInstance();
   358             translet.postInitialization();
   369             translet.postInitialization();
   359             translet.setTemplates(this);
   370             translet.setTemplates(this);
       
   371             translet.setServicesMechnism(_useServicesMechanism);
   360             if (_auxClasses != null) {
   372             if (_auxClasses != null) {
   361                 translet.setAuxiliaryClasses(_auxClasses);
   373                 translet.setAuxiliaryClasses(_auxClasses);
   362             }
   374             }
   363 
   375 
   364             return translet;
   376             return translet;