Search in sources :

Example 1 with Hashtable

use of org.apache.xalan.xsltc.runtime.Hashtable in project servicemix-bundles by apache.

the class TemplatesImpl method defineTransletClasses.

/**
 * Defines the translet class and auxiliary classes.
 * Returns a reference to the Class object that defines the main class
 */
private void defineTransletClasses() throws TransformerConfigurationException {
    if (_bytecodes == null) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.NO_TRANSLET_CLASS_ERR);
        throw new TransformerConfigurationException(err.toString());
    }
    TransletClassLoader loader = (TransletClassLoader) AccessController.doPrivileged(new PrivilegedAction() {

        public Object run() {
            return new TransletClassLoader(ObjectFactory.findClassLoader());
        }
    });
    try {
        final int classCount = _bytecodes.length;
        _class = new Class[classCount];
        if (classCount > 1) {
            _auxClasses = new Hashtable();
        }
        for (int i = 0; i < classCount; i++) {
            _class[i] = loader.defineClass(_bytecodes[i]);
            final Class superClass = _class[i].getSuperclass();
            // Check if this is the main class
            if (superClass.getName().equals(ABSTRACT_TRANSLET)) {
                _transletIndex = i;
            } else {
                _auxClasses.put(_class[i].getName(), _class[i]);
            }
        }
        if (_transletIndex < 0) {
            ErrorMsg err = new ErrorMsg(ErrorMsg.NO_MAIN_TRANSLET_ERR, _name);
            throw new TransformerConfigurationException(err.toString());
        }
    } catch (ClassFormatError e) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_CLASS_ERR, _name);
        throw new TransformerConfigurationException(err.toString());
    } catch (LinkageError e) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.TRANSLET_OBJECT_ERR, _name);
        throw new TransformerConfigurationException(err.toString());
    }
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) PrivilegedAction(java.security.PrivilegedAction) Hashtable(org.apache.xalan.xsltc.runtime.Hashtable) ErrorMsg(org.apache.xalan.xsltc.compiler.util.ErrorMsg)

Aggregations

PrivilegedAction (java.security.PrivilegedAction)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 ErrorMsg (org.apache.xalan.xsltc.compiler.util.ErrorMsg)1 Hashtable (org.apache.xalan.xsltc.runtime.Hashtable)1