Author: rareddy
Date: 2011-08-29 22:16:42 -0400 (Mon, 29 Aug 2011)
New Revision: 3433
Added:
branches/as7/build/kits/jboss-as7/docs/
branches/as7/build/kits/jboss-as7/docs/teiid/
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
branches/as7/client/src/test/resources/parser-test-vdb.xml
Modified:
branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java
branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java
branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java
branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd
branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
Log:
TEIID-1720: vdb deploys and client can connect and issue queries
Modified: branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -111,8 +111,9 @@
protected List<FunctionParameter> inParameters = new
ArrayList<FunctionParameter>();
private FunctionParameter outputParameter;
private Schema parent;
+ private ClassLoader classLoader;
- protected FunctionMethod() {
+ public FunctionMethod() {
}
public FunctionMethod(String name, String description, String category,
FunctionParameter[] inputParams, FunctionParameter outputParam) {
@@ -464,4 +465,12 @@
public Schema getParent() {
return parent;
}
+
+ public ClassLoader getClassLoader() {
+ return this.classLoader;
+ }
+
+ public void setClassloader(ClassLoader classloader) {
+ this.classLoader = classloader;
+ }
}
Added: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
(rev 0)
+++ branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -0,0 +1,8 @@
+<drivers>
+ <driver name="h2" module="com.h2database.h2">
+
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
+ </driver>
+ <driver name="oracle" module="com.oracle">
+
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ </driver>
+</drivers>
\ No newline at end of file
Property changes on:
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
(rev 0)
+++ branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml 2011-08-30 02:16:42
UTC (rev 3433)
@@ -0,0 +1,14 @@
+<datasource jndi-name="java:jboss/datasources/ExampleDS"
pool-name="H2DS" enabled="true" jta="true"
use-java-context="true" use-ccm="true">
+ <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+ <driver>h2</driver>
+ <pool>
+ <prefill>false</prefill>
+ <use-strict-min>false</use-strict-min>
+ <flush-strategy>FailingConnectionOnly</flush-strategy>
+ </pool>
+ <security>
+ <user-name>sa</user-name>
+ <password>sa</password>
+ </security>
+</datasource>
+
Property changes on: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
(rev 0)
+++ branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -0,0 +1,13 @@
+<datasource jndi-name="java:/Oracle11_PushDS" pool-name="OracleDS"
enabled="true" jta="true" use-java-context="true"
use-ccm="true">
+
<connection-url>jdbc:oracle:thin:@englxdbs11.mw.lab.eng.bos.redhat.com:1521:orcl</connection-url>
+ <driver>oracle</driver>
+ <pool>
+ <prefill>false</prefill>
+ <use-strict-min>false</use-strict-min>
+ <flush-strategy>FailingConnectionOnly</flush-strategy>
+ </pool>
+ <security>
+ <user-name>bqt2_ro</user-name>
+ <password>mm</password>
+ </security>
+</datasource>
\ No newline at end of file
Property changes on: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -7,6 +7,7 @@
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.jboss.teiid.common-core"/>
<module name="org.jboss.teiid.client" />
Modified:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -6,5 +6,7 @@
</resources>
<dependencies>
+ <module name="javax.api"/>
+ <module name="javax.activation.api"/>
</dependencies>
</module>
\ No newline at end of file
Added:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
(rev 0)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties 2011-08-30
02:16:42 UTC (rev 3433)
@@ -0,0 +1,3 @@
+# A roles.properties file for use with the UsersRolesLoginModule
+# username=role1,role2
+user=example-role
Property changes on:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
(rev 0)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties 2011-08-30
02:16:42 UTC (rev 3433)
@@ -0,0 +1,3 @@
+# A users.properties file for use with the UsersRolesLoginModule
+# username=password
+user=user
Property changes on:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -10,8 +10,8 @@
<resource-root path="teiid-runtime-${project.version}.jar" />
<resource-root path="teiid-engine-${project.version}.jar" />
<resource-root path="saxonhe-9.2.1.5.jar" />
- <resource-root path="json-simple-1.1.jar" />
- <!-- Insert resources here -->
+ <resource-root path="json-simple-1.1.jar" />
+ <resource-root path="conf" />
</resources>
@@ -37,6 +37,7 @@
<module name="org.jboss.as.naming"/>
<module name="javax.xml.bind.api"/>
<module name="javax.transaction.api"/>
+ <module name="javax.activation.api"/>
</dependencies>
</module>
\ No newline at end of file
Modified:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -7,6 +7,7 @@
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j"/>
Modified:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -7,6 +7,7 @@
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j"/>
Modified:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -6,5 +6,6 @@
</resources>
<dependencies>
+ <module name="javax.api"/>
</dependencies>
</module>
\ No newline at end of file
Modified:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -6,6 +6,7 @@
</resources>
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j"/>
Modified: branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
---
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -105,10 +105,26 @@
<password>sa</password>
</security>
</datasource>
+ <datasource jndi-name="java:/Oracle11_PushDS"
pool-name="OracleDS" enabled="true" jta="true"
use-java-context="true" use-ccm="true">
+
<connection-url>jdbc:oracle:thin:@englxdbs11.mw.lab.eng.bos.redhat.com:1521:orcl</connection-url>
+ <driver>oracle</driver>
+ <pool>
+ <prefill>false</prefill>
+ <use-strict-min>false</use-strict-min>
+
<flush-strategy>FailingConnectionOnly</flush-strategy>
+ </pool>
+ <security>
+ <user-name>bqt2_ro</user-name>
+ <password>mm</password>
+ </security>
+ </datasource>
<drivers>
<driver name="h2"
module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
+ <driver name="oracle" module="com.oracle">
+
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ </driver>
</drivers>
</datasources>
</subsystem>
Added: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
(rev 0)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.impl;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+@SuppressWarnings("nls")
+public class VDBMetadataParser {
+
+ public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
+ XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
+
+ // elements
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case VDB:
+ VDBMetaData vdb = new VDBMetaData();
+ Properties props = getAttributes(reader);
+ vdb.setName(props.getProperty(Element.NAME.getLocalName()));
+ vdb.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
+ parseVDB(reader, vdb);
+ return vdb;
+ default:
+ throw new XMLStreamException("Unexpected element '" +
reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ return null;
+ }
+
+ private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws
XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ vdb.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, vdb);
+ break;
+ case MODEL:
+ ModelMetaData model = new ModelMetaData();
+ parseModel(reader, model);
+ vdb.addModel(model);
+ break;
+ case TRANSLATOR:
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ parseTranslator(reader, translator);
+ vdb.addOverideTranslator(translator);
+ break;
+ case DATA_ROLE:
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ parseDataRole(reader, policy);
+ vdb.addDataPolicy(policy);
+ break;
+ case ENTRY:
+ // this is designer specific.
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" +
reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
+ throws XMLStreamException {
+ if (reader.getAttributeCount() > 0) {
+ String key = null;
+ String value = null;
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (attrName.equals(Element.NAME.getLocalName())) {
+ key = attrValue;
+ }
+ if (attrName.equals(Element.VALUE.getLocalName())) {
+ value = attrValue;
+ }
+ }
+ anObj.addProperty(key, value);
+ }
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ }
+
+ private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy)
throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ policy.setName(props.getProperty(Element.NAME.getLocalName()));
+ policy.setAnyAuthenticated(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName())));
+ policy.setAllowCreateTemporaryTables(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName())));
+
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ policy.setDescription(reader.getElementText());
+ break;
+ case PERMISSION:
+ PermissionMetaData permission = new PermissionMetaData();
+ parsePermission(reader, permission);
+ policy.addPermission(permission);
+ break;
+ case MAPPED_ROLE_NAME:
+ policy.addMappedRoleName(reader.getElementText());
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" +
reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parsePermission(XMLStreamReader reader, PermissionMetaData
permission) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case RESOURCE_NAME:
+ permission.setResourceName(reader.getElementText());
+ break;
+ case ALLOW_ALTER:
+ permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_CREATE:
+ permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_DELETE:
+ permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_EXECUTE:
+ permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_READ:
+ permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_UPADTE:
+ permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+
+ default:
+ throw new XMLStreamException("Unexpected element '" +
reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseTranslator(XMLStreamReader reader, VDBTranslatorMetaData
translator) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ translator.setName(props.getProperty(Element.NAME.getLocalName()));
+ translator.setType(props.getProperty(Element.TYPE.getLocalName()));
+ translator.setDescription(props.getProperty(Element.DESCRIPTION.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case PROPERTY:
+ parseProperty(reader, translator);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" +
reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseModel(XMLStreamReader reader, ModelMetaData model) throws
XMLStreamException {
+ Properties props = getAttributes(reader);
+ model.setName(props.getProperty(Element.NAME.getLocalName()));
+ model.setModelType(Model.Type.valueOf(props.getProperty(Element.TYPE.getLocalName(),
"PHYSICAL")));
+ model.setVisible(Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(),
"true")));
+ model.setPath(props.getProperty(Element.PATH.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ model.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, model);
+ break;
+ case SOURCE:
+ Properties sourceProps = getAttributes(reader);
+ String name = sourceProps.getProperty(Element.NAME.getLocalName());
+ String translatorName =
sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
+ String connectionName =
sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
+ model.addSourceMapping(name, translatorName, connectionName);
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ break;
+ case VALIDATION_ERROR:
+ Properties validationProps = getAttributes(reader);
+ String msg = reader.getElementText();
+ String severity =
validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
+ String path = validationProps.getProperty(Element.PATH.getLocalName());
+ ValidationError ve = new ValidationError(severity, msg);
+ ve.setPath(path);
+ model.addError(ve);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" +
reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+
+ 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;
+ }
+
+ enum Element {
+ // must be first
+ UNKNOWN(null),
+ VDB("vdb"),
+ NAME("name"),
+ VERSION("version"),
+ DESCRIPTION("description"),
+ PROPERTY("property"),
+ VALUE("value"),
+ MODEL("model"),
+ TYPE("type"),
+ VISIBLE("visible"),
+ PATH("path"),
+ SOURCE("source"),
+ SOURCE_TRANSLATOR_NAME_ATTR("translator-name"),
+ SOURCE_CONNECTION_JNDI_NAME_ATTR("connection-jndi-name"),
+ VALIDATION_ERROR("validation-error"),
+ VALIDATION_SEVERITY_ATTR("severity"),
+ TRANSLATOR("translator"),
+ DATA_ROLE("data-role"),
+ DATA_ROLE_ANY_ATHENTICATED_ATTR("any-authenticated"),
+ DATA_ROLE_ALLOW_TEMP_TABLES_ATTR("allow-create-temporary-tables"),
+ PERMISSION("permission"),
+ RESOURCE_NAME("resource-name"),
+ ALLOW_CREATE("allow-create"),
+ ALLOW_READ("allow-read"),
+ ALLOW_UPADTE("allow-update"),
+ ALLOW_DELETE("allow-delete"),
+ ALLOW_EXECUTE("allow-execute"),
+ ALLOW_ALTER("allow-alyer"),
+ MAPPED_ROLE_NAME("mapped-role-name"),
+ ENTRY("entry");
+
+ private final String name;
+
+ Element(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Element> elements;
+
+ static {
+ final Map<String, Element> map = new HashMap<String, Element>();
+ for (Element element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ elements = map;
+ }
+
+ public static Element forName(String localName) {
+ final Element element = elements.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+ }
+}
Property changes on:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -22,23 +22,20 @@
package org.teiid.client.plan;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.StringWriter;
+import java.io.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
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.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.ExternalizeUtil;
@@ -171,18 +168,50 @@
*/
public String toXml() {
try {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
//$NON-NLS-1$
- StringWriter writer = new StringWriter();
- marshaller.marshal(this, writer);
- return writer.toString();
- } catch (JAXBException e) {
- //shouldn't happen
- throw new TeiidRuntimeException(e);
+ XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter);
+ writer.writeStartDocument("UTF-8", "1.0"); //$NON-NLS-1$
//$NON-NLS-2$
+ writePlanNode(this, writer);
+ writer.writeEndDocument();
+ return stringWriter.toString();
+ } catch (FactoryConfigurationError e) {
+ throw new TeiidRuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ private void writeProperty(Property property, XMLStreamWriter writer) throws
XMLStreamException {
+ writer.writeStartElement("property"); //$NON-NLS-1$
+ writer.writeAttribute("name", property.getName()); //$NON-NLS-1$
+ if (property.getValues() != null) {
+ for (String value:property.getValues()) {
+ writeElement(writer, "value", value); //$NON-NLS-1$
+ }
}
+ PlanNode node = property.getPlanNode();
+ if (node != null) {
+ writePlanNode(node, writer);
+ }
+ writer.writeEndElement();
}
+ private void writePlanNode(PlanNode node, XMLStreamWriter writer) throws
XMLStreamException {
+ writer.writeStartElement("node"); //$NON-NLS-1$
+ writer.writeAttribute("name", node.getName()); //$NON-NLS-1$
+ for (Property p:node.getProperties()) {
+ writeProperty(p, writer);
+ }
+ writer.writeEndElement();
+ }
+
+ private void writeElement(final XMLStreamWriter writer, String name, String value)
throws XMLStreamException {
+ writer.writeStartElement(name);
+ writer.writeCharacters(value);
+ writer.writeEndElement();
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
Modified: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
---
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -65,7 +65,7 @@
StringWriter sw = new StringWriter();
marshell.marshal(vdb, sw);
- //System.out.println(sw.toString());
+ System.out.println(sw.toString());
// UnMarshell
Unmarshaller un = jc.createUnmarshaller();
@@ -75,7 +75,7 @@
validateVDB(vdb);
}
- private void validateVDB(VDBMetaData vdb) {
+ static void validateVDB(VDBMetaData vdb) {
ModelMetaData modelOne;
ModelMetaData modelTwo;
assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
Added:
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
(rev 0)
+++
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -0,0 +1,17 @@
+package org.teiid.adminapi.impl;
+
+import java.io.FileInputStream;
+
+import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestVDBMetadataParser {
+
+ @Test
+ public void testparseVDB() throws Exception {
+ FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() +
"/parser-test-vdb.xml");
+ VDBMetaData vdb = VDBMetadataParser.unmarshell(in);
+ TestVDBMetaData.validateVDB(vdb);
+ }
+}
Property changes on:
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -62,7 +62,7 @@
}
public void testXml() throws Exception {
- assertEquals("<?xml version=\"1.0\"
encoding=\"UTF-8\" standalone=\"yes\"?>\n<node
name=\"x\">\n <property name=\"test\">\n
<value></value>\n </property>\n <property
name=\"string\">\n <value>string</value>\n
</property>\n <property name=\"list<string>\">\n
<value>item1</value>\n <value>item2</value>\n
<value>item3</value>\n </property>\n <property
name=\"child\">\n <node name=\"y\">\n
<property name=\"outputCols\">\n <value>Name
(string)</value>\n <value>Year (integer)</value>\n
</property>\n <property name=\"Join Type\">\n
<value>INNER JOIN</value>\n </property>\n
<property name=\"Criteria\">\n <value>Item.ID =
History.ID</value>\n </property>\n <property
name=\"Other\"/>\n </node>\n
</property>\n</node>\n", example1().toXml()); //$NON-NLS-1$
+ assertEquals("<?xml version=\"1.0\"
encoding=\"UTF-8\"?><node name=\"x\"><property
name=\"test\"><value></value></property><property
name=\"string\"><value>string</value></property><property
name=\"list<string>\"><value>item1</value><value>item2</value><value>item3</value></property><property
name=\"child\"><node name=\"y\"><property
name=\"outputCols\"><value>Name (string)</value><value>Year
(integer)</value></property><property name=\"Join
Type\"><value>INNER JOIN</value></property><property
name=\"Criteria\"><value>Item.ID =
History.ID</value></property><property
name=\"Other\"></property></node></property></node>",
example1().toXml()); //$NON-NLS-1$
}
public void testText() throws Exception {
Added: branches/as7/client/src/test/resources/parser-test-vdb.xml
===================================================================
--- branches/as7/client/src/test/resources/parser-test-vdb.xml
(rev 0)
+++ branches/as7/client/src/test/resources/parser-test-vdb.xml 2011-08-30 02:16:42 UTC
(rev 3433)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<vdb name="myVDB" version="1">
+ <description>vdb description</description>
+ <property value="vdb-value" name="vdb-property"/>
+ <property value="vdb-value2" name="vdb-property2"/>
+ <model name="model-one" visible="false"
type="PHYSICAL">
+ <description>model description</description>
+ <property value="model-value-override"
name="model-prop"/>
+ <source translator-name="translator"
connection-jndi-name="java:mybinding" name="s1"/>
+ <validation-error severity="ERROR">There is an error in
VDB</validation-error>
+ </model>
+ <model name="model-two" visible="true"
type="VIRTUAL">
+ <property value="model-value" name="model-prop"/>
+ <source translator-name="translator"
connection-jndi-name="java:binding-one" name="s1"/>
+ <source translator-name="translator"
connection-jndi-name="java:binding-two" name="s2"/>
+ </model>
+ <translator type="oracle" name="oracleOverride"
description="hello world">
+ <property value="my-value" name="my-property"/>
+ </translator>
+ <data-role allow-create-temporary-tables="true"
any-authenticated="false" name="roleOne">
+ <description>roleOne described</description>
+ <permission>
+ <resource-name>myTable.T1</resource-name>
+ <allow-read>true</allow-read>
+ </permission>
+ <permission>
+ <resource-name>myTable.T2</resource-name>
+ <allow-read>false</allow-read>
+ <allow-delete>true</allow-delete>
+ </permission>
+ <mapped-role-name>ROLE1</mapped-role-name>
+ <mapped-role-name>ROLE2</mapped-role-name>
+ </data-role>
+</vdb>
\ No newline at end of file
Property changes on: branches/as7/client/src/test/resources/parser-test-vdb.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF 2011-08-30
02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF 2011-08-30
02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF
===================================================================
---
branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF 2011-08-30
02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF 2011-08-30
02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified:
branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
---
branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -30,6 +30,7 @@
import java.util.List;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import junit.framework.Assert;
@@ -76,7 +77,7 @@
util.addUDF("foo", methods); //$NON-NLS-1$
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
}
}
@@ -91,7 +92,7 @@
Collection <FunctionMethod> methods = new
ArrayList<FunctionMethod>();
try {
methods.addAll(FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream()));
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
Modified:
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -52,5 +52,5 @@
* @return Class reference
* @throws ClassNotFoundException If class could not be found
*/
- Class getInvocationClass(String className) throws ClassNotFoundException;
+ Class getInvocationClass(String className, ClassLoader cl) throws
ClassNotFoundException;
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -80,7 +80,7 @@
* @param source The metadata source
*/
public FunctionTree(String name, FunctionMetadataSource source) {
- this(name, source, false);
+ this(name, source, false, null);
}
/**
@@ -88,12 +88,19 @@
* @param source The metadata source
*/
public FunctionTree(String name, FunctionMetadataSource source, boolean
validateClass) {
+ this(name, source, validateClass, null);
+ }
+
+ public FunctionTree(String name, FunctionMetadataSource source, boolean
validateClass, ClassLoader defaultClassloader) {
// Load data structures
this.validateClass = validateClass;
Collection<FunctionMethod> functions = source.getFunctionMethods();
for (FunctionMethod method : functions) {
if (!containsIndistinguishableFunction(method)){
+ if (method.getClassLoader() == null) {
+ method.setClassloader(defaultClassloader);
+ }
// Add to tree
addFunction(name, source, method);
} else if (!CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name)) {
@@ -288,7 +295,7 @@
// Defect 20007 - Ignore the invocation method if pushdown is not required.
if (validateClass && (method.getPushdown() == PushDown.CAN_PUSHDOWN ||
method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) {
try {
- Class<?> methodClass =
source.getInvocationClass(method.getInvocationClass());
+ Class<?> methodClass =
source.getInvocationClass(method.getInvocationClass(), method.getClassLoader());
ReflectionHelper helper = new ReflectionHelper(methodClass);
try {
invocationMethod =
helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
Modified:
branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -34,6 +34,7 @@
private FunctionTree systemFunctionTree;
private boolean allowEnvFunction = true;
+ private ClassLoader classLoader;
public FunctionTree getSystemFunctions() {
if(systemFunctionTree == null) {
@@ -47,7 +48,7 @@
// Should never happen as SystemSourcTe doesn't change
System.err.println(QueryPlugin.Util.getString("ERR.015.001.0005",
report)); //$NON-NLS-1$
}
- systemFunctionTree = new FunctionTree(CoreConstants.SYSTEM_MODEL, systemSource,
true);
+ systemFunctionTree = new FunctionTree(CoreConstants.SYSTEM_MODEL, systemSource, true,
this.classLoader);
}
return systemFunctionTree;
}
@@ -74,4 +75,12 @@
public void setAllowEnvFunction(boolean allowEnvFunction) {
this.allowEnvFunction = allowEnvFunction;
}
+
+ public ClassLoader getClassLoader() {
+ return this.classLoader;
+ }
+
+ public void setClassloader(ClassLoader classloader) {
+ this.classLoader = classloader;
+ }
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -40,7 +40,7 @@
return this.methods;
}
- public Class<?> getInvocationClass(String className) throws
ClassNotFoundException {
- return Class.forName(className);
+ public Class<?> getInvocationClass(String className, ClassLoader cl) throws
ClassNotFoundException {
+ return Class.forName(className, true, cl);
}
}
Modified:
branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -1,17 +1,18 @@
package org.teiid.query.function.metadata;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
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;
+import javax.xml.stream.XMLStreamReader;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
@XmlType
@XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
@@ -20,11 +21,196 @@
@XmlElement(namespace="http://www.metamatrix.com/metamodels/MetaMatrixFunction",
name="ScalarFunction")
List<FunctionMethod> functionMethods = new ArrayList<FunctionMethod>();
- public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws
JAXBException {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[]
{FunctionMetadataReader.class});
- Unmarshaller marshaller = jc.createUnmarshaller();
- FunctionMetadataReader md = (FunctionMetadataReader) marshaller.unmarshal(source);
+ public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws
XMLStreamException {
+ FunctionMetadataReader md = parseFunctions(source);
return md.functionMethods;
}
+
+ public static FunctionMetadataReader parseFunctions(InputStream content) throws
XMLStreamException {
+ XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
+ FunctionMetadataReader fmr = new FunctionMetadataReader();
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ System.out.println(reader.getLocalName());
+ switch (Namespace.forUri(reader.getNamespaceURI())) {
+ case XMI: {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case XMI:
+ parseFunctions(reader, fmr);
+ while(reader.hasNext() && reader.next() !=
XMLStreamConstants.END_DOCUMENT);
+ break;
+ }
+ break;
+ }
+ }
+ }
+ return fmr;
+ }
+
+ private static void parseFunctions(XMLStreamReader reader, FunctionMetadataReader fmr)
throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ String elementName = reader.getLocalName();
+ switch (Element.forName(elementName)) {
+ case SCALAR_FUNCTION:
+ fmr.functionMethods.add(parseScalarFunction(reader));
+ break;
+ default:
+ // skip the elements not needed.
+ while (reader.hasNext()) {
+ if (reader.nextTag() == XMLStreamConstants.END_ELEMENT &&
reader.getLocalName().equals(elementName)) {
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ private static FunctionMethod parseScalarFunction(XMLStreamReader reader) throws
XMLStreamException {
+ FunctionMethod function = new FunctionMethod();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (Element.NAME.getLocalName().equals(attrName)) {
+ function.setName(attrValue);
+ }
+ else if (Element.CATEGORY.getLocalName().equals(attrName)) {
+ function.setCategory(attrValue);
+ }
+ else if (Element.INVOCATION_CLASS.getLocalName().equals(attrName)) {
+ function.setInvocationClass(attrValue);
+ // TODO: set class loader
+ // function.setClassloader();
+ }
+ else if (Element.INVOCATION_METHOD.getLocalName().equals(attrName)) {
+ function.setInvocationMethod(attrValue);
+ }
+ else if (Element.PUSHDOWN.getLocalName().equals(attrName)) {
+ function.setPushDown(attrValue);
+ }
+ else if (Element.DETERMINISTIC.getLocalName().equals(attrName)) {
+ function.setDeterministicBoolean(Boolean.parseBoolean(attrValue));
+ }
+ }
+ }
+ LinkedList<FunctionParameter> inputs = new
LinkedList<FunctionParameter>();
+
+ while (reader.hasNext() && (reader.nextTag() !=
XMLStreamConstants.END_ELEMENT)) {
+ switch (Element.forName(reader.getLocalName())) {
+ case INPUT_PARAMTERS:
+ inputs.addLast(parseParameter(reader));
+ break;
+ case RETURN_PARAMETER:
+ function.setOutputParameter(parseParameter(reader));
+ break;
+ }
+ }
+ function.setInputParameters(inputs);
+ return function;
+ }
+
+ private static FunctionParameter parseParameter(XMLStreamReader reader) throws
XMLStreamException {
+ FunctionParameter fp = new FunctionParameter();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (Element.NAME.getLocalName().equals(attrName)) {
+ fp.setName(attrValue);
+ }
+ else if (Element.DESCRIPTION.getLocalName().equals(attrName)) {
+ fp.setDescription(attrValue);
+ }
+ else if (Element.TYPE.getLocalName().equals(attrName)) {
+ fp.setType(attrValue);
+ }
+ }
+ }
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ return fp;
+ }
+
+ enum Element {
+ // must be first
+ UNKNOWN(null),
+ XMI("XMI"),//$NON-NLS-1$
+ SCALAR_FUNCTION("ScalarFunction"),//$NON-NLS-1$
+ NAME("name"), //$NON-NLS-1$
+ INPUT_PARAMTERS("inputParameters"),//$NON-NLS-1$
+ DESCRIPTION("description"),//$NON-NLS-1$
+ CATEGORY("category"),//$NON-NLS-1$
+ PUSHDOWN("pushDown"),//$NON-NLS-1$
+ INVOCATION_CLASS("invocationClass"),//$NON-NLS-1$
+ INVOCATION_METHOD("invocationMethod"),//$NON-NLS-1$
+ RETURN_PARAMETER("returnParameter"),//$NON-NLS-1$
+ DETERMINISTIC("deterministic"),//$NON-NLS-1$
+ TYPE("type");//$NON-NLS-1$
+
+ private final String name;
+
+ Element(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Element> elements;
+
+ static {
+ final Map<String, Element> map = new HashMap<String, Element>();
+ for (Element element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ elements = map;
+ }
+
+ public static Element forName(String localName) {
+ final Element element = elements.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+ }
+
+ enum Namespace {
+ // must be first
+ UNKNOWN(null),
+
XMI("http://www.omg.org/XMI"), //$NON-NLS-1$
+
FUNCTION("http://www.metamatrix.com/metamodels/MetaMatrixFunction&qu...;
//$NON-NLS-1$
+
+ private final String uri;
+
+ Namespace(String uri) {
+ this.uri = uri;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ private static final Map<String, Namespace> namespaces;
+
+ static {
+ final Map<String, Namespace> map = new HashMap<String,
Namespace>();
+ for (Namespace namespace : values()) {
+ final String name = namespace.getUri();
+ if (name != null) map.put(name, namespace);
+ }
+ namespaces = map;
+ }
+
+ public static Namespace forUri(String uri) {
+ final Namespace element = namespaces.get(uri);
+ return element == null ? UNKNOWN : element;
+ }
+ }
}
Modified:
branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -1101,7 +1101,7 @@
* @return Class reference
* @throws ClassNotFoundException If class could not be found
*/
- public Class<?> getInvocationClass(String className) throws
ClassNotFoundException {
- return Class.forName(className);
+ public Class<?> getInvocationClass(String className, ClassLoader classloader)
throws ClassNotFoundException {
+ return Class.forName(className, true, classloader);
}
}
Modified:
branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
---
branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -60,8 +60,8 @@
return methods;
}
- public Class getInvocationClass(String className) throws ClassNotFoundException {
- return Class.forName(className);
+ public Class getInvocationClass(String className, ClassLoader cl) throws
ClassNotFoundException {
+ return Class.forName(className, true, cl);
}
// dummy function
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -48,10 +48,10 @@
MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT(MAX_ODBC_LOB_SIZE_ALLOWED),
EVENT_DISTRIBUTOR_NAME_ELEMENT(EVENT_DISTRIBUTOR_NAME),
DETECTING_CHANGE_EVENTS_ELEMENT(DETECTING_CHANGE_EVENTS),
- JDBC_SECURITY_DOMAIN_ELEMENT(SECURITY_DOMAIN),
MAX_SESSIONS_ALLOWED_ELEMENT(MAX_SESSIONS_ALLOWED),
SESSION_EXPIRATION_TIME_LIMIT_ELEMENT(SESSION_EXPIRATION_TIME_LIMIT),
ALLOW_ENV_FUNCTION_ELEMENT(ALLOW_ENV_FUNCTION),
+ SECURITY_DOMAIN_ELEMENT(SECURITY_DOMAIN),
//children
BUFFER_SERVICE_ELEMENT(BUFFER_SERVICE),
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -67,6 +67,7 @@
if (!attachmentsStore.exists() || force) {
ObjectOutputStream oos = null;
try {
+ attachmentsStore.getParentFile().mkdirs();
oos = new ObjectOutputStream(new FileOutputStream(attachmentsStore));
oos.writeObject(attachment);
return true;
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -138,14 +138,10 @@
// add security domains
if ( operation.hasDefined(Configuration.SECURITY_DOMAIN)) {
- String domainNameOrder =
operation.get(Configuration.SECURITY_DOMAIN).asString();
- if (domainNameOrder != null && domainNameOrder.trim().length()>0) {
+ List<ModelNode> domains =
operation.get(Configuration.SECURITY_DOMAIN).asList();
+ for (ModelNode domain:domains) {
LogManager.logInfo(LogConstants.CTX_SECURITY, "Security Enabled:
true"); //$NON-NLS-1$
- String[] domainNames = domainNameOrder.split(","); //$NON-NLS-1$
- for (String domainName : domainNames) {
- engine.addSecurityDomain(domainName);
- serviceBuilder.addDependency(ServiceName.JBOSS.append("security",
"security-domain", domainName), SecurityDomainContext.class, new
ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains,
domainName)); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ serviceBuilder.addDependency(ServiceName.JBOSS.append("security",
"security-domain", domain.asString()), SecurityDomainContext.class, new
ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains,
domain.asString())); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -201,8 +197,13 @@
}
if (node.hasDefined(Configuration.MAX_SESSIONS_ALLOWED)) {
engine.setSessionMaxLimit(node.get(Configuration.MAX_SESSIONS_ALLOWED).asInt());
- }
-
+ }
+ if (node.hasDefined(Configuration.SECURITY_DOMAIN)) {
+ List<ModelNode> securityDomains =
node.get(Configuration.SECURITY_DOMAIN).asList();
+ for (ModelNode domain:securityDomains) {
+ engine.addSecurityDomain(domain.asString());
+ }
+ }
return engine;
}
@@ -286,7 +287,7 @@
addAttribute(node, Configuration.DETECTING_CHANGE_EVENTS, type,
bundle.getString(Configuration.DETECTING_CHANGE_EVENTS+DESC), ModelType.BOOLEAN, false,
"true"); //$NON-NLS-1$
//session stuff
- addAttribute(node, Configuration.SECURITY_DOMAIN, type,
bundle.getString(Configuration.SECURITY_DOMAIN+DESC), ModelType.STRING, false, null);
+ addAttribute(node, Configuration.SECURITY_DOMAIN, type,
bundle.getString(Configuration.SECURITY_DOMAIN+DESC), ModelType.LIST, false, null);
addAttribute(node, Configuration.MAX_SESSIONS_ALLOWED, type,
bundle.getString(Configuration.MAX_SESSIONS_ALLOWED+DESC),
ModelType.INT, false,
"5000"); //$NON-NLS-1$
addAttribute(node, Configuration.SESSION_EXPIRATION_TIME_LIMIT, type,
bundle.getString(Configuration.SESSION_EXPIRATION_TIME_LIMIT+DESC),
ModelType.INT, false,
"0"); //$NON-NLS-1$
@@ -370,6 +371,12 @@
if (operation.hasDefined(Configuration.EVENT_DISTRIBUTOR_NAME)) {
model.get(Configuration.EVENT_DISTRIBUTOR_NAME).set(operation.get(Configuration.EVENT_DISTRIBUTOR_NAME).asString());
}
+ if (operation.hasDefined(Configuration.SECURITY_DOMAIN)) {
+ List<ModelNode> domains =
operation.get(Configuration.SECURITY_DOMAIN).asList();
+ for (ModelNode domain: domains) {
+ model.get(Configuration.SECURITY_DOMAIN).add(domain.asString());
+ }
+ }
if (operation.hasDefined(Configuration.DETECTING_CHANGE_EVENTS)) {
model.get(Configuration.DETECTING_CHANGE_EVENTS).set(operation.get(Configuration.DETECTING_CHANGE_EVENTS).asBoolean());
}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -138,13 +138,19 @@
newControllers.add(service);
// system function tree
- SystemFunctionManager systemFunctionManager = new SystemFunctionManager();
- if (operation.hasDefined(Configuration.ALLOW_ENV_FUNCTION)) {
-
systemFunctionManager.setAllowEnvFunction(operation.get(Configuration.ALLOW_ENV_FUNCTION).asBoolean());
- }
- else {
- systemFunctionManager.setAllowEnvFunction(false);
- }
+ SystemFunctionManager systemFunctionManager = null;
+ try {
+ systemFunctionManager = new SystemFunctionManager();
+ if (operation.hasDefined(Configuration.ALLOW_ENV_FUNCTION)) {
+ systemFunctionManager.setAllowEnvFunction(operation.get(Configuration.ALLOW_ENV_FUNCTION).asBoolean());
+ }
+ else {
+ systemFunctionManager.setAllowEnvFunction(false);
+ }
+ systemFunctionManager.setClassloader(Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getClassLoader());
//$NON-NLS-1$
+ } catch (ModuleLoadException e) {
+ throw new OperationFailedException(e, operation);
+ }
// VDB repository
final VDBRepository vdbRepository = new VDBRepository();
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -47,7 +47,7 @@
}
public static ServiceName vdbServiceName(String vdbName, int version) {
- return VDB_SVC_BASE.append(vdbName, ".", String.valueOf(version));
//$NON-NLS-1$
+ return VDB_SVC_BASE.append(vdbName, String.valueOf(version));
}
public static ServiceName executorServiceName(String poolName) {
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -123,9 +123,15 @@
writeElement(writer, Element.MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT, node);
writeElement(writer, Element.EVENT_DISTRIBUTOR_NAME_ELEMENT, node);
writeElement(writer, Element.DETECTING_CHANGE_EVENTS_ELEMENT, node);
- writeElement(writer, Element.JDBC_SECURITY_DOMAIN_ELEMENT, node);
+
+ if (node.hasDefined(Element.SECURITY_DOMAIN_ELEMENT.getLocalName())) {
+ List<ModelNode> domains =
node.get(Element.SECURITY_DOMAIN_ELEMENT.getLocalName()).asList();
+ writeElement(writer, Element.SECURITY_DOMAIN_ELEMENT, domains);
+ }
+
writeElement(writer, Element.MAX_SESSIONS_ALLOWED_ELEMENT, node);
writeElement(writer, Element.SESSION_EXPIRATION_TIME_LIMIT_ELEMENT, node);
+
//jdbc
if (has(node, Element.JDBC_ELEMENT.getLocalName())){
@@ -201,8 +207,16 @@
writer.writeCharacters(node.get(element.getLocalName()).asString());
writer.writeEndElement();
}
- }
+ }
+ private void writeElement(final XMLExtendedStreamWriter writer, final Element
element, final List<ModelNode> nodes) throws XMLStreamException {
+ for (ModelNode node:nodes) {
+ writer.writeStartElement(element.getLocalName());
+ writer.writeCharacters(node.asString());
+ writer.writeEndElement();
+ }
+ }
+
private void writeAttribute(final XMLExtendedStreamWriter writer, final Element
element, final ModelNode node) throws XMLStreamException {
if (has(node, element.getLocalName())) {
writer.writeAttribute(element.getLocalName(),
node.get(element.getLocalName()).asString());
@@ -327,9 +341,14 @@
//Strings
case EVENT_DISTRIBUTOR_NAME_ELEMENT:
- case JDBC_SECURITY_DOMAIN_ELEMENT:
node.get(reader.getLocalName()).set(reader.getElementText());
break;
+
+ //List
+ case SECURITY_DOMAIN_ELEMENT:
+ node.get(reader.getLocalName()).add(reader.getElementText());
+ break;
+
case JDBC_ELEMENT:
node.get(reader.getLocalName()).set(parseSocketConfiguration(reader));
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -82,13 +82,9 @@
try {
final ModuleSpecification moduleSpecification =
deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader =
Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getModuleLoader();
//$NON-NLS-1$
- VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
-
- for (ModelMetaData model: vdb.getModelMetaDatas().values()) {
- for (String source:model.getSourceNames()) {
- moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader,
ModuleIdentifier.create(model.getSourceTranslatorName(source)), false, false, false));
- }
- }
+ moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader,
ModuleIdentifier.create("org.jboss.teiid.api"), false, false, false));
//$NON-NLS-1$
+ moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader,
ModuleIdentifier.create("org.jboss.teiid.common-core"), false, false, false));
//$NON-NLS-1$
+ moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader,
ModuleIdentifier.create("javax.api"), false, false, false)); //$NON-NLS-1$
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -22,6 +22,7 @@
package org.teiid.jboss;
import java.util.List;
+import java.util.concurrent.Executor;
import org.jboss.as.server.deployment.*;
import org.jboss.msc.service.ServiceBuilder;
@@ -110,11 +111,19 @@
vdbService.addDependency(ServiceName.JBOSS.append("data-source",
model.getSourceConnectionJndiName(sourceName))); //$NON-NLS-1$
}
}
+
+ // adding the translator services is redundant, however if one is removed then it is an
issue.
+ for (Translator t: deployment.getOverrideTranslators()) {
+ VDBTranslatorMetaData data = (VDBTranslatorMetaData)t;
+ String type = data.getType();
+ vdbService.addDependency(TeiidServiceNames.translatorServiceName(type));
+ }
+
vdbService.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class,
vdb.getVDBRepositoryInjector());
vdbService.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class,
vdb.getTranslatorRepositoryInjector());
- vdbService.addDependency(TeiidServiceNames.executorServiceName(this.asyncThreadPoolName),
TranslatorRepository.class, vdb.getTranslatorRepositoryInjector());
+ vdbService.addDependency(TeiidServiceNames.executorServiceName(this.asyncThreadPoolName),
Executor.class, vdb.getExecutorInjector());
vdbService.addDependency(TeiidServiceNames.OBJECT_SERIALIZER, ObjectSerializer.class,
vdb.getSerializerInjector());
- vdbService.setInitialMode(Mode.ACTIVE).install();
+ vdbService.setInitialMode(Mode.PASSIVE).install();
}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -24,18 +24,14 @@
import java.io.IOException;
import java.util.List;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
+import javax.xml.stream.XMLStreamException;
import org.jboss.as.server.deployment.*;
import org.jboss.vfs.VirtualFile;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.VDBMetadataParser;
import org.teiid.deployers.TeiidAttachments;
import org.teiid.deployers.UDFMetaData;
import org.teiid.logging.LogConstants;
@@ -43,7 +39,6 @@
import org.teiid.metadata.VdbConstants;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.runtime.RuntimePlugin;
-import org.xml.sax.SAXException;
/**
@@ -84,10 +79,10 @@
}
}
else {
- if (file.getLowerCaseName().equals(VdbConstants.DEPLOYMENT_FILE)) {
+ if (file.getName().toLowerCase().equals(VdbConstants.DEPLOYMENT_FILE)) {
parseVDBXML(file, deploymentUnit);
}
- else if (file.getLowerCaseName().endsWith(VdbConstants.INDEX_EXT)) {
+ else if (file.getName().endsWith(VdbConstants.INDEX_EXT)) {
IndexMetadataFactory imf =
deploymentUnit.getAttachment(TeiidAttachments.INDEX_METADATA);
if (imf == null) {
imf = new IndexMetadataFactory();
@@ -95,7 +90,7 @@
}
imf.addIndexFile(file);
}
- else if (file.getLowerCaseName().endsWith(VdbConstants.MODEL_EXT)) {
+ else if (file.getName().toLowerCase().endsWith(VdbConstants.MODEL_EXT)) {
UDFMetaData udf = deploymentUnit.getAttachment(TeiidAttachments.UDF_METADATA);
if (udf == null) {
udf = new UDFMetaData();
@@ -103,21 +98,16 @@
}
udf.addModelFile(file);
}
-
}
}
- private void parseVDBXML(VirtualFile file, DeploymentUnit deploymentUnit)
- throws DeploymentUnitProcessingException {
+ private void parseVDBXML(VirtualFile file, DeploymentUnit deploymentUnit) throws
DeploymentUnitProcessingException {
try {
- Unmarshaller un = getUnMarsheller();
- VDBMetaData vdb = (VDBMetaData)un.unmarshal(file.openStream());
+ VDBMetaData vdb = VDBMetadataParser.unmarshell(file.openStream());
deploymentUnit.putAttachment(TeiidAttachments.VDB_METADATA, vdb);
LogManager.logDetail(LogConstants.CTX_RUNTIME,"VDB "+file.getName()+"
has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new DeploymentUnitProcessingException(e);
- } catch (SAXException e) {
- throw new DeploymentUnitProcessingException(e);
} catch (IOException e) {
throw new DeploymentUnitProcessingException(e);
}
@@ -126,16 +116,6 @@
public void undeploy(final DeploymentUnit context) {
}
-
- static Unmarshaller getUnMarsheller() throws JAXBException, SAXException {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
- SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema =
schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd"));
//$NON-NLS-1$
- Unmarshaller un = jc.createUnmarshaller();
- un.setSchema(schema);
- return un;
- }
-
protected VDBMetaData mergeMetaData(DeploymentUnit deploymentUnit) throws
DeploymentUnitProcessingException {
VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
UDFMetaData udf = deploymentUnit.getAttachment(TeiidAttachments.UDF_METADATA);
@@ -172,7 +152,7 @@
}
} catch(IOException e) {
throw new DeploymentUnitProcessingException(e);
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new DeploymentUnitProcessingException(e);
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -72,7 +72,10 @@
// check if this is a VDB with index files, if there are then build the
TransformationMetadata
UDFMetaData udf = this.vdb.getAttachment(UDFMetaData.class);
IndexMetadataFactory indexFactory =
this.vdb.getAttachment(IndexMetadataFactory.class);
- long vdbModifiedTime =
Long.parseLong(vdb.getPropertyValue(VDBService.VDB_LASTMODIFIED_TIME));
+ long vdbModifiedTime = -1L;
+ if (vdb.getPropertyValue(VDBService.VDB_LASTMODIFIED_TIME) != null) {
+ vdbModifiedTime =
Long.parseLong(vdb.getPropertyValue(VDBService.VDB_LASTMODIFIED_TIME));
+ }
// add required connector managers; if they are not already there
for (Translator t: this.vdb.getOverrideTranslators()) {
@@ -93,7 +96,7 @@
createConnectorManagers(cmr, repo, this.vdb);
// check to see if the vdb has been modified when server is down; if it is then clear
the old files
- if (getSerializer().isStale(this.vdb, vdbModifiedTime)) {
+ if (vdbModifiedTime != -1L && getSerializer().isStale(this.vdb,
vdbModifiedTime)) {
getSerializer().removeAttachments(this.vdb);
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB ", vdb.getName(), "
old cached metadata has been removed"); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -21,15 +21,7 @@
*/
package org.teiid.jboss;
-import java.io.Closeable;
-import java.io.IOException;
-
import org.jboss.as.server.deployment.*;
-import org.jboss.as.server.deployment.module.ModuleRootMarker;
-import org.jboss.as.server.deployment.module.MountHandle;
-import org.jboss.as.server.deployment.module.ResourceRoot;
-import org.jboss.as.server.deployment.module.TempFileProviderService;
-import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
import org.teiid.deployers.TeiidAttachments;
import org.teiid.metadata.VdbConstants;
@@ -50,28 +42,19 @@
return;
}
- if(file.getLowerCaseName().endsWith(VDB_EXTENSION)) {
-
- try {
- final Closeable closable = VFS.mountZip(file, file,
TempFileProviderService.provider());
- final ResourceRoot vdbArchiveRoot = new ResourceRoot(file.getName(), file, new
MountHandle(closable));
- ModuleRootMarker.mark(vdbArchiveRoot);
-
- VirtualFile metainf = file.getChild("META-INF"); //$NON-NLS-1$
- if (metainf == null) {
- return;
- }
-
- if (metainf.getChild(VdbConstants.DEPLOYMENT_FILE) == null) {
- return;
- }
- // adds a TYPE attachment.
- TeiidAttachments.setAsVDBDeployment(deploymentUnit);
- } catch (IOException e) {
- throw new DeploymentUnitProcessingException("failed to process " + file,
e); //$NON-NLS-1$
- }
+ if(file.getName().toLowerCase().endsWith(VDB_EXTENSION)) {
+ VirtualFile metainf = file.getChild("META-INF"); //$NON-NLS-1$
+ if (metainf == null) {
+ return;
+ }
+
+ if (metainf.getChild(VdbConstants.DEPLOYMENT_FILE) == null) {
+ return;
+ }
+ // adds a TYPE attachment.
+ TeiidAttachments.setAsVDBDeployment(deploymentUnit);
}
- else if (file.getLowerCaseName().endsWith(DYNAMIC_VDB_STRUCTURE)) {
+ else if (file.getName().toLowerCase().endsWith(DYNAMIC_VDB_STRUCTURE)) {
TeiidAttachments.setAsDynamicVDBDeployment(deploymentUnit);
}
}
@@ -79,7 +62,6 @@
@Override
public void undeploy(final DeploymentUnit context) {
-
}
}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -167,6 +167,7 @@
this.sessionService.setSessionMaxLimit(this.sessionMaxLimit);
this.sessionService.setDqp(this.dqpCore);
this.sessionService.setVDBRepository(this.vdbRepository);
+ this.sessionService.setSecurityHelper(getSecurityHelper());
this.sessionService.start();
this.setBufferService(bufferServiceInjector.getValue());
Modified:
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
---
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-08-30
02:16:42 UTC (rev 3433)
@@ -32,6 +32,7 @@
policy_not_found=Policy name "{0}" not found in the VDB with name
"{1}" version "{2}"
datasource_not_found=Datasource {0} not found in the configuration.
sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
+vdb_file_not_found = VDB file {0} not found at the location specified.
no_operation=No operation found with given name = {0}
failed_to_remove=Failed to remove the deployment
Modified: branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd
===================================================================
--- branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd 2011-08-30
02:16:42 UTC (rev 3433)
@@ -250,7 +250,7 @@
<xs:documentation>Set to true for the engine to detect local
change events. Should be disabled if using external change data capture tools. (default
true)</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="security-domain" type="xs:string"
minOccurs="0" maxOccurs="1">
+ <xs:element name="security-domain" type="xs:string"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Comma separated list of domains to be used to
login into Teiid</xs:documentation>
</xs:annotation>
Modified: branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-08-30
02:16:42 UTC (rev 3433)
@@ -91,7 +91,7 @@
"default" => true
},
"security-domain" => {
- "type" => STRING,
+ "type" => LIST,
"description" => "Comma separated list of domains to be
used to login into Teiid",
"required" => false,
"max-occurs" => 1
Modified: branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-08-30
02:16:42 UTC (rev 3433)
@@ -49,6 +49,7 @@
<event-distributor-name>teiid/event-distributor</event-distributor-name>
<detect-change-events>true</detect-change-events>
<security-domain>teiid-security</security-domain>
+ <security-domain>teiid-security2</security-domain>
<max-sessions-allowed>5000</max-sessions-allowed>
<sessions-expiration-timelimit>0</sessions-expiration-timelimit>
Modified:
branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
---
branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -32,6 +32,7 @@
import java.util.concurrent.Executors;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import org.jboss.vfs.TempFileProvider;
import org.jboss.vfs.VFS;
@@ -98,7 +99,7 @@
return vdbmetadata;
} catch (URISyntaxException e) {
throw new IOException(e);
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new IOException(e);
}
}
Modified:
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -29,6 +29,9 @@
import java.util.Random;
import java.util.UUID;
+import org.jboss.modules.Module;
+import org.jboss.modules.ModuleIdentifier;
+import org.jboss.modules.ModuleLoadException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
@@ -550,16 +553,21 @@
private FunctionMethod addHasFunctionPrivilage() throws TranslatorException {
FunctionMethod func = addFunction("has_function_privilege"); //$NON-NLS-1$
- ArrayList<FunctionParameter> inParams = new
ArrayList<FunctionParameter>();
- inParams.add(new FunctionParameter("oid",
DataTypeManager.DefaultDataTypes.INTEGER, ""));//$NON-NLS-1$ //$NON-NLS-2$
- inParams.add(new FunctionParameter("permission",
DataTypeManager.DefaultDataTypes.STRING, "")); //$NON-NLS-1$ //$NON-NLS-2$
-
- func.setInputParameters(inParams);
- func.setOutputParameter(new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "")); //$NON-NLS-1$ //$NON-NLS-2$
-
- func.setInvocationClass(ReturnTrue.class.getName());
- func.setInvocationMethod("result"); //$NON-NLS-1$
- func.setPushdown(PushDown.CANNOT_PUSHDOWN);
+ try {
+ ArrayList<FunctionParameter> inParams = new
ArrayList<FunctionParameter>();
+ inParams.add(new FunctionParameter("oid",
DataTypeManager.DefaultDataTypes.INTEGER, ""));//$NON-NLS-1$ //$NON-NLS-2$
+ inParams.add(new FunctionParameter("permission",
DataTypeManager.DefaultDataTypes.STRING, "")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ func.setInputParameters(inParams);
+ func.setOutputParameter(new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.BOOLEAN, "")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ func.setInvocationClass(ReturnTrue.class.getName());
+ func.setInvocationMethod("result"); //$NON-NLS-1$
+ func.setPushdown(PushDown.CANNOT_PUSHDOWN);
+ func.setClassloader(Module.getModuleFromCallerModuleLoader(ModuleIdentifier.create("org.jboss.teiid")).getClassLoader());
//$NON-NLS-1$
+ } catch (ModuleLoadException e) {
+ throw new TranslatorException(e);
+ }
return func;
}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -25,6 +25,7 @@
import java.util.*;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import org.jboss.vfs.VirtualFile;
import org.teiid.metadata.FunctionMethod;
@@ -45,7 +46,7 @@
}
- public void buildFunctionModelFile(String name, String path) throws IOException,
JAXBException {
+ public void buildFunctionModelFile(String name, String path) throws IOException,
XMLStreamException {
for (String f:files.keySet()) {
if (f.endsWith(path)) {
path = f;
Modified: branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-08-29
19:07:09 UTC (rev 3432)
+++
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -96,11 +96,11 @@
if (authManager != null) {
Principal userPrincipal = new SimplePrincipal(username);
Subject subject = new Subject();
- boolean isValid = authManager.isValid(userPrincipal, credential,
subject);
+ boolean isValid = authManager.isValid(userPrincipal, new
String(credential.getCredentialsAsCharArray()), subject);
if (isValid) {
this.userName = baseUsername+AT+domain;
this.securitydomain = domain;
- this.securityContext =
this.securityHelper.createSecurityContext(this.securitydomain, userPrincipal, credential,
subject);
+ this.securityContext =
this.securityHelper.createSecurityContext(this.securitydomain, userPrincipal, new
String(credential.getCredentialsAsCharArray()), subject);
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", username, "\""}); //$NON-NLS-1$
//$NON-NLS-2$
return;
}
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2011-08-29
19:07:09 UTC (rev 3432)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2011-08-30
02:16:42 UTC (rev 3433)
@@ -32,6 +32,7 @@
import javax.crypto.SealedObject;
+import org.jboss.modules.Module;
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.client.util.ExceptionHolder;
import org.teiid.client.util.ResultsFuture;
@@ -67,7 +68,9 @@
Message result = null;
String loggingContext = null;
final boolean encrypt = message.getContents() instanceof SealedObject;
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
+
Thread.currentThread().setContextClassLoader(Module.getCallerModule().getClassLoader());
message.setContents(this.socketClientInstance.getCryptor().unsealObject(message.getContents()));
if (!(message.getContents() instanceof ServiceInvocationStruct)) {
throw new AssertionError("unknown message contents"); //$NON-NLS-1$
@@ -109,6 +112,8 @@
Message holder = new Message();
holder.setContents(processException(t, loggingContext));
result = holder;
+ } finally {
+ Thread.currentThread().setContextClassLoader(classLoader);
}
if (result != null) {