Author: rareddy
Date: 2012-04-30 09:56:47 -0400 (Mon, 30 Apr 2012)
New Revision: 4042
Modified:
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java
branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java
branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties
branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
Log:
TEIID-2019: removing the references to JAXB in favor of direct stream based parsing.
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
---
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -28,12 +28,9 @@
import java.util.Map;
import java.util.Properties;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
import org.teiid.adminapi.AdminObject;
-(a)XmlAccessorType(XmlAccessType.NONE)
public abstract class AdminObjectImpl implements AdminObject, Serializable {
private static final long serialVersionUID = -6381303538713462682L;
Modified:
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
---
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -25,30 +25,18 @@
import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.*;
import org.teiid.adminapi.DataPolicy;
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "permissions",
- "mappedRoleNames"
-})
public class DataPolicyMetadata implements DataPolicy, Serializable {
private static final long serialVersionUID = -4119646357275977190L;
- @XmlAttribute(name = "name", required = true)
protected String name;
- @XmlElement(name = "description")
protected String description;
- @XmlAttribute(name = "any-authenticated")
protected boolean anyAuthenticated;
- @XmlAttribute(name = "allow-create-temporary-tables")
protected Boolean allowCreateTemporaryTables;
- @XmlElement(name = "permission")
protected PermissionMap permissions = new PermissionMap(new
KeyBuilder<PermissionMetaData>() {
private static final long serialVersionUID = -6992984146431492449L;
@Override
@@ -57,7 +45,6 @@
}
});
- @XmlElement(name = "mapped-role-name")
protected List<String> mappedRoleNames = new ArrayList<String>();
@Override
@@ -129,37 +116,19 @@
return false;
}
-
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "resourceName",
- "allowCreate",
- "allowRead",
- "allowUpdate",
- "allowDelete",
- "allowExecute",
- "allowAlter"
- })
public static class PermissionMetaData implements DataPermission, Serializable {
private static final long serialVersionUID = 7034744531663164277L;
// XML based fields
private String resourceName;
- @XmlElement(name = "allow-create")
protected Boolean allowCreate;
- @XmlElement(name = "allow-read")
protected Boolean allowRead;
- @XmlElement(name = "allow-update")
protected Boolean allowUpdate;
- @XmlElement(name = "allow-delete")
protected Boolean allowDelete;
- @XmlElement(name = "allow-execute")
protected Boolean allowExecute;
- @XmlElement(name = "allow-alter")
protected Boolean allowAlter;
@Override
- @XmlElement(name = "resource-name", required = true)
public String getResourceName() {
return resourceName;
}
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
---
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -28,31 +28,16 @@
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "sources",
- "errors"
-})
public class ModelMetaData extends AdminObjectImpl implements Model {
private static final int DEFAULT_ERROR_HISTORY = 10;
private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY =
"supports-multi-source-bindings"; //$NON-NLS-1$
private static final long serialVersionUID = 3714234763056162230L;
- @XmlElement(name = "source")
protected ListOverMap<SourceMappingMetadata> sources = new
ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
private static final long serialVersionUID = 2273673984691112369L;
@@ -62,26 +47,14 @@
}
});
- @XmlAttribute(name = "type")
protected String modelType = Type.PHYSICAL.name();
-
- @XmlElement(name = "description")
protected String description;
-
- @XmlAttribute(name = "path")
protected String path;
-
- @XmlAttribute(name = "visible")
protected Boolean visible = true;
-
- @XmlElement(name = "validation-error")
protected List<ValidationError> errors;
-
protected String schemaSourceType;
-
protected String schemaText;
-
- @XmlAttribute(name = "name", required = true)
+
public String getName() {
return super.getName();
}
@@ -134,7 +107,6 @@
}
@Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -264,22 +236,13 @@
this.errors.clear();
}
- @XmlAccessorType(XmlAccessType.NONE)
- @XmlType(name = "", propOrder = {
- "value"
- })
public static class ValidationError implements Serializable{
private static final long serialVersionUID = 2044197069467559527L;
public enum Severity {ERROR, WARNING};
- @XmlValue
protected String value;
-
- @XmlAttribute(name = "severity", required = true)
protected String severity;
-
- @XmlAttribute(name = "path")
protected String path;
public ValidationError() {};
Modified:
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
---
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -24,11 +24,6 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
/**
* <pre>
* <complexType name="property">
@@ -43,14 +38,10 @@
*
*
*/
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "property")
public class PropertyMetadata implements Serializable{
private static final long serialVersionUID = -5040224539939758816L;
- @XmlAttribute(name = "name", required = true)
protected String name;
- @XmlAttribute(name = "value", required = true)
protected String value;
public PropertyMetadata() {
Modified:
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
---
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -24,23 +24,11 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "")
public class SourceMappingMetadata implements Serializable {
private static final long serialVersionUID = -4417878417697685794L;
- @XmlAttribute(name = "name", required = true)
private String name;
-
- @XmlAttribute(name = "connection-jndi-name")
private String jndiName;
-
- @XmlAttribute(name = "translator-name",required = true)
private String translatorName;
public SourceMappingMetadata() {}
Modified: branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-04-27
15:38:44 UTC (rev 4041)
+++ branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -24,8 +24,6 @@
import java.net.URL;
import java.util.*;
-import javax.xml.bind.annotation.*;
-
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
@@ -34,15 +32,6 @@
import org.teiid.core.util.StringUtil;
-(a)XmlAccessorType(XmlAccessType.NONE)
-@XmlType(name = "", propOrder = {
- "description",
- "JAXBProperties",
- "models",
- "translators",
- "dataPolicies"
-})
-@XmlRootElement(name = "vdb")
public class VDBMetaData extends AdminObjectImpl implements VDB {
private static final String VERSION_DELIM = "."; //$NON-NLS-1$
@@ -53,7 +42,6 @@
* This simulating a list over a map. JAXB requires a list and performance recommends
* map and we would like to keep one variable to represent both.
*/
- @XmlElement(name = "model", required = true, type = ModelMetaData.class)
protected ListOverMap<ModelMetaData> models = new
ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
private static final long serialVersionUID = 846247100420118961L;
@@ -63,7 +51,6 @@
}
});
- @XmlElement(name = "translator", required = true, type =
VDBTranslatorMetaData.class)
protected ListOverMap<VDBTranslatorMetaData> translators = new
ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
private static final long serialVersionUID = 3890502172003653563L;
@@ -73,7 +60,6 @@
}
});
- @XmlElement(name = "data-role", required = true, type =
DataPolicyMetadata.class)
protected ListOverMap<DataPolicyMetadata> dataPolicies = new
ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
private static final long serialVersionUID = 4954591545242715254L;
@@ -83,10 +69,8 @@
}
});
- @XmlAttribute(name = "version", required = true)
private int version = 1;
- @XmlElement(name = "description")
protected String description;
private String fileUrl = null;
@@ -96,7 +80,6 @@
private boolean removed;
private long queryTimeout = Long.MIN_VALUE;
- @XmlAttribute(name = "name", required = true)
public String getName() {
return super.getName();
}
@@ -300,7 +283,6 @@
// This one manages the JAXB binding
@Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
Modified:
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
---
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -23,15 +23,9 @@
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
import org.teiid.adminapi.Translator;
-(a)XmlAccessorType(XmlAccessType.NONE)
public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
private static final long serialVersionUID = -3454161477587996138L;
private String type;
@@ -44,7 +38,6 @@
return super.getName();
}
- @XmlAttribute(name = "name", required = true)
public void setName(String name) {
super.setName(name);
}
@@ -54,13 +47,11 @@
return type;
}
- @XmlAttribute(name = "type",required = true)
public void setType(String type) {
this.type = type;
}
@Override
- @XmlElement(name = "property", type = PropertyMetadata.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -82,7 +73,6 @@
return this.description;
}
- @XmlAttribute(name = "description")
public void setDescription(String desc) {
this.description = desc;
}
Modified: branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
---
branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/admin/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -30,13 +30,6 @@
import java.util.Arrays;
import java.util.List;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.teiid.adminapi.DataPolicy;
@@ -49,33 +42,7 @@
@SuppressWarnings("nls")
public class TestVDBMetaData {
-
- public void testMarshellUnmarshellUsingJaxb() throws Exception {
-
- VDBMetaData vdb = buildVDB();
-
- SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema =
schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd"));
//$NON-NLS-1$
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
- Marshaller marshell = jc.createMarshaller();
- marshell.setSchema(schema);
- marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
-
- StringWriter sw = new StringWriter();
- marshell.marshal(vdb, sw);
-
- //System.out.println(sw.toString());
-
- // UnMarshell
- Unmarshaller un = jc.createUnmarshaller();
- un.setSchema(schema);
- vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
-
- validateVDB(vdb);
- }
-
-
@Test
public void testMarshellUnmarshellDirectParsing() throws Exception {
Modified: branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-04-27
15:38:44 UTC (rev 4041)
+++ branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -26,9 +26,6 @@
import java.util.Arrays;
import java.util.List;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
@@ -108,7 +105,6 @@
private Determinism determinism = Determinism.DETERMINISTIC;
- @XmlElement(name="inputParameters")
protected List<FunctionParameter> inParameters = new
ArrayList<FunctionParameter>(2);
private FunctionParameter outputParameter;
private Schema parent;
@@ -154,7 +150,6 @@
* Return name of method
* @return Name
*/
- @XmlAttribute
public String getName() {
return super.getName();
}
@@ -180,7 +175,6 @@
* Get description of method
* @return Description
*/
- @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -198,7 +192,6 @@
* @return Category
* @see FunctionCategoryConstants
*/
- @XmlAttribute
public String getCategory() {
return this.category;
}
@@ -228,7 +221,6 @@
this.pushdown = pushdown;
}
- @XmlAttribute
public void setPushDown(String pushdown) {
if (pushdown != null) {
if (pushdown.equals(REQUIRED)) {
@@ -247,7 +239,6 @@
* Get invocation class name
* @return Invocation class name
*/
- @XmlAttribute
public String getInvocationClass() {
return this.invocationClass;
}
@@ -264,7 +255,6 @@
* Get invocation method name
* @return Invocation method name
*/
- @XmlAttribute
public String getInvocationMethod() {
return this.invocationMethod;
}
@@ -312,7 +302,6 @@
* Get ouput parameter.
* @return Output parameter or return argument
*/
- @XmlElement(name="returnParameter")
public FunctionParameter getOutputParameter() {
return this.outputParameter;
}
@@ -448,7 +437,6 @@
return this.determinism;
}
- @XmlAttribute(name="deterministic")
public void setDeterministicBoolean(boolean deterministic) {
this.determinism = deterministic ? Determinism.DETERMINISTIC :
Determinism.NONDETERMINISTIC;
}
Modified: branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java
===================================================================
--- branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java 2012-04-27
15:38:44 UTC (rev 4041)
+++ branches/8.0.x/api/src/main/java/org/teiid/metadata/FunctionParameter.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -24,9 +24,6 @@
import java.io.Serializable;
-import javax.xml.bind.annotation.XmlAttribute;
-
-
/**
* A function parameter defines the name and description of an input or output
* parameter for a function. The name should not be null, but that is not
@@ -81,7 +78,6 @@
* Return name of parameter.
* @return Name
*/
- @XmlAttribute
public String getName() {
return this.name;
}
@@ -98,7 +94,6 @@
* Get description of parameter
* @return Description
*/
- @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -116,7 +111,6 @@
* @return Type name
* @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
*/
- @XmlAttribute
public String getType() {
return this.type;
}
Modified: branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
===================================================================
--- branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2012-04-27
15:38:44 UTC (rev 4041)
+++ branches/8.0.x/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2012-04-30
13:56:47 UTC (rev 4042)
@@ -15,12 +15,13 @@
<dependencies>
+ <module name="javax.api" />
+ <module name="javax.xml.bind.api" />
+ <module name="javax.resource.api"/>
<module name="org.jboss.teiid.common-core" />
<module name="org.jboss.teiid.api" />
<module name="org.jboss.teiid.client" />
<module name="org.jboss.teiid.admin" />
- <module name="javax.api" />
- <module name="javax.resource.api"/>
<module name="org.jboss.logging" />
<module name="org.jboss.as.controller"/>
<module name="org.jboss.modules"/>
Modified: branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java 2012-04-27
15:38:44 UTC (rev 4041)
+++ branches/8.0.x/client/src/main/java/org/teiid/client/plan/PlanNode.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -28,24 +28,23 @@
import java.io.ObjectOutput;
import java.io.StringReader;
import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Properties;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.XMLType;
import org.teiid.core.util.ExternalizeUtil;
import org.teiid.jdbc.JDBCPlugin;
@@ -56,17 +55,13 @@
* parent. For procedure plans child PlanNodes will be processing instructions,
* which can in turn contain other relational or procedure plans.
*/
-@XmlType
-@XmlRootElement(name="node")
public class PlanNode implements Externalizable {
/**
* A Property is a named value of a {@link PlanNode} that may be
* another {@link PlanNode} or a non-null list of values.
*/
- @XmlType(name = "property")
public static class Property implements Externalizable {
- @XmlAttribute
private String name;
private List<String> values;
private PlanNode planNode;
@@ -83,7 +78,6 @@
return name;
}
- @XmlElement(name="value")
public List<String> getValues() {
return values;
}
@@ -92,7 +86,6 @@
this.values = values;
}
- @XmlElement(name="node")
public PlanNode getPlanNode() {
return planNode;
}
@@ -118,10 +111,8 @@
}
- @XmlElement(name="property")
private List<Property> properties = new LinkedList<Property>();
private PlanNode parent;
- @XmlAttribute
private String name;
public PlanNode() {
@@ -221,28 +212,68 @@
writer.writeEndElement();
}
- public static PlanNode fromXml(String planString) {
- try {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
- Unmarshaller marshaller = jc.createUnmarshaller();
- PlanNode planNode = (PlanNode) marshaller.unmarshal(new StringReader(planString));
- setParents(planNode);
- return planNode;
- } catch (JAXBException e) {
- //shouldn't happen
- throw new TeiidRuntimeException(e);
+ private static Properties getAttributes(XMLStreamReader reader) {
+ Properties props = new Properties();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ props.setProperty(attrName, attrValue);
+ }
}
- }
+ return props;
+ }
+
+ public static PlanNode fromXml(String planString) throws XMLStreamException {
+ XMLInputFactory inputFactory = XMLType.getXmlInputFactory();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new
StringReader(planString));
- private static void setParents(PlanNode planNode) {
- for (Property property : planNode.properties) {
- if (property.planNode != null) {
- property.planNode.parent = planNode;
- setParents(property.planNode);
+ while (reader.hasNext()&& (reader.nextTag() != XMLStreamConstants.END_ELEMENT))
{
+ String element = reader.getLocalName();
+ if (element.equals("node")) { //$NON-NLS-1$
+ Properties props = getAttributes(reader);
+ PlanNode planNode = new PlanNode(props.getProperty("name"));//$NON-NLS-1$
+ planNode.setParent(null);
+ buildNode(reader, planNode);
+ return planNode;
}
+ throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element",
reader.getName(), "node"),reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
}
+ return null;
}
-
+
+ private static PlanNode buildNode(XMLStreamReader reader, PlanNode node) throws
XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ String property = reader.getLocalName();
+ if (property.equals("property")) {//$NON-NLS-1$
+ Properties props = getAttributes(reader);
+ ArrayList<String> values = new ArrayList<String>();
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ String valueNode = reader.getLocalName();
+ if (valueNode.equals("value")) {//$NON-NLS-1$
+ values.add(reader.getElementText());
+ }
+ else if (valueNode.equals("node")) {//$NON-NLS-1$
+ values = null;
+ Properties nodeProps = getAttributes(reader);
+ PlanNode childNode = new
PlanNode(nodeProps.getProperty("name"));//$NON-NLS-1$
+ node.addProperty(props.getProperty("name"), buildNode(reader,
childNode));//$NON-NLS-1$
+ }
+ else {
+ throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element",
reader.getName(), "value"), reader.getLocation());//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ if (values != null) {
+ node.addProperty(props.getProperty("name"), values);//$NON-NLS-1$
+ }
+ }
+ else {
+ throw new XMLStreamException(JDBCPlugin.Util.gs("unexpected_element",
reader.getName(), "property"), reader.getLocation()); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ }
+ return node;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
Modified: branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties 2012-04-27
15:38:44 UTC (rev 4041)
+++ branches/8.0.x/client/src/main/resources/org/teiid/jdbc/i18n.properties 2012-04-30
13:56:47 UTC (rev 4042)
@@ -172,4 +172,5 @@
TEIID20008=Failed to load "org.jboss.teiid" module.
TEIID20023=connection closed
TEIID20007=Duplicate Class
-TEIID20028=data length too big: {0} > max of {1}. You may need to adjust the
maxObjectSize client setting.
\ No newline at end of file
+TEIID20028=data length too big: {0} > max of {1}. You may need to adjust the
maxObjectSize client setting.
+unexpected_element=Unexpected Element {0} encountered, expecting one of {1}
\ No newline at end of file
Modified:
branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
---
branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -7,9 +7,6 @@
import java.util.List;
import java.util.Map;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
@@ -19,11 +16,8 @@
import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
-@XmlType
-@XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
public class FunctionMetadataReader {
- @XmlElement(namespace="http://www.metamatrix.com/metamodels/MetaMatrixFunction",
name="ScalarFunction")
List<FunctionMethod> functionMethods = new ArrayList<FunctionMethod>();
public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws
XMLStreamException {
Modified:
branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
===================================================================
---
branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2012-04-27
15:38:44 UTC (rev 4041)
+++
branches/8.0.x/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2012-04-30
13:56:47 UTC (rev 4042)
@@ -29,8 +29,6 @@
import java.io.StringWriter;
import java.util.ArrayList;
-import javax.xml.bind.JAXBException;
-
import org.teiid.query.mapping.xml.MappingAttribute;
import org.teiid.query.mapping.xml.MappingChoiceNode;
import org.teiid.query.mapping.xml.MappingCriteriaNode;