Enhydra 3.1 API

org.apache.xalan.xpath
Class XSLTJavaClassEngine

org.apache.xalan.xpath.XSLTJavaClassEngine

public class XSLTJavaClassEngine
implements ExtensionFunctionHandler.ExtensionLiaison

This is a custom scripting engine for the XSLT processor's needs of calling into Java objects.


Field Summary
protected static boolean bsfInitialized
          Tell if we've already initialized the bsf engine.
 java.lang.Class classObject
           
protected  boolean componentStarted
           
protected  boolean hasCalledCTor
           
 java.lang.Object javaObject
           
protected static java.lang.Boolean m_bsfInitSynch
           
protected  com.ibm.bsf.BSFManager mgr
           
 java.lang.String scriptLang
           
 java.lang.String scriptSrc
           
 java.lang.String scriptSrcURL
           
 
Constructor Summary
XSLTJavaClassEngine()
           
 
Method Summary
 java.lang.Object call(java.lang.Object object, java.lang.String method, java.lang.Object[] args)
          call the named method on the object that was loaded by eval.
 java.lang.Object callFunction(java.lang.String funcName, java.util.Vector args, java.lang.Object methodKey, java.lang.Class javaClass)
          Process a call to a function.
 java.lang.Object callJava(java.lang.Object object, java.lang.String method, java.lang.Object[] args, java.lang.Object methodKey)
          call the named method on the object that was loaded by eval.
 void checkInit()
          Make sure the component is initialized
 java.lang.Object eval(java.lang.String source, int lineNo, int columnNo, java.lang.Object oscript)
          This is used by an application to evaluate an object containing some expression - clearly not possible for compiled code ..
 void setScript(java.lang.String lang, java.lang.String srcURL, java.lang.String scriptSrc)
          Set the script data for this extension NS.
 void startupComponent(java.lang.Class classObj)
          Start the component up by executing any script that needs to run at startup time.
 

Field Detail

scriptLang

public java.lang.String scriptLang

scriptSrcURL

public java.lang.String scriptSrcURL

scriptSrc

public java.lang.String scriptSrc

hasCalledCTor

protected boolean hasCalledCTor

javaObject

public java.lang.Object javaObject

classObject

public java.lang.Class classObject

mgr

protected com.ibm.bsf.BSFManager mgr

componentStarted

protected boolean componentStarted

bsfInitialized

protected static boolean bsfInitialized
Tell if we've already initialized the bsf engine.

m_bsfInitSynch

protected static java.lang.Boolean m_bsfInitSynch
Constructor Detail

XSLTJavaClassEngine

public XSLTJavaClassEngine()
Method Detail

eval

public java.lang.Object eval(java.lang.String source,
                             int lineNo,
                             int columnNo,
                             java.lang.Object oscript)
                      throws org.apache.xalan.xpath.BSFException
This is used by an application to evaluate an object containing some expression - clearly not possible for compiled code ..

call

public java.lang.Object call(java.lang.Object object,
                             java.lang.String method,
                             java.lang.Object[] args)
                      throws org.apache.xalan.xpath.BSFException
call the named method on the object that was loaded by eval. The method selection stuff is very XSLT-specific, hence the custom engine.
Parameters:
object - ignored - should always be null

setScript

public void setScript(java.lang.String lang,
                      java.lang.String srcURL,
                      java.lang.String scriptSrc)
Set the script data for this extension NS. If srcURL is !null then the script body is read from that URL. If not the scriptSrc is used as the src. This method does not actually execute anything - that's done when the component is first hit by the user by an element or a function call.
Specified by:
setScript in interface ExtensionFunctionHandler.ExtensionLiaison
Parameters:
lang - language of the script.
srcURL - value of src attribute (if any) - treated as a URL or a classname depending on the value of lang. If srcURL is not null, then scriptSrc is ignored.
scriptSrc - the actual script code (if any)

callJava

public java.lang.Object callJava(java.lang.Object object,
                                 java.lang.String method,
                                 java.lang.Object[] args,
                                 java.lang.Object methodKey)
                          throws XPathException
call the named method on the object that was loaded by eval. The method selection stuff is very XSLT-specific, hence the custom engine.
Specified by:
callJava in interface ExtensionFunctionHandler.ExtensionLiaison
Parameters:
object - ignored - should always be null

callFunction

public java.lang.Object callFunction(java.lang.String funcName,
                                     java.util.Vector args,
                                     java.lang.Object methodKey,
                                     java.lang.Class javaClass)
                              throws XPathException
Process a call to a function.
Specified by:
callFunction in interface ExtensionFunctionHandler.ExtensionLiaison
Parameters:
funcName - Function name.
args - The arguments of the function call.
Returns:
the return value of the function evaluation.
Throws:
XSLProcessorException - thrown if something goes wrong while running the extension handler.
MalformedURLException - if loading trouble
java.io.FileNotFoundException - if loading trouble
java.io.IOException - if loading trouble
SAXException - if parsing trouble

checkInit

public void checkInit()
               throws XPathProcessorException
Description copied from interface: ExtensionFunctionHandler.ExtensionLiaison
Make sure the component is initialized
Specified by:
checkInit in interface ExtensionFunctionHandler.ExtensionLiaison

startupComponent

public void startupComponent(java.lang.Class classObj)
                      throws XPathProcessorException
Start the component up by executing any script that needs to run at startup time. This needs to happen before any functions can be called on the component.
Specified by:
startupComponent in interface ExtensionFunctionHandler.ExtensionLiaison
Throws:
XPathProcessorException - if something bad happens.

Enhydra 3.1 API