Renamed X4OLanguageContext to X4OLanguageSession

This commit is contained in:
Willem Cazander 2013-08-24 19:30:58 +02:00
parent b1193b9051
commit 4e9052244c
58 changed files with 412 additions and 412 deletions

View file

@ -169,19 +169,19 @@ public abstract class X4ODriver<T> {
} }
/* /*
* Creates the X4OLanguageContext for the default language version. * Creates the X4OLanguageSession for the default language version.
* @return The created X4OLanguageContext. * @return The created X4OLanguageSession.
* *
final public X4OLanguageContext createLanguageContext() { final public X4OLanguageSession createLanguageSession() {
return createLanguageContext(getLanguageVersionDefault()); 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. * @param version The language version to create the context for.
* @return The created X4OLanguageContext. * @return The created X4OLanguageSession.
* *
final public X4OLanguageContext createLanguageContext(String version) { final public X4OLanguageSession createLanguageSession(String version) {
return createLanguage(version).createLanguageContext(); return createLanguage(version).createLanguageSession();
}*/ }*/
} }

View file

@ -33,7 +33,7 @@ import org.x4o.xml.io.X4OConnectionException;
import org.x4o.xml.io.X4OReader; import org.x4o.xml.io.X4OReader;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageModule; 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.X4OLanguageModuleLoader;
import org.x4o.xml.lang.X4OLanguageModuleLoaderException; import org.x4o.xml.lang.X4OLanguageModuleLoaderException;
import org.x4o.xml.lang.X4OLanguageLocal; import org.x4o.xml.lang.X4OLanguageLocal;
@ -90,7 +90,7 @@ public class EldModuleLoader implements X4OLanguageModuleLoader {
X4OReader<?> reader = driver.createReader(); X4OReader<?> reader = driver.createReader();
//X4OLanguageContext eldLang = driver.createLanguageContext(driver.getLanguageVersionDefault()); //X4OLanguageSession eldLang = driver.createLanguageSession(driver.getLanguageVersionDefault());
//X4OReader<?> reader = new DefaultX4OReader<Object>(eldLang); //X4OReader<?> reader = new DefaultX4OReader<Object>(eldLang);
reader.addELBeanInstance(EL_PARENT_LANGUAGE, language); 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); ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE+"}", X4OLanguage.class);
return (X4OLanguage)ee.getValue(context.getExpressionLanguageContext()); 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); ValueExpression ee = context.getExpressionLanguageFactory().createValueExpression(context.getExpressionLanguageContext(),"${"+EL_PARENT_LANGUAGE_MODULE+"}", X4OLanguageModule.class);
return (X4OLanguageModule)ee.getValue(context.getExpressionLanguageContext()); return (X4OLanguageModule)ee.getValue(context.getExpressionLanguageContext());
} }

View file

@ -75,7 +75,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
*/ */
public void bindChild(Element childElement,X4OLanguageModule languageModule, Object childObject) throws ElementBindingHandlerException { 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) { if (x4oParsingContext==null) {
return; return;
} }
@ -133,7 +133,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
} }
try { try {
elementNamespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider())); elementNamespace.setElementNamespaceInstanceProvider((ElementNamespaceInstanceProvider)X4OLanguageClassLoader.newInstance(childElement.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementNamespaceInstanceProvider()));
} catch (Exception e) { } catch (Exception e) {
throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e); throw new ElementBindingHandlerException("Error loading: "+e.getMessage(),e);
} }

View file

@ -45,7 +45,7 @@ public class ModuleElement extends AbstractElement {
if (getParent()!=null) { if (getParent()!=null) {
throw new ElementException("Need to be root tag"); throw new ElementException("Need to be root tag");
} }
X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageContext()); X4OLanguageModule elementLanguageModule = EldModuleLoader.getLanguageModule(getLanguageSession());
setElementObject(elementLanguageModule); setElementObject(elementLanguageModule);
} }
} }

View file

@ -27,7 +27,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguageClassLoader; import org.x4o.xml.lang.X4OLanguageClassLoader;
/** /**
@ -43,7 +43,7 @@ public abstract class AbstractElement implements Element {
/** The config object */ /** The config object */
private Object elementObject = null; private Object elementObject = null;
/** The language parsing context */ /** The language parsing context */
private X4OLanguageContext languageContext = null; private X4OLanguageSession languageSession = null;
/** The ElementClass */ /** The ElementClass */
private ElementClass elementClass = null; private ElementClass elementClass = null;
/** The attributes */ /** The attributes */
@ -93,7 +93,7 @@ public abstract class AbstractElement implements Element {
getAttributes().clear(); getAttributes().clear();
setElementClass(null); setElementClass(null);
setParent(null); setParent(null);
setLanguageContext(null); setLanguageSession(null);
attributes.clear(); attributes.clear();
childeren.clear(); // we do not release childeren, x4o does that childeren.clear(); // we do not release childeren, x4o does that
allChilderen.clear(); 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) { public void setLanguageSession(X4OLanguageSession languageSession) {
this.languageContext=languageContext; this.languageSession=languageSession;
} }
/** /**
* @see Element#getLanguageContext() * @see Element#getLanguageSession()
*/ */
public X4OLanguageContext getLanguageContext() { public X4OLanguageSession getLanguageSession() {
return languageContext; return languageSession;
} }
/** /**
@ -132,7 +132,7 @@ public abstract class AbstractElement implements Element {
*/ */
public void doCharacters(String characters) throws ElementException { public void doCharacters(String characters) throws ElementException {
try { try {
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters()); Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyCharacters());
e.setElementObject(characters); e.setElementObject(characters);
addChild(e); addChild(e);
} catch (Exception exception) { } catch (Exception exception) {
@ -145,7 +145,7 @@ public abstract class AbstractElement implements Element {
*/ */
public void doComment(String comment) throws ElementException { public void doComment(String comment) throws ElementException {
try { try {
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment()); Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyComment());
e.setElementObject(comment); e.setElementObject(comment);
addChild(e); addChild(e);
} catch (Exception exception) { } catch (Exception exception) {
@ -158,7 +158,7 @@ public abstract class AbstractElement implements Element {
*/ */
public void doIgnorableWhitespace(String space) throws ElementException { public void doIgnorableWhitespace(String space) throws ElementException {
try { try {
Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace()); Element e = (Element)X4OLanguageClassLoader.newInstance(getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementBodyWhitespace());
e.setElementObject(space); e.setElementObject(space);
addChild(e); addChild(e);
} catch (Exception exception) { } catch (Exception exception) {

View file

@ -53,7 +53,7 @@ public abstract class AbstractElementBindingHandler<T> extends AbstractElementMe
if (parentElement==null) { if (parentElement==null) {
throw new NullPointerException("Can't create child with null parent."); 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) { if (childElement==null) {
throw new NullPointerException("Could not find Element for child: "+childObject.getClass()); throw new NullPointerException("Could not find Element for child: "+childObject.getClass());
} }

View file

@ -82,7 +82,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
if (element.getElementObject()==null) { if (element.getElementObject()==null) {
return value; 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."); logger.finer("Found interface match executing converter.");
for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) { for (ElementClassAttribute attrClass:ei.getElementClassAttributes()) {
if (name.equals(attrClass.getId())==false) { 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) * @see org.x4o.xml.element.ElementAttributeValueParser#getELParameterValue(java.lang.String, org.x4o.xml.element.Element)
*/ */
public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException { public Object getELParameterValue(String value, Element element) throws ElementAttributeValueParserException {
ValueExpression e = element.getLanguageContext().getExpressionLanguageFactory().createValueExpression(element.getLanguageContext().getExpressionLanguageContext(), (String)value,Object.class); ValueExpression e = element.getLanguageSession().getExpressionLanguageFactory().createValueExpression(element.getLanguageSession().getExpressionLanguageContext(), (String)value,Object.class);
return e.getValue(element.getLanguageContext().getExpressionLanguageContext()); return e.getValue(element.getLanguageSession().getExpressionLanguageContext());
} }
/** /**
@ -129,7 +129,7 @@ public class DefaultElementAttributeValueParser implements ElementAttributeValue
return false; 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."); logger.finest("Found interface match checking disables el parameters.");
attr = ei.getElementClassAttributeByName(name); attr = ei.getElementClassAttributeByName(name);

View file

@ -27,7 +27,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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; 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) {
} }
/** /**

View file

@ -24,7 +24,7 @@ package org.x4o.xml.element;
import java.util.logging.Logger; 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.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageClassLoader; 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. * @param tag The xml tag to create an Element instance for.
* @return The Element to handle the given tag. * @return The Element to handle the given tag.
* @throws ElementNamespaceInstanceProviderException * @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); ElementClass elementClass = elementNamespace.getElementClass(tag);
Element element = null; Element element = null;
@ -80,7 +80,7 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
throw new ElementNamespaceInstanceProviderException(this,"Provided elementClassName is not an Element: "+obj.getClass()); throw new ElementNamespaceInstanceProviderException(this,"Provided elementClassName is not an Element: "+obj.getClass());
} }
} else { } else {
element = (Element)X4OLanguageClassLoader.newInstance((languageContext.getLanguage().getLanguageConfiguration().getDefaultElement())); element = (Element)X4OLanguageClassLoader.newInstance((languageSession.getLanguage().getLanguageConfiguration().getDefaultElement()));
} }
if (elementClass.getObjectClass()!=null) { if (elementClass.getObjectClass()!=null) {
@ -94,7 +94,7 @@ public class DefaultElementNamespaceInstanceProvider implements ElementNamespace
throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e); throw new ElementNamespaceInstanceProviderException(this,"Error while providing Element: "+e.getMessage(),e);
} */ } */
element.setElementClass(elementClass); element.setElementClass(elementClass);
element.setLanguageContext(languageContext); element.setLanguageSession(languageSession);
return element; return element;
} }
} }

View file

@ -26,7 +26,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
/** /**
* Defines an XML element with an object.<br> * Defines an XML element with an object.<br>
@ -132,16 +132,16 @@ public interface Element {
void setElementObject(Object object); void setElementObject(Object object);
/** /**
* Sets the ElementLanguage. * Sets the X4OLanguageSession.
* @param elementLanguage The ElementLanguage to set. * @param languageSession The X4OLanguageSession to set.
*/ */
void setLanguageContext(X4OLanguageContext elementLanguage); void setLanguageSession(X4OLanguageSession languageSession);
/** /**
* Gets the ElementLanguage. * Gets the X4OLanguageSession.
* @return Returns the ElementLanguage. * @return Returns the X4OLanguageSession.
*/ */
X4OLanguageContext getLanguageContext(); X4OLanguageSession getLanguageSession();
/** /**
* Sets the body texts on an event based system. * Sets the body texts on an event based system.

View file

@ -22,7 +22,7 @@
*/ */
package org.x4o.xml.element; package org.x4o.xml.element;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
/** /**
@ -43,10 +43,10 @@ public interface ElementNamespaceInstanceProvider {
/** /**
* Provide an Element for an xml tag. * 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. * @param tag The xml tag to create instance for.
* @return An new Element instance. * @return An new Element instance.
* @throws ElementNamespaceInstanceProviderException Thrown when error happened in language. * @throws ElementNamespaceInstanceProviderException Thrown when error happened in language.
*/ */
Element createElementInstance(X4OLanguageContext languageContext,String tag) throws ElementNamespaceInstanceProviderException; Element createElementInstance(X4OLanguageSession languageSession,String tag) throws ElementNamespaceInstanceProviderException;
} }

View file

@ -32,7 +32,7 @@ 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.X4OLanguageClassLoader;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -57,7 +57,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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) { if (fileName==null) {
throw new NullPointerException("Can't convert null fileName to file object."); throw new NullPointerException("Can't convert null fileName to file object.");
} }
@ -73,7 +73,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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) { if (file==null) {
throw new NullPointerException("Can't read null file."); throw new NullPointerException("Can't read null file.");
} }
@ -100,7 +100,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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) { if (resourceName==null) {
throw new NullPointerException("Can't read null resourceName from classpath."); throw new NullPointerException("Can't read null resourceName from classpath.");
} }
@ -130,7 +130,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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) { if (xmlString==null) {
throw new NullPointerException("Can't read null xml string."); throw new NullPointerException("Can't read null xml string.");
} }
@ -147,7 +147,7 @@ abstract public class AbstractX4OReaderContext<T> extends AbstractX4OConnection
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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) { if (url==null) {
throw new NullPointerException("Can't read null url."); throw new NullPointerException("Can't read null url.");
} }

View file

@ -29,7 +29,7 @@ import java.io.OutputStream;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -44,10 +44,10 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> i
super(language); super(language);
} }
abstract X4OLanguageContext getLanguageContext(); abstract X4OLanguageSession createLanguageSession();
private X4OLanguageContext toObjectContext(T object) throws SAXException { private X4OLanguageSession toObjectContext(T object) throws SAXException {
X4OLanguageContext context = getLanguageContext(); X4OLanguageSession context = createLanguageSession();
Element rootElement = null; Element rootElement = null;
try { try {
rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance(); rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance();
@ -57,7 +57,7 @@ public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> i
throw new SAXException(e); throw new SAXException(e);
} }
rootElement.setElementObject(object); rootElement.setElementObject(object);
rootElement.setLanguageContext(context); rootElement.setLanguageSession(context);
context.setRootElement(rootElement); context.setRootElement(rootElement);
return context; return context;
} }

View file

@ -30,7 +30,7 @@ import java.io.OutputStream;
import org.x4o.xml.io.sax.ext.ContentWriterXml; import org.x4o.xml.io.sax.ext.ContentWriterXml;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -45,14 +45,14 @@ public abstract class AbstractX4OWriterContext<T> extends AbstractX4OConnection
super(language); 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) { if (fileName==null) {
throw new NullPointerException("Can't convert null fileName to file object."); throw new NullPointerException("Can't convert null fileName to file object.");
} }
writeFileContext(context,new File(fileName)); 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) { if (file==null) {
throw new NullPointerException("Can't read null file."); throw new NullPointerException("Can't read null file.");
} }
@ -64,7 +64,7 @@ public abstract class AbstractX4OWriterContext<T> 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); ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
writeContext(context, out); writeContext(context, out);
String encoding = (String)getProperty(ContentWriterXml.OUTPUT_ENCODING); String encoding = (String)getProperty(ContentWriterXml.OUTPUT_ENCODING);

View file

@ -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;
import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem; import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem;
import org.x4o.xml.lang.X4OLanguage; import org.x4o.xml.lang.X4OLanguage;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguageContextLocal; import org.x4o.xml.lang.X4OLanguageSessionLocal;
import org.x4o.xml.lang.phase.X4OPhaseException; import org.x4o.xml.lang.phase.X4OPhaseException;
import org.x4o.xml.lang.phase.X4OPhaseType; import org.x4o.xml.lang.phase.X4OPhaseType;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
@ -62,7 +62,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
/** The logger to log to. */ /** The logger to log to. */
private Logger logger = null; private Logger logger = null;
private X4OLanguageContext languageContext = null; private X4OLanguageSession languageSession = null;
private PropertyConfig propertyConfig; private PropertyConfig propertyConfig;
@ -117,7 +117,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
public DefaultX4OReader(X4OLanguage language) { public DefaultX4OReader(X4OLanguage language) {
super(language); super(language);
logger = Logger.getLogger(DefaultX4OReader.class.getName()); logger = Logger.getLogger(DefaultX4OReader.class.getName());
languageContext = language.createLanguageContext(); languageSession = language.createLanguageSession();
propertyConfig = new PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX); propertyConfig = new PropertyConfig(DEFAULT_PROPERTY_CONFIG,PROPERTY_CONTEXT_PREFIX);
} }
@ -126,12 +126,12 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
return propertyConfig; 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_STREAM, input);
setProperty(INPUT_SYSTEM_ID, systemId); setProperty(INPUT_SYSTEM_ID, systemId);
setProperty(INPUT_BASE_PATH, basePath); setProperty(INPUT_BASE_PATH, basePath);
read(); read();
return languageContext; return languageSession;
} }
public void addELBeanInstance(String name,Object bean) { public void addELBeanInstance(String name,Object bean) {
@ -144,21 +144,21 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
if (bean==null) { if (bean==null) {
throw new NullPointerException("Can't add null bean."); throw new NullPointerException("Can't add null bean.");
} }
ValueExpression ve = languageContext.getExpressionLanguageFactory().createValueExpression(languageContext.getExpressionLanguageContext(),"${"+name+"}", bean.getClass()); ValueExpression ve = languageSession.getExpressionLanguageFactory().createValueExpression(languageSession.getExpressionLanguageContext(),"${"+name+"}", bean.getClass());
ve.setValue(languageContext.getExpressionLanguageContext(), bean); ve.setValue(languageSession.getExpressionLanguageContext(), bean);
} }
/** /**
* Parses the input stream as a X4O document. * Parses the input stream as a X4O document.
*/ */
protected void read() throws X4OConnectionException,SAXException,IOException { protected void read() throws X4OConnectionException,SAXException,IOException {
if (languageContext.getLanguage()==null) { if (languageSession.getLanguage()==null) {
throw new X4OConnectionException("languageContext is broken getLanguage() returns null."); throw new X4OConnectionException("languageSession is broken getLanguage() returns null.");
} }
if (languageContext instanceof X4OLanguageContextLocal) { if (languageSession instanceof X4OLanguageSessionLocal) {
X4OLanguageContextLocal ll = (X4OLanguageContextLocal)languageContext; X4OLanguageSessionLocal ll = (X4OLanguageSessionLocal)languageSession;
if (phaseStop!=null) { if (phaseStop!=null) {
ll.setPhaseStop(phaseStop); ll.setPhaseStop(phaseStop);
} }
@ -171,7 +171,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
boolean startedDebugWriter = false; boolean startedDebugWriter = false;
Object debugOutputHandler = null; //TODO: getProperty(X4OLanguageProperty.DEBUG_OUTPUT_HANDLER.name()); Object debugOutputHandler = null; //TODO: getProperty(X4OLanguageProperty.DEBUG_OUTPUT_HANDLER.name());
Object debugOutputStream = null; //getProperty(X4OLanguageProperty.DEBUG_OUTPUT_STREAM.name()); Object debugOutputStream = null; //getProperty(X4OLanguageProperty.DEBUG_OUTPUT_STREAM.name());
if (languageContext.getX4ODebugWriter()==null) { if (languageSession.getX4ODebugWriter()==null) {
ContentWriter xmlDebugWriter = null; ContentWriter xmlDebugWriter = null;
if (debugOutputHandler instanceof ContentWriter) { if (debugOutputHandler instanceof ContentWriter) {
xmlDebugWriter = (ContentWriter)debugOutputHandler; xmlDebugWriter = (ContentWriter)debugOutputHandler;
@ -182,37 +182,37 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
xmlDebugWriter.startDocument(); xmlDebugWriter.startDocument();
xmlDebugWriter.startPrefixMapping("debug", X4ODebugWriter.DEBUG_URI); xmlDebugWriter.startPrefixMapping("debug", X4ODebugWriter.DEBUG_URI);
X4ODebugWriter debugWriter = new X4ODebugWriter(xmlDebugWriter); X4ODebugWriter debugWriter = new X4ODebugWriter(xmlDebugWriter);
X4OLanguageContextLocal local = (X4OLanguageContextLocal)languageContext; X4OLanguageSessionLocal local = (X4OLanguageSessionLocal)languageSession;
local.setX4ODebugWriter(debugWriter); local.setX4ODebugWriter(debugWriter);
startedDebugWriter = true; startedDebugWriter = true;
} }
} }
// debug language // debug language
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "language", "", "", languageContext.getLanguage().getLanguageName()); atts.addAttribute ("", "language", "", "", languageSession.getLanguage().getLanguageName());
atts.addAttribute ("", "currentTimeMillis", "", "", System.currentTimeMillis()+""); 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 // start parsing language
try { try {
X4OContentParser parser = new X4OContentParser(propertyConfig); 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) { } catch (Exception e) {
// also debug exceptions // also debug exceptions
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
try { try {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "message", "", "", e.getMessage()); atts.addAttribute ("", "message", "", "", e.getMessage());
if (e instanceof X4OPhaseException) { if (e instanceof X4OPhaseException) {
atts.addAttribute ("", "phase", "", "", ((X4OPhaseException)e).getX4OPhaseHandler().getId()); 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(); StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter(writer); PrintWriter printer = new PrintWriter(writer);
printer.append('\n'); printer.append('\n');
@ -222,8 +222,8 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
e.getCause().printStackTrace(printer); e.getCause().printStackTrace(printer);
} }
char[] stack = writer.getBuffer().toString().toCharArray(); char[] stack = writer.getBuffer().toString().toCharArray();
languageContext.getX4ODebugWriter().getContentWriter().characters(stack, 0, stack.length); languageSession.getX4ODebugWriter().getContentWriter().characters(stack, 0, stack.length);
languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", ""); languageSession.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "exceptionStackTrace", "");
} catch (Exception ee) { } catch (Exception ee) {
logger.warning(ee.getMessage()); logger.warning(ee.getMessage());
} }
@ -245,12 +245,12 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
throw new SAXException((Exception)e.getCause()); throw new SAXException((Exception)e.getCause());
} }
} finally { } finally {
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", ""); languageSession.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "X4ODriver", "");
} }
if (startedDebugWriter && languageContext.hasX4ODebugWriter()) { if (startedDebugWriter && languageSession.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().getContentWriter().endPrefixMapping("debug"); languageSession.getX4ODebugWriter().getContentWriter().endPrefixMapping("debug");
languageContext.getX4ODebugWriter().getContentWriter().endDocument(); languageSession.getX4ODebugWriter().getContentWriter().endDocument();
if (debugOutputStream instanceof OutputStream) { if (debugOutputStream instanceof OutputStream) {
OutputStream outputStream = (OutputStream)debugOutputStream; OutputStream outputStream = (OutputStream)debugOutputStream;
outputStream.flush(); outputStream.flush();
@ -260,7 +260,7 @@ public class DefaultX4OReader<T> extends AbstractX4OReader<T> {
} }
} }
public void releaseContext(X4OLanguageContext context) throws X4OPhaseException { public void releaseContext(X4OLanguageSession context) throws X4OPhaseException {
if (context==null) { if (context==null) {
return; return;
} }

View file

@ -76,7 +76,7 @@ public class DefaultX4OSchemaWriter extends AbstractX4OConnection implements X4O
public void writeSchema(File basePath, String namespace) throws ElementException { public void writeSchema(File basePath, String namespace) throws ElementException {
setProperty(OUTPUT_PATH, basePath); setProperty(OUTPUT_PATH, basePath);
// TODO: fix create context // 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 xsd.writeSchema(namespace); // Start xsd generator
} }
} }

View file

@ -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.ContentWriterXml;
import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem; import org.x4o.xml.io.sax.ext.PropertyConfig.PropertyConfigItem;
import org.x4o.xml.lang.X4OLanguage; 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.X4OLanguageModule;
import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhase;
import org.x4o.xml.lang.phase.X4OPhaseException; import org.x4o.xml.lang.phase.X4OPhaseException;
@ -81,7 +81,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
/** /**
* Default constructor. * Default constructor.
* @param languageContext The language context for this writer. * @param language The language for this writer.
*/ */
public DefaultX4OWriter(X4OLanguage language) { public DefaultX4OWriter(X4OLanguage language) {
super(language); super(language);
@ -89,35 +89,35 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
} }
/** /**
* @see org.x4o.xml.lang.X4OLanguageContext#getPropertyConfig() * @see org.x4o.xml.lang.X4OLanguageSession#getPropertyConfig()
*/ */
public PropertyConfig getPropertyConfig() { public PropertyConfig getPropertyConfig() {
return propertyConfig; return propertyConfig;
} }
X4OLanguageContext getLanguageContext() { X4OLanguageSession createLanguageSession() {
return getLanguage().createLanguageContext(); 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); setProperty(OUTPUT_STREAM, output);
addPhaseSkip(X4OPhase.WRITE_RELEASE); addPhaseSkip(X4OPhase.WRITE_RELEASE);
try { try {
languageContext.getLanguage().getPhaseManager().runPhases(languageContext, X4OPhaseType.XML_WRITE); languageSession.getLanguage().getPhaseManager().runPhases(languageSession, X4OPhaseType.XML_WRITE);
} catch (X4OPhaseException e) { } catch (X4OPhaseException e) {
throw new X4OConnectionException(e); throw new X4OConnectionException(e);
} }
runWrite(languageContext); runWrite(languageSession);
} }
private AttributeEntryComparator attributeEntryComparator = new AttributeEntryComparator(); private AttributeEntryComparator attributeEntryComparator = new AttributeEntryComparator();
private boolean schemaUriPrint; private boolean schemaUriPrint;
private String schemaUriRoot; private String schemaUriRoot;
private void runWrite(X4OLanguageContext languageContext) throws X4OConnectionException { private void runWrite(X4OLanguageSession languageSession) throws X4OConnectionException {
OutputStream out = (OutputStream)getProperty(OUTPUT_STREAM); OutputStream out = (OutputStream)getProperty(OUTPUT_STREAM);
try { try {
String encoding = getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING); String encoding = getPropertyConfig().getPropertyString(ContentWriterXml.OUTPUT_ENCODING);
@ -125,10 +125,10 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
schemaUriRoot = getPropertyConfig().getPropertyString(SCHEMA_ROOT_URI); schemaUriRoot = getPropertyConfig().getPropertyString(SCHEMA_ROOT_URI);
if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; } if (encoding==null) { encoding = XMLConstants.XML_DEFAULT_ENCODING; }
Element root = languageContext.getRootElement(); Element root = languageSession.getRootElement();
if (schemaUriRoot==null) { if (schemaUriRoot==null) {
String rootUri = findElementUri(root); String rootUri = findElementUri(root);
ElementNamespace ns = languageContext.getLanguage().findElementNamespace(rootUri); ElementNamespace ns = languageSession.getLanguage().findElementNamespace(rootUri);
if (ns!=null) { if (ns!=null) {
schemaUriRoot = ns.getSchemaUri(); schemaUriRoot = ns.getSchemaUri();
} }
@ -214,7 +214,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
continue; continue;
} }
Object value = element.getLanguageContext().getElementObjectPropertyValue().getProperty(element.getElementObject(),eca.getId()); Object value = element.getLanguageSession().getElementObjectPropertyValue().getProperty(element.getElementObject(),eca.getId());
if (value==null) { if (value==null) {
continue; continue;
} }
@ -236,7 +236,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
continue; continue;
} }
boolean writeValue = true; 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); eca = ei.getElementClassAttributeByName(p);
if (eca!=null && writeOrder==null) { if (eca!=null && writeOrder==null) {
writeOrder = eca.getWriteOrder(); // add interface but allow override local writeOrder = eca.getWriteOrder(); // add interface but allow override local
@ -251,7 +251,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
} }
// TODO: check attr see reader // 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) { if (value==null) {
continue; continue;
} }
@ -315,7 +315,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
} }
private String findElementUri(Element e) { private String findElementUri(Element e) {
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) { for (X4OLanguageModule mod:e.getLanguageSession().getLanguage().getLanguageModules()) {
for (ElementNamespace c:mod.getElementNamespaces()) { for (ElementNamespace c:mod.getElementNamespaces()) {
ElementClass ec = c.getElementClass(e.getElementClass().getId()); ElementClass ec = c.getElementClass(e.getElementClass().getId());
if (ec!=null) { if (ec!=null) {
@ -327,7 +327,7 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
} }
private String findNamespacePrefix(Element e,String uri) { 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) { if (ns.getPrefixMapping()!=null) {
return ns.getPrefixMapping(); return ns.getPrefixMapping();
} }

View file

@ -28,7 +28,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; 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.x4o.xml.lang.phase.X4OPhaseException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -40,7 +40,7 @@ import org.xml.sax.SAXException;
*/ */
public interface X4OReaderContext<T> extends X4OReader<T> { public interface X4OReaderContext<T> extends X4OReader<T> {
void releaseContext(X4OLanguageContext context) throws X4OPhaseException; void releaseContext(X4OLanguageSession context) throws X4OPhaseException;
/** /**
* Method to parse the xml data. * Method to parse the xml data.
@ -49,7 +49,7 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @throws SAXException Is thrown after sax xml exception. * @throws SAXException Is thrown after sax xml exception.
* @throws IOException Is thrown after io 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. * Reads the file fileName and parses it as an InputStream.
@ -60,7 +60,7 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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. * Reads the file and parses it as an InputStream.
@ -71,7 +71,7 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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. * Parses an resource locaction.
@ -81,7 +81,7 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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. * Converts a String to a InputStream to is can me parsed by SAX.
@ -91,7 +91,7 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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. * Fetched the data direct from remote url to a InputStream to is can me parsed by SAX.
@ -101,5 +101,5 @@ public interface X4OReaderContext<T> extends X4OReader<T> {
* @throws IOException Is thrown after io exception. * @throws IOException Is thrown after io exception.
* @see org.x4o.xml.io.X4OReaderContext#readContext(java.io.InputStream,java.lang.String,java.net.URL) * @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;
} }

View file

@ -26,7 +26,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -37,11 +37,11 @@ import org.xml.sax.SAXException;
*/ */
public interface X4OWriterContext<T> extends X4OWriter<T> { public interface X4OWriterContext<T> extends X4OWriter<T> {
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;
} }

View file

@ -30,7 +30,7 @@ import org.x4o.xml.element.ElementNamespaceInstanceProvider;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.sax.ext.AttributeMap; import org.x4o.xml.io.sax.ext.AttributeMap;
import org.x4o.xml.io.sax.ext.PropertyConfig; 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.Attributes;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -61,7 +61,7 @@ public class X4OContentHandler extends DefaultHandler2 {
private Stack<Element> elementStack = null; private Stack<Element> elementStack = null;
/** The elememtContext */ /** The elememtContext */
private X4OLanguageContext elementLanguage = null; private X4OLanguageSession elementLanguage = null;
/** Store the override element */ /** Store the override element */
private Element overrideSaxElement = null; private Element overrideSaxElement = null;
@ -75,7 +75,7 @@ public class X4OContentHandler extends DefaultHandler2 {
* Creates an X4OTagHandler * Creates an X4OTagHandler
* which can receice sax xml events and converts them into the Element* interfaces events. * 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()); logger = Logger.getLogger(X4OContentHandler.class.getName());
loggerFinest = logger.isLoggable(Level.FINEST); loggerFinest = logger.isLoggable(Level.FINEST);
elementStack = new Stack<Element>(); elementStack = new Stack<Element>();

View file

@ -26,7 +26,7 @@ import org.x4o.xml.eld.EldDriver;
import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementException;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.sax.ext.PropertyConfig; 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.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
@ -57,7 +57,7 @@ public class X4OContentParser {
return propertyConfig; 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 // If xsd caching is needed this should be the way
//XMLParserConfiguration config = new XIncludeAwareParserConfiguration(); //XMLParserConfiguration config = new XIncludeAwareParserConfiguration();
@ -65,56 +65,56 @@ public class X4OContentParser {
//SAXParser parser = new SAXParser(config); //SAXParser parser = new SAXParser(config);
// Create Sax parser with x4o tag handler // Create Sax parser with x4o tag handler
X4OContentHandler xth = new X4OContentHandler(languageContext,getPropertyConfig()); X4OContentHandler xth = new X4OContentHandler(languageSession,getPropertyConfig());
XMLReader saxParser = XMLReaderFactory.createXMLReader(); XMLReader saxParser = XMLReaderFactory.createXMLReader();
saxParser.setErrorHandler(new X4OErrorHandler(languageContext,getPropertyConfig())); saxParser.setErrorHandler(new X4OErrorHandler(languageSession,getPropertyConfig()));
saxParser.setEntityResolver(new X4OEntityResolver(languageContext,getPropertyConfig())); saxParser.setEntityResolver(new X4OEntityResolver(languageSession,getPropertyConfig()));
saxParser.setContentHandler(xth); saxParser.setContentHandler(xth);
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth); saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", xth);
saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth); saxParser.setProperty("http://xml.org/sax/properties/declaration-handler",xth);
// Set properties and optional // Set properties and optional
Map<String,Object> saxParserProperties = getSAXParserProperties(languageContext); Map<String,Object> saxParserProperties = getSAXParserProperties(languageSession);
for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) { for (Map.Entry<String,Object> entry:saxParserProperties.entrySet()) {
String name = entry.getKey(); String name = entry.getKey();
Object value= entry.getValue(); Object value= entry.getValue();
saxParser.setProperty(name, value); saxParser.setProperty(name, value);
debugMessage("Set SAX property: "+name+" to: "+value,languageContext); debugMessage("Set SAX property: "+name+" to: "+value,languageSession);
} }
Map<String,Object> saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageContext); Map<String,Object> saxParserPropertiesOptional = getSAXParserPropertiesOptional(languageSession);
for (Map.Entry<String,Object> entry:saxParserPropertiesOptional.entrySet()) { for (Map.Entry<String,Object> entry:saxParserPropertiesOptional.entrySet()) {
String name = entry.getKey(); String name = entry.getKey();
Object value= entry.getValue(); Object value= entry.getValue();
try { try {
saxParser.setProperty(name, value); 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) { } 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 // Set sax features and optional
Map<String, Boolean> features = getSAXParserFeatures(languageContext); Map<String, Boolean> features = getSAXParserFeatures(languageSession);
for (String key:features.keySet()) { for (String key:features.keySet()) {
Boolean value=features.get(key); Boolean value=features.get(key);
saxParser.setFeature(key, value); saxParser.setFeature(key, value);
debugMessage("Set SAX feature: "+key+" to: "+value,languageContext); debugMessage("Set SAX feature: "+key+" to: "+value,languageSession);
} }
Map<String, Boolean> featuresOptional = getSAXParserFeaturesOptional(languageContext); Map<String, Boolean> featuresOptional = getSAXParserFeaturesOptional(languageSession);
for (String key:featuresOptional.keySet()) { for (String key:featuresOptional.keySet()) {
Boolean value=featuresOptional.get(key); Boolean value=featuresOptional.get(key);
try { try {
saxParser.setFeature(key, value); 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) { } 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 // check for required features
List<String> requiredFeatures = getSAXParserFeaturesRequired(languageContext); List<String> requiredFeatures = getSAXParserFeaturesRequired(languageSession);
for (String requiredFeature:requiredFeatures) { for (String requiredFeature:requiredFeatures) {
debugMessage("Checking required SAX feature: "+requiredFeature,languageContext); debugMessage("Checking required SAX feature: "+requiredFeature,languageSession);
if (saxParser.getFeature(requiredFeature)==false) { if (saxParser.getFeature(requiredFeature)==false) {
throw new IllegalStateException("Missing required feature: "+requiredFeature); throw new IllegalStateException("Missing required feature: "+requiredFeature);
} }
@ -149,10 +149,10 @@ public class X4OContentParser {
} }
} }
private void debugMessage(String message,X4OLanguageContext languageContext) throws SAXException { private void debugMessage(String message,X4OLanguageSession languageSession) throws SAXException {
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
try { try {
languageContext.getX4ODebugWriter().debugPhaseMessage(message, X4OContentParser.class); languageSession.getX4ODebugWriter().debugPhaseMessage(message, X4OContentParser.class);
} catch (ElementException ee) { } catch (ElementException ee) {
throw new SAXException(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<String, Object> getSAXParserProperties(X4OLanguageContext elementContext) { public Map<String, Object> getSAXParserProperties(X4OLanguageSession elementContext) {
Map<String,Object> saxParserProperties = new HashMap<String,Object>(1); Map<String,Object> saxParserProperties = new HashMap<String,Object>(1);
return saxParserProperties; 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<String, Object> getSAXParserPropertiesOptional(X4OLanguageContext elementContext) { public Map<String, Object> getSAXParserPropertiesOptional(X4OLanguageSession elementContext) {
Map<String,Object> saxParserProperties = new HashMap<String,Object>(1); Map<String,Object> saxParserProperties = new HashMap<String,Object>(1);
saxParserProperties.put("http://apache.org/xml/properties/input-buffer-size",getPropertyConfig().getProperty(DefaultX4OReader.DOC_BUFFER_SIZE)); // Increase buffer to 8KB saxParserProperties.put("http://apache.org/xml/properties/input-buffer-size",getPropertyConfig().getProperty(DefaultX4OReader.DOC_BUFFER_SIZE)); // Increase buffer to 8KB
return saxParserProperties; 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<String, Boolean> getSAXParserFeatures(X4OLanguageContext elementContext) { public Map<String, Boolean> getSAXParserFeatures(X4OLanguageSession elementContext) {
// see example: http://xerces.apache.org/xerces2-j/features.html // see example: http://xerces.apache.org/xerces2-j/features.html
Map<String,Boolean> saxParserFeatures = new HashMap<String,Boolean>(20); Map<String,Boolean> saxParserFeatures = new HashMap<String,Boolean>(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<String, Boolean> getSAXParserFeaturesOptional(X4OLanguageContext elementContext) { public Map<String, Boolean> getSAXParserFeaturesOptional(X4OLanguageSession elementContext) {
Map<String,Boolean> saxParserFeatures = new HashMap<String,Boolean>(20); Map<String,Boolean> saxParserFeatures = new HashMap<String,Boolean>(20);
// Make Sax Impl more strict. // 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<String> getSAXParserFeaturesRequired(X4OLanguageContext elementContext) { public List<String> getSAXParserFeaturesRequired(X4OLanguageSession elementContext) {
List<String> result = new ArrayList<String>(5); List<String> result = new ArrayList<String>(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-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. result.add("http://xml.org/sax/features/use-locator2"); // Locator objects passed by the parser are org.xml.sax.ext.Locator2 interface.

View file

@ -42,7 +42,7 @@ import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.element.ElementNamespaceInstanceProvider; import org.x4o.xml.element.ElementNamespaceInstanceProvider;
import org.x4o.xml.io.sax.ext.ContentWriter; import org.x4o.xml.io.sax.ext.ContentWriter;
import org.x4o.xml.lang.X4OLanguageModule; 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.X4OLanguageConfiguration;
import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhase;
import org.x4o.xml.lang.phase.X4OPhaseException; import org.x4o.xml.lang.phase.X4OPhaseException;
@ -81,9 +81,9 @@ public class X4ODebugWriter {
/** /**
* @throws X4OPhaseException * @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(); startTime = System.currentTimeMillis();
try { try {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
@ -97,7 +97,7 @@ public class X4ODebugWriter {
debugPhase(phase); debugPhase(phase);
} }
public void endRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException { public void endRunPhase(X4OPhase phase,X4OLanguageSession elementLanguage) throws X4OPhaseException {
long stopTime = System.currentTimeMillis(); long stopTime = System.currentTimeMillis();
try { try {
AttributesImpl atts = new AttributesImpl(); 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 { try {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
contentWriter.startElement (DEBUG_URI, "X4OLanguageProperties", "", atts); 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 { try {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
contentWriter.startElement (DEBUG_URI, "X4OLanguageDefaultClasses", "", atts); 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 { try {
AttributesImpl attsEmpty = new AttributesImpl(); AttributesImpl attsEmpty = new AttributesImpl();
contentWriter.startElement (DEBUG_URI, "ElementLanguageModules", "", attsEmpty); 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(); AttributesImpl atts = new AttributesImpl();
//atts.addAttribute ("", key, "", "", value); //atts.addAttribute ("", key, "", "", value);
atts.addAttribute ("", "language", "", "", elementLanguage.getLanguage().getLanguageName()); atts.addAttribute ("", "language", "", "", elementLanguage.getLanguage().getLanguageName());

View file

@ -34,7 +34,7 @@ import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.sax.ext.PropertyConfig; import org.x4o.xml.io.sax.ext.PropertyConfig;
import org.x4o.xml.lang.X4OLanguageModule; 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.x4o.xml.lang.X4OLanguageClassLoader;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -64,7 +64,7 @@ public class X4OEntityResolver implements EntityResolver {
* Creates an X4OEntityResolver for a language. * Creates an X4OEntityResolver for a language.
* @param elementContext The x4o language to resolve entities for. * @param elementContext The x4o language to resolve entities for.
*/ */
public X4OEntityResolver(X4OLanguageContext elementContext,PropertyConfig propertyConfig) { public X4OEntityResolver(X4OLanguageSession elementContext,PropertyConfig propertyConfig) {
if (elementContext==null) { if (elementContext==null) {
throw new NullPointerException("Can't provide entities with null elementContext."); throw new NullPointerException("Can't provide entities with null elementContext.");
} }

View file

@ -25,7 +25,7 @@ package org.x4o.xml.io.sax;
import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementException;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.sax.ext.PropertyConfig; 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.ErrorHandler;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
@ -38,18 +38,18 @@ import org.xml.sax.SAXParseException;
*/ */
public class X4OErrorHandler implements ErrorHandler { public class X4OErrorHandler implements ErrorHandler {
private X4OLanguageContext languageContext = null; private X4OLanguageSession languageSession = null;
private ErrorHandler errorHandler = null; private ErrorHandler errorHandler = null;
/** /**
* Construct a new SAXErrorPrinter * 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) { public X4OErrorHandler(X4OLanguageSession languageSession,PropertyConfig propertyConfig) {
if (languageContext==null) { if (languageSession==null) {
throw new NullPointerException("Can't debug and proxy errors with null languageContext."); 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); 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. * Prints the error message to debug output.
*/ */
private void printError(boolean isError, SAXParseException exception) throws SAXException { private void printError(boolean isError, SAXParseException exception) throws SAXException {
if (languageContext.hasX4ODebugWriter()==false) { if (languageSession.hasX4ODebugWriter()==false) {
return; return;
} }
String message = printErrorString(isError,exception); String message = printErrorString(isError,exception);
try { try {
languageContext.getX4ODebugWriter().debugPhaseMessage(message, X4OErrorHandler.class); languageSession.getX4ODebugWriter().debugPhaseMessage(message, X4OErrorHandler.class);
} catch (ElementException e) { } catch (ElementException e) {
throw new SAXException(e); throw new SAXException(e);
} }

View file

@ -59,7 +59,7 @@ public abstract class AbstractX4OLanguageModule extends AbstractElementMetaBase
* Creates a new empty ElementLanguage. * Creates a new empty ElementLanguage.
*/ */
public AbstractX4OLanguageModule() { public AbstractX4OLanguageModule() {
logger = Logger.getLogger(AbstractX4OLanguageContext.class.getName()); logger = Logger.getLogger(AbstractX4OLanguageSession.class.getName());
logger.finest("Creating new ParsingContext"); logger.finest("Creating new ParsingContext");
elementAttributeHandlers = new ArrayList<ElementAttributeHandler>(4); elementAttributeHandlers = new ArrayList<ElementAttributeHandler>(4);
elementBindingHandlers = new ArrayList<ElementBindingHandler>(4); elementBindingHandlers = new ArrayList<ElementBindingHandler>(4);

View file

@ -38,12 +38,12 @@ import org.x4o.xml.io.sax.X4ODebugWriter;
import org.x4o.xml.lang.phase.X4OPhase; import org.x4o.xml.lang.phase.X4OPhase;
/** /**
* An AbstractElementLanguage. * AbstractX4OLanguageSession.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 20, 2005 * @version 1.0 Aug 20, 2005
*/ */
public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLocal { public abstract class AbstractX4OLanguageSession implements X4OLanguageSessionLocal {
private Logger logger = null; private Logger logger = null;
private X4OLanguage language = null; private X4OLanguage language = null;
@ -61,11 +61,11 @@ public abstract class AbstractX4OLanguageContext implements X4OLanguageContextLo
/** /**
* Creates a new empty language context. * Creates a new empty language context.
*/ */
public AbstractX4OLanguageContext(X4OLanguage language) { public AbstractX4OLanguageSession(X4OLanguage language) {
if (language==null) { if (language==null) {
throw new NullPointerException("language may not be 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"); logger.finest("Creating new ParsingContext");
this.language=language; this.language=language;
dirtyElements = new HashMap<Element, X4OPhase>(40); dirtyElements = new HashMap<Element, X4OPhase>(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() { public ELContext getExpressionLanguageContext() {
return eLContext; 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) { public void setExpressionLanguageContext(ELContext context) {
if (eLContext!=null) { 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() { public ExpressionFactory getExpressionLanguageFactory() {
return expressionFactory; 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) { public void setExpressionLanguageFactory(ExpressionFactory expressionFactory) {
if (this.expressionFactory!=null) { 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) { public void addDirtyElement(Element element, X4OPhase phase) {
if (dirtyElements.containsKey(element)) { 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<Element, X4OPhase> getDirtyElements() { public Map<Element, X4OPhase> getDirtyElements() {
return dirtyElements; return dirtyElements;
} }
/** /**
* @see org.x4o.xml.lang.X4OLanguageContext#getRootElement() * @see org.x4o.xml.lang.X4OLanguageSession#getRootElement()
*/ */
public Element getRootElement() { public Element getRootElement() {
return rootElement; 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) { public void setRootElement(Element element) {
if (element==null) { 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() { public X4ODebugWriter getX4ODebugWriter() {
return debugWriter; return debugWriter;
} }
/** /**
* @see org.x4o.xml.lang.X4OLanguageContext#hasX4ODebugWriter() * @see org.x4o.xml.lang.X4OLanguageSession#hasX4ODebugWriter()
*/ */
public boolean hasX4ODebugWriter() { public boolean hasX4ODebugWriter() {
return debugWriter!=null; 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) { public void setX4ODebugWriter(X4ODebugWriter debugWriter) {
this.debugWriter=debugWriter; this.debugWriter=debugWriter;
} }
/** /**
* @see org.x4o.xml.lang.X4OLanguageContext#getPhaseCurrent() * @see org.x4o.xml.lang.X4OLanguageSession#getPhaseCurrent()
*/ */
public X4OPhase getPhaseCurrent() { public X4OPhase getPhaseCurrent() {
return phaseCurrent; 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) { public void setPhaseCurrent(X4OPhase phaseCurrent) {
this.phaseCurrent = phaseCurrent; this.phaseCurrent = phaseCurrent;
} }
/** /**
* @see org.x4o.xml.lang.X4OLanguageContext#getPhaseStop() * @see org.x4o.xml.lang.X4OLanguageSession#getPhaseStop()
*/ */
public String getPhaseStop() { public String getPhaseStop() {
return phaseStop; return phaseStop;
} }
/** /**
* @see org.x4o.xml.lang.X4OLanguageContext#getPhaseSkip() * @see org.x4o.xml.lang.X4OLanguageSession#getPhaseSkip()
*/ */
public List<String> getPhaseSkip() { public List<String> getPhaseSkip() {
return phaseSkip; 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) { public void setPhaseStop(String phaseId) {
this.phaseStop=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) { public void addPhaseSkip(String phaseId) {
phaseSkip.add(phaseId); phaseSkip.add(phaseId);

View file

@ -118,8 +118,8 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
* @throws X4OPhaseException * @throws X4OPhaseException
* @see org.x4o.xml.lang.X4OLanguage#createLanguageContext(org.x4o.xml.X4ODriver) * @see org.x4o.xml.lang.X4OLanguage#createLanguageContext(org.x4o.xml.X4ODriver)
*/ */
public X4OLanguageContext createLanguageContext() { public X4OLanguageSession createLanguageSession() {
X4OLanguageContext result = buildElementLanguage(new DefaultX4OLanguageContext(this)); X4OLanguageSession result = buildElementLanguage(new DefaultX4OLanguageSession(this));
try { try {
getPhaseManager().runPhases(result, X4OPhaseType.INIT); getPhaseManager().runPhases(result, X4OPhaseType.INIT);
} catch (X4OPhaseException e) { } catch (X4OPhaseException e) {
@ -128,11 +128,11 @@ public class DefaultX4OLanguage implements X4OLanguageLocal {
return result; return result;
} }
protected X4OLanguageContext buildElementLanguage(X4OLanguageContext languageContext) { protected X4OLanguageSession buildElementLanguage(X4OLanguageSession languageSession) {
if ((languageContext instanceof X4OLanguageContextLocal)==false) { if ((languageSession instanceof X4OLanguageSessionLocal)==false) {
throw new RuntimeException("Can't init X4OLanguageContext which has not X4OLanguageContextLocal interface obj: "+languageContext); throw new RuntimeException("Can't init X4OLanguageSession which has not X4OLanguageSessionLocal interface obj: "+languageSession);
} }
X4OLanguageContextLocal contextInit = (X4OLanguageContextLocal)languageContext; X4OLanguageSessionLocal contextInit = (X4OLanguageSessionLocal)languageSession;
try { try {
if (contextInit.getExpressionLanguageFactory()==null) { if (contextInit.getExpressionLanguageFactory()==null) {
contextInit.setExpressionLanguageFactory(X4OExpressionFactory.createExpressionFactory()); 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 (X4OLanguageModule modContext:getLanguageModules()) {
for (ElementNamespace nsContext:modContext.getElementNamespaces()) { for (ElementNamespace nsContext:modContext.getElementNamespaces()) {
for (ElementClass ec:nsContext.getElementClasses()) { for (ElementClass ec:nsContext.getElementClasses()) {

View file

@ -89,7 +89,7 @@ public class DefaultX4OLanguageConfiguration extends AbstractX4OLanguageConfigur
Class<?>[] invokeArgs = new Class[argsLength]; Class<?>[] invokeArgs = new Class[argsLength];
for (int i=0;i<argsLength;i++) { for (int i=0;i<argsLength;i++) {
//Object o = args[i]; //Object o = args[i];
invokeArgs[i] = X4OLanguageContext.class; //o.getClass(); todo fix invokeArgs[i] = X4OLanguageSession.class; //o.getClass(); todo fix
} }
Method localMethod = local.getClass().getMethod(method.getName(), invokeArgs); Method localMethod = local.getClass().getMethod(method.getName(), invokeArgs);
Object result = localMethod.invoke(local, args); Object result = localMethod.invoke(local, args);

View file

@ -24,17 +24,17 @@ package org.x4o.xml.lang;
/** /**
* An DefaultElementLanguage. * An DefaultX4OLanguageSession.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Feb 16, 2007 * @version 1.0 Feb 16, 2007
*/ */
public class DefaultX4OLanguageContext extends AbstractX4OLanguageContext { public class DefaultX4OLanguageSession extends AbstractX4OLanguageSession {
/** /**
* Creates a new empty language context. * Creates a new empty language context.
*/ */
public DefaultX4OLanguageContext(X4OLanguage language) { public DefaultX4OLanguageSession(X4OLanguage language) {
super(language); super(language);
} }
} }

View file

@ -61,9 +61,9 @@ public interface X4OLanguage {
/** /**
* Creates and fills the initial element language used to store the language. * Creates and fills the initial element language used to store the language.
* @return The newly created ElementLanguage. * @return The newly created X4OLanguageSession.
*/ */
X4OLanguageContext createLanguageContext(); X4OLanguageSession createLanguageSession();
/** /**
* Search language for object and create element for it. * Search language for object and create element for it.
@ -71,7 +71,7 @@ public interface X4OLanguage {
* @param objectClass The object to search for. * @param objectClass The object to search for.
* @return Returns an new Element instance for the object. * @return Returns an new Element instance for the object.
*/ */
Element createElementInstance(X4OLanguageContext context,Class<?> objectClass); Element createElementInstance(X4OLanguageSession context,Class<?> objectClass);
/** /**
* Gets all ElementBindingHandlers which are possible for parent. * Gets all ElementBindingHandlers which are possible for parent.

View file

@ -35,12 +35,12 @@ import org.x4o.xml.io.sax.X4ODebugWriter;
import org.x4o.xml.lang.phase.X4OPhase; 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 * @author Willem Cazander
* @version 1.0 Feb 14, 2007 * @version 1.0 Feb 14, 2007
*/ */
public interface X4OLanguageContext { public interface X4OLanguageSession {
X4OLanguage getLanguage(); X4OLanguage getLanguage();

View file

@ -31,12 +31,12 @@ import org.x4o.xml.io.sax.X4ODebugWriter;
import org.x4o.xml.lang.phase.X4OPhase; 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 * @author Willem Cazander
* @version 1.0 Oct 28, 2009 * @version 1.0 Oct 28, 2009
*/ */
public interface X4OLanguageContextLocal extends X4OLanguageContext { public interface X4OLanguageSessionLocal extends X4OLanguageSession {
/** /**
* Sets the EL Context. * Sets the EL Context.

View file

@ -26,7 +26,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.x4o.xml.element.Element; 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. * @param elementLanguage The language to run phase for.
* @throws X4OPhaseException when phase has error. * @throws X4OPhaseException when phase has error.
*/ */
public void runPhase(X4OLanguageContext elementLanguage) throws X4OPhaseException { public void runPhase(X4OLanguageSession elementLanguage) throws X4OPhaseException {
} }
} }

View file

@ -28,8 +28,8 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.x4o.xml.lang.X4OLanguageContextLocal; import org.x4o.xml.lang.X4OLanguageSessionLocal;
/** /**
* X4OPhaseManager stores the X4OPhaseHandler and puts them in the right order. * 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. * Runs all the phases in the right order.
* @throws X4OPhaseException When a running handlers throws one. * @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 // sort for the order
List<X4OPhase> x4oPhasesOrder = getOrderedPhases(type); List<X4OPhase> x4oPhasesOrder = getOrderedPhases(type);
// debug output // debug output
if (languageContext.getX4ODebugWriter()!=null) { if (languageSession.getX4ODebugWriter()!=null) {
languageContext.getX4ODebugWriter().debugPhaseOrder(x4oPhases); languageSession.getX4ODebugWriter().debugPhaseOrder(x4oPhases);
} }
List<String> phaseSkip = languageContext.getPhaseSkip(); List<String> phaseSkip = languageSession.getPhaseSkip();
String phaseStop = languageContext.getPhaseStop(); String phaseStop = languageSession.getPhaseStop();
// run the phases in ordered order // run the phases in ordered order
for (X4OPhase phase:x4oPhasesOrder) { for (X4OPhase phase:x4oPhasesOrder) {
@ -139,24 +139,24 @@ PHASE_ORDER = { *startupX4OPhase,
} }
// debug output // debug output
((X4OLanguageContextLocal)languageContext).setPhaseCurrent(phase); ((X4OLanguageSessionLocal)languageSession).setPhaseCurrent(phase);
// run listeners // run listeners
for (X4OPhaseListener l:phase.getPhaseListeners()) { for (X4OPhaseListener l:phase.getPhaseListeners()) {
l.preRunPhase(phase, languageContext); l.preRunPhase(phase, languageSession);
} }
// always run endRunPhase for valid debug xml // always run endRunPhase for valid debug xml
try { try {
// do the run interface // do the run interface
phase.runPhase(languageContext); phase.runPhase(languageSession);
// run the element phase if possible // run the element phase if possible
executePhaseRoot(languageContext,phase); executePhaseRoot(languageSession,phase);
} finally { } finally {
// run the listeners again // run the listeners again
for (X4OPhaseListener l:phase.getPhaseListeners()) { 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. * @throws X4OPhaseException When a running handlers throws one.
*/ */
public void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException { public void runPhasesForElement(Element e,X4OPhaseType type,X4OPhase p) throws X4OPhaseException {
X4OLanguageContext languageContext = e.getLanguageContext(); X4OLanguageSession languageSession = e.getLanguageSession();
List<String> phaseSkip = languageContext.getPhaseSkip(); List<String> phaseSkip = languageSession.getPhaseSkip();
String phaseStop = languageContext.getPhaseStop(); String phaseStop = languageSession.getPhaseStop();
// sort for the order // sort for the order
List<X4OPhase> x4oPhasesOrder = getOrderedPhases(type); List<X4OPhase> x4oPhasesOrder = getOrderedPhases(type);
@ -188,13 +188,13 @@ PHASE_ORDER = { *startupX4OPhase,
} }
// set phase // set phase
((X4OLanguageContextLocal)languageContext).setPhaseCurrent(phase); ((X4OLanguageSessionLocal)languageSession).setPhaseCurrent(phase);
// do the run interface // do the run interface
phase.runPhase(languageContext); phase.runPhase(languageSession);
// run the element phase if possible // run the element phase if possible
executePhaseRoot(languageContext,phase); executePhaseRoot(languageSession,phase);
if (phaseStop!=null && phaseStop.equals(phase.getId())) { if (phaseStop!=null && phaseStop.equals(phase.getId())) {
return; // we are done return; // we are done
@ -206,8 +206,8 @@ PHASE_ORDER = { *startupX4OPhase,
* Run release phase manual if auto release is disabled by config. * Run release phase manual if auto release is disabled by config.
* @throws X4OPhaseException When a running handlers throws one. * @throws X4OPhaseException When a running handlers throws one.
*/ */
public void doReleasePhaseManual(X4OLanguageContext languageContext) throws X4OPhaseException { public void doReleasePhaseManual(X4OLanguageSession languageSession) throws X4OPhaseException {
List<String> phaseSkip = languageContext.getPhaseSkip(); List<String> phaseSkip = languageSession.getPhaseSkip();
String releaseRequested = null; String releaseRequested = null;
if (phaseSkip.contains(X4OPhase.READ_RELEASE)) { if (phaseSkip.contains(X4OPhase.READ_RELEASE)) {
releaseRequested = X4OPhase.READ_RELEASE; releaseRequested = X4OPhase.READ_RELEASE;
@ -218,10 +218,10 @@ PHASE_ORDER = { *startupX4OPhase,
if (releaseRequested==null) { if (releaseRequested==null) {
throw new IllegalStateException("No manual release requested."); throw new IllegalStateException("No manual release requested.");
} }
if (languageContext.getRootElement()==null) { if (languageSession.getRootElement()==null) {
return; // no root element , empty xml document ? 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."); throw new IllegalStateException("Release phase has already been runned.");
} }
@ -237,13 +237,13 @@ PHASE_ORDER = { *startupX4OPhase,
} }
// set phase // set phase
((X4OLanguageContextLocal)languageContext).setPhaseCurrent(h); ((X4OLanguageSessionLocal)languageSession).setPhaseCurrent(h);
// do the run interface // do the run interface
h.runPhase(languageContext); h.runPhase(languageSession);
// run the element phase if possible // run the element phase if possible
executePhaseRoot(languageContext,h); executePhaseRoot(languageSession,h);
} }
class X4OPhaseComparator implements Comparator<X4OPhase> { class X4OPhaseComparator implements Comparator<X4OPhase> {
@ -305,7 +305,7 @@ PHASE_ORDER = { *startupX4OPhase,
* @param phase The phase to run. * @param phase The phase to run.
* @throws X4OPhaseException When a running handlers throws one. * @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) { if (elementLanguage.getRootElement()==null) {
return; return;
} }

View file

@ -25,7 +25,7 @@ package org.x4o.xml.lang.phase;
import java.util.List; import java.util.List;
import org.x4o.xml.element.Element; 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. * @param elementLanguage The elementLanguage running this phase.
* @throws X4OPhaseException When error has happend. * @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. * Returns all phase listeners which where added.

View file

@ -28,7 +28,7 @@ import java.util.logging.Logger;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
import org.x4o.xml.lang.X4OLanguageModule; 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.X4OLanguageModuleLoaderSibling;
import org.x4o.xml.lang.X4OLanguageClassLoader; import org.x4o.xml.lang.X4OLanguageClassLoader;
import org.x4o.xml.lang.X4OLanguageLoader; import org.x4o.xml.lang.X4OLanguageLoader;
@ -73,7 +73,7 @@ public class X4OPhaseLanguageInit {
} }
public void runElementPhase(Element element) throws X4OPhaseException { 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"); logger.finest("Run init start phase");
} }
}; };
@ -97,14 +97,14 @@ public class X4OPhaseLanguageInit {
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
} }
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
try { try {
//debugPhaseMessage("Loading main language: "+elementLanguage.getLanguage(),this,elementLanguage); //debugPhaseMessage("Loading main language: "+elementLanguage.getLanguage(),this,elementLanguage);
X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageContext.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader()); X4OLanguageLoader loader = (X4OLanguageLoader)X4OLanguageClassLoader.newInstance(languageSession.getLanguage().getLanguageConfiguration().getDefaultLanguageLoader());
loader.loadLanguage((X4OLanguageLocal)languageContext.getLanguage(),languageContext.getLanguage().getLanguageName(),languageContext.getLanguage().getLanguageVersion()); loader.loadLanguage((X4OLanguageLocal)languageSession.getLanguage(),languageSession.getLanguage().getLanguageName(),languageSession.getLanguage().getLanguageVersion());
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().debugElementLanguageModules(languageContext); languageSession.getX4ODebugWriter().debugElementLanguageModules(languageSession);
} }
} catch (Exception e) { } catch (Exception e) {
throw new X4OPhaseException(this,e); throw new X4OPhaseException(this,e);
@ -130,22 +130,22 @@ public class X4OPhaseLanguageInit {
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
} }
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
try { try {
List<X4OLanguageModuleLoaderSibling> siblingLoaders = new ArrayList<X4OLanguageModuleLoaderSibling>(3); List<X4OLanguageModuleLoaderSibling> siblingLoaders = new ArrayList<X4OLanguageModuleLoaderSibling>(3);
for (X4OLanguageModule module:languageContext.getLanguage().getLanguageModules()) { for (X4OLanguageModule module:languageSession.getLanguage().getLanguageModules()) {
if (module.getLanguageModuleLoader() instanceof X4OLanguageModuleLoaderSibling) { if (module.getLanguageModuleLoader() instanceof X4OLanguageModuleLoaderSibling) {
siblingLoaders.add((X4OLanguageModuleLoaderSibling)module.getLanguageModuleLoader()); siblingLoaders.add((X4OLanguageModuleLoaderSibling)module.getLanguageModuleLoader());
} }
} }
if (siblingLoaders.isEmpty()==false) { 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) { for (X4OLanguageModuleLoaderSibling siblingLoader:siblingLoaders) {
//debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage); //debugPhaseMessage("Loading sibling langauge loader: "+siblingLoader,this,elementLanguage);
siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageContext.getLanguage(), loader); siblingLoader.loadLanguageSibling((X4OLanguageLocal)languageSession.getLanguage(), loader);
} }
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().debugElementLanguageModules(languageContext); languageSession.getX4ODebugWriter().debugElementLanguageModules(languageSession);
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -172,7 +172,7 @@ public class X4OPhaseLanguageInit {
} }
public void runElementPhase(Element element) throws X4OPhaseException { 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"); logger.finest("Run init end phase");
} }
}; };

View file

@ -44,7 +44,7 @@ import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.sax.X4ODebugWriter; import org.x4o.xml.io.sax.X4ODebugWriter;
import org.x4o.xml.io.sax.ext.ContentWriter; import org.x4o.xml.io.sax.ext.ContentWriter;
import org.x4o.xml.lang.X4OLanguageModule; 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.x4o.xml.lang.X4OLanguageClassLoader;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
@ -69,7 +69,7 @@ public class X4OPhaseLanguageRead {
// meta start point // meta start point
// manager.addX4OPhase(factory.startX4OPhase()); // manager.addX4OPhase(factory.startX4OPhase());
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// config // config
X4OPhaseReadRunConfigurator runConf = new X4OPhaseReadRunConfigurator(); X4OPhaseReadRunConfigurator runConf = new X4OPhaseReadRunConfigurator();
@ -80,27 +80,27 @@ public class X4OPhaseLanguageRead {
// run all attribute events // run all attribute events
manager.addX4OPhase(new X4OPhaseReadRunAttribute()); manager.addX4OPhase(new X4OPhaseReadRunAttribute());
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// templating // templating
manager.addX4OPhase(new X4OPhaseReadFillTemplate()); manager.addX4OPhase(new X4OPhaseReadFillTemplate());
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// transforming // transforming
manager.addX4OPhase(new X4OPhaseReadTransform()); manager.addX4OPhase(new X4OPhaseReadTransform());
manager.addX4OPhase(new X4OPhaseReadRunDirty(manager)); manager.addX4OPhase(new X4OPhaseReadRunDirty(manager));
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
// binding elements // binding elements
manager.addX4OPhase(new X4OPhaseReadBindElement()); manager.addX4OPhase(new X4OPhaseReadBindElement());
// runing and releasing // runing and releasing
manager.addX4OPhase(new X4OPhaseReadRun()); manager.addX4OPhase(new X4OPhaseReadRun());
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
manager.addX4OPhase(runConf); manager.addX4OPhase(runConf);
manager.addX4OPhase(new X4OPhaseReadRunDirtyLast(manager)); manager.addX4OPhase(new X4OPhaseReadRunDirtyLast(manager));
// if (languageContext.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());} // if (languageSession.hasX4ODebugWriter()) {manager.addX4OPhaseHandler(factory.debugPhase());}
manager.addX4OPhase(new X4OPhaseReadEnd()); manager.addX4OPhase(new X4OPhaseReadEnd());
@ -109,19 +109,19 @@ public class X4OPhaseLanguageRead {
manager.addX4OPhase(releasePhase()); manager.addX4OPhase(releasePhase());
// Add debug phase listener to all phases // Add debug phase listener to all phases
// if (languageContext.hasX4ODebugWriter()) { // if (languageSession.hasX4ODebugWriter()) {
//for (X4OPhase h:manager.getOrderedPhases()) { //for (X4OPhase h:manager.getOrderedPhases()) {
// h.addPhaseListener(languageContext.getX4ODebugWriter().createDebugX4OPhaseListener()); // h.addPhaseListener(languageSession.getX4ODebugWriter().createDebugX4OPhaseListener());
//} //}
//} //}
// We are done // We are done
} }
private void debugPhaseMessage(String message,X4OPhase phaseHandler,X4OLanguageContext languageContext) throws X4OPhaseException { private void debugPhaseMessage(String message,X4OPhase phaseHandler,X4OLanguageSession languageSession) throws X4OPhaseException {
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
try { try {
languageContext.getX4ODebugWriter().debugPhaseMessage(message,phaseHandler.getClass()); languageSession.getX4ODebugWriter().debugPhaseMessage(message,phaseHandler.getClass());
} catch (ElementException ee) { } catch (ElementException ee) {
throw new X4OPhaseException(phaseHandler,ee); throw new X4OPhaseException(phaseHandler,ee);
} }
@ -147,12 +147,12 @@ public class X4OPhaseLanguageRead {
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
// not used. // 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 // print the properties and classes for this language/config
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
try { try {
//languageContext.getX4ODebugWriter().debugLanguageProperties(languageContext); //languageSession.getX4ODebugWriter().debugLanguageProperties(languageSession);
languageContext.getX4ODebugWriter().debugLanguageDefaultClasses(languageContext); languageSession.getX4ODebugWriter().debugLanguageDefaultClasses(languageSession);
} catch (ElementException e) { } catch (ElementException e) {
throw new X4OPhaseException(this,e); throw new X4OPhaseException(this,e);
} }
@ -223,7 +223,7 @@ public class X4OPhaseLanguageRead {
logger.finest("Null elementObject skipping, interfaces"); logger.finest("Null elementObject skipping, interfaces");
return; 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()); logger.finest("Do ElementInterface Config Configurators: "+ei.getElementConfigurators().size());
for (ElementConfigurator ec:ei.getElementConfigurators()) { for (ElementConfigurator ec:ei.getElementConfigurators()) {
runConf.runElementConfigurator(ec,element,this); runConf.runElementConfigurator(ec,element,this);
@ -250,7 +250,7 @@ public class X4OPhaseLanguageRead {
return new String[] {"READ_CONFIG_ELEMENT","READ_CONFIG_ELEMENT_INTERFACE"}; return new String[] {"READ_CONFIG_ELEMENT","READ_CONFIG_ELEMENT_INTERFACE"};
} }
public void runElementPhase(Element element) throws X4OPhaseException { 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()); logger.finest("Do Element Config Global Configurators: "+mod.getElementConfiguratorGlobals().size());
for (ElementConfiguratorGlobal ec:mod.getElementConfiguratorGlobals()) { for (ElementConfiguratorGlobal ec:mod.getElementConfiguratorGlobals()) {
runConf.runElementConfigurator(ec,element,this); runConf.runElementConfigurator(ec,element,this);
@ -281,7 +281,7 @@ public class X4OPhaseLanguageRead {
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
if (elementAttributeHandlerComparator==null) { if (elementAttributeHandlerComparator==null) {
try { try {
elementAttributeHandlerComparator = (Comparator<ElementAttributeHandler>)X4OLanguageClassLoader.newInstance(element.getLanguageContext().getLanguage().getLanguageConfiguration().getDefaultElementAttributeHandlerComparator()); elementAttributeHandlerComparator = (Comparator<ElementAttributeHandler>)X4OLanguageClassLoader.newInstance(element.getLanguageSession().getLanguage().getLanguageConfiguration().getDefaultElementAttributeHandlerComparator());
} catch (Exception e) { } catch (Exception e) {
throw new X4OPhaseException(this,e); throw new X4OPhaseException(this,e);
} }
@ -290,7 +290,7 @@ public class X4OPhaseLanguageRead {
// do global parameters // do global parameters
logger.finest("Do Element Global AttributeHandlers."); logger.finest("Do Element Global AttributeHandlers.");
List<ElementAttributeHandler> handlers = new ArrayList<ElementAttributeHandler>(); List<ElementAttributeHandler> handlers = new ArrayList<ElementAttributeHandler>();
for (X4OLanguageModule mod:element.getLanguageContext().getLanguage().getLanguageModules()) { for (X4OLanguageModule mod:element.getLanguageSession().getLanguage().getLanguageModules()) {
for (ElementAttributeHandler global:mod.getElementAttributeHandlers()) { for (ElementAttributeHandler global:mod.getElementAttributeHandlers()) {
String attribute = element.getAttributes().get(global.getAttributeName()); String attribute = element.getAttributes().get(global.getAttributeName());
@ -329,7 +329,7 @@ public class X4OPhaseLanguageRead {
// do config // do config
Map<String,String> attr = element.getAttributes(); Map<String,String> attr = element.getAttributes();
ElementAttributeValueParser attrParser = element.getLanguageContext().getElementAttributeValueParser(); ElementAttributeValueParser attrParser = element.getLanguageSession().getElementAttributeValueParser();
Boolean autoAttributes = element.getElementClass().getAutoAttributes(); Boolean autoAttributes = element.getElementClass().getAutoAttributes();
if (autoAttributes==null) { if (autoAttributes==null) {
autoAttributes = true; autoAttributes = true;
@ -350,12 +350,12 @@ public class X4OPhaseLanguageRead {
value = attrParser.getConvertedParameterValue(name, value, element); value = attrParser.getConvertedParameterValue(name, value, element);
} }
if (attrClass.getRunBeanValue()==null || attrClass.getRunBeanValue()) { 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) { } else if (autoAttributes) {
value = attrParser.getParameterValue(name,valueString,element); value = attrParser.getParameterValue(name,valueString,element);
element.getLanguageContext().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value); element.getLanguageSession().getElementObjectPropertyValue().setProperty(element.getElementObject(), name, value);
} else { } else {
continue; // skip all non auto attribute non attribute defined xml attributes, or throw exception ? continue; // skip all non auto attribute non attribute defined xml attributes, or throw exception ?
@ -371,7 +371,7 @@ public class X4OPhaseLanguageRead {
value = attrClass.getDefaultValue(); value = attrClass.getDefaultValue();
} }
if (attrClass.getRunBeanValue()==null || attrClass.getRunBeanValue()) { 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; return;
} }
try { try {
if (element.getLanguageContext().hasX4ODebugWriter()) { if (element.getLanguageSession().hasX4ODebugWriter()) {
element.getLanguageContext().getX4ODebugWriter().debugElement(element); element.getLanguageSession().getX4ODebugWriter().debugElement(element);
} }
element.doElementRun(); element.doElementRun();
} catch (ElementException e) { } catch (ElementException e) {
@ -447,16 +447,16 @@ public class X4OPhaseLanguageRead {
return new String[] {"READ_TRANSFORM"}; return new String[] {"READ_TRANSFORM"};
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
Map<Element,X4OPhase> dirtyElements = element.getLanguageContext().getDirtyElements(); Map<Element,X4OPhase> dirtyElements = element.getLanguageSession().getDirtyElements();
if (dirtyElements.isEmpty()) { if (dirtyElements.isEmpty()) {
return; return;
} }
debugPhaseMessage("Dirty elements: "+dirtyElements.size(), this,element.getLanguageContext()); debugPhaseMessage("Dirty elements: "+dirtyElements.size(), this,element.getLanguageSession());
for (Element e:dirtyElements.keySet()) { for (Element e:dirtyElements.keySet()) {
X4OPhase p = dirtyElements.get(e); X4OPhase p = dirtyElements.get(e);
phaseManager.runPhasesForElement(e,getType(), p); 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"}; return new String[] {"READ_RUN"};
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
Map<Element,X4OPhase> dirtyElements = element.getLanguageContext().getDirtyElements(); Map<Element,X4OPhase> dirtyElements = element.getLanguageSession().getDirtyElements();
if (dirtyElements.isEmpty()) { if (dirtyElements.isEmpty()) {
return; return;
} }
debugPhaseMessage("Dirty elements last: "+dirtyElements.size(), this,element.getLanguageContext()); debugPhaseMessage("Dirty elements last: "+dirtyElements.size(), this,element.getLanguageSession());
for (Element e:dirtyElements.keySet()) { for (Element e:dirtyElements.keySet()) {
X4OPhase p = dirtyElements.get(e); X4OPhase p = dirtyElements.get(e);
phaseManager.runPhasesForElement(e,getType(), p); phaseManager.runPhasesForElement(e,getType(), p);
} }
element.getLanguageContext().getDirtyElements().clear(); element.getLanguageSession().getDirtyElements().clear();
} }
}; };
@ -521,12 +521,12 @@ public class X4OPhaseLanguageRead {
return; return;
} }
List<ElementBindingHandler> binds = element.getLanguageContext().getLanguage().findElementBindingHandlers(parentObject, childObject); List<ElementBindingHandler> binds = element.getLanguageSession().getLanguage().findElementBindingHandlers(parentObject, childObject);
logger.finest("Calling bindings handlers; "+binds.size()); logger.finest("Calling bindings handlers; "+binds.size());
try { try {
for (ElementBindingHandler binding:binds) { for (ElementBindingHandler binding:binds) {
if (element.getLanguageContext().hasX4ODebugWriter()) { if (element.getLanguageSession().hasX4ODebugWriter()) {
element.getLanguageContext().getX4ODebugWriter().debugElementBindingHandler(binding,element); element.getLanguageSession().getX4ODebugWriter().debugElementBindingHandler(binding,element);
} }
binding.bindChild(element); binding.bindChild(element);
} }
@ -554,8 +554,8 @@ public class X4OPhaseLanguageRead {
return; // has already runned. return; // has already runned.
} }
try { try {
//if (element.getLanguageContext().hasX4ODebugWriter()) { //if (element.getlanguageSession().hasX4ODebugWriter()) {
// element.getLanguageContext().getX4ODebugWriter().debugElement(element); // element.getlanguageSession().getX4ODebugWriter().debugElement(element);
//} //}
element.doElementRun(); element.doElementRun();
} catch (ElementException e) { } catch (ElementException e) {
@ -581,11 +581,11 @@ public class X4OPhaseLanguageRead {
public boolean isElementPhase() { public boolean isElementPhase() {
return false; return false;
} }
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
for (RunConfigurator conf:runConf) { for (RunConfigurator conf:runConf) {
try { try {
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
languageContext.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element); languageSession.getX4ODebugWriter().debugElementConfigurator(conf.elementConfigurator,conf.element);
} }
conf.elementConfigurator.doConfigElement(conf.element); conf.elementConfigurator.doConfigElement(conf.element);
} catch (ElementException e) { } catch (ElementException e) {
@ -610,8 +610,8 @@ public class X4OPhaseLanguageRead {
return; return;
} }
try { try {
if (e.getLanguageContext().hasX4ODebugWriter()) { if (e.getLanguageSession().hasX4ODebugWriter()) {
e.getLanguageContext().getX4ODebugWriter().debugElementConfigurator(ec,e); e.getLanguageSession().getX4ODebugWriter().debugElementConfigurator(ec,e);
} }
ec.doConfigElement(e); ec.doConfigElement(e);
@ -644,12 +644,12 @@ public class X4OPhaseLanguageRead {
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
// not used. // 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 // print the properties and classes for this language/config
if (languageContext.hasX4ODebugWriter()) { if (languageSession.hasX4ODebugWriter()) {
try { try {
//languageContext.getX4ODebugWriter().debugLanguageProperties(languageContext); //languageSession.getX4ODebugWriter().debugLanguageProperties(languageSession);
languageContext.getX4ODebugWriter().debugLanguageDefaultClasses(languageContext); languageSession.getX4ODebugWriter().debugLanguageDefaultClasses(languageSession);
} catch (ElementException e) { } catch (ElementException e) {
throw new X4OPhaseException(this,e); throw new X4OPhaseException(this,e);
} }
@ -667,23 +667,23 @@ public class X4OPhaseLanguageRead {
class ReleasePhaseListener implements X4OPhaseListener { class ReleasePhaseListener implements X4OPhaseListener {
private int elementsReleased = 0; 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; 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 { public void endRunPhase(X4OPhase phase,X4OLanguageSession languageSession) throws X4OPhaseException {
if (languageContext.hasX4ODebugWriter()==false) { if (languageSession.hasX4ODebugWriter()==false) {
return; return;
} }
try { try {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
atts.addAttribute ("", "elements", "", "", elementsReleased+""); atts.addAttribute ("", "elements", "", "", elementsReleased+"");
languageContext.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts); languageSession.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "executeReleases", "", atts);
languageContext.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , ""); languageSession.getX4ODebugWriter().getContentWriter().endElement (X4ODebugWriter.DEBUG_URI, "executeReleases" , "");
} catch (SAXException e) { } catch (SAXException e) {
throw new X4OPhaseException(phase,e); throw new X4OPhaseException(phase,e);
} }
@ -705,7 +705,7 @@ public class X4OPhaseLanguageRead {
public String[] getPhaseDependencies() { public String[] getPhaseDependencies() {
return new String[] {X4OPhase.READ_END}; 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 { public void runElementPhase(Element element) throws X4OPhaseException {
try { try {
@ -741,23 +741,23 @@ public class X4OPhaseLanguageRead {
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
} }
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
// safety check // safety check
if (languageContext.hasX4ODebugWriter()==false) { if (languageSession.hasX4ODebugWriter()==false) {
throw new X4OPhaseException(this,"Use debugPhase only when X4OParser.debugWriter is filled."); throw new X4OPhaseException(this,"Use debugPhase only when X4OParser.debugWriter is filled.");
} }
try { try {
AttributesImpl atts = new AttributesImpl(); AttributesImpl atts = new AttributesImpl();
//atts.addAttribute ("", key, "", "", value); //atts.addAttribute ("", key, "", "", value);
//atts.addAttribute ("", "verbose", "", "", "true"); //atts.addAttribute ("", "verbose", "", "", "true");
languageContext.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts); languageSession.getX4ODebugWriter().getContentWriter().startElement (X4ODebugWriter.DEBUG_URI, "printElementTree", "", atts);
startedPrefix.clear(); startedPrefix.clear();
printXML(languageContext.getRootElement()); printXML(languageSession.getRootElement());
for (String prefix:startedPrefix) { for (String prefix:startedPrefix) {
languageContext.getX4ODebugWriter().getContentWriter().endPrefixMapping(prefix); languageSession.getX4ODebugWriter().getContentWriter().endPrefixMapping(prefix);
} }
languageContext.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", ""); languageSession.getX4ODebugWriter().getContentWriter().endElement(X4ODebugWriter.DEBUG_URI, "printElementTree", "");
languageContext.getX4ODebugWriter().debugLanguageContext(languageContext); languageSession.getX4ODebugWriter().debugLanguageSession(languageSession);
} catch (SAXException e) { } catch (SAXException e) {
throw new X4OPhaseException(this,e); throw new X4OPhaseException(this,e);
} }
@ -766,7 +766,7 @@ public class X4OPhaseLanguageRead {
// note: slow version // note: slow version
private String getNamespaceForElement(Element e) { private String getNamespaceForElement(Element e) {
for (X4OLanguageModule mod:e.getLanguageContext().getLanguage().getLanguageModules()) { for (X4OLanguageModule mod:e.getLanguageSession().getLanguage().getLanguageModules()) {
for (ElementNamespace enc:mod.getElementNamespaces()) { for (ElementNamespace enc:mod.getElementNamespaces()) {
List<ElementClass> l = enc.getElementClasses(); List<ElementClass> l = enc.getElementClasses();
if (l.contains(e.getElementClass())) { if (l.contains(e.getElementClass())) {
@ -781,7 +781,7 @@ public class X4OPhaseLanguageRead {
if (element==null) { if (element==null) {
throw new SAXException("Can't print debug xml of null element."); 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)) { if (element.getElementType().equals(Element.ElementType.comment)) {
handler.comment((String)element.getElementObject()); handler.comment((String)element.getElementObject());
return; return;
@ -802,7 +802,7 @@ public class X4OPhaseLanguageRead {
} }
String nameSpace = getNamespaceForElement(element); 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) { if (startedPrefix.contains(prefix)==false) {
handler.startPrefixMapping(prefix, nameSpace); handler.startPrefixMapping(prefix, nameSpace);

View file

@ -32,7 +32,7 @@ import org.x4o.xml.element.ElementException;
import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.element.ElementNamespaceInstanceProviderException; import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
import org.x4o.xml.lang.X4OLanguageModule; 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. * X4OPhaseLanguageWrite defines all phases to write the language.
@ -73,7 +73,7 @@ public class X4OPhaseLanguageWrite {
} }
public void runElementPhase(Element element) throws X4OPhaseException { 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"); logger.finest("Run init begin phase");
} }
}; };
@ -96,58 +96,58 @@ public class X4OPhaseLanguageWrite {
} }
public void runElementPhase(Element element) throws X4OPhaseException { public void runElementPhase(Element element) throws X4OPhaseException {
} }
public void runPhase(X4OLanguageContext languageContext) throws X4OPhaseException { public void runPhase(X4OLanguageSession languageSession) throws X4OPhaseException {
try { try {
Element root = languageContext.getRootElement(); Element root = languageSession.getRootElement();
// TODO: check for read tree then write support as ec is not null then .. // TODO: check for read tree then write support as ec is not null then ..
if (root.getElementClass()==null) { if (root.getElementClass()==null) {
root = fillElementTree(languageContext,root.getElementObject()); root = fillElementTree(languageSession,root.getElementObject());
} }
} catch (Exception e) { } catch (Exception e) {
throw new X4OPhaseException(this,e); throw new X4OPhaseException(this,e);
} }
} }
private Element fillElementTree(X4OLanguageContext languageContext,Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException { private Element fillElementTree(X4OLanguageSession languageSession,Object object) throws ElementNamespaceInstanceProviderException, ElementBindingHandlerException {
Element element = findRootElement(languageContext,object.getClass()); Element element = findRootElement(languageSession,object.getClass());
element.setElementObject(object); 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); bind.createChilderen(element);
fillTree(languageContext,element); fillTree(languageSession,element);
} }
return 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()) { for (Element e:element.getChilderen()) {
Object object = e.getElementObject(); Object object = e.getElementObject();
for (ElementBindingHandler bind:languageContext.getLanguage().findElementBindingHandlers(object)) { for (ElementBindingHandler bind:languageSession.getLanguage().findElementBindingHandlers(object)) {
bind.createChilderen(e); 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 // 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()) { for (ElementNamespace nsContext:modContext.getElementNamespaces()) {
if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) { if (nsContext.getLanguageRoot()!=null && nsContext.getLanguageRoot()) {
for (ElementClass ec:nsContext.getElementClasses()) { for (ElementClass ec:nsContext.getElementClasses()) {
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { 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 (ElementNamespace nsContext:modContext.getElementNamespaces()) {
for (ElementClass ec:nsContext.getElementClasses()) { for (ElementClass ec:nsContext.getElementClasses()) {
if (ec.getObjectClass()!=null && ec.getObjectClass().equals(objectClass)) { 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 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"); logger.finest("Run init end phase");
} }
}; };
@ -189,7 +189,7 @@ public class X4OPhaseLanguageWrite {
public String[] getPhaseDependencies() { public String[] getPhaseDependencies() {
return new String[] {X4OPhase.WRITE_END}; 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 { public void runElementPhase(Element element) throws X4OPhaseException {
try { try {

View file

@ -22,7 +22,7 @@
*/ */
package org.x4o.xml.lang.phase; 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. * @param elementLanguage The elementLanguage of the driver.
* @throws X4OPhaseException Is throws when listeners has error. * @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. * Gets called after the X4OPhaseHandler is runned.
@ -48,5 +48,5 @@ public interface X4OPhaseListener {
* @param elementLanguage The elementLanguage of the driver. * @param elementLanguage The elementLanguage of the driver.
* @throws X4OPhaseException Is throws when listeners has error. * @throws X4OPhaseException Is throws when listeners has error.
*/ */
void endRunPhase(X4OPhase phase,X4OLanguageContext elementLanguage) throws X4OPhaseException; void endRunPhase(X4OPhase phase,X4OLanguageSession elementLanguage) throws X4OPhaseException;
} }

View file

@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import org.x4o.xml.element.Element; 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<X4OPhase> getOrderedPhases(X4OPhaseType type); List<X4OPhase> getOrderedPhases(X4OPhaseType type);
void doReleasePhaseManual(X4OLanguageContext languageContext) throws X4OPhaseException; void doReleasePhaseManual(X4OLanguageSession languageSession) throws X4OPhaseException;
/** /**
* Runs all the phases in the right order. * Runs all the phases in the right order.
* @throws X4OPhaseException When a running handlers throws one. * @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. * Runs phase on single element.

View file

@ -86,7 +86,7 @@ public class X4ODriverManagerTest extends TestCase {
Throwable e = null; Throwable e = null;
try { try {
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(language); X4ODriver<?> driver = X4ODriverManager.getX4ODriver(language);
driver.createLanguage(version).createLanguageContext(); driver.createLanguage(version).createLanguageSession();
} catch (Throwable catchE) { } catch (Throwable catchE) {
e = catchE; e = catchE;
} }

View file

@ -24,7 +24,7 @@ package org.x4o.xml.core;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.X4OReaderContext; 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.lang.phase.X4OPhase;
import org.x4o.xml.test.TestDriver; import org.x4o.xml.test.TestDriver;
import org.x4o.xml.test.models.TestObjectRoot; import org.x4o.xml.test.models.TestObjectRoot;
@ -40,7 +40,7 @@ import junit.framework.TestCase;
public class NamespaceUriTest extends TestCase { public class NamespaceUriTest extends TestCase {
public void testSimpleUri() throws Exception { public void testSimpleUri() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
@ -53,7 +53,7 @@ public class NamespaceUriTest extends TestCase {
} }
public void testEmptyUri() throws Exception { public void testEmptyUri() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
@ -67,7 +67,7 @@ public class NamespaceUriTest extends TestCase {
} }
public void testSchemaUri() throws Exception { public void testSchemaUri() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);

View file

@ -29,7 +29,7 @@ import org.x4o.xml.eld.CelDriver;
import org.x4o.xml.io.DefaultX4OReader; import org.x4o.xml.io.DefaultX4OReader;
import org.x4o.xml.io.sax.X4OEntityResolver; import org.x4o.xml.io.sax.X4OEntityResolver;
import org.x4o.xml.io.sax.ext.PropertyConfig; 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.TestDriver;
import org.x4o.xml.test.models.TestObjectRoot; import org.x4o.xml.test.models.TestObjectRoot;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
@ -60,14 +60,14 @@ public class X4OEntityResolverTest extends TestCase {
public void testResolve() throws Exception { public void testResolve() throws Exception {
X4ODriver<?> driver = new CelDriver(); 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"); InputSource input = resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd");
assertNotNull(input); assertNotNull(input);
} }
public void testResolveMissing() throws Exception { public void testResolveMissing() throws Exception {
X4ODriver<TestObjectRoot> driver = new TestDriver(); X4ODriver<TestObjectRoot> 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; Exception e = null;
try { try {
resolver.resolveEntity("","http://cel.x4o.org/xml/ns/cel-root-1.0.xsd-missing-resource"); 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 { public void testResolveProperty() throws Exception {
X4ODriver<TestObjectRoot> driver = new TestDriver(); X4ODriver<TestObjectRoot> 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); PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER);
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver()); conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
X4OEntityResolver resolver = new X4OEntityResolver(language,conf); X4OEntityResolver resolver = new X4OEntityResolver(language,conf);
@ -98,7 +98,7 @@ public class X4OEntityResolverTest extends TestCase {
public void testResolvePropertyNull() throws Exception { public void testResolvePropertyNull() throws Exception {
X4ODriver<TestObjectRoot> driver = new TestDriver(); X4ODriver<TestObjectRoot> 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); PropertyConfig conf = new PropertyConfig(DefaultX4OReader.DEFAULT_PROPERTY_CONFIG,PropertyConfig.X4O_PROPERTIES_PREFIX+PropertyConfig.X4O_PROPERTIES_READER);
conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver()); conf.setProperty(DefaultX4OReader.SAX_ENTITY_RESOLVER, new TestEntityResolver());
X4OEntityResolver resolver = new X4OEntityResolver(language,conf); X4OEntityResolver resolver = new X4OEntityResolver(language,conf);

View file

@ -25,7 +25,7 @@ package org.x4o.xml.core;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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.X4OPhase;
import org.x4o.xml.lang.phase.X4OPhaseManager; import org.x4o.xml.lang.phase.X4OPhaseManager;
import org.x4o.xml.lang.phase.X4OPhaseType; import org.x4o.xml.lang.phase.X4OPhaseType;
@ -50,7 +50,7 @@ public class X4OPhaseManagerTest extends TestCase {
public void testPhases() throws Exception { public void testPhases() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OLanguageContext context = driver.createLanguage().createLanguageContext(); X4OLanguageSession context = driver.createLanguage().createLanguageSession();
X4OPhaseManager manager = context.getLanguage().getPhaseManager(); X4OPhaseManager manager = context.getLanguage().getPhaseManager();
Collection<X4OPhase> phasesAll = manager.getAllPhases(); Collection<X4OPhase> phasesAll = manager.getAllPhases();
List<X4OPhase> phases = manager.getOrderedPhases(X4OPhaseType.XML_READ); List<X4OPhase> phases = manager.getOrderedPhases(X4OPhaseType.XML_READ);
@ -67,7 +67,7 @@ public class X4OPhaseManagerTest extends TestCase {
/* /*
public void testPhaseManager() throws Exception { public void testPhaseManager() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
ElementLanguage context = driver.createLanguageContext(); ElementLanguage context = driver.createLanguageSession();
X4OPhaseManager manager = context.getLanguage().getPhaseManager(); X4OPhaseManager manager = context.getLanguage().getPhaseManager();
Exception e = null; Exception e = null;

View file

@ -29,7 +29,7 @@ import java.net.URL;
import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriver;
import org.x4o.xml.io.X4OReader; 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.TestDriver;
import org.x4o.xml.test.models.TestBean; import org.x4o.xml.test.models.TestBean;
import org.x4o.xml.test.models.TestObjectRoot; import org.x4o.xml.test.models.TestObjectRoot;
@ -62,7 +62,7 @@ public class X4OReaderContextTest extends TestCase {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
File xmlFile = copyResourceToTempFile(); File xmlFile = copyResourceToTempFile();
X4OLanguageContext context = reader.readFileContext(xmlFile.getAbsolutePath()); X4OLanguageSession context = reader.readFileContext(xmlFile.getAbsolutePath());
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
assertTrue(root.getTestBeans().size()>0); assertTrue(root.getTestBeans().size()>0);
@ -90,7 +90,7 @@ public class X4OReaderContextTest extends TestCase {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
File xmlFile = copyResourceToTempFile(); File xmlFile = copyResourceToTempFile();
X4OLanguageContext context = reader.readFileContext(xmlFile); X4OLanguageSession context = reader.readFileContext(xmlFile);
TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
assertTrue(root.getTestBeans().size()>0); assertTrue(root.getTestBeans().size()>0);
@ -153,7 +153,7 @@ public class X4OReaderContextTest extends TestCase {
public void testReadResource() throws Exception { public void testReadResource() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> 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(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
} }
@ -176,7 +176,7 @@ public class X4OReaderContextTest extends TestCase {
public void testReadString() throws Exception { public void testReadString() throws Exception {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
X4OLanguageContext context = reader.readStringContext( X4OLanguageSession context = reader.readStringContext(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<root:root xmlns:root=\"http://test.x4o.org/xml/ns/test-root\" xmlns=\"http://test.x4o.org/xml/ns/test-lang\">"+ "<root:root xmlns:root=\"http://test.x4o.org/xml/ns/test-root\" xmlns=\"http://test.x4o.org/xml/ns/test-lang\">"+
"<testBean privateIntegerTypeField=\"987654321\"/>"+ "<testBean privateIntegerTypeField=\"987654321\"/>"+
@ -209,7 +209,7 @@ public class X4OReaderContextTest extends TestCase {
TestDriver driver = TestDriver.getInstance(); TestDriver driver = TestDriver.getInstance();
X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext(); X4OReaderContext<TestObjectRoot> reader = driver.createReaderContext();
URL xmlUrl = Thread.currentThread().getContextClassLoader().getResource("tests/attributes/test-bean.xml"); 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(); TestObjectRoot root = (TestObjectRoot)context.getRootElement().getElementObject();
assertNotNull(root); assertNotNull(root);
assertTrue(root.getTestBeans().size()>0); assertTrue(root.getTestBeans().size()>0);

View file

@ -30,7 +30,7 @@ import java.io.OutputStream;
import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriver;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
import org.x4o.xml.io.X4OReader; 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.TestDriver;
import org.x4o.xml.test.models.TestObjectRoot; import org.x4o.xml.test.models.TestObjectRoot;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -51,11 +51,11 @@ public class X4OWriterContextTest extends TestCase {
return outputFile; return outputFile;
} }
private X4OLanguageContext createContext() throws SAXException, X4OConnectionException, IOException { private X4OLanguageSession createContext() throws SAXException, X4OConnectionException, IOException {
X4ODriver<TestObjectRoot> driver = TestDriver.getInstance(); X4ODriver<TestObjectRoot> driver = TestDriver.getInstance();
X4OReader<TestObjectRoot> reader = driver.createReader(); X4OReader<TestObjectRoot> reader = driver.createReader();
TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml"); TestObjectRoot root = reader.readResource("tests/attributes/test-bean.xml");
X4OLanguageContext context = driver.createLanguage().createLanguageContext(); X4OLanguageSession context = driver.createLanguage().createLanguageSession();
Element rootElement = null; Element rootElement = null;
try { try {
rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance(); rootElement = (Element)context.getLanguage().getLanguageConfiguration().getDefaultElement().newInstance();

View file

@ -42,7 +42,7 @@ public class SwiXmlActionConfigurator extends AbstractElementConfigurator {
if (actionName==null) { if (actionName==null) {
return; return;
} }
SwingEngine se = SwiXmlDriver.getSwingEngine(element.getLanguageContext()); SwingEngine se = SwiXmlDriver.getSwingEngine(element.getLanguageSession());
Action action = se.getUIActionByName(actionName); Action action = se.getUIActionByName(actionName);
Object object = element.getElementObject(); Object object = element.getElementObject();
if (object instanceof JMenuItem) { if (object instanceof JMenuItem) {

View file

@ -28,7 +28,7 @@ import javax.el.ValueExpression;
import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriver;
import org.x4o.xml.X4ODriverManager; 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. * SwiXmlParser works with the SwingEngine to config the UI tree.
@ -50,7 +50,7 @@ public class SwiXmlDriver extends X4ODriver<Component> {
* @param elementLanguage The elementLanguage to get the swingEngine out. * @param elementLanguage The elementLanguage to get the swingEngine out.
* @return Returns the SwingEngine for this elementLanguage. * @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); ValueExpression ee = elementLanguage.getExpressionLanguageFactory().createValueExpression(elementLanguage.getExpressionLanguageContext(),"${"+SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE+"}",Object.class);
SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getExpressionLanguageContext()); SwingEngine se = (SwingEngine)ee.getValue(elementLanguage.getExpressionLanguageContext());
return se; return se;

View file

@ -45,7 +45,7 @@ import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementException; import org.x4o.xml.element.ElementException;
import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.lang.X4OLanguageModule; import org.x4o.xml.lang.X4OLanguageModule;
import org.x4o.xml.lang.X4OLanguageContext; import org.x4o.xml.lang.X4OLanguageSession;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
@ -57,7 +57,7 @@ import org.xml.sax.SAXException;
public class EldDocWriter { public class EldDocWriter {
// The context to write doc over. // The context to write doc over.
private X4OLanguageContext context = null; private X4OLanguageSession context = null;
// Core concepts // Core concepts
private static final String[] C_CONTEXT = {"language","Overview","All language modules.","The loaded language modules.."}; 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. * Creates an EldDocGenerator for this langauge context.
* @param context The language context to generate doc for. * @param context The language context to generate doc for.
*/ */
public EldDocWriter(X4OLanguageContext context) { public EldDocWriter(X4OLanguageSession context) {
this.context=context; this.context=context;
} }
@ -118,7 +118,7 @@ public class EldDocWriter {
doc.setFrameNavConceptClass(ElementClass.class); doc.setFrameNavConceptClass(ElementClass.class);
doc.addTreeNodePageModeClass(X4OLanguageContext.class); doc.addTreeNodePageModeClass(X4OLanguageSession.class);
doc.addTreeNodePageModeClass(X4OLanguageModule.class); doc.addTreeNodePageModeClass(X4OLanguageModule.class);
doc.addTreeNodePageModeClass(ElementInterface.class); doc.addTreeNodePageModeClass(ElementInterface.class);
doc.addTreeNodePageModeClass(ElementNamespace.class); doc.addTreeNodePageModeClass(ElementNamespace.class);
@ -129,7 +129,7 @@ public class EldDocWriter {
doc.addAnnotatedClasses(EldDocWriterElementNamespace.class); doc.addAnnotatedClasses(EldDocWriterElementNamespace.class);
doc.addAnnotatedClasses(EldDocWriterElementInterface.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 adcMod = doc.addConcept(new ApiDocConcept(adcRoot,C_MODULE,X4OLanguageModule.class));
ApiDocConcept adcIface = doc.addConcept(new ApiDocConcept(adcMod,C_INTERFACE,ElementInterface.class)); ApiDocConcept adcIface = doc.addConcept(new ApiDocConcept(adcMod,C_INTERFACE,ElementInterface.class));
ApiDocConcept adcNs = doc.addConcept(new ApiDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class)); ApiDocConcept adcNs = doc.addConcept(new ApiDocConcept(adcMod,C_NAMESPACE,ElementNamespace.class));

View file

@ -39,7 +39,7 @@ import org.x4o.xml.element.ElementClassAttribute;
import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementConfigurator;
import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag; 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.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -113,7 +113,7 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
ElementClass ec = (ElementClass)event.getEventObject().getUserData(); ElementClass ec = (ElementClass)event.getEventObject().getUserData();
ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData(); ElementNamespace ns = (ElementNamespace)event.getEventObject().getParent().getUserData();
X4OLanguageModule mod = (X4OLanguageModule)event.getEventObject().getParent().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 // TODO: this is hacky
EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0); EldDocXTreePageWriter xtree = (EldDocXTreePageWriter)event.getDoc().findDocPageById("overview-xtree").getPageWriters().get(0);

View file

@ -33,7 +33,7 @@ import org.x4o.xml.element.ElementBindingHandler;
import org.x4o.xml.element.ElementClassAttribute; import org.x4o.xml.element.ElementClassAttribute;
import org.x4o.xml.element.ElementConfigurator; import org.x4o.xml.element.ElementConfigurator;
import org.x4o.xml.element.ElementNamespace; 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.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException; 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<ApiDocNode> event) throws SAXException { public void writeLanguageSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
ApiDocNode node = event.getEventObject(); ApiDocNode node = event.getEventObject();
X4OLanguageContext context = (X4OLanguageContext)node.getUserData(); X4OLanguageSession context = (X4OLanguageSession)node.getUserData();
int attrHandlers = 0; int attrHandlers = 0;
int bindHandlers = 0; int bindHandlers = 0;
int interFaces = 0; int interFaces = 0;
@ -99,16 +99,16 @@ public class EldDocWriterLanguage extends AbstractApiDocWriter {
writer.docTableEnd(); writer.docTableEnd();
} }
@ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageContext.class},nodeBodyOrders={2}) @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={X4OLanguageSession.class},nodeBodyOrders={2})
public void writeModulesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException { public void writeModulesSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
printApiTable(event,"Module Summary",X4OLanguageModule.class); 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<ApiDocNode> event) throws SAXException { public void writeNamespaceSummary(ApiDocWriteEvent<ApiDocNode> event) throws SAXException {
ApiDocContentWriter writer = event.getWriter(); ApiDocContentWriter writer = event.getWriter();
ApiDocNode node = event.getEventObject(); 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.docTableStart("Namespace Summary", "All Language Namespaces Overview",ApiDocContentCss.overviewSummary);
writer.docTableHeader("ID", "URI"); writer.docTableHeader("ID", "URI");
for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) { for (X4OLanguageModule mod:context.getLanguage().getLanguageModules()) {

View file

@ -39,7 +39,7 @@ import org.x4o.xml.element.ElementClass;
import org.x4o.xml.element.ElementInterface; import org.x4o.xml.element.ElementInterface;
import org.x4o.xml.element.ElementNamespace; import org.x4o.xml.element.ElementNamespace;
import org.x4o.xml.io.sax.ext.ContentWriterHtml.Tag; 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.x4o.xml.lang.X4OLanguageModule;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -81,7 +81,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException { public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws SAXException {
//selectRootNode(e.getDoc()); // create //selectRootNode(e.getDoc()); // create
ApiDoc doc = e.getDoc(); ApiDoc doc = e.getDoc();
X4OLanguageContext context = (X4OLanguageContext)doc.getRootNode().getUserData(); X4OLanguageSession context = (X4OLanguageSession)doc.getRootNode().getUserData();
String pathPrefix = "language/"; String pathPrefix = "language/";
@ -137,7 +137,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
private ApiDocNode createXTree(ApiDoc doc) throws SAXException { 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"); ApiDocNode root = new ApiDocNode(context,"root","Root","Language root");
List<TreeNode> rootNodes = new ArrayList<TreeNode>(3); List<TreeNode> rootNodes = new ArrayList<TreeNode>(3);
@ -175,7 +175,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
class TreeNode { class TreeNode {
X4OLanguageContext context; X4OLanguageSession context;
X4OLanguageModule module; X4OLanguageModule module;
ElementNamespace namespace; ElementNamespace namespace;
ElementClass elementClass; ElementClass elementClass;

View file

@ -30,7 +30,7 @@ import java.util.List;
import org.x4o.xml.X4ODriver; import org.x4o.xml.X4ODriver;
import org.x4o.xml.X4ODriverManager; import org.x4o.xml.X4ODriverManager;
import org.x4o.xml.element.ElementException; 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. * X4OWriteLanguageDoc is support class to write html documentation from the eld.
@ -95,7 +95,7 @@ public class X4OWriteLanguageDocExecutor {
*/ */
public void execute() throws ElementException { public void execute() throws ElementException {
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguageName()); X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguageName());
X4OLanguageContext context = driver.createLanguage(getLanguageVersion()).createLanguageContext(); X4OLanguageSession context = driver.createLanguage(getLanguageVersion()).createLanguageSession();
// Run doc writer // Run doc writer
EldDocWriter docWriter = new EldDocWriter(context); EldDocWriter docWriter = new EldDocWriter(context);

View file

@ -53,8 +53,8 @@ public class ELIDAttributeHandler extends AbstractElementAttributeHandler {
return; return;
} }
if(element.getElementObject()==null) { throw new NullPointerException("Can't bind null object to el context"); } 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()); 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());
} }
} }

View file

@ -43,8 +43,8 @@ public class ELReferenceElement extends AbstractElement {
public void doElementRun() throws ElementException { public void doElementRun() throws ElementException {
String attributeValue = getAttributes().get("el.ref"); String attributeValue = getAttributes().get("el.ref");
if("".equals(attributeValue) | attributeValue==null) { throw new ElementException("Set the el.ref attribute"); } 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+"}"); Logger.getLogger(ELReferenceElement.class.getName()).finer("Get Variable in ELContext: ${"+attributeValue+"}");
setElementObject(ee.getValue(getLanguageContext().getExpressionLanguageContext())); setElementObject(ee.getValue(getLanguageSession().getExpressionLanguageContext()));
} }
} }

View file

@ -64,7 +64,7 @@ public class PropertyElement extends AbstractElement {
// convert value object // convert value object
try { try {
value = getLanguageContext().getElementAttributeValueParser().getParameterValue(name,valueString,this); value = getLanguageSession().getElementAttributeValueParser().getParameterValue(name,valueString,this);
} catch (ObjectConverterException ece) { } catch (ObjectConverterException ece) {
throw new ElementException(ece); throw new ElementException(ece);
} }
@ -101,7 +101,7 @@ public class PropertyElement extends AbstractElement {
// try to set as property on bean. // try to set as property on bean.
try { try {
getLanguageContext().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value); getLanguageSession().getElementObjectPropertyValue().setProperty(getParent().getElementObject(), name, value);
return; return;
} catch (Exception e) { } catch (Exception e) {
throw new ElementException("Could not set property on parent element object: "+name,e); throw new ElementException("Could not set property on parent element object: "+name,e);

View file

@ -27,7 +27,7 @@ import javax.swing.JLabel;
import org.x4o.xml.element.DefaultElement; import org.x4o.xml.element.DefaultElement;
import org.x4o.xml.element.Element; import org.x4o.xml.element.Element;
import org.x4o.xml.io.X4OReaderContext; 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.lang.phase.X4OPhase;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -41,7 +41,7 @@ import junit.framework.TestCase;
public class ParentObjectTest extends TestCase { public class ParentObjectTest extends TestCase {
public void testParentElement() throws Exception { public void testParentElement() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderContext<?> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);

View file

@ -25,7 +25,7 @@ package org.x4o.xml.lang.meta;
import java.util.Date; import java.util.Date;
import org.x4o.xml.io.X4OReaderContext; 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.lang.phase.X4OPhase;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -39,7 +39,7 @@ import junit.framework.TestCase;
public class ReferenceStoreTest extends TestCase { public class ReferenceStoreTest extends TestCase {
public void testMetaGeneric() throws Exception { public void testMetaGeneric() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderContext<?> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
@ -52,7 +52,7 @@ public class ReferenceStoreTest extends TestCase {
} }
public void testLoadClass() throws Exception { public void testLoadClass() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderContext<?> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);
@ -65,7 +65,7 @@ public class ReferenceStoreTest extends TestCase {
} }
public void testStoreRef() throws Exception { public void testStoreRef() throws Exception {
X4OLanguageContext context = null; X4OLanguageSession context = null;
MTestDriver driver = new MTestDriver(); MTestDriver driver = new MTestDriver();
X4OReaderContext<?> reader = driver.createReaderContext(); X4OReaderContext<?> reader = driver.createReaderContext();
reader.addPhaseSkip(X4OPhase.READ_RELEASE); reader.addPhaseSkip(X4OPhase.READ_RELEASE);