From 4e9052244c075b71dcbc5e93ce9a77c536388dd3 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Sat, 24 Aug 2013 19:30:58 +0200 Subject: [PATCH] Renamed X4OLanguageContext to X4OLanguageSession --- .../src/main/java/org/x4o/xml/X4ODriver.java | 16 +-- .../java/org/x4o/xml/eld/EldModuleLoader.java | 8 +- .../eld/lang/ElementModuleBindingHandler.java | 4 +- .../org/x4o/xml/eld/lang/ModuleElement.java | 2 +- .../org/x4o/xml/element/AbstractElement.java | 24 ++-- .../AbstractElementBindingHandler.java | 2 +- .../DefaultElementAttributeValueParser.java | 8 +- .../element/DefaultElementBodyCharacters.java | 10 +- ...faultElementNamespaceInstanceProvider.java | 12 +- .../java/org/x4o/xml/element/Element.java | 14 +- .../ElementNamespaceInstanceProvider.java | 6 +- .../x4o/xml/io/AbstractX4OReaderContext.java | 14 +- .../org/x4o/xml/io/AbstractX4OWriter.java | 10 +- .../x4o/xml/io/AbstractX4OWriterContext.java | 8 +- .../java/org/x4o/xml/io/DefaultX4OReader.java | 58 ++++---- .../x4o/xml/io/DefaultX4OSchemaWriter.java | 2 +- .../java/org/x4o/xml/io/DefaultX4OWriter.java | 34 ++--- .../java/org/x4o/xml/io/X4OReaderContext.java | 16 +-- .../java/org/x4o/xml/io/X4OWriterContext.java | 10 +- .../org/x4o/xml/io/sax/X4OContentHandler.java | 6 +- .../org/x4o/xml/io/sax/X4OContentParser.java | 60 ++++---- .../org/x4o/xml/io/sax/X4ODebugWriter.java | 16 +-- .../org/x4o/xml/io/sax/X4OEntityResolver.java | 4 +- .../org/x4o/xml/io/sax/X4OErrorHandler.java | 18 +-- .../xml/lang/AbstractX4OLanguageModule.java | 2 +- ...t.java => AbstractX4OLanguageSession.java} | 42 +++--- .../org/x4o/xml/lang/DefaultX4OLanguage.java | 16 +-- .../lang/DefaultX4OLanguageConfiguration.java | 2 +- ...xt.java => DefaultX4OLanguageSession.java} | 6 +- .../java/org/x4o/xml/lang/X4OLanguage.java | 6 +- ...geContext.java => X4OLanguageSession.java} | 4 +- ...ocal.java => X4OLanguageSessionLocal.java} | 4 +- .../x4o/xml/lang/phase/AbstractX4OPhase.java | 4 +- .../lang/phase/DefaultX4OPhaseManager.java | 52 +++---- .../java/org/x4o/xml/lang/phase/X4OPhase.java | 4 +- .../xml/lang/phase/X4OPhaseLanguageInit.java | 28 ++-- .../xml/lang/phase/X4OPhaseLanguageRead.java | 128 +++++++++--------- .../xml/lang/phase/X4OPhaseLanguageWrite.java | 40 +++--- .../x4o/xml/lang/phase/X4OPhaseListener.java | 6 +- .../x4o/xml/lang/phase/X4OPhaseManager.java | 6 +- .../org/x4o/xml/X4ODriverManagerTest.java | 2 +- .../org/x4o/xml/core/NamespaceUriTest.java | 8 +- .../x4o/xml/core/X4OEntityResolverTest.java | 10 +- .../org/x4o/xml/core/X4OPhaseManagerTest.java | 6 +- .../org/x4o/xml/io/X4OReaderContextTest.java | 12 +- .../org/x4o/xml/io/X4OWriterContextTest.java | 6 +- .../test/swixml/SwiXmlActionConfigurator.java | 2 +- .../org/x4o/xml/test/swixml/SwiXmlDriver.java | 4 +- .../org/x4o/xml/eld/doc/EldDocWriter.java | 10 +- .../xml/eld/doc/EldDocWriterElementClass.java | 4 +- .../x4o/xml/eld/doc/EldDocWriterLanguage.java | 12 +- .../xml/eld/doc/EldDocXTreePageWriter.java | 8 +- .../eld/doc/X4OWriteLanguageDocExecutor.java | 4 +- .../xml/lang/meta/ELIDAttributeHandler.java | 4 +- .../x4o/xml/lang/meta/ELReferenceElement.java | 4 +- .../x4o/xml/lang/meta/PropertyElement.java | 4 +- .../x4o/xml/lang/meta/ParentObjectTest.java | 4 +- .../x4o/xml/lang/meta/ReferenceStoreTest.java | 8 +- 58 files changed, 412 insertions(+), 412 deletions(-) rename x4o-driver/src/main/java/org/x4o/xml/lang/{AbstractX4OLanguageContext.java => AbstractX4OLanguageSession.java} (82%) rename x4o-driver/src/main/java/org/x4o/xml/lang/{DefaultX4OLanguageContext.java => DefaultX4OLanguageSession.java} (90%) rename x4o-driver/src/main/java/org/x4o/xml/lang/{X4OLanguageContext.java => X4OLanguageSession.java} (96%) rename x4o-driver/src/main/java/org/x4o/xml/lang/{X4OLanguageContextLocal.java => X4OLanguageSessionLocal.java} (94%) diff --git a/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java b/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java index adf8299..b1d6154 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java +++ b/x4o-driver/src/main/java/org/x4o/xml/X4ODriver.java @@ -169,19 +169,19 @@ public abstract class X4ODriver { } /* - * Creates the X4OLanguageContext for the default language version. - * @return The created X4OLanguageContext. + * Creates the X4OLanguageSession for the default language version. + * @return The created X4OLanguageSession. * - final public X4OLanguageContext createLanguageContext() { - return createLanguageContext(getLanguageVersionDefault()); + final public X4OLanguageSession createLanguageSession() { + return createLanguageSession(getLanguageVersionDefault()); } * - * Creates the X4OLanguageContext for the specified version. + * Creates the X4OLanguageSession for the specified version. * @param version The language version to create the context for. - * @return The created X4OLanguageContext. + * @return The created X4OLanguageSession. * - final public X4OLanguageContext createLanguageContext(String version) { - return createLanguage(version).createLanguageContext(); + final public X4OLanguageSession createLanguageSession(String version) { + return createLanguage(version).createLanguageSession(); }*/ } diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoader.java b/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoader.java index 41f000f..6c7327f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoader.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/EldModuleLoader.java @@ -33,7 +33,7 @@ import org.x4o.xml.io.X4OConnectionException; import org.x4o.xml.io.X4OReader; import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageModuleLoader; import org.x4o.xml.lang.X4OLanguageModuleLoaderException; import org.x4o.xml.lang.X4OLanguageLocal; @@ -90,7 +90,7 @@ public class EldModuleLoader implements X4OLanguageModuleLoader { X4OReader reader = driver.createReader(); - //X4OLanguageContext eldLang = driver.createLanguageContext(driver.getLanguageVersionDefault()); + //X4OLanguageSession eldLang = driver.createLanguageSession(driver.getLanguageVersionDefault()); //X4OReader reader = new DefaultX4OReader(eldLang); reader.addELBeanInstance(EL_PARENT_LANGUAGE, language); @@ -110,12 +110,12 @@ public class EldModuleLoader implements X4OLanguageModuleLoader { } } - public static X4OLanguage getLanguage(X4OLanguageContext context) { + public static X4OLanguage getLanguage(X4OLanguageSession context) { ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE+"}", X4OLanguage.class); return (X4OLanguage)ee.getValue(context.getExpressionLanguageContext()); } - public static X4OLanguageModule getLanguageModule(X4OLanguageContext context) { + public static X4OLanguageModule getLanguageModule(X4OLanguageSession context) { ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE_MODULE+"}", X4OLanguageModule.class); return (X4OLanguageModule)ee.getValue(context.getExpressionLanguageContext()); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java index d7b840e..61f1d7f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ElementModuleBindingHandler.java @@ -75,7 +75,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler< */ public void bindChild(Element childElement,X4OLanguageModule languageModule, Object childObject) throws ElementBindingHandlerException { - X4OLanguage x4oParsingContext = EldModuleLoader.getLanguage(childElement.getLanguageContext()); + X4OLanguage x4oParsingContext = EldModuleLoader.getLanguage(childElement.getLanguageSession()); if (x4oParsingContext==null) { return; } @@ -133,7 +133,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler< } try { - elementNamespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); + elementNamespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); } catch (Exception e) { throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ModuleElement.java b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ModuleElement.java index ebf2b7c..f85c165 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ModuleElement.java +++ b/x4o-driver/src/main/java/org/x4o/xml/eld/lang/ModuleElement.java @@ -45,7 +45,7 @@ public class ModuleElement extends AbstractElement { if (getParent()!=null) { throw new ElementException("Need to be root tag"); } - X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageContext()); + X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession()); setElementObject(elementLanguageModule); } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElement.java b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElement.java index 2d67429..cc1a700 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElement.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElement.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageClassLoader; /** @@ -43,7 +43,7 @@ public abstract class AbstractElement implements Element { /** The config object */ private Object elementObject = null; /** The language parsing context */ - private X4OLanguageContext languageContext = null; + private X4OLanguageSession languageSession = null; /** The ElementClass */ private ElementClass elementClass = null; /** The attributes */ @@ -93,7 +93,7 @@ public abstract class AbstractElement implements Element { getAttributes().clear(); setElementClass(null); setParent(null); - setLanguageContext(null); + setLanguageSession(null); attributes.clear(); childeren.clear(); // we do not release childeren, x4o does that allChilderen.clear(); @@ -114,17 +114,17 @@ public abstract class AbstractElement implements Element { } /** - * @see Element#setLanguageContext(X4OLanguageContext) + * @see Element#setLanguageSession(X4OLanguageSession) */ - public void setLanguageContext(X4OLanguageContext languageContext) { - this.languageContext=languageContext; + public void setLanguageSession(X4OLanguageSession languageSession) { + this.languageSession=languageSession; } /** - * @see Element#getLanguageContext() + * @see Element#getLanguageSession() */ - public X4OLanguageContext getLanguageContext() { - return languageContext; + public X4OLanguageSession getLanguageSession() { + return languageSession; } /** @@ -132,7 +132,7 @@ public abstract class AbstractElement implements Element { */ public void doCharacters(String characters) throws ElementException { try { - Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters()); + Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters()); e.setElementObject(characters); addChild(e); } catch (Exception exception) { @@ -145,7 +145,7 @@ public abstract class AbstractElement implements Element { */ public void doComment(String comment) throws ElementException { try { - Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment()); + Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment()); e.setElementObject(comment); addChild(e); } catch (Exception exception) { @@ -158,7 +158,7 @@ public abstract class AbstractElement implements Element { */ public void doIgnorableWhitespace(String space) throws ElementException { try { - Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace()); + Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace()); e.setElementObject(space); addChild(e); } catch (Exception exception) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementBindingHandler.java b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementBindingHandler.java index c5515e5..852d5de 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementBindingHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/AbstractElementBindingHandler.java @@ -53,7 +53,7 @@ public abstract class AbstractElementBindingHandler extends AbstractElementMe if (parentElement==null) { throw new NullPointerException("Can't create child with null parent."); } - Element childElement = parentElement.getLanguageContext().getLanguage().createElementInstance(parentElement.getLanguageContext(), childObject.getClass()); + Element childElement = parentElement.getLanguageSession().getLanguage().createElementInstance(parentElement.getLanguageSession(), childObject.getClass()); if (childElement==null) { throw new NullPointerException("Could not find Element for child: "+childObject.getClass()); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementAttributeValueParser.java b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementAttributeValueParser.java index 92aed85..5ffdcf0 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementAttributeValueParser.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementAttributeValueParser.java @@ -82,7 +82,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue if (element.getElementObject()==null) { return value; } - for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject())) { + for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) { logger.finer("Found interface match executing converter."); for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) { if (name.equals(attrClass.getId())==false) { @@ -106,8 +106,8 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue * @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element) */ public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException { - ValueExpression e = element.getLanguageContext().getExpressionLanguageFactory().createValueExpression(element.getLanguageContext().getExpressionLanguageContext(), (String)value,Object.class); - return e.getValue(element.getLanguageContext().getExpressionLanguageContext()); + ValueExpression e = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(element.getLanguageSession().getExpressionLanguageContext(), (String)value,Object.class); + return e.getValue(element.getLanguageSession().getExpressionLanguageContext()); } /** @@ -129,7 +129,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue return false; } - for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject())) { + for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) { logger.finest("Found interface match checking disables el parameters."); attr = ei.getElementClassAttributeByName(name); diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementBodyCharacters.java b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementBodyCharacters.java index f8af8e4..874db7b 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementBodyCharacters.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementBodyCharacters.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** @@ -124,9 +124,9 @@ public class DefaultElementBodyCharacters implements Element { } /** - * @see org.x4o.xml.element.Element#getLanguageContext() + * @see org.x4o.xml.element.Element#getLanguageSession() */ - public X4OLanguageContext getLanguageContext() { + public X4OLanguageSession getLanguageSession() { return null; } @@ -176,9 +176,9 @@ public class DefaultElementBodyCharacters implements Element { } /** - * @see org.x4o.xml.element.Element#setLanguageContext(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.element.Element#setLanguageSession(org.x4o.xml.lang.X4OLanguageSession) */ - public void setLanguageContext(X4OLanguageContext elementLanguage) { + public void setLanguageSession(X4OLanguageSession elementLanguage) { } /** diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java index 3faaf17..a7746be 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/DefaultElementNamespaceInstanceProvider.java @@ -24,7 +24,7 @@ package org.x4o.xml.element; import java.util.logging.Logger; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguageClassLoader; @@ -57,13 +57,13 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace } /** - * @param languageContext The language context for which we create the Element instance. + * @param languageSession The language context for which we create the Element instance. * @param tag The xml tag to create an Element instance for. * @return The Element to handle the given tag. * @throws ElementNamespaceInstanceProviderException - * @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageContext,java.lang.String) + * @see org.x4o.xml.element.ElementNamespaceInstanceProvider#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.String) */ - public Element createElementInstance(X4OLanguageContext languageContext,String tag) throws ElementNamespaceInstanceProviderException { + public Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException { ElementClass elementClass = elementNamespace.getElementClass(tag); Element element = null; @@ -80,7 +80,7 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace throw new ElementNamespaceInstanceProviderException(this,"Provided elementClassName is not an Element: "+obj.getClass()); } } else { - element = (Element)X4OLanguageClassLoader.newInstance((languageContext.getLanguage().getLanguageConfiguration().getDefaultElement())); + element = (Element)X4OLanguageClassLoader.newInstance((languageSession.getLanguage().getLanguageConfiguration().getDefaultElement())); } if (elementClass.getObjectClass()!=null) { @@ -94,7 +94,7 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e); } */ element.setElementClass(elementClass); - element.setLanguageContext(languageContext); + element.setLanguageSession(languageSession); return element; } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/Element.java b/x4o-driver/src/main/java/org/x4o/xml/element/Element.java index 964c10f..7da4776 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/Element.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/Element.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** * Defines an XML element with an object.
@@ -132,16 +132,16 @@ public interface Element { void setElementObject(Object object); /** - * Sets the ElementLanguage. - * @param elementLanguage The ElementLanguage to set. + * Sets the X4OLanguageSession. + * @param languageSession The X4OLanguageSession to set. */ - void setLanguageContext(X4OLanguageContext elementLanguage); + void setLanguageSession(X4OLanguageSession languageSession); /** - * Gets the ElementLanguage. - * @return Returns the ElementLanguage. + * Gets the X4OLanguageSession. + * @return Returns the X4OLanguageSession. */ - X4OLanguageContext getLanguageContext(); + X4OLanguageSession getLanguageSession(); /** * Sets the body texts on an event based system. diff --git a/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java b/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java index 12b7fcb..b0772e2 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java +++ b/x4o-driver/src/main/java/org/x4o/xml/element/ElementNamespaceInstanceProvider.java @@ -22,7 +22,7 @@ */ package org.x4o.xml.element; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguage; /** @@ -43,10 +43,10 @@ public interface ElementNamespaceInstanceProvider { /** * Provide an Element for an xml tag. - * @param languageContext The languageContext to create element for. + * @param languageSession The languageSession to create element for. * @param tag The xml tag to create instance for. * @return An new Element instance. * @throws ElementNamespaceInstanceProviderException Thrown when error happened in language. */ - Element createElementInstance(X4OLanguageContext languageContext,String tag) throws ElementNamespaceInstanceProviderException; + Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OReaderContext.java b/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OReaderContext.java index 1d38643..41549d7 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OReaderContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OReaderContext.java @@ -30,9 +30,9 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; -import org.x4o.xml.lang.X4OLanguage; +import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguageClassLoader; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.SAXException; /** @@ -57,7 +57,7 @@ abstract public class AbstractX4OReaderContext extends AbstractX4OConnection * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - public X4OLanguageContext readFileContext(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException { + public X4OLanguageSession readFileContext(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException { if (fileName==null) { throw new NullPointerException("Can't convert null fileName to file object."); } @@ -73,7 +73,7 @@ abstract public class AbstractX4OReaderContext extends AbstractX4OConnection * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - public X4OLanguageContext readFileContext(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException { + public X4OLanguageSession readFileContext(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException { if (file==null) { throw new NullPointerException("Can't read null file."); } @@ -100,7 +100,7 @@ abstract public class AbstractX4OReaderContext extends AbstractX4OConnection * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - public X4OLanguageContext readResourceContext(String resourceName) throws X4OConnectionException,SAXException,IOException { + public X4OLanguageSession readResourceContext(String resourceName) throws X4OConnectionException,SAXException,IOException { if (resourceName==null) { throw new NullPointerException("Can't read null resourceName from classpath."); } @@ -130,7 +130,7 @@ abstract public class AbstractX4OReaderContext extends AbstractX4OConnection * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - public X4OLanguageContext readStringContext(String xmlString) throws X4OConnectionException,SAXException,IOException { + public X4OLanguageSession readStringContext(String xmlString) throws X4OConnectionException,SAXException,IOException { if (xmlString==null) { throw new NullPointerException("Can't read null xml string."); } @@ -147,7 +147,7 @@ abstract public class AbstractX4OReaderContext extends AbstractX4OConnection * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - public X4OLanguageContext readUrlContext(URL url) throws X4OConnectionException,SAXException,IOException { + public X4OLanguageSession readUrlContext(URL url) throws X4OConnectionException,SAXException,IOException { if (url==null) { throw new NullPointerException("Can't read null url."); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriter.java index 7e47905..4b82129 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriter.java @@ -29,7 +29,7 @@ import java.io.OutputStream; import org.x4o.xml.element.Element; import org.x4o.xml.lang.X4OLanguage; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.SAXException; /** @@ -44,10 +44,10 @@ public abstract class AbstractX4OWriter extends AbstractX4OWriterContext i super(language); } - abstract X4OLanguageContext getLanguageContext(); + abstract X4OLanguageSession createLanguageSession(); - private X4OLanguageContext toObjectContext(T object) throws SAXException { - X4OLanguageContext context = getLanguageContext(); + private X4OLanguageSession toObjectContext(T object) throws SAXException { + X4OLanguageSession context = createLanguageSession(); Element rootElement = null; try { rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance(); @@ -57,7 +57,7 @@ public abstract class AbstractX4OWriter extends AbstractX4OWriterContext i throw new SAXException(e); } rootElement.setElementObject(object); - rootElement.setLanguageContext(context); + rootElement.setLanguageSession(context); context.setRootElement(rootElement); return context; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriterContext.java b/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriterContext.java index 28b6140..a80bb46 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriterContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/AbstractX4OWriterContext.java @@ -30,7 +30,7 @@ import java.io.OutputStream; import org.x4o.xml.io.sax.ext.ContentWriterXml; import org.x4o.xml.lang.X4OLanguage; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.SAXException; /** @@ -45,14 +45,14 @@ public abstract class AbstractX4OWriterContext extends AbstractX4OConnection super(language); } - public void writeFileContext(X4OLanguageContext context,String fileName) throws X4OConnectionException,SAXException,IOException { + public void writeFileContext(X4OLanguageSession context,String fileName) throws X4OConnectionException,SAXException,IOException { if (fileName==null) { throw new NullPointerException("Can't convert null fileName to file object."); } writeFileContext(context,new File(fileName)); } - public void writeFileContext(X4OLanguageContext context,File file) throws X4OConnectionException,SAXException,IOException { + public void writeFileContext(X4OLanguageSession context,File file) throws X4OConnectionException,SAXException,IOException { if (file==null) { throw new NullPointerException("Can't read null file."); } @@ -64,7 +64,7 @@ public abstract class AbstractX4OWriterContext extends AbstractX4OConnection } } - public String writeStringContext(X4OLanguageContext context) throws X4OConnectionException,SAXException,IOException { + public String writeStringContext(X4OLanguageSession context) throws X4OConnectionException,SAXException,IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(4096); writeContext(context, out); String encoding = (String)getProperty(ContentWriterXml.OUTPUT_ENCODING); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java index 20b4446..e5ed46d 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OReader.java @@ -41,8 +41,8 @@ import org.x4o.xml.io.sax.ext.ContentWriterXml; import org.x4o.xml.io.sax.ext.PropertyConfig; import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem; import org.x4o.xml.lang.X4OLanguage; -import org.x4o.xml.lang.X4OLanguageContext; -import org.x4o.xml.lang.X4OLanguageContextLocal; +import org.x4o.xml.lang.X4OLanguageSession; +import org.x4o.xml.lang.X4OLanguageSessionLocal; import org.x4o.xml.lang.phase.X4OPhaseException; import org.x4o.xml.lang.phase.X4OPhaseType; import org.xml.sax.EntityResolver; @@ -62,7 +62,7 @@ public class DefaultX4OReader extends AbstractX4OReader { /** The logger to log to. */ private Logger logger = null; - private X4OLanguageContext languageContext = null; + private X4OLanguageSession languageSession = null; private PropertyConfig propertyConfig; @@ -117,7 +117,7 @@ public class DefaultX4OReader extends AbstractX4OReader { public DefaultX4OReader(X4OLanguage language) { super(language); logger = Logger.getLogger(DefaultX4OReader.class.getName()); - languageContext = language.createLanguageContext(); + languageSession = language.createLanguageSession(); propertyConfig = new PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX); } @@ -126,12 +126,12 @@ public class DefaultX4OReader extends AbstractX4OReader { return propertyConfig; } - public X4OLanguageContext readContext(InputStream input, String systemId, URL basePath) throws X4OConnectionException, SAXException, IOException { + public X4OLanguageSession readContext(InputStream input, String systemId, URL basePath) throws X4OConnectionException, SAXException, IOException { setProperty(INPUT_STREAM, input); setProperty(INPUT_SYSTEM_ID, systemId); setProperty(INPUT_BASE_PATH, basePath); read(); - return languageContext; + return languageSession; } public void addELBeanInstance(String name,Object bean) { @@ -144,21 +144,21 @@ public class DefaultX4OReader extends AbstractX4OReader { if (bean==null) { throw new NullPointerException("Can't add null bean."); } - ValueExpression ve = languageContext.getExpressionLanguageFactory().createValueExpression(languageContext.getExpressionLanguageContext(),"${"+name+"}", bean.getClass()); - ve.setValue(languageContext.getExpressionLanguageContext(), bean); + ValueExpression ve = languageSession.getExpressionLanguageFactory().createValueExpression(languageSession.getExpressionLanguageContext(),"${"+name+"}", bean.getClass()); + ve.setValue(languageSession.getExpressionLanguageContext(), bean); } /** * Parses the input stream as a X4O document. */ protected void read() throws X4OConnectionException,SAXException,IOException { - if (languageContext.getLanguage()==null) { - throw new X4OConnectionException("languageContext is broken getLanguage() returns null."); + if (languageSession.getLanguage()==null) { + throw new X4OConnectionException("languageSession is broken getLanguage() returns null."); } - if (languageContext instanceof X4OLanguageContextLocal) { - X4OLanguageContextLocal ll = (X4OLanguageContextLocal)languageContext; + if (languageSession instanceof X4OLanguageSessionLocal) { + X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal)languageSession; if (phaseStop!=null) { ll.setPhaseStop(phaseStop); } @@ -171,7 +171,7 @@ public class DefaultX4OReader extends AbstractX4OReader { boolean startedDebugWriter = false; Object debugOutputHandler = null; //TODO: getProperty(X4OLanguageProperty.DEBUG_OUTPUT_HANDLER.name()); Object debugOutputStream = null; //getProperty(X4OLanguageProperty.DEBUG_OUTPUT_STREAM.name()); - if (languageContext.getX4ODebugWriter()==null) { + if (languageSession.getX4ODebugWriter()==null) { ContentWriter xmlDebugWriter = null; if (debugOutputHandler instanceof ContentWriter) { xmlDebugWriter = (ContentWriter)debugOutputHandler; @@ -182,37 +182,37 @@ public class DefaultX4OReader extends AbstractX4OReader { xmlDebugWriter.startDocument(); xmlDebugWriter.startPrefixMapping("debug", X4ODebugWriter.DEBUG_URI); X4ODebugWriter debugWriter = new X4ODebugWriter(xmlDebugWriter); - X4OLanguageContextLocal local = (X4OLanguageContextLocal)languageContext; + X4OLanguageSessionLocal local = (X4OLanguageSessionLocal)languageSession; local.setX4ODebugWriter(debugWriter); startedDebugWriter = true; } } // debug language - if (languageContext.hasX4ODebugWriter()) { + if (languageSession.hasX4ODebugWriter()) { AttributesImpl atts = new AttributesImpl(); - atts.addAttribute ("", "language", "", "", languageContext.getLanguage().getLanguageName()); + atts.addAttribute ("", "language", "", "", languageSession.getLanguage().getLanguageName()); atts.addAttribute ("", "currentTimeMillis", "", "", System.currentTimeMillis()+""); - languageContext.getX4ODebugWriter().getContentWriter().startElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", "", atts); + languageSession.getX4ODebugWriter().getContentWriter().startElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", "", atts); } // start parsing language try { X4OContentParser parser = new X4OContentParser(propertyConfig); - parser.parse(languageContext); + parser.parse(languageSession); - getLanguage().getPhaseManager().runPhases(languageContext, X4OPhaseType.XML_READ); + getLanguage().getPhaseManager().runPhases(languageSession, X4OPhaseType.XML_READ); } catch (Exception e) { // also debug exceptions - if (languageContext.hasX4ODebugWriter()) { + if (languageSession.hasX4ODebugWriter()) { try { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "message", "", "", e.getMessage()); if (e instanceof X4OPhaseException) { atts.addAttribute ("", "phase", "", "", ((X4OPhaseException)e).getX4OPhaseHandler().getId()); } - languageContext.getX4ODebugWriter().getContentWriter().startElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", "", atts); + languageSession.getX4ODebugWriter().getContentWriter().startElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", "", atts); StringWriter writer = new StringWriter(); PrintWriter printer = new PrintWriter(writer); printer.append('\n'); @@ -222,8 +222,8 @@ public class DefaultX4OReader extends AbstractX4OReader { e.getCause().printStackTrace(printer); } char[] stack = writer.getBuffer().toString().toCharArray(); - languageContext.getX4ODebugWriter().getContentWriter().characters(stack, 0, stack.length); - languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", ""); + languageSession.getX4ODebugWriter().getContentWriter().characters(stack, 0, stack.length); + languageSession.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", ""); } catch (Exception ee) { logger.warning(ee.getMessage()); } @@ -245,12 +245,12 @@ public class DefaultX4OReader extends AbstractX4OReader { throw new SAXException((Exception)e.getCause()); } } finally { - if (languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", ""); + if (languageSession.hasX4ODebugWriter()) { + languageSession.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", ""); } - if (startedDebugWriter && languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().getContentWriter().endPrefixMapping("debug"); - languageContext.getX4ODebugWriter().getContentWriter().endDocument(); + if (startedDebugWriter && languageSession.hasX4ODebugWriter()) { + languageSession.getX4ODebugWriter().getContentWriter().endPrefixMapping("debug"); + languageSession.getX4ODebugWriter().getContentWriter().endDocument(); if (debugOutputStream instanceof OutputStream) { OutputStream outputStream = (OutputStream)debugOutputStream; outputStream.flush(); @@ -260,7 +260,7 @@ public class DefaultX4OReader extends AbstractX4OReader { } } - public void releaseContext(X4OLanguageContext context) throws X4OPhaseException { + public void releaseContext(X4OLanguageSession context) throws X4OPhaseException { if (context==null) { return; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OSchemaWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OSchemaWriter.java index 636f15b..538c87b 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OSchemaWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OSchemaWriter.java @@ -76,7 +76,7 @@ public class DefaultX4OSchemaWriter extends AbstractX4OConnection implements X4O public void writeSchema(File basePath, String namespace) throws ElementException { setProperty(OUTPUT_PATH, basePath); // TODO: fix create context - EldXsdXmlGenerator xsd = new EldXsdXmlGenerator(getLanguage().createLanguageContext().getLanguage(),getPropertyConfig()); + EldXsdXmlGenerator xsd = new EldXsdXmlGenerator(getLanguage().createLanguageSession().getLanguage(),getPropertyConfig()); xsd.writeSchema(namespace); // Start xsd generator } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java index 9185135..ed5c3c3 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/DefaultX4OWriter.java @@ -43,7 +43,7 @@ import org.x4o.xml.io.sax.ext.PropertyConfig; import org.x4o.xml.io.sax.ext.ContentWriterXml; import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem; import org.x4o.xml.lang.X4OLanguage; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhaseException; @@ -81,7 +81,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { /** * Default constructor. - * @param languageContext The language context for this writer. + * @param language The language for this writer. */ public DefaultX4OWriter(X4OLanguage language) { super(language); @@ -89,35 +89,35 @@ public class DefaultX4OWriter extends AbstractX4OWriter { } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getPropertyConfig() + * @see org.x4o.xml.lang.X4OLanguageSession#getPropertyConfig() */ public PropertyConfig getPropertyConfig() { return propertyConfig; } - X4OLanguageContext getLanguageContext() { - return getLanguage().createLanguageContext(); + X4OLanguageSession createLanguageSession() { + return getLanguage().createLanguageSession(); } /** - * @see org.x4o.xml.io.X4OWriterContext#writeContext(org.x4o.xml.lang.X4OLanguageContext, java.io.OutputStream) + * @see org.x4o.xml.io.X4OWriterContext#writeContext(org.x4o.xml.lang.X4OLanguageSession, java.io.OutputStream) */ - public void writeContext(X4OLanguageContext languageContext,OutputStream output) throws X4OConnectionException,SAXException,IOException { + public void writeContext(X4OLanguageSession languageSession,OutputStream output) throws X4OConnectionException,SAXException,IOException { setProperty(OUTPUT_STREAM, output); addPhaseSkip(X4OPhase.WRITE_RELEASE); try { - languageContext.getLanguage().getPhaseManager().runPhases(languageContext, X4OPhaseType.XML_WRITE); + languageSession.getLanguage().getPhaseManager().runPhases(languageSession, X4OPhaseType.XML_WRITE); } catch (X4OPhaseException e) { throw new X4OConnectionException(e); } - runWrite(languageContext); + runWrite(languageSession); } private AttributeEntryComparator attributeEntryComparator = new AttributeEntryComparator(); private boolean schemaUriPrint; private String schemaUriRoot; - private void runWrite(X4OLanguageContext languageContext) throws X4OConnectionException { + private void runWrite(X4OLanguageSession languageSession) throws X4OConnectionException { OutputStream out = (OutputStream)getProperty(OUTPUT_STREAM); try { String encoding = getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING); @@ -125,10 +125,10 @@ public class DefaultX4OWriter extends AbstractX4OWriter { schemaUriRoot = getPropertyConfig().getPropertyString(SCHEMA_ROOT_URI); if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; } - Element root = languageContext.getRootElement(); + Element root = languageSession.getRootElement(); if (schemaUriRoot==null) { String rootUri = findElementUri(root); - ElementNamespace ns = languageContext.getLanguage().findElementNamespace(rootUri); + ElementNamespace ns = languageSession.getLanguage().findElementNamespace(rootUri); if (ns!=null) { schemaUriRoot = ns.getSchemaUri(); } @@ -214,7 +214,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { continue; } - Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),eca.getId()); + Object value = element.getLanguageSession().getElementObjectPropertyValue().getProperty(element.getElementObject(),eca.getId()); if (value==null) { continue; } @@ -236,7 +236,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { continue; } boolean writeValue = true; - for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject().getClass())) { + for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject().getClass())) { eca = ei.getElementClassAttributeByName(p); if (eca!=null && writeOrder==null) { writeOrder = eca.getWriteOrder(); // add interface but allow override local @@ -251,7 +251,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { } // TODO: check attr see reader - Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),p); + Object value = element.getLanguageSession().getElementObjectPropertyValue().getProperty(element.getElementObject(),p); if (value==null) { continue; } @@ -315,7 +315,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { } private String findElementUri(Element e) { - for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) { + for (X4OLanguageModule mod:e.getLanguageSession().getLanguage().getLanguageModules()) { for (ElementNamespace c:mod.getElementNamespaces()) { ElementClass ec = c.getElementClass(e.getElementClass().getId()); if (ec!=null) { @@ -327,7 +327,7 @@ public class DefaultX4OWriter extends AbstractX4OWriter { } private String findNamespacePrefix(Element e,String uri) { - ElementNamespace ns = e.getLanguageContext().getLanguage().findElementNamespace(uri); + ElementNamespace ns = e.getLanguageSession().getLanguage().findElementNamespace(uri); if (ns.getPrefixMapping()!=null) { return ns.getPrefixMapping(); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/X4OReaderContext.java b/x4o-driver/src/main/java/org/x4o/xml/io/X4OReaderContext.java index bdfaa24..3a592d9 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/X4OReaderContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/X4OReaderContext.java @@ -28,7 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.phase.X4OPhaseException; import org.xml.sax.SAXException; @@ -40,7 +40,7 @@ import org.xml.sax.SAXException; */ public interface X4OReaderContext extends X4OReader { - void releaseContext(X4OLanguageContext context) throws X4OPhaseException; + void releaseContext(X4OLanguageSession context) throws X4OPhaseException; /** * Method to parse the xml data. @@ -49,7 +49,7 @@ public interface X4OReaderContext extends X4OReader { * @throws SAXException Is thrown after sax xml exception. * @throws IOException Is thrown after io exception. */ - X4OLanguageContext readContext(InputStream input,String systemId,URL basePath) throws X4OConnectionException,SAXException,IOException; + X4OLanguageSession readContext(InputStream input,String systemId,URL basePath) throws X4OConnectionException,SAXException,IOException; /** * Reads the file fileName and parses it as an InputStream. @@ -60,7 +60,7 @@ public interface X4OReaderContext extends X4OReader { * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - X4OLanguageContext readFileContext(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException; + X4OLanguageSession readFileContext(String fileName) throws X4OConnectionException,SAXException,IOException,FileNotFoundException; /** * Reads the file and parses it as an InputStream. @@ -71,7 +71,7 @@ public interface X4OReaderContext extends X4OReader { * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - X4OLanguageContext readFileContext(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException; + X4OLanguageSession readFileContext(File file) throws X4OConnectionException,SAXException,IOException,FileNotFoundException; /** * Parses an resource locaction. @@ -81,7 +81,7 @@ public interface X4OReaderContext extends X4OReader { * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - X4OLanguageContext readResourceContext(String resourceName) throws X4OConnectionException,SAXException,IOException; + X4OLanguageSession readResourceContext(String resourceName) throws X4OConnectionException,SAXException,IOException; /** * Converts a String to a InputStream to is can me parsed by SAX. @@ -91,7 +91,7 @@ public interface X4OReaderContext extends X4OReader { * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - X4OLanguageContext readStringContext(String xmlString) throws X4OConnectionException,SAXException,IOException; + X4OLanguageSession readStringContext(String xmlString) throws X4OConnectionException,SAXException,IOException; /** * Fetched the data direct from remote url to a InputStream to is can me parsed by SAX. @@ -101,5 +101,5 @@ public interface X4OReaderContext extends X4OReader { * @throws IOException Is thrown after io exception. * @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) */ - X4OLanguageContext readUrlContext(URL url) throws X4OConnectionException,SAXException,IOException; + X4OLanguageSession readUrlContext(URL url) throws X4OConnectionException,SAXException,IOException; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/X4OWriterContext.java b/x4o-driver/src/main/java/org/x4o/xml/io/X4OWriterContext.java index 3d8f0b5..3d5cbd4 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/X4OWriterContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/X4OWriterContext.java @@ -26,7 +26,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.SAXException; /** @@ -37,11 +37,11 @@ import org.xml.sax.SAXException; */ public interface X4OWriterContext extends X4OWriter { - void writeContext(X4OLanguageContext context,OutputStream out) throws X4OConnectionException,SAXException,IOException; + void writeContext(X4OLanguageSession context,OutputStream out) throws X4OConnectionException,SAXException,IOException; - void writeFileContext(X4OLanguageContext context,String fileName) throws X4OConnectionException,SAXException,IOException; + void writeFileContext(X4OLanguageSession context,String fileName) throws X4OConnectionException,SAXException,IOException; - void writeFileContext(X4OLanguageContext context,File file) throws X4OConnectionException,SAXException,IOException; + void writeFileContext(X4OLanguageSession context,File file) throws X4OConnectionException,SAXException,IOException; - String writeStringContext(X4OLanguageContext context) throws X4OConnectionException,SAXException,IOException; + String writeStringContext(X4OLanguageSession context) throws X4OConnectionException,SAXException,IOException; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java index b9da3dd..0d9bd70 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentHandler.java @@ -30,7 +30,7 @@ import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.ext.AttributeMap; import org.x4o.xml.io.sax.ext.PropertyConfig; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.Attributes; import org.xml.sax.Locator; import org.xml.sax.SAXException; @@ -61,7 +61,7 @@ public class X4OContentHandler extends DefaultHandler2 { private Stack elementStack = null; /** The elememtContext */ - private X4OLanguageContext elementLanguage = null; + private X4OLanguageSession elementLanguage = null; /** Store the override element */ private Element overrideSaxElement = null; @@ -75,7 +75,7 @@ public class X4OContentHandler extends DefaultHandler2 { * Creates an X4OTagHandler * which can receice sax xml events and converts them into the Element* interfaces events. */ - public X4OContentHandler(X4OLanguageContext elementLanguage,PropertyConfig propertyConfig) { + public X4OContentHandler(X4OLanguageSession elementLanguage,PropertyConfig propertyConfig) { logger = Logger.getLogger(X4OContentHandler.class.getName()); loggerFinest = logger.isLoggable(Level.FINEST); elementStack = new Stack(); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java index 0ed630b..06f17b0 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OContentParser.java @@ -26,7 +26,7 @@ import org.x4o.xml.eld.EldDriver; import org.x4o.xml.element.ElementException; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.ext.PropertyConfig; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -57,7 +57,7 @@ public class X4OContentParser { return propertyConfig; } - public void parse(X4OLanguageContext languageContext) throws SAXException, IOException { + public void parse(X4OLanguageSession languageSession) throws SAXException, IOException { // If xsd caching is needed this should be the way //XMLParserConfiguration config = new XIncludeAwareParserConfiguration(); @@ -65,56 +65,56 @@ public class X4OContentParser { //SAXParser parser = new SAXParser(config); // Create Sax parser with x4o tag handler - X4OContentHandler xth = new X4OContentHandler(languageContext,getPropertyConfig()); + X4OContentHandler xth = new X4OContentHandler(languageSession,getPropertyConfig()); XMLReader saxParser = XMLReaderFactory.createXMLReader(); - saxParser.setErrorHandler(new X4OErrorHandler(languageContext,getPropertyConfig())); - saxParser.setEntityResolver(new X4OEntityResolver(languageContext,getPropertyConfig())); + saxParser.setErrorHandler(new X4OErrorHandler(languageSession,getPropertyConfig())); + saxParser.setEntityResolver(new X4OEntityResolver(languageSession,getPropertyConfig())); saxParser.setContentHandler(xth); saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth); saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth); // Set properties and optional - Map saxParserProperties = getSAXParserProperties(languageContext); + Map saxParserProperties = getSAXParserProperties(languageSession); for (Map.Entry entry:saxParserProperties.entrySet()) { String name = entry.getKey(); Object value= entry.getValue(); saxParser.setProperty(name, value); - debugMessage("Set SAX property: "+name+" to: "+value,languageContext); + debugMessage("Set SAX property: "+name+" to: "+value,languageSession); } - Map saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageContext); + Map saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageSession); for (Map.Entry entry:saxParserPropertiesOptional.entrySet()) { String name = entry.getKey(); Object value= entry.getValue(); try { saxParser.setProperty(name, value); - debugMessage("Set SAX optional property: "+name+" to: "+value,languageContext); + debugMessage("Set SAX optional property: "+name+" to: "+value,languageSession); } catch (SAXException e) { - debugMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageContext); + debugMessage("Could not set optional SAX property: "+name+" to: "+value+" error: "+e.getMessage(),languageSession); } } // Set sax features and optional - Map features = getSAXParserFeatures(languageContext); + Map features = getSAXParserFeatures(languageSession); for (String key:features.keySet()) { Boolean value=features.get(key); saxParser.setFeature(key, value); - debugMessage("Set SAX feature: "+key+" to: "+value,languageContext); + debugMessage("Set SAX feature: "+key+" to: "+value,languageSession); } - Map featuresOptional = getSAXParserFeaturesOptional(languageContext); + Map featuresOptional = getSAXParserFeaturesOptional(languageSession); for (String key:featuresOptional.keySet()) { Boolean value=featuresOptional.get(key); try { saxParser.setFeature(key, value); - debugMessage("Set SAX optional feature: "+key+" to: "+value,languageContext); + debugMessage("Set SAX optional feature: "+key+" to: "+value,languageSession); } catch (SAXException e) { - debugMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageContext); + debugMessage("Could not set optional SAX feature: "+key+" to: "+value+" error: "+e.getMessage(),languageSession); } } // check for required features - List requiredFeatures = getSAXParserFeaturesRequired(languageContext); + List requiredFeatures = getSAXParserFeaturesRequired(languageSession); for (String requiredFeature:requiredFeatures) { - debugMessage("Checking required SAX feature: "+requiredFeature,languageContext); + debugMessage("Checking required SAX feature: "+requiredFeature,languageSession); if (saxParser.getFeature(requiredFeature)==false) { throw new IllegalStateException("Missing required feature: "+requiredFeature); } @@ -149,10 +149,10 @@ public class X4OContentParser { } } - private void debugMessage(String message,X4OLanguageContext languageContext) throws SAXException { - if (languageContext.hasX4ODebugWriter()) { + private void debugMessage(String message,X4OLanguageSession languageSession) throws SAXException { + if (languageSession.hasX4ODebugWriter()) { try { - languageContext.getX4ODebugWriter().debugPhaseMessage(message, X4OContentParser.class); + languageSession.getX4ODebugWriter().debugPhaseMessage(message, X4OContentParser.class); } catch (ElementException ee) { throw new SAXException(ee); } @@ -160,26 +160,26 @@ public class X4OContentParser { } /** - * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserProperties(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserProperties(org.x4o.xml.lang.X4OLanguageSession) */ - public Map getSAXParserProperties(X4OLanguageContext elementContext) { + public Map getSAXParserProperties(X4OLanguageSession elementContext) { Map saxParserProperties = new HashMap(1); return saxParserProperties; } /** - * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserPropertiesOptional(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserPropertiesOptional(org.x4o.xml.lang.X4OLanguageSession) */ - public Map getSAXParserPropertiesOptional(X4OLanguageContext elementContext) { + public Map getSAXParserPropertiesOptional(X4OLanguageSession elementContext) { Map saxParserProperties = new HashMap(1); saxParserProperties.put("http://apache.org/xml/properties/input-buffer-size",getPropertyConfig().getProperty(DefaultX4OReader.DOC_BUFFER_SIZE)); // Increase buffer to 8KB return saxParserProperties; } /** - * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserFeatures(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserFeatures(org.x4o.xml.lang.X4OLanguageSession) */ - public Map getSAXParserFeatures(X4OLanguageContext elementContext) { + public Map getSAXParserFeatures(X4OLanguageSession elementContext) { // see example: http://xerces.apache.org/xerces2-j/features.html Map saxParserFeatures = new HashMap(20); @@ -226,9 +226,9 @@ public class X4OContentParser { } /** - * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserFeaturesOptional(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserFeaturesOptional(org.x4o.xml.lang.X4OLanguageSession) */ - public Map getSAXParserFeaturesOptional(X4OLanguageContext elementContext) { + public Map getSAXParserFeaturesOptional(X4OLanguageSession elementContext) { Map saxParserFeatures = new HashMap(20); // Make Sax Impl more strict. @@ -250,9 +250,9 @@ public class X4OContentParser { } /** - * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserFeaturesRequired(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.X4OLanguageConfiguration#getSAXParserFeaturesRequired(org.x4o.xml.lang.X4OLanguageSession) */ - public List getSAXParserFeaturesRequired(X4OLanguageContext elementContext) { + public List getSAXParserFeaturesRequired(X4OLanguageSession elementContext) { List result = new ArrayList(5); result.add("http://xml.org/sax/features/use-attributes2"); // Attributes objects passed by the parser are ext.Attributes2 interface. result.add("http://xml.org/sax/features/use-locator2"); // Locator objects passed by the parser are org.xml.sax.ext.Locator2 interface. diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java index 58764b2..c69f3fb 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4ODebugWriter.java @@ -42,7 +42,7 @@ import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.io.sax.ext.ContentWriter; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageConfiguration; import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhaseException; @@ -81,9 +81,9 @@ public class X4ODebugWriter { /** * @throws X4OPhaseException - * @see org.x4o.xml.lang.phase.X4OPhaseListener#preRunPhase(org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.phase.X4OPhaseListener#preRunPhase(org.x4o.xml.lang.X4OLanguageSession) */ - public void preRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException { + public void preRunPhase(X4OPhase phase,X4OLanguageSession elementLanguage) throws X4OPhaseException { startTime = System.currentTimeMillis(); try { AttributesImpl atts = new AttributesImpl(); @@ -97,7 +97,7 @@ public class X4ODebugWriter { debugPhase(phase); } - public void endRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException { + public void endRunPhase(X4OPhase phase,X4OLanguageSession elementLanguage) throws X4OPhaseException { long stopTime = System.currentTimeMillis(); try { AttributesImpl atts = new AttributesImpl(); @@ -114,7 +114,7 @@ public class X4ODebugWriter { } /* - public void debugLanguageProperties(X4OLanguageContext ec) throws ElementException { + public void debugLanguageProperties(X4OLanguageSession ec) throws ElementException { try { AttributesImpl atts = new AttributesImpl(); contentWriter.startElement (DEBUG_URI, "X4OLanguageProperties", "", atts); @@ -136,7 +136,7 @@ public class X4ODebugWriter { } */ - public void debugLanguageDefaultClasses(X4OLanguageContext ec) throws ElementException { + public void debugLanguageDefaultClasses(X4OLanguageSession ec) throws ElementException { try { AttributesImpl atts = new AttributesImpl(); contentWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClasses", "", atts); @@ -212,7 +212,7 @@ public class X4ODebugWriter { } } - public void debugElementLanguageModules(X4OLanguageContext elementLanguage) throws ElementException { + public void debugElementLanguageModules(X4OLanguageSession elementLanguage) throws ElementException { try { AttributesImpl attsEmpty = new AttributesImpl(); contentWriter.startElement (DEBUG_URI, "ElementLanguageModules", "", attsEmpty); @@ -422,7 +422,7 @@ public class X4ODebugWriter { } } - public void debugLanguageContext(X4OLanguageContext elementLanguage) throws SAXException { + public void debugLanguageSession(X4OLanguageSession elementLanguage) throws SAXException { AttributesImpl atts = new AttributesImpl(); //atts.addAttribute ("", key, "", "", value); atts.addAttribute ("", "language", "", "", elementLanguage.getLanguage().getLanguageName()); diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java index a4ed56f..d6633d6 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OEntityResolver.java @@ -34,7 +34,7 @@ import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.ext.PropertyConfig; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageClassLoader; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -64,7 +64,7 @@ public class X4OEntityResolver implements EntityResolver { * Creates an X4OEntityResolver for a language. * @param elementContext The x4o language to resolve entities for. */ - public X4OEntityResolver(X4OLanguageContext elementContext,PropertyConfig propertyConfig) { + public X4OEntityResolver(X4OLanguageSession elementContext,PropertyConfig propertyConfig) { if (elementContext==null) { throw new NullPointerException("Can't provide entities with null elementContext."); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OErrorHandler.java b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OErrorHandler.java index 85ff1a2..39711a5 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OErrorHandler.java +++ b/x4o-driver/src/main/java/org/x4o/xml/io/sax/X4OErrorHandler.java @@ -25,7 +25,7 @@ package org.x4o.xml.io.sax; import org.x4o.xml.element.ElementException; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.ext.PropertyConfig; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -38,18 +38,18 @@ import org.xml.sax.SAXParseException; */ public class X4OErrorHandler implements ErrorHandler { - private X4OLanguageContext languageContext = null; + private X4OLanguageSession languageSession = null; private ErrorHandler errorHandler = null; /** * Construct a new SAXErrorPrinter - * @param languageContext The language to get errors to. + * @param languageSession The language to get errors to. */ - public X4OErrorHandler(X4OLanguageContext languageContext,PropertyConfig propertyConfig) { - if (languageContext==null) { - throw new NullPointerException("Can't debug and proxy errors with null languageContext."); + public X4OErrorHandler(X4OLanguageSession languageSession,PropertyConfig propertyConfig) { + if (languageSession==null) { + throw new NullPointerException("Can't debug and proxy errors with null languageSession."); } - this.languageContext=languageContext; + this.languageSession=languageSession; this.errorHandler=(ErrorHandler)propertyConfig.getProperty(DefaultX4OReader.SAX_ERROR_HANDLER); } @@ -57,12 +57,12 @@ public class X4OErrorHandler implements ErrorHandler { * Prints the error message to debug output. */ private void printError(boolean isError, SAXParseException exception) throws SAXException { - if (languageContext.hasX4ODebugWriter()==false) { + if (languageSession.hasX4ODebugWriter()==false) { return; } String message = printErrorString(isError,exception); try { - languageContext.getX4ODebugWriter().debugPhaseMessage(message, X4OErrorHandler.class); + languageSession.getX4ODebugWriter().debugPhaseMessage(message, X4OErrorHandler.class); } catch (ElementException e) { throw new SAXException(e); } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java index 93e916f..7056ddc 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageModule.java @@ -59,7 +59,7 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase * Creates a new empty ElementLanguage. */ public AbstractX4OLanguageModule() { - logger = Logger.getLogger(AbstractX4OLanguageContext.class.getName()); + logger = Logger.getLogger(AbstractX4OLanguageSession.class.getName()); logger.finest("Creating new ParsingContext"); elementAttributeHandlers = new ArrayList(4); elementBindingHandlers = new ArrayList(4); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageContext.java b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageSession.java similarity index 82% rename from x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageContext.java rename to x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageSession.java index 7e6a182..8111ce3 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/AbstractX4OLanguageSession.java @@ -38,12 +38,12 @@ import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.lang.phase.X4OPhase; /** - * An AbstractElementLanguage. + * AbstractX4OLanguageSession. * * @author Willem Cazander * @version 1.0 Aug 20, 2005 */ -public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLocal { +public abstract class AbstractX4OLanguageSession implements X4OLanguageSessionLocal { private Logger logger = null; private X4OLanguage language = null; @@ -61,11 +61,11 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo /** * Creates a new empty language context. */ - public AbstractX4OLanguageContext(X4OLanguage language) { + public AbstractX4OLanguageSession(X4OLanguage language) { if (language==null) { throw new NullPointerException("language may not be null"); } - logger = Logger.getLogger(AbstractX4OLanguageContext.class.getName()); + logger = Logger.getLogger(AbstractX4OLanguageSession.class.getName()); logger.finest("Creating new ParsingContext"); this.language=language; dirtyElements = new HashMap(40); @@ -77,14 +77,14 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getExpressionLanguageContext() + * @see org.x4o.xml.lang.X4OLanguageSession#getExpressionLanguageContext() */ public ELContext getExpressionLanguageContext() { return eLContext; } /** - * @see org.x4o.xml.lang.X4OLanguageContextLocal#setExpressionLanguageContext(javax.el.ELContext) + * @see org.x4o.xml.lang.X4OLanguageSessionLocal#setExpressionLanguageContext(javax.el.ELContext) */ public void setExpressionLanguageContext(ELContext context) { if (eLContext!=null) { @@ -94,14 +94,14 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getExpressionLanguageFactory() + * @see org.x4o.xml.lang.X4OLanguageSession#getExpressionLanguageFactory() */ public ExpressionFactory getExpressionLanguageFactory() { return expressionFactory; } /** - * @see org.x4o.xml.lang.X4OLanguageContextLocal#setExpressionLanguageFactory(javax.el.ExpressionFactory) + * @see org.x4o.xml.lang.X4OLanguageSessionLocal#setExpressionLanguageFactory(javax.el.ExpressionFactory) */ public void setExpressionLanguageFactory(ExpressionFactory expressionFactory) { if (this.expressionFactory!=null) { @@ -145,7 +145,7 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo } /** - * @see org.x4o.xml.lang.X4OLanguageContext#addDirtyElement(org.x4o.xml.element.Element, org.x4o.xml.lang.phase.X4OPhase) + * @see org.x4o.xml.lang.X4OLanguageSession#addDirtyElement(org.x4o.xml.element.Element, org.x4o.xml.lang.phase.X4OPhase) */ public void addDirtyElement(Element element, X4OPhase phase) { if (dirtyElements.containsKey(element)) { @@ -155,21 +155,21 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getDirtyElements() + * @see org.x4o.xml.lang.X4OLanguageSession#getDirtyElements() */ public Map getDirtyElements() { return dirtyElements; } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getRootElement() + * @see org.x4o.xml.lang.X4OLanguageSession#getRootElement() */ public Element getRootElement() { return rootElement; } /** - * @see org.x4o.xml.lang.X4OLanguageContext#setRootElement(org.x4o.xml.element.Element) + * @see org.x4o.xml.lang.X4OLanguageSession#setRootElement(org.x4o.xml.element.Element) */ public void setRootElement(Element element) { if (element==null) { @@ -179,63 +179,63 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getX4ODebugWriter() + * @see org.x4o.xml.lang.X4OLanguageSession#getX4ODebugWriter() */ public X4ODebugWriter getX4ODebugWriter() { return debugWriter; } /** - * @see org.x4o.xml.lang.X4OLanguageContext#hasX4ODebugWriter() + * @see org.x4o.xml.lang.X4OLanguageSession#hasX4ODebugWriter() */ public boolean hasX4ODebugWriter() { return debugWriter!=null; } /** - * @see org.x4o.xml.lang.X4OLanguageContextLocal#setX4ODebugWriter(org.x4o.xml.io.sax.X4ODebugWriter) + * @see org.x4o.xml.lang.X4OLanguageSessionLocal#setX4ODebugWriter(org.x4o.xml.io.sax.X4ODebugWriter) */ public void setX4ODebugWriter(X4ODebugWriter debugWriter) { this.debugWriter=debugWriter; } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getPhaseCurrent() + * @see org.x4o.xml.lang.X4OLanguageSession#getPhaseCurrent() */ public X4OPhase getPhaseCurrent() { return phaseCurrent; } /** - * @see org.x4o.xml.lang.X4OLanguageContextLocal#setPhaseCurrent(org.x4o.xml.lang.phase.X4OPhase) + * @see org.x4o.xml.lang.X4OLanguageSessionLocal#setPhaseCurrent(org.x4o.xml.lang.phase.X4OPhase) */ public void setPhaseCurrent(X4OPhase phaseCurrent) { this.phaseCurrent = phaseCurrent; } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getPhaseStop() + * @see org.x4o.xml.lang.X4OLanguageSession#getPhaseStop() */ public String getPhaseStop() { return phaseStop; } /** - * @see org.x4o.xml.lang.X4OLanguageContext#getPhaseSkip() + * @see org.x4o.xml.lang.X4OLanguageSession#getPhaseSkip() */ public List getPhaseSkip() { return phaseSkip; } /** - * @see org.x4o.xml.lang.X4OLanguageContextLocal#setPhaseStop(java.lang.String) + * @see org.x4o.xml.lang.X4OLanguageSessionLocal#setPhaseStop(java.lang.String) */ public void setPhaseStop(String phaseId) { this.phaseStop=phaseId; } /** - * @see org.x4o.xml.lang.X4OLanguageContextLocal#addPhaseSkip(java.lang.String) + * @see org.x4o.xml.lang.X4OLanguageSessionLocal#addPhaseSkip(java.lang.String) */ public void addPhaseSkip(String phaseId) { phaseSkip.add(phaseId); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java index 8da8225..2041b49 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguage.java @@ -118,8 +118,8 @@ public class DefaultX4OLanguage implements X4OLanguageLocal { * @throws X4OPhaseException * @see org.x4o.xml.lang.X4OLanguage#createLanguageContext(org.x4o.xml.X4ODriver) */ - public X4OLanguageContext createLanguageContext() { - X4OLanguageContext result = buildElementLanguage(new DefaultX4OLanguageContext(this)); + public X4OLanguageSession createLanguageSession() { + X4OLanguageSession result = buildElementLanguage(new DefaultX4OLanguageSession(this)); try { getPhaseManager().runPhases(result, X4OPhaseType.INIT); } catch (X4OPhaseException e) { @@ -128,11 +128,11 @@ public class DefaultX4OLanguage implements X4OLanguageLocal { return result; } - protected X4OLanguageContext buildElementLanguage(X4OLanguageContext languageContext) { - if ((languageContext instanceof X4OLanguageContextLocal)==false) { - throw new RuntimeException("Can't init X4OLanguageContext which has not X4OLanguageContextLocal interface obj: "+languageContext); + protected X4OLanguageSession buildElementLanguage(X4OLanguageSession languageSession) { + if ((languageSession instanceof X4OLanguageSessionLocal)==false) { + throw new RuntimeException("Can't init X4OLanguageSession which has not X4OLanguageSessionLocal interface obj: "+languageSession); } - X4OLanguageContextLocal contextInit = (X4OLanguageContextLocal)languageContext; + X4OLanguageSessionLocal contextInit = (X4OLanguageSessionLocal)languageSession; try { if (contextInit.getExpressionLanguageFactory()==null) { contextInit.setExpressionLanguageFactory(X4OExpressionFactory.createExpressionFactory()); @@ -153,9 +153,9 @@ public class DefaultX4OLanguage implements X4OLanguageLocal { } /** - * @see org.x4o.xml.lang.X4OLanguage#createElementInstance(org.x4o.xml.lang.X4OLanguageContext,java.lang.Class) + * @see org.x4o.xml.lang.X4OLanguage#createElementInstance(org.x4o.xml.lang.X4OLanguageSession,java.lang.Class) */ - public Element createElementInstance(X4OLanguageContext context,Class objectClass) { + public Element createElementInstance(X4OLanguageSession context,Class objectClass) { for (X4OLanguageModule modContext:getLanguageModules()) { for (ElementNamespace nsContext:modContext.getElementNamespaces()) { for (ElementClass ec:nsContext.getElementClasses()) { diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguageConfiguration.java b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguageConfiguration.java index 430b0e3..5ac516f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguageConfiguration.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/DefaultX4OLanguageConfiguration.java @@ -89,7 +89,7 @@ public class DefaultX4OLanguageConfiguration extends AbstractX4OLanguageConfigur Class[] invokeArgs = new Class[argsLength]; for (int i=0;i objectClass); + Element createElementInstance(X4OLanguageSession context,Class objectClass); /** * Gets all ElementBindingHandlers which are possible for parent. diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageContext.java b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageSession.java similarity index 96% rename from x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageContext.java rename to x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageSession.java index 12fb87b..ec3db6f 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageContext.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageSession.java @@ -35,12 +35,12 @@ import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.lang.phase.X4OPhase; /** - * ElementLanguage is the central store of the defined element language. + * X4OLanguageSession store all language session related information. * * @author Willem Cazander * @version 1.0 Feb 14, 2007 */ -public interface X4OLanguageContext { +public interface X4OLanguageSession { X4OLanguage getLanguage(); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageContextLocal.java b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageSessionLocal.java similarity index 94% rename from x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageContextLocal.java rename to x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageSessionLocal.java index a73340e..b86ceb9 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageContextLocal.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/X4OLanguageSessionLocal.java @@ -31,12 +31,12 @@ import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.lang.phase.X4OPhase; /** - * ElementLanguageLocal is the local set interface for ElementLanguage. + * X4OLanguageSessionLocal is the local set interface for X4OLanguageSession. * * @author Willem Cazander * @version 1.0 Oct 28, 2009 */ -public interface X4OLanguageContextLocal extends X4OLanguageContext { +public interface X4OLanguageSessionLocal extends X4OLanguageSession { /** * Sets the EL Context. diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/AbstractX4OPhase.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/AbstractX4OPhase.java index 6eabecf..2636f0c 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/AbstractX4OPhase.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/AbstractX4OPhase.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.List; import org.x4o.xml.element.Element; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** @@ -97,6 +97,6 @@ public abstract class AbstractX4OPhase implements X4OPhase { * @param elementLanguage The language to run phase for. * @throws X4OPhaseException when phase has error. */ - public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException { + public void runPhase(X4OLanguageSession elementLanguage) throws X4OPhaseException { } } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/DefaultX4OPhaseManager.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/DefaultX4OPhaseManager.java index 346a57c..6566fdd 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/DefaultX4OPhaseManager.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/DefaultX4OPhaseManager.java @@ -28,8 +28,8 @@ import java.util.Comparator; import java.util.List; import org.x4o.xml.element.Element; -import org.x4o.xml.lang.X4OLanguageContext; -import org.x4o.xml.lang.X4OLanguageContextLocal; +import org.x4o.xml.lang.X4OLanguageSession; +import org.x4o.xml.lang.X4OLanguageSessionLocal; /** * X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order. @@ -118,18 +118,18 @@ PHASE_ORDER = { *startupX4OPhase, * Runs all the phases in the right order. * @throws X4OPhaseException When a running handlers throws one. */ - public void runPhases(X4OLanguageContext languageContext,X4OPhaseType type) throws X4OPhaseException { + public void runPhases(X4OLanguageSession languageSession,X4OPhaseType type) throws X4OPhaseException { // sort for the order List x4oPhasesOrder = getOrderedPhases(type); // debug output - if (languageContext.getX4ODebugWriter()!=null) { - languageContext.getX4ODebugWriter().debugPhaseOrder(x4oPhases); + if (languageSession.getX4ODebugWriter()!=null) { + languageSession.getX4ODebugWriter().debugPhaseOrder(x4oPhases); } - List phaseSkip = languageContext.getPhaseSkip(); - String phaseStop = languageContext.getPhaseStop(); + List phaseSkip = languageSession.getPhaseSkip(); + String phaseStop = languageSession.getPhaseStop(); // run the phases in ordered order for (X4OPhase phase:x4oPhasesOrder) { @@ -139,24 +139,24 @@ PHASE_ORDER = { *startupX4OPhase, } // debug output - ((X4OLanguageContextLocal)languageContext).setPhaseCurrent(phase); + ((X4OLanguageSessionLocal)languageSession).setPhaseCurrent(phase); // run listeners for (X4OPhaseListener l:phase.getPhaseListeners()) { - l.preRunPhase(phase, languageContext); + l.preRunPhase(phase, languageSession); } // always run endRunPhase for valid debug xml try { // do the run interface - phase.runPhase(languageContext); + phase.runPhase(languageSession); // run the element phase if possible - executePhaseRoot(languageContext,phase); + executePhaseRoot(languageSession,phase); } finally { // run the listeners again for (X4OPhaseListener l:phase.getPhaseListeners()) { - l.endRunPhase(phase, languageContext); + l.endRunPhase(phase, languageSession); } } @@ -173,9 +173,9 @@ PHASE_ORDER = { *startupX4OPhase, * @throws X4OPhaseException When a running handlers throws one. */ public void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException { - X4OLanguageContext languageContext = e.getLanguageContext(); - List phaseSkip = languageContext.getPhaseSkip(); - String phaseStop = languageContext.getPhaseStop(); + X4OLanguageSession languageSession = e.getLanguageSession(); + List phaseSkip = languageSession.getPhaseSkip(); + String phaseStop = languageSession.getPhaseStop(); // sort for the order List x4oPhasesOrder = getOrderedPhases(type); @@ -188,13 +188,13 @@ PHASE_ORDER = { *startupX4OPhase, } // set phase - ((X4OLanguageContextLocal)languageContext).setPhaseCurrent(phase); + ((X4OLanguageSessionLocal)languageSession).setPhaseCurrent(phase); // do the run interface - phase.runPhase(languageContext); + phase.runPhase(languageSession); // run the element phase if possible - executePhaseRoot(languageContext,phase); + executePhaseRoot(languageSession,phase); if (phaseStop!=null && phaseStop.equals(phase.getId())) { return; // we are done @@ -206,8 +206,8 @@ PHASE_ORDER = { *startupX4OPhase, * Run release phase manual if auto release is disabled by config. * @throws X4OPhaseException When a running handlers throws one. */ - public void doReleasePhaseManual(X4OLanguageContext languageContext) throws X4OPhaseException { - List phaseSkip = languageContext.getPhaseSkip(); + public void doReleasePhaseManual(X4OLanguageSession languageSession) throws X4OPhaseException { + List phaseSkip = languageSession.getPhaseSkip(); String releaseRequested = null; if (phaseSkip.contains(X4OPhase.READ_RELEASE)) { releaseRequested = X4OPhase.READ_RELEASE; @@ -218,10 +218,10 @@ PHASE_ORDER = { *startupX4OPhase, if (releaseRequested==null) { throw new IllegalStateException("No manual release requested."); } - if (languageContext.getRootElement()==null) { + if (languageSession.getRootElement()==null) { return; // no root element , empty xml document ? } - if (languageContext.getRootElement().getElementClass()==null) { + if (languageSession.getRootElement().getElementClass()==null) { throw new IllegalStateException("Release phase has already been runned."); } @@ -237,13 +237,13 @@ PHASE_ORDER = { *startupX4OPhase, } // set phase - ((X4OLanguageContextLocal)languageContext).setPhaseCurrent(h); + ((X4OLanguageSessionLocal)languageSession).setPhaseCurrent(h); // do the run interface - h.runPhase(languageContext); + h.runPhase(languageSession); // run the element phase if possible - executePhaseRoot(languageContext,h); + executePhaseRoot(languageSession,h); } class X4OPhaseComparator implements Comparator { @@ -305,7 +305,7 @@ PHASE_ORDER = { *startupX4OPhase, * @param phase The phase to run. * @throws X4OPhaseException When a running handlers throws one. */ - private void executePhaseRoot(X4OLanguageContext elementLanguage,X4OPhase phase) throws X4OPhaseException { + private void executePhaseRoot(X4OLanguageSession elementLanguage,X4OPhase phase) throws X4OPhaseException { if (elementLanguage.getRootElement()==null) { return; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhase.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhase.java index f5f5176..d73108c 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhase.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhase.java @@ -25,7 +25,7 @@ package org.x4o.xml.lang.phase; import java.util.List; import org.x4o.xml.element.Element; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** @@ -68,7 +68,7 @@ public interface X4OPhase { * @param elementLanguage The elementLanguage running this phase. * @throws X4OPhaseException When error has happend. */ - void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException; + void runPhase(X4OLanguageSession elementLanguage) throws X4OPhaseException; /** * Returns all phase listeners which where added. diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageInit.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageInit.java index 0842548..95d856e 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageInit.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageInit.java @@ -28,7 +28,7 @@ import java.util.logging.Logger; import org.x4o.xml.element.Element; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageModuleLoaderSibling; import org.x4o.xml.lang.X4OLanguageClassLoader; import org.x4o.xml.lang.X4OLanguageLoader; @@ -73,7 +73,7 @@ public class X4OPhaseLanguageInit { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { logger.finest("Run init start phase"); } }; @@ -97,14 +97,14 @@ public class X4OPhaseLanguageInit { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { try { //debugPhaseMessage("Loading main language: "+elementLanguage.getLanguage(),this,elementLanguage); - X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageContext.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader()); - loader.loadLanguage((X4OLanguageLocal)languageContext.getLanguage(),languageContext.getLanguage().getLanguageName(),languageContext.getLanguage().getLanguageVersion()); + X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader()); + loader.loadLanguage((X4OLanguageLocal)languageSession.getLanguage(),languageSession.getLanguage().getLanguageName(),languageSession.getLanguage().getLanguageVersion()); - if (languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().debugElementLanguageModules(languageContext); + if (languageSession.hasX4ODebugWriter()) { + languageSession.getX4ODebugWriter().debugElementLanguageModules(languageSession); } } catch (Exception e) { throw new X4OPhaseException(this,e); @@ -130,22 +130,22 @@ public class X4OPhaseLanguageInit { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { try { List siblingLoaders = new ArrayList(3); - for (X4OLanguageModule module:languageContext.getLanguage().getLanguageModules()) { + for (X4OLanguageModule module:languageSession.getLanguage().getLanguageModules()) { if (module.getLanguageModuleLoader() instanceof X4OLanguageModuleLoaderSibling) { siblingLoaders.add((X4OLanguageModuleLoaderSibling)module.getLanguageModuleLoader()); } } if (siblingLoaders.isEmpty()==false) { - X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageContext.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader()); + X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader()); for (X4OLanguageModuleLoaderSibling siblingLoader:siblingLoaders) { //debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage); - siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageContext.getLanguage(), loader); + siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageSession.getLanguage(), loader); } - if (languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().debugElementLanguageModules(languageContext); + if (languageSession.hasX4ODebugWriter()) { + languageSession.getX4ODebugWriter().debugElementLanguageModules(languageSession); } } } catch (Exception e) { @@ -172,7 +172,7 @@ public class X4OPhaseLanguageInit { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { logger.finest("Run init end phase"); } }; diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java index cdf5bd6..a808352 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageRead.java @@ -44,7 +44,7 @@ import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.io.sax.ext.ContentWriter; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageClassLoader; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -69,7 +69,7 @@ public class X4OPhaseLanguageRead { // meta start point // manager.addX4OPhase(factory.startX4OPhase()); -// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} +// if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // config X4OPhaseReadRunConfigurator runConf = new X4OPhaseReadRunConfigurator(); @@ -80,27 +80,27 @@ public class X4OPhaseLanguageRead { // run all attribute events manager.addX4OPhase(new X4OPhaseReadRunAttribute()); -// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} +// if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // templating manager.addX4OPhase(new X4OPhaseReadFillTemplate()); -// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} +// if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // transforming manager.addX4OPhase(new X4OPhaseReadTransform()); manager.addX4OPhase(new X4OPhaseReadRunDirty(manager)); -// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} +// if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // binding elements manager.addX4OPhase(new X4OPhaseReadBindElement()); // runing and releasing manager.addX4OPhase(new X4OPhaseReadRun()); -// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} +// if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} manager.addX4OPhase(runConf); manager.addX4OPhase(new X4OPhaseReadRunDirtyLast(manager)); -// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} +// if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} manager.addX4OPhase(new X4OPhaseReadEnd()); @@ -109,19 +109,19 @@ public class X4OPhaseLanguageRead { manager.addX4OPhase(releasePhase()); // Add debug phase listener to all phases -// if (languageContext.hasX4ODebugWriter()) { +// if (languageSession.hasX4ODebugWriter()) { //for (X4OPhase h:manager.getOrderedPhases()) { -// h.addPhaseListener(languageContext.getX4ODebugWriter().createDebugX4OPhaseListener()); +// h.addPhaseListener(languageSession.getX4ODebugWriter().createDebugX4OPhaseListener()); //} //} // We are done } - private void debugPhaseMessage(String message,X4OPhase phaseHandler,X4OLanguageContext languageContext) throws X4OPhaseException { - if (languageContext.hasX4ODebugWriter()) { + private void debugPhaseMessage(String message,X4OPhase phaseHandler,X4OLanguageSession languageSession) throws X4OPhaseException { + if (languageSession.hasX4ODebugWriter()) { try { - languageContext.getX4ODebugWriter().debugPhaseMessage(message,phaseHandler.getClass()); + languageSession.getX4ODebugWriter().debugPhaseMessage(message,phaseHandler.getClass()); } catch (ElementException ee) { throw new X4OPhaseException(phaseHandler,ee); } @@ -147,12 +147,12 @@ public class X4OPhaseLanguageRead { public void runElementPhase(Element element) throws X4OPhaseException { // not used. } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { // print the properties and classes for this language/config - if (languageContext.hasX4ODebugWriter()) { + if (languageSession.hasX4ODebugWriter()) { try { - //languageContext.getX4ODebugWriter().debugLanguageProperties(languageContext); - languageContext.getX4ODebugWriter().debugLanguageDefaultClasses(languageContext); + //languageSession.getX4ODebugWriter().debugLanguageProperties(languageSession); + languageSession.getX4ODebugWriter().debugLanguageDefaultClasses(languageSession); } catch (ElementException e) { throw new X4OPhaseException(this,e); } @@ -223,7 +223,7 @@ public class X4OPhaseLanguageRead { logger.finest("Null elementObject skipping, interfaces"); return; } - for (ElementInterface ei:element.getLanguageContext().getLanguage().findElementInterfaces(element.getElementObject())) { + for (ElementInterface ei:element.getLanguageSession().getLanguage().findElementInterfaces(element.getElementObject())) { logger.finest("Do ElementInterface Config Configurators: "+ei.getElementConfigurators().size()); for (ElementConfigurator ec:ei.getElementConfigurators()) { runConf.runElementConfigurator(ec,element,this); @@ -250,7 +250,7 @@ public class X4OPhaseLanguageRead { return new String[] {"READ_CONFIG_ELEMENT","READ_CONFIG_ELEMENT_INTERFACE"}; } public void runElementPhase(Element element) throws X4OPhaseException { - for (X4OLanguageModule mod:element.getLanguageContext().getLanguage().getLanguageModules()) { + for (X4OLanguageModule mod:element.getLanguageSession().getLanguage().getLanguageModules()) { logger.finest("Do Element Config Global Configurators: "+mod.getElementConfiguratorGlobals().size()); for (ElementConfiguratorGlobal ec:mod.getElementConfiguratorGlobals()) { runConf.runElementConfigurator(ec,element,this); @@ -281,7 +281,7 @@ public class X4OPhaseLanguageRead { public void runElementPhase(Element element) throws X4OPhaseException { if (elementAttributeHandlerComparator==null) { try { - elementAttributeHandlerComparator = (Comparator)X4OLanguageClassLoader.newInstance(element.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementAttributeHandlerComparator()); + elementAttributeHandlerComparator = (Comparator)X4OLanguageClassLoader.newInstance(element.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementAttributeHandlerComparator()); } catch (Exception e) { throw new X4OPhaseException(this,e); } @@ -290,7 +290,7 @@ public class X4OPhaseLanguageRead { // do global parameters logger.finest("Do Element Global AttributeHandlers."); List handlers = new ArrayList(); - for (X4OLanguageModule mod:element.getLanguageContext().getLanguage().getLanguageModules()) { + for (X4OLanguageModule mod:element.getLanguageSession().getLanguage().getLanguageModules()) { for (ElementAttributeHandler global:mod.getElementAttributeHandlers()) { String attribute = element.getAttributes().get(global.getAttributeName()); @@ -329,7 +329,7 @@ public class X4OPhaseLanguageRead { // do config Map attr = element.getAttributes(); - ElementAttributeValueParser attrParser = element.getLanguageContext().getElementAttributeValueParser(); + ElementAttributeValueParser attrParser = element.getLanguageSession().getElementAttributeValueParser(); Boolean autoAttributes = element.getElementClass().getAutoAttributes(); if (autoAttributes==null) { autoAttributes = true; @@ -350,12 +350,12 @@ public class X4OPhaseLanguageRead { value = attrParser.getConvertedParameterValue(name, value, element); } if (attrClass.getRunBeanValue()==null || attrClass.getRunBeanValue()) { - element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value); + element.getLanguageSession().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value); } } else if (autoAttributes) { value = attrParser.getParameterValue(name,valueString,element); - element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value); + element.getLanguageSession().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value); } else { continue; // skip all non auto attribute non attribute defined xml attributes, or throw exception ? @@ -371,7 +371,7 @@ public class X4OPhaseLanguageRead { value = attrClass.getDefaultValue(); } if (attrClass.getRunBeanValue()==null || attrClass.getRunBeanValue()) { - element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), attrClass.getId(), value); + element.getLanguageSession().getElementObjectPropertyValue().setProperty(element.getElementObject(), attrClass.getId(), value); } } } @@ -419,8 +419,8 @@ public class X4OPhaseLanguageRead { return; } try { - if (element.getLanguageContext().hasX4ODebugWriter()) { - element.getLanguageContext().getX4ODebugWriter().debugElement(element); + if (element.getLanguageSession().hasX4ODebugWriter()) { + element.getLanguageSession().getX4ODebugWriter().debugElement(element); } element.doElementRun(); } catch (ElementException e) { @@ -447,16 +447,16 @@ public class X4OPhaseLanguageRead { return new String[] {"READ_TRANSFORM"}; } public void runElementPhase(Element element) throws X4OPhaseException { - Map dirtyElements = element.getLanguageContext().getDirtyElements(); + Map dirtyElements = element.getLanguageSession().getDirtyElements(); if (dirtyElements.isEmpty()) { return; } - debugPhaseMessage("Dirty elements: "+dirtyElements.size(), this,element.getLanguageContext()); + debugPhaseMessage("Dirty elements: "+dirtyElements.size(), this,element.getLanguageSession()); for (Element e:dirtyElements.keySet()) { X4OPhase p = dirtyElements.get(e); phaseManager.runPhasesForElement(e,getType(), p); } - element.getLanguageContext().getDirtyElements().clear(); + element.getLanguageSession().getDirtyElements().clear(); } }; @@ -478,16 +478,16 @@ public class X4OPhaseLanguageRead { return new String[] {"READ_RUN"}; } public void runElementPhase(Element element) throws X4OPhaseException { - Map dirtyElements = element.getLanguageContext().getDirtyElements(); + Map dirtyElements = element.getLanguageSession().getDirtyElements(); if (dirtyElements.isEmpty()) { return; } - debugPhaseMessage("Dirty elements last: "+dirtyElements.size(), this,element.getLanguageContext()); + debugPhaseMessage("Dirty elements last: "+dirtyElements.size(), this,element.getLanguageSession()); for (Element e:dirtyElements.keySet()) { X4OPhase p = dirtyElements.get(e); phaseManager.runPhasesForElement(e,getType(), p); } - element.getLanguageContext().getDirtyElements().clear(); + element.getLanguageSession().getDirtyElements().clear(); } }; @@ -521,12 +521,12 @@ public class X4OPhaseLanguageRead { return; } - List binds = element.getLanguageContext().getLanguage().findElementBindingHandlers(parentObject, childObject); + List binds = element.getLanguageSession().getLanguage().findElementBindingHandlers(parentObject, childObject); logger.finest("Calling bindings handlers; "+binds.size()); try { for (ElementBindingHandler binding:binds) { - if (element.getLanguageContext().hasX4ODebugWriter()) { - element.getLanguageContext().getX4ODebugWriter().debugElementBindingHandler(binding,element); + if (element.getLanguageSession().hasX4ODebugWriter()) { + element.getLanguageSession().getX4ODebugWriter().debugElementBindingHandler(binding,element); } binding.bindChild(element); } @@ -554,8 +554,8 @@ public class X4OPhaseLanguageRead { return; // has already runned. } try { - //if (element.getLanguageContext().hasX4ODebugWriter()) { - // element.getLanguageContext().getX4ODebugWriter().debugElement(element); + //if (element.getlanguageSession().hasX4ODebugWriter()) { + // element.getlanguageSession().getX4ODebugWriter().debugElement(element); //} element.doElementRun(); } catch (ElementException e) { @@ -581,11 +581,11 @@ public class X4OPhaseLanguageRead { public boolean isElementPhase() { return false; } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { for (RunConfigurator conf:runConf) { try { - if (languageContext.hasX4ODebugWriter()) { - languageContext.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element); + if (languageSession.hasX4ODebugWriter()) { + languageSession.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element); } conf.elementConfigurator.doConfigElement(conf.element); } catch (ElementException e) { @@ -610,8 +610,8 @@ public class X4OPhaseLanguageRead { return; } try { - if (e.getLanguageContext().hasX4ODebugWriter()) { - e.getLanguageContext().getX4ODebugWriter().debugElementConfigurator(ec,e); + if (e.getLanguageSession().hasX4ODebugWriter()) { + e.getLanguageSession().getX4ODebugWriter().debugElementConfigurator(ec,e); } ec.doConfigElement(e); @@ -644,12 +644,12 @@ public class X4OPhaseLanguageRead { public void runElementPhase(Element element) throws X4OPhaseException { // not used. } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { // print the properties and classes for this language/config - if (languageContext.hasX4ODebugWriter()) { + if (languageSession.hasX4ODebugWriter()) { try { - //languageContext.getX4ODebugWriter().debugLanguageProperties(languageContext); - languageContext.getX4ODebugWriter().debugLanguageDefaultClasses(languageContext); + //languageSession.getX4ODebugWriter().debugLanguageProperties(languageSession); + languageSession.getX4ODebugWriter().debugLanguageDefaultClasses(languageSession); } catch (ElementException e) { throw new X4OPhaseException(this,e); } @@ -667,23 +667,23 @@ public class X4OPhaseLanguageRead { class ReleasePhaseListener implements X4OPhaseListener { private int elementsReleased = 0; /** - * @see org.x4o.xml.lang.phase.X4OPhaseListener#preRunPhase(org.x4o.xml.lang.phase.X4OPhase, org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.phase.X4OPhaseListener#preRunPhase(org.x4o.xml.lang.phase.X4OPhase, org.x4o.xml.lang.X4OLanguageSession) */ - public void preRunPhase(X4OPhase phase,X4OLanguageContext languageContext) throws X4OPhaseException { + public void preRunPhase(X4OPhase phase,X4OLanguageSession languageSession) throws X4OPhaseException { elementsReleased=0; } /** - * @see org.x4o.xml.lang.phase.X4OPhaseListener#endRunPhase(org.x4o.xml.lang.phase.X4OPhase, org.x4o.xml.lang.X4OLanguageContext) + * @see org.x4o.xml.lang.phase.X4OPhaseListener#endRunPhase(org.x4o.xml.lang.phase.X4OPhase, org.x4o.xml.lang.X4OLanguageSession) */ - public void endRunPhase(X4OPhase phase,X4OLanguageContext languageContext) throws X4OPhaseException { - if (languageContext.hasX4ODebugWriter()==false) { + public void endRunPhase(X4OPhase phase,X4OLanguageSession languageSession) throws X4OPhaseException { + if (languageSession.hasX4ODebugWriter()==false) { return; } try { AttributesImpl atts = new AttributesImpl(); atts.addAttribute ("", "elements", "", "", elementsReleased+""); - languageContext.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts); - languageContext.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , ""); + languageSession.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts); + languageSession.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , ""); } catch (SAXException e) { throw new X4OPhaseException(phase,e); } @@ -705,7 +705,7 @@ public class X4OPhaseLanguageRead { public String[] getPhaseDependencies() { return new String[] {X4OPhase.READ_END}; } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { } public void runElementPhase(Element element) throws X4OPhaseException { try { @@ -741,23 +741,23 @@ public class X4OPhaseLanguageRead { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { // safety check - if (languageContext.hasX4ODebugWriter()==false) { + if (languageSession.hasX4ODebugWriter()==false) { throw new X4OPhaseException(this,"Use debugPhase only when X4OParser.debugWriter is filled."); } try { AttributesImpl atts = new AttributesImpl(); //atts.addAttribute ("", key, "", "", value); //atts.addAttribute ("", "verbose", "", "", "true"); - languageContext.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts); + languageSession.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts); startedPrefix.clear(); - printXML(languageContext.getRootElement()); + printXML(languageSession.getRootElement()); for (String prefix:startedPrefix) { - languageContext.getX4ODebugWriter().getContentWriter().endPrefixMapping(prefix); + languageSession.getX4ODebugWriter().getContentWriter().endPrefixMapping(prefix); } - languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", ""); - languageContext.getX4ODebugWriter().debugLanguageContext(languageContext); + languageSession.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", ""); + languageSession.getX4ODebugWriter().debugLanguageSession(languageSession); } catch (SAXException e) { throw new X4OPhaseException(this,e); } @@ -766,7 +766,7 @@ public class X4OPhaseLanguageRead { // note: slow version private String getNamespaceForElement(Element e) { - for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) { + for (X4OLanguageModule mod:e.getLanguageSession().getLanguage().getLanguageModules()) { for (ElementNamespace enc:mod.getElementNamespaces()) { List l = enc.getElementClasses(); if (l.contains(e.getElementClass())) { @@ -781,7 +781,7 @@ public class X4OPhaseLanguageRead { if (element==null) { throw new SAXException("Can't print debug xml of null element."); } - ContentWriter handler = element.getLanguageContext().getX4ODebugWriter().getContentWriter(); + ContentWriter handler = element.getLanguageSession().getX4ODebugWriter().getContentWriter(); if (element.getElementType().equals(Element.ElementType.comment)) { handler.comment((String)element.getElementObject()); return; @@ -802,7 +802,7 @@ public class X4OPhaseLanguageRead { } String nameSpace = getNamespaceForElement(element); - String prefix = element.getLanguageContext().getLanguage().findElementNamespace(nameSpace).getPrefixMapping(); + String prefix = element.getLanguageSession().getLanguage().findElementNamespace(nameSpace).getPrefixMapping(); if (startedPrefix.contains(prefix)==false) { handler.startPrefixMapping(prefix, nameSpace); diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java index dfbbafc..8d6dad0 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseLanguageWrite.java @@ -32,7 +32,7 @@ import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespaceInstanceProviderException; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** * X4OPhaseLanguageWrite defines all phases to write the language. @@ -73,7 +73,7 @@ public class X4OPhaseLanguageWrite { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { logger.finest("Run init begin phase"); } }; @@ -96,58 +96,58 @@ public class X4OPhaseLanguageWrite { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { try { - Element root = languageContext.getRootElement(); + Element root = languageSession.getRootElement(); // TODO: check for read tree then write support as ec is not null then .. if (root.getElementClass()==null) { - root = fillElementTree(languageContext,root.getElementObject()); + root = fillElementTree(languageSession,root.getElementObject()); } } catch (Exception e) { throw new X4OPhaseException(this,e); } } - private Element fillElementTree(X4OLanguageContext languageContext,Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException { - Element element = findRootElement(languageContext,object.getClass()); + private Element fillElementTree(X4OLanguageSession languageSession,Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException { + Element element = findRootElement(languageSession,object.getClass()); element.setElementObject(object); - languageContext.setRootElement(element); + languageSession.setRootElement(element); - for (ElementBindingHandler bind:languageContext.getLanguage().findElementBindingHandlers(object)) { + for (ElementBindingHandler bind:languageSession.getLanguage().findElementBindingHandlers(object)) { bind.createChilderen(element); - fillTree(languageContext,element); + fillTree(languageSession,element); } return element; } - private void fillTree(X4OLanguageContext languageContext,Element element) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException { + private void fillTree(X4OLanguageSession languageSession,Element element) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException { for (Element e:element.getChilderen()) { Object object = e.getElementObject(); - for (ElementBindingHandler bind:languageContext.getLanguage().findElementBindingHandlers(object)) { + for (ElementBindingHandler bind:languageSession.getLanguage().findElementBindingHandlers(object)) { bind.createChilderen(e); - fillTree(languageContext,e); + fillTree(languageSession,e); } } } - private Element findRootElement(X4OLanguageContext languageContext,Class objectClass) throws ElementNamespaceInstanceProviderException { + private Element findRootElement(X4OLanguageSession languageSession,Class objectClass) throws ElementNamespaceInstanceProviderException { // redo this mess, add nice find for root - for (X4OLanguageModule modContext:languageContext.getLanguage().getLanguageModules()) { + for (X4OLanguageModule modContext:languageSession.getLanguage().getLanguageModules()) { for (ElementNamespace nsContext:modContext.getElementNamespaces()) { if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { - return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getId()); + return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageSession, ec.getId()); } } } } } - for (X4OLanguageModule modContext:languageContext.getLanguage().getLanguageModules()) { + for (X4OLanguageModule modContext:languageSession.getLanguage().getLanguageModules()) { for (ElementNamespace nsContext:modContext.getElementNamespaces()) { for (ElementClass ec:nsContext.getElementClasses()) { if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { - return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageContext, ec.getId()); + return nsContext.getElementNamespaceInstanceProvider().createElementInstance(languageSession, ec.getId()); } } } @@ -174,7 +174,7 @@ public class X4OPhaseLanguageWrite { } public void runElementPhase(Element element) throws X4OPhaseException { } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { logger.finest("Run init end phase"); } }; @@ -189,7 +189,7 @@ public class X4OPhaseLanguageWrite { public String[] getPhaseDependencies() { return new String[] {X4OPhase.WRITE_END}; } - public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { + public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException { } public void runElementPhase(Element element) throws X4OPhaseException { try { diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseListener.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseListener.java index bd4e939..d45eca9 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseListener.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseListener.java @@ -22,7 +22,7 @@ */ package org.x4o.xml.lang.phase; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** @@ -40,7 +40,7 @@ public interface X4OPhaseListener { * @param elementLanguage The elementLanguage of the driver. * @throws X4OPhaseException Is throws when listeners has error. */ - void preRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException; + void preRunPhase(X4OPhase phase,X4OLanguageSession elementLanguage) throws X4OPhaseException; /** * Gets called after the X4OPhaseHandler is runned. @@ -48,5 +48,5 @@ public interface X4OPhaseListener { * @param elementLanguage The elementLanguage of the driver. * @throws X4OPhaseException Is throws when listeners has error. */ - void endRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException; + void endRunPhase(X4OPhase phase,X4OLanguageSession elementLanguage) throws X4OPhaseException; } diff --git a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseManager.java b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseManager.java index 7685ffc..2c6a33a 100644 --- a/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseManager.java +++ b/x4o-driver/src/main/java/org/x4o/xml/lang/phase/X4OPhaseManager.java @@ -26,7 +26,7 @@ import java.util.Collection; import java.util.List; import org.x4o.xml.element.Element; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** @@ -52,13 +52,13 @@ public interface X4OPhaseManager { */ List getOrderedPhases(X4OPhaseType type); - void doReleasePhaseManual(X4OLanguageContext languageContext) throws X4OPhaseException; + void doReleasePhaseManual(X4OLanguageSession languageSession) throws X4OPhaseException; /** * Runs all the phases in the right order. * @throws X4OPhaseException When a running handlers throws one. */ - void runPhases(X4OLanguageContext elementContext,X4OPhaseType type) throws X4OPhaseException; + void runPhases(X4OLanguageSession elementContext,X4OPhaseType type) throws X4OPhaseException; /** * Runs phase on single element. diff --git a/x4o-driver/src/test/java/org/x4o/xml/X4ODriverManagerTest.java b/x4o-driver/src/test/java/org/x4o/xml/X4ODriverManagerTest.java index 45854ed..fb925db 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/X4ODriverManagerTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/X4ODriverManagerTest.java @@ -86,7 +86,7 @@ public class X4ODriverManagerTest extends TestCase { Throwable e = null; try { X4ODriver driver = X4ODriverManager.getX4ODriver(language); - driver.createLanguage(version).createLanguageContext(); + driver.createLanguage(version).createLanguageSession(); } catch (Throwable catchE) { e = catchE; } diff --git a/x4o-driver/src/test/java/org/x4o/xml/core/NamespaceUriTest.java b/x4o-driver/src/test/java/org/x4o/xml/core/NamespaceUriTest.java index d51d57c..57d2c54 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/core/NamespaceUriTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/core/NamespaceUriTest.java @@ -24,7 +24,7 @@ package org.x4o.xml.core; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.X4OReaderContext; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.test.TestDriver; import org.x4o.xml.test.models.TestObjectRoot; @@ -40,7 +40,7 @@ import junit.framework.TestCase; public class NamespaceUriTest extends TestCase { public void testSimpleUri() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE); @@ -53,7 +53,7 @@ public class NamespaceUriTest extends TestCase { } public void testEmptyUri() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE); @@ -67,7 +67,7 @@ public class NamespaceUriTest extends TestCase { } public void testSchemaUri() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE); diff --git a/x4o-driver/src/test/java/org/x4o/xml/core/X4OEntityResolverTest.java b/x4o-driver/src/test/java/org/x4o/xml/core/X4OEntityResolverTest.java index c1faa80..fcfe553 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/core/X4OEntityResolverTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/core/X4OEntityResolverTest.java @@ -29,7 +29,7 @@ import org.x4o.xml.eld.CelDriver; import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.sax.X4OEntityResolver; import org.x4o.xml.io.sax.ext.PropertyConfig; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.test.TestDriver; import org.x4o.xml.test.models.TestObjectRoot; import org.xml.sax.EntityResolver; @@ -60,14 +60,14 @@ public class X4OEntityResolverTest extends TestCase { public void testResolve() throws Exception { X4ODriver driver = new CelDriver(); - X4OEntityResolver resolver = new X4OEntityResolver(driver.createLanguage().createLanguageContext(),DefaultX4OReader.DEFAULT_PROPERTY_CONFIG); + X4OEntityResolver resolver = new X4OEntityResolver(driver.createLanguage().createLanguageSession(),DefaultX4OReader.DEFAULT_PROPERTY_CONFIG); InputSource input = resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd"); assertNotNull(input); } public void testResolveMissing() throws Exception { X4ODriver driver = new TestDriver(); - X4OEntityResolver resolver = new X4OEntityResolver(driver.createLanguage().createLanguageContext(),DefaultX4OReader.DEFAULT_PROPERTY_CONFIG); + X4OEntityResolver resolver = new X4OEntityResolver(driver.createLanguage().createLanguageSession(),DefaultX4OReader.DEFAULT_PROPERTY_CONFIG); Exception e = null; try { resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd-missing-resource"); @@ -81,7 +81,7 @@ public class X4OEntityResolverTest extends TestCase { public void testResolveProperty() throws Exception { X4ODriver driver = new TestDriver(); - X4OLanguageContext language = driver.createLanguage().createLanguageContext(); + X4OLanguageSession language = driver.createLanguage().createLanguageSession(); PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER); conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver()); X4OEntityResolver resolver = new X4OEntityResolver(language,conf); @@ -98,7 +98,7 @@ public class X4OEntityResolverTest extends TestCase { public void testResolvePropertyNull() throws Exception { X4ODriver driver = new TestDriver(); - X4OLanguageContext language = driver.createLanguage().createLanguageContext(); + X4OLanguageSession language = driver.createLanguage().createLanguageSession(); PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER); conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver()); X4OEntityResolver resolver = new X4OEntityResolver(language,conf); diff --git a/x4o-driver/src/test/java/org/x4o/xml/core/X4OPhaseManagerTest.java b/x4o-driver/src/test/java/org/x4o/xml/core/X4OPhaseManagerTest.java index c568dcc..b22ac49 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/core/X4OPhaseManagerTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/core/X4OPhaseManagerTest.java @@ -25,7 +25,7 @@ package org.x4o.xml.core; import java.util.Collection; import java.util.List; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhaseManager; import org.x4o.xml.lang.phase.X4OPhaseType; @@ -50,7 +50,7 @@ public class X4OPhaseManagerTest extends TestCase { public void testPhases() throws Exception { TestDriver driver = TestDriver.getInstance(); - X4OLanguageContext context = driver.createLanguage().createLanguageContext(); + X4OLanguageSession context = driver.createLanguage().createLanguageSession(); X4OPhaseManager manager = context.getLanguage().getPhaseManager(); Collection phasesAll = manager.getAllPhases(); List phases = manager.getOrderedPhases(X4OPhaseType.XML_READ); @@ -67,7 +67,7 @@ public class X4OPhaseManagerTest extends TestCase { /* public void testPhaseManager() throws Exception { TestDriver driver = TestDriver.getInstance(); - ElementLanguage context = driver.createLanguageContext(); + ElementLanguage context = driver.createLanguageSession(); X4OPhaseManager manager = context.getLanguage().getPhaseManager(); Exception e = null; diff --git a/x4o-driver/src/test/java/org/x4o/xml/io/X4OReaderContextTest.java b/x4o-driver/src/test/java/org/x4o/xml/io/X4OReaderContextTest.java index bcbe634..ef6ef1b 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/io/X4OReaderContextTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/io/X4OReaderContextTest.java @@ -29,7 +29,7 @@ import java.net.URL; import org.x4o.xml.X4ODriver; import org.x4o.xml.io.X4OReader; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.test.TestDriver; import org.x4o.xml.test.models.TestBean; import org.x4o.xml.test.models.TestObjectRoot; @@ -62,7 +62,7 @@ public class X4OReaderContextTest extends TestCase { TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); File xmlFile = copyResourceToTempFile(); - X4OLanguageContext context = reader.readFileContext(xmlFile.getAbsolutePath()); + X4OLanguageSession context = reader.readFileContext(xmlFile.getAbsolutePath()); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); assertNotNull(root); assertTrue(root.getTestBeans().size()>0); @@ -90,7 +90,7 @@ public class X4OReaderContextTest extends TestCase { TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); File xmlFile = copyResourceToTempFile(); - X4OLanguageContext context = reader.readFileContext(xmlFile); + X4OLanguageSession context = reader.readFileContext(xmlFile); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); assertNotNull(root); assertTrue(root.getTestBeans().size()>0); @@ -153,7 +153,7 @@ public class X4OReaderContextTest extends TestCase { public void testReadResource() throws Exception { TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); - X4OLanguageContext context = reader.readResourceContext("tests/attributes/test-bean.xml"); + X4OLanguageSession context = reader.readResourceContext("tests/attributes/test-bean.xml"); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); assertNotNull(root); } @@ -176,7 +176,7 @@ public class X4OReaderContextTest extends TestCase { public void testReadString() throws Exception { TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); - X4OLanguageContext context = reader.readStringContext( + X4OLanguageSession context = reader.readStringContext( ""+ ""+ ""+ @@ -209,7 +209,7 @@ public class X4OReaderContextTest extends TestCase { TestDriver driver = TestDriver.getInstance(); X4OReaderContext reader = driver.createReaderContext(); URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml"); - X4OLanguageContext context = reader.readUrlContext(xmlUrl); + X4OLanguageSession context = reader.readUrlContext(xmlUrl); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); assertNotNull(root); assertTrue(root.getTestBeans().size()>0); diff --git a/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterContextTest.java b/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterContextTest.java index f546bcd..2279361 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterContextTest.java +++ b/x4o-driver/src/test/java/org/x4o/xml/io/X4OWriterContextTest.java @@ -30,7 +30,7 @@ import java.io.OutputStream; import org.x4o.xml.X4ODriver; import org.x4o.xml.element.Element; import org.x4o.xml.io.X4OReader; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.test.TestDriver; import org.x4o.xml.test.models.TestObjectRoot; import org.xml.sax.SAXException; @@ -51,11 +51,11 @@ public class X4OWriterContextTest extends TestCase { return outputFile; } - private X4OLanguageContext createContext() throws SAXException, X4OConnectionException, IOException { + private X4OLanguageSession createContext() throws SAXException, X4OConnectionException, IOException { X4ODriver driver = TestDriver.getInstance(); X4OReader reader = driver.createReader(); TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml"); - X4OLanguageContext context = driver.createLanguage().createLanguageContext(); + X4OLanguageSession context = driver.createLanguage().createLanguageSession(); Element rootElement = null; try { rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance(); diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlActionConfigurator.java b/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlActionConfigurator.java index 380873b..93c3388 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlActionConfigurator.java +++ b/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlActionConfigurator.java @@ -42,7 +42,7 @@ public class SwiXmlActionConfigurator extends AbstractElementConfigurator { if (actionName==null) { return; } - SwingEngine se = SwiXmlDriver.getSwingEngine(element.getLanguageContext()); + SwingEngine se = SwiXmlDriver.getSwingEngine(element.getLanguageSession()); Action action = se.getUIActionByName(actionName); Object object = element.getElementObject(); if (object instanceof JMenuItem) { diff --git a/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java b/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java index 4f6de08..c605bb0 100644 --- a/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java +++ b/x4o-driver/src/test/java/org/x4o/xml/test/swixml/SwiXmlDriver.java @@ -28,7 +28,7 @@ import javax.el.ValueExpression; import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriverManager; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** * SwiXmlParser works with the SwingEngine to config the UI tree. @@ -50,7 +50,7 @@ public class SwiXmlDriver extends X4ODriver { * @param elementLanguage The elementLanguage to get the swingEngine out. * @return Returns the SwingEngine for this elementLanguage. */ - static public SwingEngine getSwingEngine(X4OLanguageContext elementLanguage) { + static public SwingEngine getSwingEngine(X4OLanguageSession elementLanguage) { ValueExpression ee = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),"${"+SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE+"}",Object.class); SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getExpressionLanguageContext()); return se; diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java index 6526cc2..8a35642 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriter.java @@ -45,7 +45,7 @@ import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.lang.X4OLanguageModule; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.xml.sax.SAXException; /** @@ -57,7 +57,7 @@ import org.xml.sax.SAXException; public class EldDocWriter { // The context to write doc over. - private X4OLanguageContext context = null; + private X4OLanguageSession context = null; // Core concepts private static final String[] C_CONTEXT = {"language","Overview","All language modules.","The loaded language modules.."}; @@ -77,7 +77,7 @@ public class EldDocWriter { * Creates an EldDocGenerator for this langauge context. * @param context The language context to generate doc for. */ - public EldDocWriter(X4OLanguageContext context) { + public EldDocWriter(X4OLanguageSession context) { this.context=context; } @@ -118,7 +118,7 @@ public class EldDocWriter { doc.setFrameNavConceptClass(ElementClass.class); - doc.addTreeNodePageModeClass(X4OLanguageContext.class); + doc.addTreeNodePageModeClass(X4OLanguageSession.class); doc.addTreeNodePageModeClass(X4OLanguageModule.class); doc.addTreeNodePageModeClass(ElementInterface.class); doc.addTreeNodePageModeClass(ElementNamespace.class); @@ -129,7 +129,7 @@ public class EldDocWriter { doc.addAnnotatedClasses(EldDocWriterElementNamespace.class); doc.addAnnotatedClasses(EldDocWriterElementInterface.class); - ApiDocConcept adcRoot = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguageContext.class)); + ApiDocConcept adcRoot = doc.addConcept(new ApiDocConcept(null,C_CONTEXT,X4OLanguageSession.class)); ApiDocConcept adcMod = doc.addConcept(new ApiDocConcept(adcRoot,C_MODULE,X4OLanguageModule.class)); ApiDocConcept adcIface = doc.addConcept(new ApiDocConcept(adcMod,C_INTERFACE,ElementInterface.class)); ApiDocConcept adcNs = doc.addConcept(new ApiDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class)); diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java index 2e90e5a..6d9323b 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterElementClass.java @@ -39,7 +39,7 @@ import org.x4o.xml.element.ElementClassAttribute; import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageModule; import org.xml.sax.SAXException; @@ -113,7 +113,7 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter { ElementClass ec = (ElementClass)event.getEventObject().getUserData(); ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData(); X4OLanguageModule mod = (X4OLanguageModule)event.getEventObject().getParent().getParent().getUserData(); - X4OLanguageContext context = (X4OLanguageContext)event.getEventObject().getParent().getParent().getParent().getUserData(); + X4OLanguageSession context = (X4OLanguageSession)event.getEventObject().getParent().getParent().getParent().getUserData(); // TODO: this is hacky EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0); diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterLanguage.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterLanguage.java index aead4bf..d2a20c7 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterLanguage.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocWriterLanguage.java @@ -33,7 +33,7 @@ import org.x4o.xml.element.ElementBindingHandler; import org.x4o.xml.element.ElementClassAttribute; import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementNamespace; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageModule; import org.xml.sax.SAXException; @@ -64,11 +64,11 @@ public class EldDocWriterLanguage extends AbstractApiDocWriter { } - @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class},nodeBodyOrders={1}) + @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={1}) public void writeLanguageSummary(ApiDocWriteEvent event) throws SAXException { ApiDocContentWriter writer = event.getWriter(); ApiDocNode node = event.getEventObject(); - X4OLanguageContext context = (X4OLanguageContext)node.getUserData(); + X4OLanguageSession context = (X4OLanguageSession)node.getUserData(); int attrHandlers = 0; int bindHandlers = 0; int interFaces = 0; @@ -99,16 +99,16 @@ public class EldDocWriterLanguage extends AbstractApiDocWriter { writer.docTableEnd(); } - @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class},nodeBodyOrders={2}) + @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={2}) public void writeModulesSummary(ApiDocWriteEvent event) throws SAXException { printApiTable(event,"Module Summary",X4OLanguageModule.class); } - @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class},nodeBodyOrders={3}) + @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={3}) public void writeNamespaceSummary(ApiDocWriteEvent event) throws SAXException { ApiDocContentWriter writer = event.getWriter(); ApiDocNode node = event.getEventObject(); - X4OLanguageContext context = (X4OLanguageContext)node.getUserData(); + X4OLanguageSession context = (X4OLanguageSession)node.getUserData(); writer.docTableStart("Namespace Summary", "All Language Namespaces Overview",ApiDocContentCss.overviewSummary); writer.docTableHeader("ID", "URI"); for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java index aa4ffd4..d1c1e71 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/EldDocXTreePageWriter.java @@ -39,7 +39,7 @@ import org.x4o.xml.element.ElementClass; import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.X4OLanguageModule; import org.xml.sax.SAXException; @@ -81,7 +81,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD public void writePageContent(ApiDocWriteEvent e) throws SAXException { //selectRootNode(e.getDoc()); // create ApiDoc doc = e.getDoc(); - X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData(); + X4OLanguageSession context = (X4OLanguageSession)doc.getRootNode().getUserData(); String pathPrefix = "language/"; @@ -137,7 +137,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD private ApiDocNode createXTree(ApiDoc doc) throws SAXException { - X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData(); + X4OLanguageSession context = (X4OLanguageSession)doc.getRootNode().getUserData(); ApiDocNode root = new ApiDocNode(context,"root","Root","Language root"); List rootNodes = new ArrayList(3); @@ -175,7 +175,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD class TreeNode { - X4OLanguageContext context; + X4OLanguageSession context; X4OLanguageModule module; ElementNamespace namespace; ElementClass elementClass; diff --git a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java index 18a5431..e6ab901 100644 --- a/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java +++ b/x4o-eld-doc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java @@ -30,7 +30,7 @@ import java.util.List; import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriverManager; import org.x4o.xml.element.ElementException; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; /** * X4OWriteLanguageDoc is support class to write html documentation from the eld. @@ -95,7 +95,7 @@ public class X4OWriteLanguageDocExecutor { */ public void execute() throws ElementException { X4ODriver driver = X4ODriverManager.getX4ODriver(getLanguageName()); - X4OLanguageContext context = driver.createLanguage(getLanguageVersion()).createLanguageContext(); + X4OLanguageSession context = driver.createLanguage(getLanguageVersion()).createLanguageSession(); // Run doc writer EldDocWriter docWriter = new EldDocWriter(context); diff --git a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELIDAttributeHandler.java b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELIDAttributeHandler.java index 430be7e..8f46fd4 100644 --- a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELIDAttributeHandler.java +++ b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELIDAttributeHandler.java @@ -53,8 +53,8 @@ public class ELIDAttributeHandler extends AbstractElementAttributeHandler { return; } if(element.getElementObject()==null) { throw new NullPointerException("Can't bind null object to el context"); } - ValueExpression ee = element.getLanguageContext().getExpressionLanguageFactory().createValueExpression(element.getLanguageContext().getExpressionLanguageContext(),"${"+attributeValue+"}", element.getElementObject().getClass()); + ValueExpression ee = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(element.getLanguageSession().getExpressionLanguageContext(),"${"+attributeValue+"}", element.getElementObject().getClass()); Logger.getLogger(ELIDAttributeHandler.class.getName()).finer("Set Variable in ELContext: "+"${"+attributeValue+"}"+" object SET: "+element.getElementObject()); - ee.setValue(element.getLanguageContext().getExpressionLanguageContext(), element.getElementObject()); + ee.setValue(element.getLanguageSession().getExpressionLanguageContext(), element.getElementObject()); } } diff --git a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELReferenceElement.java b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELReferenceElement.java index 18f9d74..d3bd190 100644 --- a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELReferenceElement.java +++ b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/ELReferenceElement.java @@ -43,8 +43,8 @@ public class ELReferenceElement extends AbstractElement { public void doElementRun() throws ElementException { String attributeValue = getAttributes().get("el.ref"); if("".equals(attributeValue) | attributeValue==null) { throw new ElementException("Set the el.ref attribute"); } - ValueExpression ee = getLanguageContext().getExpressionLanguageFactory().createValueExpression(getLanguageContext().getExpressionLanguageContext(),"${"+attributeValue+"}",Object.class); + ValueExpression ee = getLanguageSession().getExpressionLanguageFactory().createValueExpression(getLanguageSession().getExpressionLanguageContext(),"${"+attributeValue+"}",Object.class); Logger.getLogger(ELReferenceElement.class.getName()).finer("Get Variable in ELContext: ${"+attributeValue+"}"); - setElementObject(ee.getValue(getLanguageContext().getExpressionLanguageContext())); + setElementObject(ee.getValue(getLanguageSession().getExpressionLanguageContext())); } } diff --git a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/PropertyElement.java b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/PropertyElement.java index 1bebc5b..1399749 100644 --- a/x4o-meta/src/main/java/org/x4o/xml/lang/meta/PropertyElement.java +++ b/x4o-meta/src/main/java/org/x4o/xml/lang/meta/PropertyElement.java @@ -64,7 +64,7 @@ public class PropertyElement extends AbstractElement { // convert value object try { - value = getLanguageContext().getElementAttributeValueParser().getParameterValue(name,valueString,this); + value = getLanguageSession().getElementAttributeValueParser().getParameterValue(name,valueString,this); } catch (ObjectConverterException ece) { throw new ElementException(ece); } @@ -101,7 +101,7 @@ public class PropertyElement extends AbstractElement { // try to set as property on bean. try { - getLanguageContext().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value); + getLanguageSession().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value); return; } catch (Exception e) { throw new ElementException("Could not set property on parent element object: "+name,e); diff --git a/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ParentObjectTest.java b/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ParentObjectTest.java index 1d41eea..71960df 100644 --- a/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ParentObjectTest.java +++ b/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ParentObjectTest.java @@ -27,7 +27,7 @@ import javax.swing.JLabel; import org.x4o.xml.element.DefaultElement; import org.x4o.xml.element.Element; import org.x4o.xml.io.X4OReaderContext; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.phase.X4OPhase; import junit.framework.TestCase; @@ -41,7 +41,7 @@ import junit.framework.TestCase; public class ParentObjectTest extends TestCase { public void testParentElement() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; MTestDriver driver = new MTestDriver(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE); diff --git a/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ReferenceStoreTest.java b/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ReferenceStoreTest.java index ae4f07e..b81981f 100644 --- a/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ReferenceStoreTest.java +++ b/x4o-meta/src/test/java/org/x4o/xml/lang/meta/ReferenceStoreTest.java @@ -25,7 +25,7 @@ package org.x4o.xml.lang.meta; import java.util.Date; import org.x4o.xml.io.X4OReaderContext; -import org.x4o.xml.lang.X4OLanguageContext; +import org.x4o.xml.lang.X4OLanguageSession; import org.x4o.xml.lang.phase.X4OPhase; import junit.framework.TestCase; @@ -39,7 +39,7 @@ import junit.framework.TestCase; public class ReferenceStoreTest extends TestCase { public void testMetaGeneric() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; MTestDriver driver = new MTestDriver(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE); @@ -52,7 +52,7 @@ public class ReferenceStoreTest extends TestCase { } public void testLoadClass() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; MTestDriver driver = new MTestDriver(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE); @@ -65,7 +65,7 @@ public class ReferenceStoreTest extends TestCase { } public void testStoreRef() throws Exception { - X4OLanguageContext context = null; + X4OLanguageSession context = null; MTestDriver driver = new MTestDriver(); X4OReaderContext reader = driver.createReaderContext(); reader.addPhaseSkip(X4OPhase.READ_RELEASE);