X4O: Some java cleanup and using new sax parser factory lookup
This commit is contained in:
parent
ec8711df9c
commit
889e4b9eb8
24 changed files with 346 additions and 365 deletions
|
|
@ -33,6 +33,10 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.parsers.SAXParser;
|
||||||
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguage;
|
import org.x4o.xml.lang.DefaultX4OLanguage;
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
|
|
@ -51,10 +55,9 @@ import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
import org.xml.sax.ext.DefaultHandler2;
|
import org.xml.sax.ext.DefaultHandler2;
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4ODriverManager controls all the x4o driver and languages loaded in the classpath.
|
* X4ODriverManager controls all the x4o driver and languages loaded in the class-path.
|
||||||
*
|
*
|
||||||
* @author Willem Cazander
|
* @author Willem Cazander
|
||||||
* @version 1.0 Apr 6, 2013
|
* @version 1.0 Apr 6, 2013
|
||||||
|
|
@ -91,10 +94,6 @@ public final class X4ODriverManager {
|
||||||
languageTasks.put(task.getId(), task);
|
languageTasks.put(task.getId(), task);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new IllegalStateException(e.getMessage(), e);
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new IllegalStateException(e.getMessage(),e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new IllegalStateException(e.getMessage(),e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,12 +127,7 @@ public final class X4ODriverManager {
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
version = driver.getLanguageVersionDefault();
|
version = driver.getLanguageVersionDefault();
|
||||||
}
|
}
|
||||||
DefaultX4OLanguage result = new DefaultX4OLanguage(
|
DefaultX4OLanguage result = new DefaultX4OLanguage(driver.buildLanguageConfiguration(), driver.buildPhaseManager(), driver.getLanguageName(), version);
|
||||||
driver.buildLanguageConfiguration(),
|
|
||||||
driver.buildPhaseManager(),
|
|
||||||
driver.getLanguageName(),
|
|
||||||
version
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
result.getPhaseManager().runPhases(result.createLanguageSession(), X4OPhaseType.INIT); // TODO: fix phase to interface T
|
result.getPhaseManager().runPhases(result.createLanguageSession(), X4OPhaseType.INIT); // TODO: fix phase to interface T
|
||||||
} catch (X4OPhaseException e) {
|
} catch (X4OPhaseException e) {
|
||||||
|
|
@ -149,25 +143,6 @@ public final class X4ODriverManager {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static public void setGlobalProperty(X4ODriver<?> driver,String key,Object value) {
|
|
||||||
Map<String,Object> driverProperties = instance.globalProperties.get(driver.getLanguageName());
|
|
||||||
if (driverProperties==null) {
|
|
||||||
driverProperties = new HashMap<String,Object>(20);
|
|
||||||
instance.globalProperties.put(driver.getLanguageName(), driverProperties);
|
|
||||||
}
|
|
||||||
String keyLimits[] = driver.getGlobalPropertyKeySet();
|
|
||||||
for (int i=0;i<keyLimits.length;i++) {
|
|
||||||
String keyLimit = keyLimits[i];
|
|
||||||
if (keyLimit.equals(key)) {
|
|
||||||
driverProperties.put(key,value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Property with key: "+key+" is protected by key limit.");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static public void registerX4ODriver(X4ODriver<?> driver) {
|
static public void registerX4ODriver(X4ODriver<?> driver) {
|
||||||
if (driver == null) {
|
if (driver == null) {
|
||||||
throw new NullPointerException("Can't register null driver.");
|
throw new NullPointerException("Can't register null driver.");
|
||||||
|
|
@ -246,25 +221,19 @@ public final class X4ODriverManager {
|
||||||
Class<?> driverClass = X4OLanguageClassLoader.loadClass(driverClassName);
|
Class<?> driverClass = X4OLanguageClassLoader.loadClass(driverClassName);
|
||||||
// Constructor<?> markedConstructor = driverClass.getDeclaredConstructor(new Class[]{ConstructorMarker.class});
|
// Constructor<?> markedConstructor = driverClass.getDeclaredConstructor(new Class[]{ConstructorMarker.class});
|
||||||
// X4ODriver<?> driver = (X4ODriver<?>)markedConstructor.newInstance(new Object[]{new ConstructorMarker()});
|
// X4ODriver<?> driver = (X4ODriver<?>)markedConstructor.newInstance(new Object[]{new ConstructorMarker()});
|
||||||
X4ODriver<?> driver = (X4ODriver<?>)driverClass.newInstance();
|
X4ODriver<?> driver = (X4ODriver<?>) X4OLanguageClassLoader.newInstance(driverClass);
|
||||||
registerX4ODriver(driver);
|
registerX4ODriver(driver);
|
||||||
return driver;
|
return driver;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new IllegalStateException(e.getMessage(), e);
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new IllegalStateException(e.getMessage(),e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new IllegalStateException(e.getMessage(),e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class to make sure all driver instances are created by this manager instance.
|
* TODO: Class to make sure all driver instances are created by this manager instance.
|
||||||
|
*
|
||||||
final public class ConstructorMarker {
|
* final public class ConstructorMarker { private ConstructorMarker() { } }
|
||||||
private ConstructorMarker() {
|
*/
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all defined language drivers in classpath.
|
* Loads all defined language drivers in classpath.
|
||||||
|
|
@ -289,21 +258,26 @@ public final class X4ODriverManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser xml inputstream and add into drivers and defaultDrivers lists.
|
* Parser xml inputstream and add into drivers and defaultDrivers lists.
|
||||||
|
*
|
||||||
* @param in The inputstream to parser.
|
* @param in The inputstream to parser.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws SAXException
|
* @throws SAXException
|
||||||
|
* @throws ParserConfigurationException
|
||||||
*/
|
*/
|
||||||
private void loadDriversXml(InputStream in) throws IOException, SAXException {
|
private void loadDriversXml(InputStream in) throws IOException, SAXException, ParserConfigurationException {
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
throw new NullPointerException("Can't parse null input stream");
|
throw new NullPointerException("Can't parse null input stream");
|
||||||
}
|
}
|
||||||
DriversTagHandler xth = new DriversTagHandler();
|
DriversTagHandler xth = new DriversTagHandler();
|
||||||
XMLReader saxParser = XMLReaderFactory.createXMLReader();
|
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
saxParser.setContentHandler(xth);
|
factory.setNamespaceAware(true);
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
SAXParser parser = factory.newSAXParser();
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
XMLReader reader = parser.getXMLReader();
|
||||||
|
reader.setContentHandler(xth);
|
||||||
|
reader.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
||||||
|
reader.setProperty("http://xml.org/sax/properties/declaration-handler", xth);
|
||||||
try {
|
try {
|
||||||
saxParser.parse(new InputSource(in));
|
reader.parse(new InputSource(in));
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class ByteConverter extends AbstractStringObjectConverter {
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return new Byte(str);
|
return Byte.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class CharacterConverter extends AbstractStringObjectConverter {
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return new Character(str.charAt(0));
|
return Character.valueOf(str.charAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class DoubleConverter extends AbstractStringObjectConverter {
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return new Double(str);
|
return Double.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class FloatConverter extends AbstractStringObjectConverter {
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return new Float(str);
|
return Float.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class IntegerConverter extends AbstractStringObjectConverter {
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return new Integer(str);
|
return Integer.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class LongConverter extends AbstractStringObjectConverter {
|
||||||
* @throws ObjectConverterException When conversion fails.
|
* @throws ObjectConverterException When conversion fails.
|
||||||
*/
|
*/
|
||||||
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
public Object convertStringTo(String str, Locale locale) throws ObjectConverterException {
|
||||||
return new Long(str);
|
return Long.valueOf(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ public class X4OExpressionFactory {
|
||||||
ExpressionFactory result = null;
|
ExpressionFactory result = null;
|
||||||
try {
|
try {
|
||||||
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_APACHE);
|
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_APACHE);
|
||||||
result = (ExpressionFactory) expressionFactoryClass.newInstance();
|
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
try {
|
try {
|
||||||
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
Class<?> expressionFactoryClass = X4OLanguageClassLoader.loadClass(EL_FACTORY_IMPL_ODYSSEUS);
|
||||||
result = (ExpressionFactory) expressionFactoryClass.newInstance();
|
result = X4OLanguageClassLoader.newInstance(ExpressionFactory.class, expressionFactoryClass);
|
||||||
} catch (Exception ee) {
|
} catch (ClassNotFoundException ee) {
|
||||||
throw new RuntimeException("Could not load ExpressionFactory tried: "+EL_FACTORY_IMPL_APACHE+" and "+EL_FACTORY_IMPL_ODYSSEUS+" but could not load one of them.");
|
throw new RuntimeException("Could not load ExpressionFactory tried: "+EL_FACTORY_IMPL_APACHE+" and "+EL_FACTORY_IMPL_ODYSSEUS+" but could not load one of them.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,12 +55,10 @@ public class X4OExpressionFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ELContext createELContext(Class<?> elContextClass) {
|
static public ELContext createELContext(Class<?> elContextClass) {
|
||||||
ELContext result = null;
|
|
||||||
try {
|
try {
|
||||||
result = (ELContext)X4OLanguageClassLoader.newInstance(elContextClass);
|
return X4OLanguageClassLoader.newInstance(ELContext.class, elContextClass);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException("Could not create instance of ELContext: "+e.getMessage(),e);
|
throw new RuntimeException("Could not create instance of ELContext: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ import org.xml.sax.SAXException;
|
||||||
*/
|
*/
|
||||||
public class EldModuleLoader implements X4OLanguageModuleLoader {
|
public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
|
|
||||||
private Logger logger = null;
|
private final Logger logger;
|
||||||
private String eldResource = null;
|
private final String eldResource;
|
||||||
private boolean isEldCore = false;
|
private final boolean isEldCore;
|
||||||
|
|
||||||
/** The EL key to access the parent language module. */
|
/** The EL key to access the parent language module. */
|
||||||
public static final String EL_PARENT_LANGUAGE_MODULE = "parentLanguageModule";
|
public static final String EL_PARENT_LANGUAGE_MODULE = "parentLanguageModule";
|
||||||
|
|
@ -68,7 +68,7 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
if (eldResource == null) {
|
if (eldResource == null) {
|
||||||
throw new NullPointerException("Can't load null eld resource.");
|
throw new NullPointerException("Can't load null eld resource.");
|
||||||
}
|
}
|
||||||
logger = Logger.getLogger(EldModuleLoader.class.getName());
|
this.logger = Logger.getLogger(EldModuleLoader.class.getName());
|
||||||
this.eldResource = eldResource;
|
this.eldResource = eldResource;
|
||||||
this.isEldCore = isEldCore;
|
this.isEldCore = isEldCore;
|
||||||
}
|
}
|
||||||
|
|
@ -97,9 +97,7 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
|
||||||
reader.addELBeanInstance(EL_PARENT_LANGUAGE, language);
|
reader.addELBeanInstance(EL_PARENT_LANGUAGE, language);
|
||||||
reader.addELBeanInstance(EL_PARENT_LANGUAGE_MODULE, languageModule);
|
reader.addELBeanInstance(EL_PARENT_LANGUAGE_MODULE, languageModule);
|
||||||
|
|
||||||
//language.createLanguageSession()
|
reader.setProperty(DefaultX4OReader.DEBUG_OUTPUT_HANDLER, null);
|
||||||
|
|
||||||
reader.setProperty(DefaultX4OReader.DEBUG_OUTPUT_HANDLER, reader);
|
|
||||||
|
|
||||||
//TODO: if (language.getLanguageConfiguration().getLanguagePropertyBoolean(X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER)) {
|
//TODO: if (language.getLanguageConfiguration().getLanguagePropertyBoolean(X4OLanguageProperty.DEBUG_OUTPUT_ELD_PARSER)) {
|
||||||
// eldLang.setX4ODebugWriter(elementLanguage.getLanguageConfiguration().getX4ODebugWriter());
|
// eldLang.setX4ODebugWriter(elementLanguage.getLanguageConfiguration().getX4ODebugWriter());
|
||||||
|
|
|
||||||
|
|
@ -210,19 +210,15 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
logger.finer("Creating "+language.getLanguageName()+" namespace.");
|
logger.finer("Creating "+language.getLanguageName()+" namespace.");
|
||||||
ElementNamespace namespace;
|
ElementNamespace namespace;
|
||||||
try {
|
try {
|
||||||
namespace = (ElementNamespace)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementNamespace());
|
namespace = X4OLanguageClassLoader.newInstance(ElementNamespace.class, language.getLanguageConfiguration().getDefaultElementNamespace());
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
namespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)
|
namespace.setElementNamespaceInstanceProvider(
|
||||||
X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())
|
X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, language.getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())
|
||||||
);
|
);
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,15 +232,13 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
|
|
||||||
private ElementClass createElementClass(X4OLanguage language,String tag,Class<?> objectClass,Class<?> elementClass,String description) throws X4OLanguageModuleLoaderException {
|
private ElementClass createElementClass(X4OLanguage language,String tag,Class<?> objectClass,Class<?> elementClass,String description) throws X4OLanguageModuleLoaderException {
|
||||||
try {
|
try {
|
||||||
ElementClass result = (ElementClass)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementClass());
|
ElementClass result = X4OLanguageClassLoader.newInstance(ElementClass.class, language.getLanguageConfiguration().getDefaultElementClass());
|
||||||
result.setId(tag);
|
result.setId(tag);
|
||||||
result.setObjectClass(objectClass);
|
result.setObjectClass(objectClass);
|
||||||
result.setElementClass(elementClass);
|
result.setElementClass(elementClass);
|
||||||
result.setDescription(description);
|
result.setDescription(description);
|
||||||
return result;
|
return result;
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +254,7 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
*/
|
*/
|
||||||
private ElementClassAttribute createElementClassAttribute(X4OLanguage language,String name,boolean required,ObjectConverter converter) throws X4OLanguageModuleLoaderException {
|
private ElementClassAttribute createElementClassAttribute(X4OLanguage language,String name,boolean required,ObjectConverter converter) throws X4OLanguageModuleLoaderException {
|
||||||
try {
|
try {
|
||||||
ElementClassAttribute result = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
ElementClassAttribute result = X4OLanguageClassLoader.newInstance(ElementClassAttribute.class, language.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||||
result.setId(name);
|
result.setId(name);
|
||||||
if (required) {
|
if (required) {
|
||||||
result.setRequired(required);
|
result.setRequired(required);
|
||||||
|
|
@ -269,9 +263,7 @@ public class EldModuleLoaderCore implements X4OLanguageModuleLoader {
|
||||||
result.setObjectConverter(converter);
|
result.setObjectConverter(converter);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
throw new X4OLanguageModuleLoaderException(this,e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class BeanElement extends AbstractElement {
|
||||||
try {
|
try {
|
||||||
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
Class<?> beanClass = X4OLanguageClassLoader.loadClass(className);
|
||||||
if (constructorArguments.isEmpty()) {
|
if (constructorArguments.isEmpty()) {
|
||||||
setElementObject(beanClass.newInstance());
|
setElementObject(X4OLanguageClassLoader.newInstance(beanClass));
|
||||||
} else {
|
} else {
|
||||||
Class<?>[] arguClass = new Class<?>[constructorArguments.size()];
|
Class<?>[] arguClass = new Class<?>[constructorArguments.size()];
|
||||||
constructorArguments.toArray(arguClass);
|
constructorArguments.toArray(arguClass);
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,8 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
elementNamespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
elementNamespace.setElementNamespaceInstanceProvider(X4OLanguageClassLoader.newInstance(ElementNamespaceInstanceProvider.class, childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -132,10 +132,10 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doCharacters(String characters) throws ElementException {
|
public void doCharacters(String characters) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
|
||||||
e.setElementObject(characters);
|
e.setElementObject(characters);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (Exception exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
throw new ElementException(exception);
|
throw new ElementException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -145,10 +145,10 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doComment(String comment) throws ElementException {
|
public void doComment(String comment) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
|
||||||
e.setElementObject(comment);
|
e.setElementObject(comment);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (Exception exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
throw new ElementException(exception);
|
throw new ElementException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -158,10 +158,10 @@ public abstract class AbstractElement implements Element {
|
||||||
*/
|
*/
|
||||||
public void doIgnorableWhitespace(String space) throws ElementException {
|
public void doIgnorableWhitespace(String space) throws ElementException {
|
||||||
try {
|
try {
|
||||||
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
Element e = X4OLanguageClassLoader.newInstance(Element.class, getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
|
||||||
e.setElementObject(space);
|
e.setElementObject(space);
|
||||||
addChild(e);
|
addChild(e);
|
||||||
} catch (Exception exception) {
|
} catch (ClassNotFoundException exception) {
|
||||||
throw new ElementException(exception);
|
throw new ElementException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,13 +86,9 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
|
||||||
if (elementClass.getObjectClass()!=null) {
|
if (elementClass.getObjectClass()!=null) {
|
||||||
element.setElementObject(X4OLanguageClassLoader.newInstance(elementClass.getObjectClass()));
|
element.setElementObject(X4OLanguageClassLoader.newInstance(elementClass.getObjectClass()));
|
||||||
}
|
}
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
|
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
|
||||||
} catch (IllegalAccessException e) {
|
}
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
|
|
||||||
} /*catch (ClassNotFoundException e) {
|
|
||||||
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
|
|
||||||
} */
|
|
||||||
element.setElementClass(elementClass);
|
element.setElementClass(elementClass);
|
||||||
element.setLanguageSession(languageSession);
|
element.setLanguageSession(languageSession);
|
||||||
return element;
|
return element;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
import org.x4o.xml.element.Element;
|
import org.x4o.xml.element.Element;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
|
import org.x4o.xml.lang.X4OLanguageClassLoader;
|
||||||
import org.x4o.xml.lang.X4OLanguageSession;
|
import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
|
@ -49,10 +50,8 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterSession<T> i
|
||||||
X4OLanguageSession context = createLanguageSession();
|
X4OLanguageSession context = createLanguageSession();
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
try {
|
try {
|
||||||
rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance();
|
rootElement = X4OLanguageClassLoader.newInstance(Element.class, context.getLanguage().getLanguageConfiguration().getDefaultElement());
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new SAXException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new SAXException(e);
|
throw new SAXException(e);
|
||||||
}
|
}
|
||||||
rootElement.setElementObject(object);
|
rootElement.setElementObject(object);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ import org.x4o.sax3.io.SAX3PropertyConfig.PropertyConfigItem;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
import org.x4o.xml.lang.X4OLanguage;
|
||||||
import org.x4o.xml.lang.X4OLanguageSession;
|
import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
import org.x4o.xml.lang.X4OLanguageSessionLocal;
|
import org.x4o.xml.lang.X4OLanguageSessionLocal;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseException;
|
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseType;
|
import org.x4o.xml.lang.phase.X4OPhaseType;
|
||||||
import org.xml.sax.EntityResolver;
|
import org.xml.sax.EntityResolver;
|
||||||
import org.xml.sax.ErrorHandler;
|
import org.xml.sax.ErrorHandler;
|
||||||
|
|
|
||||||
|
|
@ -64,11 +64,12 @@ import org.xml.sax.helpers.AttributesImpl;
|
||||||
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
|
|
||||||
private final SAX3PropertyConfig propertyConfig;
|
private final SAX3PropertyConfig propertyConfig;
|
||||||
|
private boolean schemaUriPrint;
|
||||||
|
private String schemaUriRoot;
|
||||||
|
|
||||||
|
private final static AttributeEntryComparator ATTR_ENTRY_COMPARATOR = new AttributeEntryComparator();
|
||||||
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
private final static String PROPERTY_CONTEXT_PREFIX = SAX3PropertyConfig.X4O_PROPERTIES_PREFIX+"writer/x4o/";
|
||||||
|
|
||||||
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
public final static SAX3PropertyConfig DEFAULT_PROPERTY_CONFIG;
|
||||||
|
|
||||||
public final static String OUTPUT_STREAM = PROPERTY_CONTEXT_PREFIX+"output/stream";
|
public final static String OUTPUT_STREAM = PROPERTY_CONTEXT_PREFIX+"output/stream";
|
||||||
public final static String OUTPUT_XDBX = PROPERTY_CONTEXT_PREFIX+"output/xdbx";
|
public final static String OUTPUT_XDBX = PROPERTY_CONTEXT_PREFIX+"output/xdbx";
|
||||||
public final static String SCHEMA_PRINT = PROPERTY_CONTEXT_PREFIX+"schema/print";
|
public final static String SCHEMA_PRINT = PROPERTY_CONTEXT_PREFIX+"schema/print";
|
||||||
|
|
@ -120,18 +121,15 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
runWrite(languageSession);
|
runWrite(languageSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AttributeEntryComparator attributeEntryComparator = new AttributeEntryComparator();
|
|
||||||
private boolean schemaUriPrint;
|
|
||||||
private String schemaUriRoot;
|
|
||||||
|
|
||||||
private void runWrite(X4OLanguageSession languageSession) throws X4OConnectionException {
|
private void runWrite(X4OLanguageSession languageSession) throws X4OConnectionException {
|
||||||
OutputStream out = (OutputStream)getProperty(OUTPUT_STREAM);
|
OutputStream out = (OutputStream)getProperty(OUTPUT_STREAM);
|
||||||
try {
|
try {
|
||||||
String encoding = getPropertyConfig().getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
String encoding = getPropertyConfig().getPropertyString(SAX3WriterXml.OUTPUT_ENCODING);
|
||||||
schemaUriPrint = getPropertyConfig().getPropertyBoolean(SCHEMA_PRINT);
|
schemaUriPrint = getPropertyConfig().getPropertyBoolean(SCHEMA_PRINT);
|
||||||
schemaUriRoot = getPropertyConfig().getPropertyString(SCHEMA_ROOT_URI);
|
schemaUriRoot = getPropertyConfig().getPropertyString(SCHEMA_ROOT_URI);
|
||||||
if (encoding==null) { encoding = SAX3XMLConstants.XML_DEFAULT_ENCODING; }
|
if (encoding == null) {
|
||||||
|
encoding = SAX3XMLConstants.XML_DEFAULT_ENCODING;
|
||||||
|
}
|
||||||
Element root = languageSession.getRootElement();
|
Element root = languageSession.getRootElement();
|
||||||
if (schemaUriRoot == null) {
|
if (schemaUriRoot == null) {
|
||||||
String rootUri = findElementUri(root);
|
String rootUri = findElementUri(root);
|
||||||
|
|
@ -153,7 +151,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
}
|
}
|
||||||
writer.startDocument();
|
writer.startDocument();
|
||||||
|
|
||||||
Map<String,String> prefixes = new HashMap<String,String>();
|
Map<String, String> prefixes = new HashMap<>();
|
||||||
startPrefixTree(root,prefixes);
|
startPrefixTree(root,prefixes);
|
||||||
for (String uri : prefixes.keySet()) {
|
for (String uri : prefixes.keySet()) {
|
||||||
String prefix = prefixes.get(uri);
|
String prefix = prefixes.get(uri);
|
||||||
|
|
@ -208,20 +206,30 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
}
|
}
|
||||||
String name = m.getName().substring(3, 4).toLowerCase() + m.getName().substring(4);
|
String name = m.getName().substring(3, 4).toLowerCase() + m.getName().substring(4);
|
||||||
result.add(name);
|
result.add(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
class AttributeEntry {
|
|
||||||
String id;
|
static final class AttributeEntry {
|
||||||
String value;
|
final String id;
|
||||||
Integer writeOrder;
|
final String value;
|
||||||
|
final Integer writeOrder;
|
||||||
|
|
||||||
|
public AttributeEntry(String id, String value, Integer writeOrder) {
|
||||||
|
this.id = id;
|
||||||
|
this.value = value;
|
||||||
|
this.writeOrder = writeOrder;
|
||||||
}
|
}
|
||||||
class AttributeEntryComparator implements Comparator<AttributeEntry> {
|
}
|
||||||
|
|
||||||
|
static final class AttributeEntryComparator implements Comparator<AttributeEntry> {
|
||||||
|
|
||||||
|
@Override
|
||||||
public int compare(AttributeEntry o1, AttributeEntry o2) {
|
public int compare(AttributeEntry o1, AttributeEntry o2) {
|
||||||
return o1.writeOrder.compareTo(o2.writeOrder);
|
return o1.writeOrder.compareTo(o2.writeOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeTree(ContentWriter writer, Element element, boolean isRoot) throws SAXException, ElementObjectPropertyValueException {
|
private void writeTree(ContentWriter writer, Element element, boolean isRoot) throws SAXException, ElementObjectPropertyValueException {
|
||||||
List<AttributeEntry> attr = new ArrayList<AttributeEntry>(20);
|
List<AttributeEntry> attr = new ArrayList<AttributeEntry>(20);
|
||||||
if (element.getElementClass().getAutoAttributes() != null && element.getElementClass().getAutoAttributes() == false) {
|
if (element.getElementClass().getAutoAttributes() != null && element.getElementClass().getAutoAttributes() == false) {
|
||||||
|
|
@ -229,15 +237,11 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
if (eca.getRunBeanValue() != null && eca.getRunBeanValue() == false) {
|
if (eca.getRunBeanValue() != null && eca.getRunBeanValue() == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object value = element.getLanguageSession().getElementObjectPropertyValue().getProperty(element.getElementObject(), eca.getId());
|
Object value = element.getLanguageSession().getElementObjectPropertyValue().getProperty(element.getElementObject(), eca.getId());
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AttributeEntry e = new AttributeEntry();
|
AttributeEntry e = new AttributeEntry(eca.getId(), ""+value, calcOrderNumber(eca.getId(),eca.getWriteOrder()));
|
||||||
e.id = eca.getId();
|
|
||||||
e.value = ""+value;
|
|
||||||
e.writeOrder = calcOrderNumber(e.id,eca.getWriteOrder());
|
|
||||||
attr.add(e);
|
attr.add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,10 +278,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
if (value instanceof List || value instanceof Collection) {
|
if (value instanceof List || value instanceof Collection) {
|
||||||
continue; // TODO; filter on type of childeren
|
continue; // TODO; filter on type of childeren
|
||||||
}
|
}
|
||||||
AttributeEntry e = new AttributeEntry();
|
AttributeEntry e = new AttributeEntry(p, ""+value, calcOrderNumber(p,writeOrder));
|
||||||
e.id = p;
|
|
||||||
e.value = ""+value;
|
|
||||||
e.writeOrder = calcOrderNumber(e.id,writeOrder);
|
|
||||||
attr.add(e);
|
attr.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +292,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort attributes in natural order of localName and add to attributes
|
// Sort attributes in natural order of localName and add to attributes
|
||||||
Collections.sort(attr, attributeEntryComparator);
|
Collections.sort(attr, ATTR_ENTRY_COMPARATOR);
|
||||||
for (int i = 0; i < attr.size(); i++) {
|
for (int i = 0; i < attr.size(); i++) {
|
||||||
AttributeEntry a = attr.get(i);
|
AttributeEntry a = attr.get(i);
|
||||||
atts.addAttribute ("", a.id, "", "", a.value);
|
atts.addAttribute ("", a.id, "", "", a.value);
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import org.x4o.xml.lang.X4OLanguageSession;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
@ -38,6 +37,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.parsers.SAXParser;
|
||||||
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X4OContentParser Runs the SAX parser with the X4OContentHandler.
|
* X4OContentParser Runs the SAX parser with the X4OContentHandler.
|
||||||
*
|
*
|
||||||
|
|
@ -56,7 +59,7 @@ public class X4OContentParser {
|
||||||
return propertyConfig;
|
return propertyConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parse(X4OLanguageSession languageSession) throws SAXException, IOException {
|
public void parse(X4OLanguageSession languageSession) throws SAXException, IOException, ParserConfigurationException {
|
||||||
// Group debug config property messages
|
// Group debug config property messages
|
||||||
if (languageSession.hasX4ODebugWriter()) {
|
if (languageSession.hasX4ODebugWriter()) {
|
||||||
languageSession.getX4ODebugWriter().debugSAXConfigStart();
|
languageSession.getX4ODebugWriter().debugSAXConfigStart();
|
||||||
|
|
@ -70,7 +73,7 @@ public class X4OContentParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseSax(X4OLanguageSession languageSession) throws SAXException, IOException {
|
private void parseSax(X4OLanguageSession languageSession) throws SAXException, IOException, ParserConfigurationException {
|
||||||
// If xsd caching is needed this should be the way
|
// If xsd caching is needed this should be the way
|
||||||
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
|
||||||
//config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
//config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",myFullGrammarPool);
|
||||||
|
|
@ -78,19 +81,22 @@ public class X4OContentParser {
|
||||||
|
|
||||||
// Create Sax parser with x4o tag handler
|
// Create Sax parser with x4o tag handler
|
||||||
X4OContentHandler xth = new X4OContentHandler(languageSession,getPropertyConfig());
|
X4OContentHandler xth = new X4OContentHandler(languageSession,getPropertyConfig());
|
||||||
XMLReader saxParser = XMLReaderFactory.createXMLReader();
|
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
saxParser.setErrorHandler(new X4OErrorHandler(languageSession,getPropertyConfig()));
|
factory.setNamespaceAware(true);
|
||||||
saxParser.setEntityResolver(new X4OEntityResolver(languageSession,getPropertyConfig()));
|
SAXParser parser = factory.newSAXParser();
|
||||||
saxParser.setContentHandler(xth);
|
XMLReader reader = parser.getXMLReader();
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
reader.setErrorHandler(new X4OErrorHandler(languageSession,getPropertyConfig()));
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
reader.setEntityResolver(new X4OEntityResolver(languageSession,getPropertyConfig()));
|
||||||
|
reader.setContentHandler(xth);
|
||||||
|
reader.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
||||||
|
reader.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
||||||
|
|
||||||
// Set properties and optional
|
// Set properties and optional
|
||||||
Map<String,Object> saxParserProperties = getSAXParserProperties(languageSession);
|
Map<String,Object> saxParserProperties = getSAXParserProperties(languageSession);
|
||||||
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
|
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
Object value= entry.getValue();
|
Object value= entry.getValue();
|
||||||
saxParser.setProperty(name, value);
|
reader.setProperty(name, value);
|
||||||
debugMessage("property",name,value,languageSession);
|
debugMessage("property",name,value,languageSession);
|
||||||
}
|
}
|
||||||
Map<String,Object> saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageSession);
|
Map<String,Object> saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageSession);
|
||||||
|
|
@ -98,7 +104,7 @@ public class X4OContentParser {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
Object value= entry.getValue();
|
Object value= entry.getValue();
|
||||||
try {
|
try {
|
||||||
saxParser.setProperty(name, value);
|
reader.setProperty(name, value);
|
||||||
debugMessage("optional-property",name,value,languageSession);
|
debugMessage("optional-property",name,value,languageSession);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
debugMessageLog("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageSession);
|
debugMessageLog("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageSession);
|
||||||
|
|
@ -109,14 +115,14 @@ public class X4OContentParser {
|
||||||
Map<String, Boolean> features = getSAXParserFeatures(languageSession);
|
Map<String, Boolean> features = getSAXParserFeatures(languageSession);
|
||||||
for (String key:features.keySet()) {
|
for (String key:features.keySet()) {
|
||||||
Boolean value=features.get(key);
|
Boolean value=features.get(key);
|
||||||
saxParser.setFeature(key, value);
|
reader.setFeature(key, value);
|
||||||
debugMessage("feature",key,value,languageSession);
|
debugMessage("feature",key,value,languageSession);
|
||||||
}
|
}
|
||||||
Map<String, Boolean> featuresOptional = getSAXParserFeaturesOptional(languageSession);
|
Map<String, Boolean> featuresOptional = getSAXParserFeaturesOptional(languageSession);
|
||||||
for (String key:featuresOptional.keySet()) {
|
for (String key:featuresOptional.keySet()) {
|
||||||
Boolean value=featuresOptional.get(key);
|
Boolean value=featuresOptional.get(key);
|
||||||
try {
|
try {
|
||||||
saxParser.setFeature(key, value);
|
reader.setFeature(key, value);
|
||||||
debugMessage("optional-feature",key,value,languageSession);
|
debugMessage("optional-feature",key,value,languageSession);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
debugMessageLog("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageSession);
|
debugMessageLog("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageSession);
|
||||||
|
|
@ -126,7 +132,7 @@ public class X4OContentParser {
|
||||||
// check for required features
|
// check for required features
|
||||||
List<String> requiredFeatures = getSAXParserFeaturesRequired(languageSession);
|
List<String> requiredFeatures = getSAXParserFeaturesRequired(languageSession);
|
||||||
for (String requiredFeature:requiredFeatures) {
|
for (String requiredFeature:requiredFeatures) {
|
||||||
if (saxParser.getFeature(requiredFeature)==false) {
|
if (reader.getFeature(requiredFeature)==false) {
|
||||||
throw new IllegalStateException("Missing required feature: "+requiredFeature);
|
throw new IllegalStateException("Missing required feature: "+requiredFeature);
|
||||||
}
|
}
|
||||||
debugMessage("required",requiredFeature,"true",languageSession);
|
debugMessage("required",requiredFeature,"true",languageSession);
|
||||||
|
|
@ -153,7 +159,7 @@ public class X4OContentParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
saxParser.parse(input);
|
reader.parse(input);
|
||||||
} finally {
|
} finally {
|
||||||
if (inputStream!=null) {
|
if (inputStream!=null) {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ public class X4ODebugWriter {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("0x");
|
buf.append("0x");
|
||||||
for (char c:newline.toCharArray()) {
|
for (char c:newline.toCharArray()) {
|
||||||
Integer i = new Integer(c);
|
Integer i = Integer.valueOf(c);
|
||||||
if (i<16) {
|
if (i<16) {
|
||||||
buf.append('0');
|
buf.append('0');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,13 @@ import org.x4o.xml.lang.phase.X4OPhaseManager;
|
||||||
*/
|
*/
|
||||||
public class DefaultX4OLanguage implements X4OLanguageLocal {
|
public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
|
|
||||||
private Logger logger = null;
|
private final Logger logger;
|
||||||
private X4OLanguageConfiguration languageConfiguration = null;
|
private final X4OLanguageConfiguration languageConfiguration;
|
||||||
private List<X4OLanguageModule> elementLanguageModules = null;
|
private final List<X4OLanguageModule> elementLanguageModules;
|
||||||
private String languageName = null;
|
private final String languageName;
|
||||||
private String languageVersion = null;
|
private final String languageVersion;
|
||||||
private X4OPhaseManager phaseManager = null;
|
private final X4OPhaseManager phaseManager;
|
||||||
private Map<String,ElementNamespace> keyedNamespaceLookup = null;
|
private final Map<String, ElementNamespace> keyedNamespaceLookup;
|
||||||
|
|
||||||
public DefaultX4OLanguage(X4OLanguageConfiguration languageConfiguration, X4OPhaseManager phaseManager, String languageName, String languageVersion) {
|
public DefaultX4OLanguage(X4OLanguageConfiguration languageConfiguration, X4OPhaseManager phaseManager, String languageName, String languageVersion) {
|
||||||
if (languageName == null) {
|
if (languageName == null) {
|
||||||
|
|
@ -63,9 +63,9 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
if (languageVersion == null) {
|
if (languageVersion == null) {
|
||||||
throw new NullPointerException("Can't define myself with null version.");
|
throw new NullPointerException("Can't define myself with null version.");
|
||||||
}
|
}
|
||||||
logger = Logger.getLogger(DefaultX4OLanguage.class.getName());
|
this.logger = Logger.getLogger(DefaultX4OLanguage.class.getName());
|
||||||
elementLanguageModules = new ArrayList<X4OLanguageModule>(20);
|
this.elementLanguageModules = new ArrayList<X4OLanguageModule>(20);
|
||||||
keyedNamespaceLookup = new HashMap<String,ElementNamespace>(20);
|
this.keyedNamespaceLookup = new HashMap<String, ElementNamespace>(20);
|
||||||
this.languageConfiguration = languageConfiguration;
|
this.languageConfiguration = languageConfiguration;
|
||||||
this.languageName = languageName;
|
this.languageName = languageName;
|
||||||
this.languageVersion = languageVersion;
|
this.languageVersion = languageVersion;
|
||||||
|
|
@ -113,7 +113,6 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elementLanguageModules.add(elementLanguageModule);
|
elementLanguageModules.add(elementLanguageModule);
|
||||||
|
|
||||||
for (ElementNamespace ns : elementLanguageModule.getElementNamespaces()) {
|
for (ElementNamespace ns : elementLanguageModule.getElementNamespaces()) {
|
||||||
keyedNamespaceLookup.put(ns.getUri(), ns);
|
keyedNamespaceLookup.put(ns.getUri(), ns);
|
||||||
}
|
}
|
||||||
|
|
@ -140,15 +139,18 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
languageSession.setExpressionLanguageFactory(X4OExpressionFactory.createExpressionFactory());
|
languageSession.setExpressionLanguageFactory(X4OExpressionFactory.createExpressionFactory());
|
||||||
}
|
}
|
||||||
if (languageSession.getExpressionLanguageContext() == null) {
|
if (languageSession.getExpressionLanguageContext() == null) {
|
||||||
languageSession.setExpressionLanguageContext(X4OExpressionFactory.createELContext(languageSession.getLanguage().getLanguageConfiguration().getDefaultExpressionLanguageContext()));
|
languageSession.setExpressionLanguageContext(
|
||||||
|
X4OExpressionFactory.createELContext(languageSession.getLanguage().getLanguageConfiguration().getDefaultExpressionLanguageContext()));
|
||||||
}
|
}
|
||||||
if (languageSession.getElementAttributeValueParser() == null) {
|
if (languageSession.getElementAttributeValueParser() == null) {
|
||||||
languageSession.setElementAttributeValueParser((ElementAttributeValueParser)X4OLanguageClassLoader.newInstance(getLanguageConfiguration().getDefaultElementAttributeValueParser()));
|
languageSession.setElementAttributeValueParser(X4OLanguageClassLoader.newInstance(ElementAttributeValueParser.class,
|
||||||
|
getLanguageConfiguration().getDefaultElementAttributeValueParser()));
|
||||||
}
|
}
|
||||||
if (languageSession.getElementObjectPropertyValue() == null) {
|
if (languageSession.getElementObjectPropertyValue() == null) {
|
||||||
languageSession.setElementObjectPropertyValue((ElementObjectPropertyValue)X4OLanguageClassLoader.newInstance(getLanguageConfiguration().getDefaultElementObjectPropertyValue()));
|
languageSession.setElementObjectPropertyValue(X4OLanguageClassLoader.newInstance(ElementObjectPropertyValue.class,
|
||||||
|
getLanguageConfiguration().getDefaultElementObjectPropertyValue()));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return languageSession;
|
return languageSession;
|
||||||
|
|
@ -198,7 +200,8 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findElementBindingHandlerInList(Object parent,Object child,List<ElementBindingHandler> result,List<ElementBindingHandler> checkList,boolean checkChild) {
|
private void findElementBindingHandlerInList(Object parent, Object child, List<ElementBindingHandler> result, List<ElementBindingHandler> checkList,
|
||||||
|
boolean checkChild) {
|
||||||
for (ElementBindingHandler binding : checkList) {
|
for (ElementBindingHandler binding : checkList) {
|
||||||
boolean parentBind = false;
|
boolean parentBind = false;
|
||||||
if (parent instanceof Class) {
|
if (parent instanceof Class) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.parsers.SAXParser;
|
||||||
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
import org.x4o.xml.eld.EldDriver;
|
import org.x4o.xml.eld.EldDriver;
|
||||||
import org.x4o.xml.eld.EldModuleLoader;
|
import org.x4o.xml.eld.EldModuleLoader;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseLanguageInit;
|
import org.x4o.xml.lang.phase.X4OPhaseLanguageInit;
|
||||||
|
|
@ -40,7 +44,6 @@ import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
import org.xml.sax.ext.DefaultHandler2;
|
import org.xml.sax.ext.DefaultHandler2;
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefaultX4OLanguageLoader loads the modules of language.
|
* DefaultX4OLanguageLoader loads the modules of language.
|
||||||
|
|
@ -101,7 +104,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
}
|
}
|
||||||
for (String value:versionedResources.moduleLoaders) {
|
for (String value:versionedResources.moduleLoaders) {
|
||||||
try {
|
try {
|
||||||
loader = (X4OLanguageModuleLoader)X4OLanguageClassLoader.loadClass(value).newInstance();
|
loader = (X4OLanguageModuleLoader)X4OLanguageClassLoader.newInstance(value);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
throw new X4OLanguageLoaderException("Could not load class: "+value+" error: "+ee.getMessage(),ee);
|
throw new X4OLanguageLoaderException("Could not load class: "+value+" error: "+ee.getMessage(),ee);
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +112,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
}
|
}
|
||||||
for (String value:versionedResources.siblingLoaders) {
|
for (String value:versionedResources.siblingLoaders) {
|
||||||
try {
|
try {
|
||||||
loader = (X4OLanguageModuleLoader)X4OLanguageClassLoader.loadClass(value).newInstance();
|
loader = (X4OLanguageModuleLoader)X4OLanguageClassLoader.newInstance(value);
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
throw new X4OLanguageLoaderException("Could not load class: "+value+" error: "+ee.getMessage(),ee);
|
throw new X4OLanguageLoaderException("Could not load class: "+value+" error: "+ee.getMessage(),ee);
|
||||||
}
|
}
|
||||||
|
|
@ -135,10 +138,8 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
List<VersionedResources> result = new ArrayList<VersionedResources>(resources.size());
|
List<VersionedResources> result = new ArrayList<VersionedResources>(resources.size());
|
||||||
X4OLanguageVersionFilter lvf;
|
X4OLanguageVersionFilter lvf;
|
||||||
try {
|
try {
|
||||||
lvf = (X4OLanguageVersionFilter)X4OLanguageClassLoader.newInstance(languageLocal.getLanguageConfiguration().getDefaultLanguageVersionFilter());
|
lvf = X4OLanguageClassLoader.newInstance(X4OLanguageVersionFilter.class, languageLocal.getLanguageConfiguration().getDefaultLanguageVersionFilter());
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageLoaderException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new X4OLanguageLoaderException(e);
|
throw new X4OLanguageLoaderException(e);
|
||||||
}
|
}
|
||||||
for (VersionedResources versionedResources:resources) {
|
for (VersionedResources versionedResources:resources) {
|
||||||
|
|
@ -178,10 +179,8 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
private void loadModule(X4OLanguageLocal languageLocal,X4OLanguageModuleLoader loader,String resource,VersionedResources versionedResources) throws X4OLanguageLoaderException {
|
private void loadModule(X4OLanguageLocal languageLocal,X4OLanguageModuleLoader loader,String resource,VersionedResources versionedResources) throws X4OLanguageLoaderException {
|
||||||
X4OLanguageModuleLocal module;
|
X4OLanguageModuleLocal module;
|
||||||
try {
|
try {
|
||||||
module = (X4OLanguageModuleLocal)X4OLanguageClassLoader.newInstance(languageLocal.getLanguageConfiguration().getDefaultElementLanguageModule());
|
module = X4OLanguageClassLoader.newInstance(X4OLanguageModuleLocal.class, languageLocal.getLanguageConfiguration().getDefaultElementLanguageModule());
|
||||||
} catch (InstantiationException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OLanguageLoaderException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new X4OLanguageLoaderException(e);
|
throw new X4OLanguageLoaderException(e);
|
||||||
}
|
}
|
||||||
logMessage(languageLocal,"Created module: "+module);
|
logMessage(languageLocal,"Created module: "+module);
|
||||||
|
|
@ -236,9 +235,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
result.addAll(loadLanguageModulesXml(u.openStream(),u.toString()));
|
result.addAll(loadLanguageModulesXml(u.openStream(),u.toString()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (IOException e) {
|
} catch (IOException | SAXException | ParserConfigurationException e) {
|
||||||
throw new X4OLanguageLoaderException(e);
|
|
||||||
} catch (SAXException e) {
|
|
||||||
throw new X4OLanguageLoaderException(e);
|
throw new X4OLanguageLoaderException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -248,18 +245,22 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
||||||
* @param in The inputstream to parser.
|
* @param in The inputstream to parser.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws SAXException
|
* @throws SAXException
|
||||||
|
* @throws ParserConfigurationException
|
||||||
*/
|
*/
|
||||||
protected List<VersionedResources> loadLanguageModulesXml(InputStream in,String loadedFrom) throws IOException, SAXException {
|
protected List<VersionedResources> loadLanguageModulesXml(InputStream in,String loadedFrom) throws IOException, SAXException, ParserConfigurationException {
|
||||||
if (in==null) {
|
if (in==null) {
|
||||||
throw new NullPointerException("Can't parse null input stream");
|
throw new NullPointerException("Can't parse null input stream");
|
||||||
}
|
}
|
||||||
ModulesTagHandler xth = new ModulesTagHandler(loadedFrom);
|
ModulesTagHandler xth = new ModulesTagHandler(loadedFrom);
|
||||||
XMLReader saxParser = XMLReaderFactory.createXMLReader();
|
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||||
saxParser.setContentHandler(xth);
|
factory.setNamespaceAware(true);
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
SAXParser parser = factory.newSAXParser();
|
||||||
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
XMLReader reader = parser.getXMLReader();
|
||||||
|
reader.setContentHandler(xth);
|
||||||
|
reader.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
|
||||||
|
reader.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
|
||||||
try {
|
try {
|
||||||
saxParser.parse(new InputSource(in));
|
reader.parse(new InputSource(in));
|
||||||
return xth.getResult();
|
return xth.getResult();
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
package org.x4o.xml.lang;
|
package org.x4o.xml.lang;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -65,24 +66,37 @@ public final class X4OLanguageClassLoader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new instance of clazz.
|
* Creates new instance of clazz.
|
||||||
|
* @param resultType The result type to cast to..
|
||||||
* @param clazz The class to make object from.
|
* @param clazz The class to make object from.
|
||||||
* @return The object of the clazz.
|
* @return The object of the clazz.
|
||||||
* @throws InstantiationException When className has no default constructor.
|
* @throws ClassNotFoundException On any construct access or invoke error.
|
||||||
* @throws IllegalAccessException When class loading has security error.
|
|
||||||
*/
|
*/
|
||||||
public static Object newInstance(Class<?> clazz) throws InstantiationException, IllegalAccessException {
|
@SuppressWarnings("unchecked")
|
||||||
return clazz.newInstance();
|
public static <T> T newInstance(Class<T> resultType, Class<?> clazz) throws ClassNotFoundException {
|
||||||
|
return (T) newInstance(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new instance of clazz.
|
||||||
|
* @param clazz The class to make object from.
|
||||||
|
* @return The object of the clazz.
|
||||||
|
* @throws ClassNotFoundException On any construct access or invoke error.
|
||||||
|
*/
|
||||||
|
public static Object newInstance(Class<?> clazz) throws ClassNotFoundException {
|
||||||
|
try {
|
||||||
|
return clazz.getConstructor().newInstance();
|
||||||
|
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException e) {
|
||||||
|
throw new ClassNotFoundException(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new instance of className.
|
* Creates new instance of className.
|
||||||
* @param className The className to create object from.
|
* @param className The className to create object from.
|
||||||
* @return The object of the className.
|
* @return The object of the className.
|
||||||
* @throws ClassNotFoundException When className is not found.
|
* @throws ClassNotFoundException When className is not found or can't be created.
|
||||||
* @throws InstantiationException When className has no default constructor.
|
|
||||||
* @throws IllegalAccessException When class loading has security error.
|
|
||||||
*/
|
*/
|
||||||
public static Object newInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
public static Object newInstance(String className) throws ClassNotFoundException {
|
||||||
return newInstance(loadClass(className));
|
return newInstance(loadClass(className));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ public class X4OPhaseLanguageInit {
|
||||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||||
try {
|
try {
|
||||||
//debugPhaseMessage("Loading main language: "+elementLanguage.getLanguage(),this,elementLanguage);
|
//debugPhaseMessage("Loading main language: "+elementLanguage.getLanguage(),this,elementLanguage);
|
||||||
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
X4OLanguageLoader loader = X4OLanguageClassLoader.newInstance(X4OLanguageLoader.class, languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||||
loader.loadLanguage((X4OLanguageLocal)languageSession.getLanguage(),languageSession.getLanguage().getLanguageName(),languageSession.getLanguage().getLanguageVersion());
|
loader.loadLanguage((X4OLanguageLocal)languageSession.getLanguage(),languageSession.getLanguage().getLanguageName(),languageSession.getLanguage().getLanguageVersion());
|
||||||
|
|
||||||
if (languageSession.hasX4ODebugWriter()) {
|
if (languageSession.hasX4ODebugWriter()) {
|
||||||
|
|
@ -141,7 +141,7 @@ public class X4OPhaseLanguageInit {
|
||||||
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
|
||||||
try {
|
try {
|
||||||
if (siblingLoaders.isEmpty()==false) {
|
if (siblingLoaders.isEmpty()==false) {
|
||||||
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
X4OLanguageLoader loader = X4OLanguageClassLoader.newInstance(X4OLanguageLoader.class, languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
|
||||||
for (X4OLanguageModuleLoaderSibling siblingLoader:siblingLoaders) {
|
for (X4OLanguageModuleLoaderSibling siblingLoader:siblingLoaders) {
|
||||||
//debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage);
|
//debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage);
|
||||||
siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageSession.getLanguage(), loader);
|
siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageSession.getLanguage(), loader);
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ public class X4OPhaseLanguageRead {
|
||||||
if (elementNamespaceAttributeComparator==null) {
|
if (elementNamespaceAttributeComparator==null) {
|
||||||
try {
|
try {
|
||||||
elementNamespaceAttributeComparator = (Comparator<ElementNamespaceAttribute>)X4OLanguageClassLoader.newInstance(element.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceAttributeComparator());
|
elementNamespaceAttributeComparator = (Comparator<ElementNamespaceAttribute>)X4OLanguageClassLoader.newInstance(element.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceAttributeComparator());
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new X4OPhaseException(this,e);
|
throw new X4OPhaseException(this,e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue