teiid SVN: r2084 - in trunk: build/kits/jboss-container/deploy/teiid and 16 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-04-27 18:25:00 -0400 (Tue, 27 Apr 2010)
New Revision: 2084
Added:
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedPropertyInfo.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeploymentGroup.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryParserDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryMetadataGroup.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorDeploymentTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTemplateInfo.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
Removed:
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
Modified:
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/client/src/main/java/org/teiid/adminapi/Admin.java
trunk/client/src/main/java/org/teiid/adminapi/ConnectionFactory.java
trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectionFactoryMetaData.java
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCManagedConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/rar/META-INF/ra.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
Log:
TEIID-1067, TEIID-1068: Providing a single connection for JDBC based connector
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -49,7 +49,6 @@
import org.teiid.adminapi.Transaction;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.WorkerPoolStatistics;
-import org.teiid.adminapi.Admin.DataSourceType;
import org.teiid.adminshell.Help.Doc;
import com.metamatrix.common.util.ReaderInputStream;
@@ -171,12 +170,6 @@
getAdmin().deleteConnector(name);
}
- @Doc(text = "Delete a DataSource")
- public static void deleteDataSource(
- @Doc(text = "deployed name") String deploymentName) throws AdminException {
- getAdmin().deleteDataSource(deploymentName);
- }
-
@Doc(text = "Delete a VDB")
public static void deleteVDB(
@Doc(text = "vdb name") String vdbName,
@@ -209,29 +202,17 @@
return getAdmin().getConnectionFactory(deployedName);
}
- @Doc(text = "Get the ConnectionPoolStatistics for the given ConnectionFactory")
- public static ConnectionPoolStatistics getConnectionFactoryStats(
- @Doc(text = "deployed name") String deployedName) throws AdminException {
- return getAdmin().getConnectionFactoryStats(deployedName);
- }
-
@Doc(text = "Get all connector name Strings")
public static Set<String> getConnectorNames() throws AdminException {
- return getAdmin().getConnectorNames();
+ return getAdmin().getConnectorTemplateNames();
}
@Doc(text = "Get all PropertyDefinition instances for the given connector")
public static Collection<PropertyDefinition> getConnectorPropertyDefinitions(
@Doc(text = "connector name") String connectorName) throws AdminException {
- return getAdmin().getConnectorPropertyDefinitions(connectorName);
+ return getAdmin().getConnectorTemplatePropertyDefinitions(connectorName);
}
- @Doc(text = "Get all ProperyDefinition instances for a DataSource")
- public static Collection<PropertyDefinition> getDataSourcePropertyDefinitions()
- throws AdminException {
- return getAdmin().getDataSourcePropertyDefinitions();
- }
-
@Doc(text = "Get the ProcessObject instances for the given identifier")
public static Collection<ProcessObject> getProcesses(
@Doc(text = "identifier") String processIdentifier)
@@ -359,7 +340,7 @@
@Doc(text = "Checks if a Connector exists")
public static boolean hasConnector(
@Doc(text = "type name") String typeName) throws AdminException {
- Collection<String> types = getAdmin().getConnectorNames();
+ Collection<String> types = getAdmin().getConnectorTemplateNames();
for (String type:types) {
if (type.equals(typeName)) {
@@ -394,22 +375,6 @@
return false;
}
- @Doc(text = "Export a Connector RAR to file")
- public static void exportConnector(
- @Doc(text = "connector name") String name,
- @Doc(text = "file name") String fileName) throws AdminException, IOException {
- InputStream contents = getAdmin().exportConnector(name);
- writeFile(name, fileName, contents);
- }
-
- @Doc(text = "Export a ConnectionFactory to an XML file")
- public static void exportConnectionFactory(
- @Doc(text = "deployed name") String deployedName,
- @Doc(text = "file name") String fileName) throws AdminException, IOException{
- Reader contents = getAdmin().exportConnectionFactory(deployedName);
- writeFile(deployedName, fileName, contents);
- }
-
private static void writeFile(String deployedName, String fileName,
Reader contents) throws IOException, AdminProcessingException {
if (contents == null) {
@@ -464,22 +429,6 @@
}
}
- @Doc(text = "Add a DataSource")
- public static void addDataSource(
- @Doc(text = "deployed name") String deploymentName,
- DataSourceType type,
- Properties properties) throws AdminException {
- getAdmin().addDataSource(deploymentName, type, properties);
- }
-
- @Doc(text = "Export the DataSource XML to file")
- public static void exportDataSource(
- @Doc(text = "deployed name") String deployedName,
- @Doc(text = "file name") String fileName) throws AdminException, IOException {
- Reader contents = getAdmin().exportDataSource(deployedName);
- writeFile(deployedName, fileName, contents);
- }
-
@Doc(text = "Get the current Admin connection")
public static Admin getAdmin() {
if (internalAdmin == null) {
Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-04-27 22:25:00 UTC (rev 2084)
@@ -1,130 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- This file defines the connector templates for Teiid based connectors -->
- <bean name="export-template" class="org.jboss.resource.deployers.management.DsDataSourceTemplate">
- <property name="info"><inject bean="export-templateinfo"/></property>
- </bean>
- <bean name="export-templateinfo" class="org.teiid.templates.connector.ExportConnectorTypeTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ExportConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">export-template</parameter>
- <parameter class="java.lang.String">Teiid Export Template</parameter>
- </constructor>
- </bean>
- <bean name="connector-jdbc-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
- <property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-jdbc-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-jdbc-xa-${project.version}" class="org.teiid.templates.connector.XaJdbcConnectorTemplate">
+ <property name="info"><inject bean="connector-jdbc-xa-templateinfo"/></property>
+ </bean>
+
+ <bean name="connector-jdbc-xa-templateinfo" class="org.teiid.templates.connector.XaJdbcConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-jdbc-${project.version}.rar</parameter>
- <parameter class="java.lang.String">Teiid JDBC Connector</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.XaJdbcConnectorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-jdbc-xa-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid JDBC XA Connector</parameter>
</constructor>
+ <property name="rarName">connector-jdbc-${project.version}.rar</property>
</bean>
- <bean name="connector-ldap-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-ldap-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-ldap-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-ldap-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-ldap-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-ldap-${project.version}.rar</parameter>
+ <parameter class="java.lang.String">connector-ldap-${project.version}</parameter>
<parameter class="java.lang.String">Teiid LDAP Connector</parameter>
</constructor>
+ <property name="rarName">connector-ldap-${project.version}.rar</property>
</bean>
- <bean name="connector-loopback-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-loopback-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-loopback-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-loopback-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-loopback-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-loopback-${project.version}.rar</parameter>
- <parameter class="java.lang.String">Teiid Loopback Connector</parameter>
+ <parameter class="java.lang.String">connector-loopback-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid Loopback Connector</parameter>
</constructor>
+ <property name="rarName">connector-loopback-${project.version}.rar</property>
</bean>
- <bean name="connector-salesforce-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-salesforce-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-salesforce-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-salesforce-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-salesforce-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-salesforce-${project.version}.rar</parameter>
+ <parameter class="java.lang.String">connector-salesforce-${project.version}</parameter>
<parameter class="java.lang.String">Teiid Salesforce Connector</parameter>
</constructor>
+ <property name="rarName">connector-salesforce-${project.version}.rar</property>
</bean>
- <bean name="connector-text-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-text-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-text-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-text-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-text-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-text-${project.version}.rar</parameter>
+ <parameter class="java.lang.String">connector-text-${project.version}</parameter>
<parameter class="java.lang.String">Teiid Text Connector</parameter>
</constructor>
+ <property name="rarName">connector-text-${project.version}.rar</property>
</bean>
- <bean name="connector-xmlsource-file-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-xmlsource-file-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-xmlsource-file-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-xmlsource-file-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-xmlsource-file-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xmlsource-file-${project.version}.rar</parameter>
+ <parameter class="java.lang.String">connector-xmlsource-file-${project.version}</parameter>
<parameter class="java.lang.String">Teiid XML File Connector</parameter>
</constructor>
+ <property name="rarName">connector-xmlsource-file-${project.version}.rar</property>
</bean>
- <bean name="connector-xmlsource-soap-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-xmlsource-soap-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-xmlsource-soap-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-xmlsource-soap-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-xmlsource-soap-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xmlsource-soap-${project.version}.rar</parameter>
+ <parameter class="java.lang.String">connector-xmlsource-soap-${project.version}</parameter>
<parameter class="java.lang.String">Teiid XML SOAP Connector</parameter>
</constructor>
+ <property name="rarName">connector-xmlsource-soap-${project.version}.rar</property>
</bean>
- <bean name="connector-xml-http-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <bean name="connector-xml-http-${project.version}" class="org.teiid.templates.connector.ConnectorDeploymentTemplate">
<property name="info"><inject bean="connector-xml-http-templateinfo"/></property>
<property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
</bean>
- <bean name="connector-xml-http-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <bean name="connector-xml-http-templateinfo" class="org.teiid.templates.connector.ConnectorTemplateInfo">
<constructor factoryMethod="createTemplateInfo">
<factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xml-http-${project.version}.rar</parameter>
+ <parameter class="java.lang.String">connector-xml-http-${project.version}</parameter>
<parameter class="java.lang.String">Teiid XML HTTP Connector</parameter>
</constructor>
+ <property name="rarName">connector-xml-http-${project.version}.rar</property>
</bean>
</deployment>
Modified: trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-04-27 22:25:00 UTC (rev 2084)
@@ -55,11 +55,23 @@
</bean>
<bean name="ConnectionFactoryDeployer" class="org.teiid.jboss.deployers.ConnectionFactoryDeployer">
- <property name="securityHelper"><inject bean="SecurityHelper"/></property>
<property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
+ <property name="VDBStatusChecker"><inject bean="VDBStatusChecker"/></property>
<property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
+ </bean>
+
+ <bean name="AutoConnectionFactoryDeployer" class="org.teiid.jboss.deployers.AutoConnectionFactoryDeployer">
+ <property name="connectorManagerRepository"><inject bean="ConnectorManagerRepository"/></property>
+ <property name="VDBStatusChecker"><inject bean="VDBStatusChecker"/></property>
+ <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
+ </bean>
+
+ <bean name="VDBStatusChecker" class="org.teiid.deployers.VDBStatusChecker">
<property name="VDBRepository"><inject bean="VDBRepository"/></property>
</bean>
+
+ <bean name="AutoConnectionFactoryParserDeployer" class="org.teiid.jboss.deployers.AutoConnectionFactoryParserDeployer">
+ </bean>
<!-- Persistence class for the VDB deployment file -->
<bean name="VDBMetadataComponentMapper" class="org.teiid.jboss.deployers.VDBMetadataComponentMapper">
Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -23,14 +23,12 @@
package org.teiid.adminapi;
import java.io.InputStream;
-import java.io.Reader;
import java.util.Collection;
import java.util.Properties;
import java.util.Set;
public interface Admin {
- public enum DataSourceType {XA, LOCAL};
public enum Cache {CODE_TABLE_CACHE,PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE};
/**
@@ -72,15 +70,6 @@
void deleteConnector(String name) throws AdminException;
/**
- * Export Connector RAR file
- *
- * @param name of the Connector
- * @return InputStream of contents of the rar file
- * @throws AdminException
- */
- InputStream exportConnector(String name) throws AdminException;
-
- /**
* Deploy a {@link ConnectionFactory} to Configuration
*
* @param deployedName Connection Factory name that will be added to Configuration
@@ -100,16 +89,6 @@
void deleteConnectionFactory(String deployedName) throws AdminException;
/**
- * Export a {@link ConnectionFactory} to character Array in XML format
- *
- * @param deployedName the unique identifier for a {@link ConnectionFactory}.
- * @return Reader in XML format
- * @throws AdminException
- *
- */
- Reader exportConnectionFactory(String deployedName) throws AdminException;
-
- /**
* Deploy a {@link VDB} file.
* @param name Name of the VDB file to save under
* @param VDB VDB.
@@ -146,12 +125,12 @@
void setRuntimeProperty(String propertyName, String propertyValue) throws AdminException;
/**
- * Get the Connectors available in the configuration.
+ * Get the Connector Template available in the configuration.
*
- * @return Set of connector names.
+ * @return Set of connector template names.
* @throws AdminException
*/
- Set<String> getConnectorNames() throws AdminException;
+ Set<String> getConnectorTemplateNames() throws AdminException;
/**
* Get the VDBs that currently deployed in the system
@@ -205,17 +184,7 @@
*/
WorkerPoolStatistics getWorkManagerStats(String identifier) throws AdminException;
-
- /**
- * Get the Connection Pool Stats that correspond to the specified identifier pattern.
- * If the {@link ConnectionPoolStatistics ConnectionPool} represents an XA connection, there
- * will be 2 {@link ConnectionPoolStatistics ConnectionPool}s.
- *
- * @param deployedName - an identifier that corresponds to the connection factory Name
- * @return {@link ConnectionPoolStatistics}
- * @throws AdminException
- */
- ConnectionPoolStatistics getConnectionFactoryStats(String deployedName) throws AdminException;
+
/**
@@ -249,11 +218,11 @@
/**
* Get all of the available configuration Properties for the specified connector
- * @param connectorName - Name of the connector
+ * @param templateName - Name of the connector
* @return
* @throws AdminException
*/
- Collection<PropertyDefinition> getConnectorPropertyDefinitions(String connectorName) throws AdminException;
+ Collection<PropertyDefinition> getConnectorTemplatePropertyDefinitions(String templateName) throws AdminException;
/**
@@ -327,37 +296,6 @@
void terminateTransaction(String transactionId) throws AdminException;
/**
- * Adds JDBC XA Data Source in the container.
- * @param deploymentName - name of the source
- * @param type - type of data source
- * @param properties - properties
- * @throws AdminException
- */
- void addDataSource(String deploymentName, DataSourceType type, Properties properties) throws AdminException;
-
- /**
- * Delete data source.
- * @param deployedName
- * @throws AdminException
- */
- void deleteDataSource(String deployedName) throws AdminException;
-
- /**
- * Export the data source in "-ds.xml" file format.
- * @param deployedName
- * @return
- * @throws AdminException
- */
- Reader exportDataSource(String deployedName) throws AdminException;
-
- /**
- * Get the property definitions for creating the JDBC data source.
- * @return
- * @throws AdminException
- */
- Collection<PropertyDefinition> getDataSourcePropertyDefinitions() throws AdminException;
-
- /**
* Closes the admin connection
*/
void close();
Modified: trunk/client/src/main/java/org/teiid/adminapi/ConnectionFactory.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/ConnectionFactory.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/client/src/main/java/org/teiid/adminapi/ConnectionFactory.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -39,4 +39,10 @@
* @return
*/
String getJNDIName();
+
+ /**
+ * Get the template name for the Connection Factory
+ * @return
+ */
+ String getTemplateName();
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectionFactoryMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectionFactoryMetaData.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectionFactoryMetaData.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -21,20 +21,25 @@
*/
package org.teiid.adminapi.impl;
+import java.util.List;
+
import org.jboss.managed.api.annotation.ManagementComponent;
import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.ConnectionFactory;
-@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="connector"))
+@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="connection-factory"))
public class ConnectionFactoryMetaData extends AdminObjectImpl implements ConnectionFactory {
+ private static final String TEMPLATE_NAME = "template-name"; //$NON-NLS-1$
private static final long serialVersionUID = -4865836616882247016L;
private transient Object type;
private String rarFileName;
private String jndiName;
@ManagementProperty(description="Connector Binding Name")
+ @ManagementObjectID(type="cf-name")
public String getName() {
return super.getName();
}
@@ -67,6 +72,22 @@
return this.type;
}
+ @Override
+ @ManagementProperty(description="Template name for this connector")
+ public String getTemplateName() {
+ return getPropertyValue(TEMPLATE_NAME);
+ }
+
+ public void setTemplateName(String templateName) {
+ addProperty(TEMPLATE_NAME, templateName);
+ }
+
+ @Override
+ @ManagementProperty(description = "Connection Factory Properties", managed=true)
+ public List<PropertyMetadata> getJAXBProperties(){
+ return super.getJAXBProperties();
+ }
+
public String toString() {
return getName();
}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -970,6 +970,37 @@
}
}
}
+
+ public static void setBeanProperty(Object bean, String name, Object value) {
+ if (value == null) {
+ return;
+ }
+ name = name.toLowerCase();
+ final Method[] methods = bean.getClass().getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ final Method method = methods[i];
+ final String methodName = method.getName();
+ // If setter ...
+ if ( methodName.startsWith("set") && method.getParameterTypes().length == 1 ) { //$NON-NLS-1$
+ // Get the property name
+ final String propertyName = methodName.substring(3); // remove the "set"
+ String shortName = propertyName.toLowerCase();
+ if (!shortName.equals(name)) {
+ continue;
+ }
+ final Class<?> argType = method.getParameterTypes()[0];
+ try {
+ Object[] params = new Object[] {value};
+ if (!argType.isAssignableFrom(value.getClass())) {
+ params = new Object[] {StringUtil.valueOf(value.toString(), argType)};
+ }
+ method.invoke(bean, params);
+ } catch (Throwable e) {
+ throw new InvalidPropertyException(propertyName, value.toString(), argType, e);
+ }
+ }
+ }
+ }
private static Properties lowerCaseAllPropNames(final Properties connectionProps) {
final Properties lcProps = new Properties();
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/Connection.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -56,13 +56,13 @@
* Release the connection. This will be called when system has completed
* using the connection for an execution.
*/
- void close();
+ void close() throws ConnectorException;
/**
* Called to determine whether the connection is open
* @return true if open, false if there is a source error.
*/
- boolean isAlive();
+ boolean isAlive() throws ConnectorException;
/**
* Get the local transaction for the connector.
Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnection.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -24,6 +24,8 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
@@ -35,16 +37,22 @@
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
+import org.teiid.connector.api.Connection;
import org.teiid.connector.api.ConnectionContext;
+import org.teiid.connector.api.Connector;
import org.teiid.connector.api.ConnectorException;
public class BasicManagedConnection implements ManagedConnection {
protected PrintWriter log;
protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
- protected WrappedConnection conn;
private BasicManagedConnectionFactory mcf;
+ private Connection physicalConnection;
+ private final Set<WrappedConnection> handles = new HashSet<WrappedConnection>();
+ private Connector cf;
- public BasicManagedConnection(BasicManagedConnectionFactory mcf) {
+ public BasicManagedConnection(Connector connectionFactory, BasicManagedConnectionFactory mcf) throws ResourceException {
+ this.cf = connectionFactory;
+ this.physicalConnection = this.cf.getConnection();
this.mcf = mcf;
}
@@ -53,15 +61,19 @@
if (!(handle instanceof WrappedConnection)) {
throw new ConnectorException("Wrong connection supplied to assosiate");
}
- this.conn = (WrappedConnection)handle;
- this.conn.setManagedConnection(this);
+ ((WrappedConnection)handle).setManagedConnection(this);
+ synchronized (this.handles) {
+ this.handles.add((WrappedConnection)handle);
+ }
}
@Override
public void cleanup() throws ResourceException {
- if (this.conn != null) {
- this.conn.close();
- this.conn = null;
+ synchronized (this.handles) {
+ for (WrappedConnection wc:this.handles) {
+ wc.setManagedConnection(null);
+ }
+ handles.clear();
}
ConnectionContext.setSubject(null);
}
@@ -69,6 +81,9 @@
@Override
public void destroy() throws ResourceException {
cleanup();
+
+ this.physicalConnection.close();
+ this.physicalConnection = null;
}
@Override
@@ -81,21 +96,26 @@
if(!(arg1 instanceof ConnectionRequestInfoWrapper)) {
throw new ConnectorException("Un recognized Connection Request Info object received");
}
- ConnectionRequestInfoWrapper criw = (ConnectionRequestInfoWrapper)arg1;
ConnectionContext.setSubject(arg0);
- this.conn = new WrappedConnection(criw.actualConnector.getConnection(), mcf);
- this.conn.setManagedConnection(this);
- return this.conn;
+ if (this.physicalConnection == null) {
+ this.physicalConnection = this.cf.getConnection();
+ }
+
+ WrappedConnection wc = new WrappedConnection(this, mcf);
+ synchronized(this.handles) {
+ this.handles.add(wc);
+ }
+ return wc;
}
@Override
public LocalTransaction getLocalTransaction() throws ResourceException {
- return this.conn.getLocalTransaction();
+ return this.physicalConnection.getLocalTransaction();
}
@Override
public XAResource getXAResource() throws ResourceException {
- return this.conn.getXAResource();
+ return this.physicalConnection.getXAResource();
}
@Override
@@ -123,9 +143,14 @@
}
// called by the wrapped connection to notify the close of the connection.
- void connectionClosed() {
+ void connectionClosed(WrappedConnection wc) throws ConnectorException {
+
+ synchronized (this.handles) {
+ handles.remove(wc);
+ }
+
ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
- ce.setConnectionHandle(this.conn);
+ ce.setConnectionHandle(wc);
ArrayList<ConnectionEventListener> copy = null;
synchronized (this.listeners) {
@@ -135,9 +160,23 @@
for(ConnectionEventListener l: copy) {
l.connectionClosed(ce);
}
+
+ // check if connector is a facade for another; in which case release it to the pool
+ if (this.mcf.getSourceJNDIName() != null) {
+ synchronized(this.physicalConnection) {
+ this.physicalConnection.close();
+ this.physicalConnection = null;
+ }
+ }
}
- public boolean isValid() {
- return this.conn.isAlive();
+ public boolean isValid() throws ConnectorException {
+ return this.physicalConnection.isAlive();
}
+
+ Connection getConnection() throws ConnectorException {
+ if (this.physicalConnection == null)
+ throw new ConnectorException("Connection has been destroyed!!!");
+ return this.physicalConnection;
+ }
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -63,6 +63,7 @@
private boolean exceptionOnMaxRows = false;
private int maxResultRows = -1;
private boolean xaCapable;
+ private String sourceJNDIName;
private String overrideCapabilitiesFile;
@@ -71,11 +72,6 @@
@Override
public Object createConnectionFactory() throws ResourceException {
- return new ResourceException("Resource Adapter does not currently support running in a non-managed environment.");
- }
-
- @Override
- public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
try {
Object o = ReflectionHelper.create(this.connectorClass, null, Thread.currentThread().getContextClassLoader());
if(!(o instanceof Connector)) {
@@ -83,15 +79,21 @@
}
Connector connector = (Connector)o;
connector.initialize(this);
- return new WrappedConnector(connector, arg0, this);
+ return connector;
} catch (MetaMatrixCoreException e) {
throw new ResourceException(e);
}
}
@Override
+ public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
+ return new WrappedConnector((Connector)createConnectionFactory(), arg0, this);
+ }
+
+ @Override
public ManagedConnection createManagedConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
- return new BasicManagedConnection(this);
+ ConnectionRequestInfoWrapper criw = (ConnectionRequestInfoWrapper)arg1;
+ return new BasicManagedConnection(criw.actualConnector, this);
}
@Override
@@ -178,6 +180,14 @@
public TypeFacility getTypeFacility() {
return TYPE_FACILITY;
}
+
+ public void setSourceJNDIName(String arg0) {
+ this.sourceJNDIName = arg0;
+ }
+
+ public String getSourceJNDIName() {
+ return sourceJNDIName;
+ }
@Override
public Properties getOverrideCapabilities() throws ConnectorException {
Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/WrappedConnection.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -41,23 +41,21 @@
public class WrappedConnection implements Connection, MetadataProvider {
- private Connection conn;
private ConnectorEnvironment env;
private ConnectorCapabilities caps;
private BasicManagedConnection mc;
boolean closed = false;
- public WrappedConnection(Connection conn, ConnectorEnvironment env) {
- this.conn = conn;
+ public WrappedConnection(BasicManagedConnection mc, ConnectorEnvironment env) {
+ this.mc = mc;
this.env = env;
}
@Override
- public void close() {
+ public void close() throws ConnectorException {
if (!this.closed && this.mc != null) {
this.closed = true;
- this.conn.close();
- this.mc.connectionClosed();
+ this.mc.connectionClosed(this);
this.mc = null;
}
}
@@ -65,13 +63,13 @@
@Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return conn.createExecution(command, executionContext, metadata);
+ return this.mc.getConnection().createExecution(command, executionContext, metadata);
}
@Override
public ConnectorCapabilities getCapabilities() throws ConnectorException {
if (this.caps == null) {
- this.caps = conn.getCapabilities();
+ this.caps = this.mc.getConnection().getCapabilities();
if (caps != null && this.env.getOverrideCapabilities() != null) {
caps = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(caps, this.env.getOverrideCapabilities()));
}
@@ -81,23 +79,23 @@
@Override
public LocalTransaction getLocalTransaction() throws ConnectorException {
- return conn.getLocalTransaction();
+ return this.mc.getConnection().getLocalTransaction();
}
@Override
- public boolean isAlive() {
- return conn.isAlive();
+ public boolean isAlive() throws ConnectorException {
+ return this.mc.getConnection().isAlive();
}
@Override
public XAResource getXAResource() throws ConnectorException {
- return conn.getXAResource();
+ return this.mc.getConnection().getXAResource();
}
@Override
public void getConnectorMetadata(MetadataFactory metadataFactory) throws ConnectorException {
- if (this.conn instanceof MetadataProvider) {
- ((MetadataProvider) this.conn).getConnectorMetadata(metadataFactory);
+ if (this.mc.getConnection() instanceof MetadataProvider) {
+ ((MetadataProvider) this.mc.getConnection()).getConnectorMetadata(metadataFactory);
} else {
throw new ConnectorException(DataPlugin.Util.getString("WrappedConnection.no_metadata")); //$NON-NLS-1$
}
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCConnector.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -35,8 +35,6 @@
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.basic.BasicConnector;
-import com.metamatrix.core.util.StringUtil;
-
/**
* JDBC implementation of Connector interface.
*/
@@ -56,15 +54,6 @@
logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_initialized._1")); //$NON-NLS-1$
-
- // Get the JNDI name for the underlying JDBC source
- String dataSourceName = this.config.getSourceJNDIName();
-
- // Verify required items
- if (!StringUtil.isValid(dataSourceName)) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_jndi_1")); //$NON-NLS-1$
- }
-
capabilities = config.getTranslator().getConnectorCapabilities();
logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_started._4")); //$NON-NLS-1$
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCManagedConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCManagedConnectionFactory.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCManagedConnectionFactory.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -40,6 +40,7 @@
private boolean trimStrings=false;
private boolean useCommentsInSourceQuery = false;
private int fetchSize = -1;
+ private String connectionFactoryClass;
// derived
private Translator sqlTranslator;
@@ -73,6 +74,7 @@
return this.sqlTranslator;
}
+ @Override
public String getSourceJNDIName() {
return sourceJNDIName;
}
@@ -97,6 +99,7 @@
this.extensionTranslationClassName = arg0;
}
+ @Override
public void setSourceJNDIName(String arg0) {
this.sourceJNDIName = arg0;
}
@@ -116,4 +119,12 @@
public int getFetchSize() {
return this.fetchSize;
}
+
+ public String getConnectionFactoryClass() {
+ return connectionFactoryClass;
+ }
+
+ public void setConnectionFactoryClass(String connectionFactoryClass) {
+ this.connectionFactoryClass = connectionFactoryClass;
+ }
}
Modified: trunk/connectors/connector-jdbc/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-jdbc/src/main/rar/META-INF/ra.xml 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/connectors/connector-jdbc/src/main/rar/META-INF/ra.xml 2010-04-27 22:25:00 UTC (rev 2084)
@@ -41,14 +41,22 @@
<managedconnectionfactory-class>org.teiid.connector.jdbc.JDBCManagedConnectionFactory</managedconnectionfactory-class>
<config-property>
- <description>{$display:"Connector Class",$advanced:"true"}</description>
+ <!-- This property is for the auto creation of the Connector from DS -->
+ <description>{$display:"Connection Factory Class",$required:"true"}</description>
+ <config-property-name>ConnectionFactoryClass</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>org.teiid.connector.jdbc.JDBCManagedConnectionFactory</config-property-value>
+ </config-property>
+
+ <config-property>
+ <description>{$display:"Connector Class"}</description>
<config-property-name>ConnectorClass</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.teiid.connector.jdbc.JDBCConnector</config-property-value>
</config-property>
<config-property>
- <description>{$display:"Connector Capabilities",$description:"The class to use to provide the Connector Capabilities",$advanced:"true"}</description>
+ <description>{$display:"Connector Capabilities",$description:"The class to use to provide the Connector Capabilities"}</description>
<config-property-name>CapabilitiesClass</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
@@ -61,7 +69,7 @@
</config-property>
<config-property>
- <description>{$display:"Is XA Capable",$description:"True, if this connector supports XA Transactions",$advanced:"true"}</description>
+ <description>{$display:"Is XA Capable",$description:"True, if this connector supports XA Transactions"}</description>
<config-property-name>XaCapable</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>false</config-property-value>
@@ -104,20 +112,13 @@
</config-property>
<config-property>
- <description>{$display:"Extension SQL Translation Class",$required:"true",$advanced:"true",$allowed:["org.teiid.connector.jdbc.translator.Translator","org.teiid.connector.jdbc.oracle.OracleSQLTranslator","org.teiid.connector.jdbc.db2.DB2SQLTranslator", "org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator", "org.teiid.connector.jdbc.mysql.MySQLTranslator","org.teiid.connector.jdbc.mysql.MySQL5Translator", "org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator", "org.teiid.connector.jdbc.derby.DerbySQLTranslator", "org.teiid.connector.jdbc.access.AccessSQLTranslator","org.teiid.connector.jdbc.h2.H2Translator","org.teiid.connector.jdbc.h2.H2Translator"]}</description>
+ <description>{$display:"Extension SQL Translation Class",$required:"true",$allowed:["org.teiid.connector.jdbc.translator.Translator","org.teiid.connector.jdbc.oracle.OracleSQLTranslator","org.teiid.connector.jdbc.db2.DB2SQLTranslator", "org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator", "org.teiid.connector.jdbc.mysql.MySQLTranslator","org.teiid.connector.jdbc.mysql.MySQL5Translator", "org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator", "org.teiid.connector.jdbc.derby.DerbySQLTranslator", "org.teiid.connector.jdbc.access.AccessSQLTranslator","org.teiid.connector.jdbc.h2.H2Translator","org.teiid.connector.jdbc.h2.H2Translator"]}</description>
<config-property-name>ExtensionTranslationClassName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>org.teiid.connector.jdbc.translator.Translator</config-property-value>
</config-property>
<config-property>
- <description>{$display:"Source Connection JNDI Name",$required:"true"}</description>
- <description>JNDI Name of the physical resource.</description>
- <config-property-name>SourceJNDIName</config-property-name>
- <config-property-type>java.lang.String</config-property-type>
- </config-property>
-
- <config-property>
<description>{$display:"Trim string flag",$description:"Right Trim fixed character types returned as Strings - note that the native type must be char or nchar and the source must support the rtrim function.",$advanced:"true"}</description>
<config-property-name>TrimStrings</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -34,9 +34,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperties;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
import org.teiid.connector.api.ConnectorCapabilities;
@@ -70,11 +67,13 @@
* The <code>ConnectorManager</code> manages a {@link org.teiid.connector.basic.BasicConnector Connector}
* and its associated workers' state.
*/
-@ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="connectormanager"), properties=ManagementProperties.EXPLICIT)
public class ConnectorManager {
public static final int DEFAULT_MAX_THREADS = 20;
private String connectorName;
+
+ // stateful connector supplied to the cm; does not do the lookup
+ private Connector statefulConnector;
//services acquired in start
private BufferService bufferService;
@@ -93,8 +92,12 @@
public ConnectorManager(String name) {
this(name, DEFAULT_MAX_THREADS);
}
-
+
public ConnectorManager(String name, int maxThreads) {
+ this(name, null, maxThreads);
+ }
+
+ public ConnectorManager(String name, Connector connector, int maxThreads) {
if (name == null) {
throw new IllegalArgumentException("Connector name can not be null"); //$NON-NLS-1$
}
@@ -103,6 +106,7 @@
}
this.maxConnections = maxThreads;
this.connectorName = name;
+ this.statefulConnector = connector;
}
public synchronized void acquireConnectionLock(ConnectorWorkItem item) throws BlockedException {
@@ -234,16 +238,6 @@
}
/**
- * Returns a list of QueueStats objects that represent the queues in
- * this service.
- * If there are no queues, an empty Collection is returned.
- */
- /* @ManagementProperty(description="Get Runtime workmanager statistics", use={ViewUse.STATISTIC}, readOnly=true)
- public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
- return workManager.getStats();
- }*/
-
- /**
* Add begin point to transaction monitoring table.
* @param qr Request that contains the MetaMatrix command information in the transaction.
*/
@@ -284,6 +278,9 @@
*/
Connector getConnector() throws ConnectorException {
try {
+ if (this.statefulConnector != null) {
+ return this.statefulConnector;
+ }
InitialContext ic = new InitialContext();
return (Connector)ic.lookup(this.connectorName);
} catch (NamingException e) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -189,7 +189,11 @@
} finally {
manager.removeState(this.id);
if (connection != null) {
- connection.close();
+ try {
+ connection.close();
+ } catch (ConnectorException e) {
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, e.getMessage());
+ }
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -27,8 +27,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -47,16 +45,13 @@
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.plugins.DefaultFieldsImpl;
import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValueSupport;
@@ -68,7 +63,6 @@
import org.teiid.adminapi.AdminObject;
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.ConnectionFactory;
-import org.teiid.adminapi.ConnectionPoolStatistics;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.PropertyDefinition;
import org.teiid.adminapi.Request;
@@ -78,7 +72,6 @@
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.WorkerPoolStatistics;
import org.teiid.adminapi.impl.ConnectionFactoryMetaData;
-import org.teiid.adminapi.impl.ConnectionPoolStatisticsMetadata;
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.PropertyDefinitionMetadata;
@@ -88,31 +81,26 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-import org.teiid.connector.api.Connector;
import org.teiid.jboss.IntegrationPlugin;
import org.teiid.jboss.deployers.RuntimeEngineDeployer;
-import org.teiid.templates.connector.ExportConnectorTypeTemplateInfo;
-import com.metamatrix.core.util.ObjectConverterUtil;
-
public class Admin extends TeiidAdmin {
private static final String CONNECTOR_PREFIX = "connector-"; //$NON-NLS-1$
private static final String RAR = ".rar"; //$NON-NLS-1$
private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
- private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate"; //$NON-NLS-1$
- private static final String LOCAL_DATA_SOURCE_TEMPLATE = "LocalTxDataSourceTemplateInfo"; //$NON-NLS-1$
private static final long serialVersionUID = 7081309086056911304L;
private static ComponentType VDBTYPE = new ComponentType("teiid", "vdb");//$NON-NLS-1$ //$NON-NLS-2$
private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ComponentType CONNECTION_FACTORY_TYPE = new ComponentType("teiid", "connection-factory");//$NON-NLS-1$ //$NON-NLS-2$
private static String DQPNAME = RuntimeEngineDeployer.class.getName();
- private static ExtendedComponentType NOTXTYPE = new ExtendedComponentType("ConnectionFactory", "NoTx", "no-tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static ExtendedComponentType TXTYPE = new ExtendedComponentType("ConnectionFactory", "Tx", "tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static ExtendedComponentType DS_LOCAL_TX = new ExtendedComponentType("DataSource", "LocalTx", "local-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static ExtendedComponentType DS_XA_TX = new ExtendedComponentType("DataSource", "XA", "xa-datasource");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static ExtendedComponentType DS_NO_TX = new ExtendedComponentType("DataSource", "NoTx", "no-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static ExtendedComponentType[] DS_TYPES = new ExtendedComponentType[] {DS_XA_TX, DS_LOCAL_TX, DS_NO_TX};
- private static ExtendedComponentType[] CF_TYPES = new ExtendedComponentType[] {NOTXTYPE, TXTYPE};
+ private static ComponentType NOTXTYPE = new ComponentType("ConnectionFactory", "NoTx");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ComponentType TXTYPE = new ComponentType("ConnectionFactory", "Tx");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ComponentType DS_LOCAL_TX = new ComponentType("DataSource", "LocalTx");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ComponentType DS_XA_TX = new ComponentType("DataSource", "XA");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ComponentType DS_NO_TX = new ComponentType("DataSource", "NoTx");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ComponentType[] DS_TYPES = {DS_XA_TX,DS_LOCAL_TX,TXTYPE,DS_NO_TX,NOTXTYPE};
+
private ManagementView view;
private DeploymentManager deploymentMgr;
@@ -171,90 +159,44 @@
@Override
public Collection<ConnectionFactory> getConnectionFactories() throws AdminException {
- ArrayList<ConnectionFactory> bindings = new ArrayList<ConnectionFactory>();
- findConnectorBindings(bindings, "NoTx"); //$NON-NLS-1$
- findConnectorBindings(bindings, "Tx"); //$NON-NLS-1$
- return bindings;
- }
-
- @Override
- public ConnectionFactory getConnectionFactory(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc != null) {
- return buildConnectorBinding(mc);
+ ArrayList<ConnectionFactory> factories = new ArrayList<ConnectionFactory>();
+ try {
+ Set<ManagedComponent> mcSet = getView().getComponentsForType(CONNECTION_FACTORY_TYPE);
+ for (ManagedComponent mc:mcSet) {
+ factories.add(AdminObjectBuilder.buildAO(mc, ConnectionFactoryMetaData.class));
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e);
}
- return null;
+ return factories;
}
@Override
- public Reader exportConnectionFactory(String deployedName) throws AdminException {
- ManagementView view = getView();
+ public ConnectionFactory getConnectionFactory(String deployedName) throws AdminException {
try {
- for (ExtendedComponentType type:CF_TYPES) {
- ManagedComponent mc = view.getComponent(deployedName, type);
- if (mc != null) {
- return exportJCAConnection(deployedName, mc, type);
- }
- }
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connectionfactory_not_found", deployedName)); //$NON-NLS-1$
- } catch (Exception e) {
- throw new AdminComponentException(e);
- }
- }
-
- private Reader exportJCAConnection(String deployedName, ManagedComponent mc, ExtendedComponentType type) throws AdminException {
- try {
- DeploymentTemplateInfo info = getView().getTemplate("export-template"); //$NON-NLS-1$
- if(info == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found", "export-template")); //$NON-NLS-1$ //$NON-NLS-2$
+ ManagedComponent mc = getConnectionFactoryComponent(deployedName);
+ if (mc != null) {
+ return AdminObjectBuilder.buildAO(mc, ConnectionFactoryMetaData.class);
}
-
- for (ManagedProperty infoProperty:info.getProperties().values()) {
- if (infoProperty != null) {
- ManagedProperty mp = mc.getProperty(infoProperty.getName());
- if (mp != null) {
- infoProperty.setValue(mp.getValue());
- }
- }
- }
-
- ManagedProperty dsType = info.getProperties().get("dsType"); //$NON-NLS-1$
- dsType.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, type.getDsType()));
-
- File dsXml = File.createTempFile(deployedName, "-ds.xml"); //$NON-NLS-1$
- ExportConnectorTypeTemplateInfo.writeTemplate(dsXml, info);
- Reader r = new StringReader(ObjectConverterUtil.convertFileToString(dsXml));
- dsXml.delete();
- return r;
- } catch (NoSuchDeploymentException e) {
- throw new AdminComponentException(e);
- } catch (IOException e) {
- throw new AdminComponentException(e);
+ return null;
} catch(Exception e) {
- throw new AdminComponentException(e);
+ throw new AdminProcessingException(e.getMessage(), e);
}
}
-
- @Override
- public Reader exportDataSource(String deployedName) throws AdminException {
+
+ private ManagedComponent getConnectionFactoryComponent(String deployedName)
+ throws Exception {
if (deployedName.startsWith("java:")) { //$NON-NLS-1$
deployedName = deployedName.substring(5);
}
- try {
- ManagedComponent mc = null;
- ManagementView view = getView();
- for (ExtendedComponentType type:DS_TYPES) {
- mc = view.getComponent(deployedName, type);
- if (mc != null) {
- return exportJCAConnection(deployedName, mc, type);
- }
- }
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("datasource_not_found", deployedName)); //$NON-NLS-1$
- } catch (Exception e) {
- throw new AdminComponentException(e);
+
+ if (!deployedName.startsWith("teiid-cf/")) { //$NON-NLS-1$
+ deployedName = "teiid-cf/"+deployedName; //$NON-NLS-1$
}
+ ManagedComponent mc = view.getComponent(deployedName, CONNECTION_FACTORY_TYPE);
+ return mc;
}
-
+
private InputStream exportDeployment(String url) throws AdminComponentException {
try {
URL contentURL = new URL(url);
@@ -264,112 +206,96 @@
} catch (IOException e) {
throw new AdminComponentException(e);
}
- }
+ }
- private ManagedComponent getConnectorBindingComponent(String deployedName) throws AdminProcessingException {
+ private ManagedComponent getManagedConnectionFactoryComponent(String deployedName) throws AdminProcessingException {
try {
if (deployedName.startsWith("java:")) { //$NON-NLS-1$
deployedName = deployedName.substring(5);
}
- ManagementView view = getView();
- for (ExtendedComponentType type:CF_TYPES) {
+ for (ComponentType type:DS_TYPES) {
ManagedComponent mc = view.getComponent(deployedName, type);
if (mc != null) {
- if (isConnectorBinding(mc)) {
- return mc;
- }
- }
- }
+ return mc;
+ }
+ }
} catch(Exception e) {
throw new AdminProcessingException(e.getMessage(), e);
}
return null;
- }
+ }
- private ConnectionFactory buildConnectorBinding(ManagedComponent mc) {
- ConnectionFactoryMetaData connector = new ConnectionFactoryMetaData();
- connector.setName(mc.getName());
- connector.setComponentType(mc.getType());
- connector.addProperty("deployer-name", mc.getDeployment().getName());//$NON-NLS-1$
-
- for (String key:mc.getProperties().keySet()) {
- ManagedProperty property = mc.getProperty(key);
- MetaValue value = property.getValue();
-
- //TODO: All properties need to be added
- if (value != null) {
- if(value.getMetaType().isSimple()) {
- connector.addProperty(key, ManagedUtil.stringValue(value));
- }
- else if (key.equals("config-property")) { //$NON-NLS-1$
- MapCompositeValueSupport v1 = (MapCompositeValueSupport)value;
- MapCompositeMetaType metaType = v1.getMetaType();
- for (String configProperty:metaType.keySet()) {
- if (!configProperty.endsWith(".type")) { //$NON-NLS-1$
- connector.addProperty(configProperty, ManagedUtil.stringValue(v1.get(configProperty)));
- }
- }
- }
- else {
- //log.info(key+" property is not added to connector properties");
- }
- }
- }
- return connector;
- }
+// private ConnectionFactory buildConnectionFactory(ManagedComponent mc) {
+//
+// ConnectionFactoryMetaData connector = new ConnectionFactoryMetaData();
+// connector.setName(mc.getName());
+// connector.setComponentType(mc.getType());
+// connector.setJNDIName(ManagedUtil.getSimpleValue(mc, "jndi-name", String.class)); //$NON-NLS-1$
+// connector.setRARFileName(ManagedUtil.getSimpleValue(mc, "rar-name", String.class)); //$NON-NLS-1$
+//
+// connector.addProperty("deployer-name", mc.getDeployment().getName());//$NON-NLS-1$
+//
+// for (String key:mc.getProperties().keySet()) {
+// ManagedProperty property = mc.getProperty(key);
+// MetaValue value = property.getValue();
+//
+// //TODO: All properties need to be added
+// if (value != null) {
+// if(value.getMetaType().isSimple()) {
+// connector.addProperty(key, ManagedUtil.stringValue(value));
+// }
+// else if (key.equals("config-property")) { //$NON-NLS-1$
+// MapCompositeValueSupport v1 = (MapCompositeValueSupport)value;
+// MapCompositeMetaType metaType = v1.getMetaType();
+// for (String configProperty:metaType.keySet()) {
+// if (!configProperty.endsWith(".type")) { //$NON-NLS-1$
+// connector.addProperty(configProperty, ManagedUtil.stringValue(v1.get(configProperty)));
+// }
+// }
+// }
+// else {
+// //log.info(key+" property is not added to connector properties");
+// }
+// }
+// }
+// return connector;
+// }
- private boolean isConnectorBinding(ManagedComponent mc) {
- String connectionDefinition = ManagedUtil.getSimpleValue(mc, "connection-definition", String.class); //$NON-NLS-1$
- return Connector.class.getName().equals(connectionDefinition);
- }
+
- private void findConnectorBindings(ArrayList<ConnectionFactory> bindings, String subType) throws AdminException {
- try {
- ComponentType type = new ComponentType("ConnectionFactory", subType); //$NON-NLS-1$
- Set<ManagedComponent> jcaConnectors = getView().getComponentsForType(type);
-
- for(ManagedComponent mc:jcaConnectors) {
- ManagedProperty mp = mc.getProperty("connection-definition"); //$NON-NLS-1$
- SimpleValueSupport v = (SimpleValueSupport)mp.getValue();
- if (v.getValue().equals(Connector.class.getName())){
- bindings.add(buildConnectorBinding(mc));
- }
- }
- }catch(Exception e) {
- throw new AdminComponentException(e);
- }
- }
-
@Override
public ConnectionFactory addConnectionFactory(String deploymentName, String typeName, Properties properties) throws AdminException {
- if (getConnectionFactory(deploymentName) != null) {
+ if (getManagedConnectionFactoryComponent(deploymentName) != null) {
throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_binding_exists",deploymentName)); //$NON-NLS-1$;
- }
- properties.setProperty("connection-definition", Connector.class.getName()); //$NON-NLS-1$
+ }
addConnectionfactory(deploymentName, typeName, properties);
-
return getConnectionFactory(deploymentName);
}
@Override
public void setConnectionFactoryProperty(String deployedName, String propertyName, String propertyValue) throws AdminException{
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_binding_exists",deployedName)); //$NON-NLS-1$;
- }
- if (mc.getProperty(propertyName) != null) {
- mc.getProperty(propertyName).setValue(SimpleValueSupport.wrap(propertyValue));
- }
- else {
- Map<String, String> configProps = new HashMap<String, String>();
- configProps.put(propertyName, propertyValue);
- configProps.put(propertyValue+".type", "java.lang.String"); //$NON-NLS-1$ //$NON-NLS-2$
- MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
- mc.getProperty("config-property").setValue(metaValue); //$NON-NLS-1$
- }
try {
- getView().updateComponent(mc);
- getView().load();
+ ManagementView localView = getView();
+ ManagedComponent mc = getManagedConnectionFactoryComponent(deployedName);
+ if (mc == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_binding_exists",deployedName)); //$NON-NLS-1$;
+ }
+ if (mc.getProperty(propertyName) != null) {
+ mc.getProperty(propertyName).setValue(SimpleValueSupport.wrap(propertyValue));
+ }
+ else {
+ // since this is not in the regular properties list; must be teiid specific property
+ // handle this by template properties
+ ConnectionFactory cf = getConnectionFactory(deployedName);
+ DeploymentTemplateInfo template = localView.getTemplate(cf.getTemplateName());
+ if (template instanceof ExtendedPropertyInfo) {
+ ExtendedPropertyInfo extendedTemplate = (ExtendedPropertyInfo)template;
+ extendedTemplate.updateProperty(propertyName, propertyValue, mc);
+ }
+ }
+
+ localView.updateComponent(mc);
+ localView.load();
} catch (Exception e) {
throw new AdminComponentException(e);
}
@@ -377,7 +303,7 @@
@Override
public void deleteConnectionFactory(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ ManagedComponent mc = getManagedConnectionFactoryComponent(deployedName);
if (mc != null) {
ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
}
@@ -386,15 +312,8 @@
@Override
public void startConnectionFactory(String deployedName) throws AdminException {
try {
- ConnectionFactory factory = getConnectionFactory(deployedName);
- if (factory == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("failed_to_connector_deployer")); //$NON-NLS-1$
- }
- String deployerName = factory.getPropertyValue("deployer-name"); //$NON-NLS-1$
- if (deployerName == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("failed_to_connector_deployer")); //$NON-NLS-1$
- }
- ManagedUtil.execute(getDeploymentManager().start(deployerName), IntegrationPlugin.Util.getString("failed_to_start_connector", factory.getName())); //$NON-NLS-1$
+ String deploymentName = getDeploymentName(deployedName);
+ ManagedUtil.execute(getDeploymentManager().start(deploymentName), IntegrationPlugin.Util.getString("failed_to_start_connector", deployedName)); //$NON-NLS-1$
} catch (Exception e) {
ManagedUtil.handleException(e);
}
@@ -403,18 +322,23 @@
@Override
public void stopConnectionFactory(String deployedName) throws AdminException {
try {
- ConnectionFactory factory = getConnectionFactory(deployedName);
- if (factory == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("failed_to_connector_deployer")); //$NON-NLS-1$
- }
- String deployerName = factory.getPropertyValue("deployer-name");//$NON-NLS-1$
- if (deployerName == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("failed_to_connector_deployer")); //$NON-NLS-1$
- }
- ManagedUtil.execute(getDeploymentManager().stop(deployerName), IntegrationPlugin.Util.getString("failed_to_stop_connector", factory.getName())); //$NON-NLS-1$
+ String deploymentName = getDeploymentName(deployedName);
+ ManagedUtil.execute(getDeploymentManager().stop(deploymentName), IntegrationPlugin.Util.getString("failed_to_stop_connector", deployedName)); //$NON-NLS-1$
} catch (Exception e) {
ManagedUtil.handleException(e);
}
+ }
+
+ private String getDeploymentName(String deployedName) throws AdminProcessingException {
+ ManagedComponent mc = getManagedConnectionFactoryComponent(deployedName);
+ if (mc == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("failed_to_find_connector", deployedName)); //$NON-NLS-1$
+ }
+ String deploymentName = mc.getDeployment().getName();
+ if (deploymentName == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("failed_to_find_connector")); //$NON-NLS-1$
+ }
+ return deploymentName;
}
@Override
@@ -438,20 +362,15 @@
@Override
- public Set<String> getConnectorNames() throws AdminException{
- try {
- Set<ManagedDeployment> rarFiles = getView().getDeploymentsForType("rar");//$NON-NLS-1$
- HashSet<String> matched = new HashSet<String>();
- for(ManagedDeployment md:rarFiles) {
- String name = md.getSimpleName();
- if (name.startsWith(CONNECTOR_PREFIX) && name.endsWith(RAR)) {
- matched.add(md.getSimpleName());
- }
+ public Set<String> getConnectorTemplateNames() throws AdminException{
+ Set<String> names = getView().getTemplateNames();
+ HashSet<String> matched = new HashSet<String>();
+ for(String name:names) {
+ if (name.startsWith(CONNECTOR_PREFIX)) {
+ matched.add(name);
}
- return matched;
- } catch(Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
}
+ return matched;
}
boolean matches(String regEx, String value) {
@@ -764,19 +683,6 @@
}
@Override
- public InputStream exportConnector(String connectorName) throws AdminException {
- if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name")); //$NON-NLS-1$
- }
-
- String deployerName = getRarDeployerName(connectorName);
- if (deployerName == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found", connectorName)); //$NON-NLS-1$
- }
- return exportDeployment(deployerName);
- }
-
- @Override
public Collection<String> getCacheTypes() throws AdminException {
try {
Collection<String> requestList = new ArrayList<String>();
@@ -839,41 +745,22 @@
}
}
- @Override
- public ConnectionPoolStatistics getConnectionFactoryStats(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc != null) {
- return buildConnectorConnectionPool(mc);
- }
- return null;
- }
-
- private ConnectionPoolStatistics buildConnectorConnectionPool(ManagedComponent mc) {
- ConnectionPoolStatisticsMetadata stats = new ConnectionPoolStatisticsMetadata();
- stats.setName(mc.getName());
- stats.setAvailableConnectionCount(ManagedUtil.getSimpleValue(mc, "availableConnectionCount", Long.class));//$NON-NLS-1$
- stats.setConnectionCount(ManagedUtil.getSimpleValue(mc, "connectionCount", Integer.class));//$NON-NLS-1$
- stats.setConnectionCreatedCount(ManagedUtil.getSimpleValue(mc, "connectionCreatedCount", Integer.class));//$NON-NLS-1$
- stats.setConnectionDestroyedCount(ManagedUtil.getSimpleValue(mc, "connectionDestroyedCount", Integer.class));//$NON-NLS-1$
- stats.setInUseConnectionCount(ManagedUtil.getSimpleValue(mc, "inUseConnectionCount", Long.class));//$NON-NLS-1$
- stats.setMaxConnectionsInUseCount(ManagedUtil.getSimpleValue(mc, "maxConnectionsInUseCount", Long.class));//$NON-NLS-1$
- stats.setMaxSize(ManagedUtil.getSimpleValue(mc, "maxSize", Integer.class));//$NON-NLS-1$
- stats.setMinSize(ManagedUtil.getSimpleValue(mc, "minSize", Integer.class));//$NON-NLS-1$
- return stats;
- }
@Override
- public Collection<PropertyDefinition> getConnectorPropertyDefinitions(String typeName) throws AdminException {
+ public Collection<PropertyDefinition> getConnectorTemplatePropertyDefinitions(String templateName) throws AdminException {
try {
- DeploymentTemplateInfo info = getView().getTemplate(typeName);
+ DeploymentTemplateInfo info = getView().getTemplate(templateName);
if(info == null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found", typeName)); //$NON-NLS-1$
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found", templateName)); //$NON-NLS-1$
}
ArrayList<PropertyDefinition> props = new ArrayList<PropertyDefinition>();
Map<String, ManagedProperty> propertyMap = info.getProperties();
for (ManagedProperty mp:propertyMap.values()) {
+ if (!includeInTemplate(mp)) {
+ continue;
+ }
PropertyDefinitionMetadata p = new PropertyDefinitionMetadata();
p.setName(mp.getName());
p.setDescription(mp.getDescription());
@@ -916,26 +803,26 @@
}
}
- @Override
- public void addDataSource(String deploymentName, DataSourceType type, Properties properties) throws AdminException {
- if (type == DataSourceType.XA) {
- addConnectionfactory(deploymentName, XA_DATA_SOURCE_TEMPLATE, properties);
+ private boolean includeInTemplate(ManagedProperty mp) {
+ Boolean teiidProperty = mp.getField("teiid-property", Boolean.class);//$NON-NLS-1$
+ if ( teiidProperty != null && teiidProperty.booleanValue()) {
+ return true;
}
- else if (type == DataSourceType.LOCAL) {
- addConnectionfactory(deploymentName, LOCAL_DATA_SOURCE_TEMPLATE, properties);
+ if (mp.isMandatory() && mp.getDefaultValue() == null) {
+ return true;
}
+ return false;
}
-
- private void addConnectionfactory(String deploymentName, String typeName, Properties properties) throws AdminException {
+
+ private void addConnectionfactory(String deploymentName, String typeName, Properties properties) throws AdminException {
try {
DeploymentTemplateInfo info = getView().getTemplate(typeName);
if(info == null) {
throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found", typeName)); //$NON-NLS-1$
}
-
- //config-properties list
- Map<String, String> configProps = new HashMap<String, String>();
+// Map<String, String> configProps = new HashMap<String, String>();
+
// template properties specific to the template
Map<String, ManagedProperty> propertyMap = info.getProperties();
@@ -949,16 +836,16 @@
mp.setValue(SimpleValueSupport.wrap(value));
}
}
- else {
- configProps.put(key, properties.getProperty(key));
- configProps.put(key+".type", "java.lang.String");//$NON-NLS-1$ //$NON-NLS-2$
- }
+// else {
+// configProps.put(key, properties.getProperty(key));
+// configProps.put(key+".type", "java.lang.String");//$NON-NLS-1$ //$NON-NLS-2$
+// }
}
- if (configProps.size() > 0) {
- MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
- info.getProperties().get("config-property").setValue(metaValue);//$NON-NLS-1$
- }
+// if (configProps.size() > 0) {
+// MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+// info.getProperties().get("config-property").setValue(metaValue);//$NON-NLS-1$
+// }
getView().applyTemplate(deploymentName, info);
@@ -969,43 +856,23 @@
}
}
- @Override
- public void deleteDataSource(String deployedName) throws AdminException {
- try {
- ManagementView view = getView();
- for (ExtendedComponentType type:DS_TYPES) {
- ManagedComponent mc = view.getComponent(deployedName, type);
- if (mc != null) {
- ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
- break;
- }
- }
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public Collection<PropertyDefinition> getDataSourcePropertyDefinitions() throws AdminException {
- return getConnectorPropertyDefinitions(XA_DATA_SOURCE_TEMPLATE);
- }
-
private static final String connectorTemplate =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ //$NON-NLS-1$
"<deployment xmlns=\"urn:jboss:bean-deployer:2.0\">\n" + //$NON-NLS-1$
"<!-- This is Teiid connector type template - DO NOT DELETE -->\n"+ //$NON-NLS-1$
- "<bean name=\"${name}\" class=\"org.teiid.templates.connector.ConnectorTypeTemplate\">\n" + //$NON-NLS-1$
+ "<bean name=\"${name}\" class=\"org.teiid.templates.connector.ConnectorDeploymentTemplate\">\n" + //$NON-NLS-1$
" <property name=\"info\"><inject bean=\"${name}-templateinfo\"/></property>\n" + //$NON-NLS-1$
" <property name=\"targetTemplate\"><inject bean=\"NoTxConnectionFactoryTemplate\"/></property>\n" + //$NON-NLS-1$
"</bean>\n" + //$NON-NLS-1$
- "<bean name=\"${name}-templateinfo\" class=\"org.teiid.templates.connector.ConnectorTypeTemplateInfo\">\n" + //$NON-NLS-1$
+ "<bean name=\"${name}-templateinfo\" class=\"org.teiid.templates.connector.ConnectorTemplateInfo\">\n" + //$NON-NLS-1$
" <constructor factoryMethod=\"createTemplateInfo\">\n" + //$NON-NLS-1$
" <factory bean=\"DSDeploymentTemplateInfoFactory\"/>\n" + //$NON-NLS-1$
- " <parameter class=\"java.lang.Class\">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>\n" + //$NON-NLS-1$
+ " <parameter class=\"java.lang.Class\">org.teiid.templates.connector.ConnectorTemplateInfo</parameter>\n" + //$NON-NLS-1$
" <parameter class=\"java.lang.Class\">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>\n" + //$NON-NLS-1$
- " <parameter class=\"java.lang.String\">${name}.rar</parameter>\n" + //$NON-NLS-1$
+ " <parameter class=\"java.lang.String\">${name}</parameter>\n" + //$NON-NLS-1$
" <parameter class=\"java.lang.String\">${name}</parameter>\n"+ //$NON-NLS-1$
" </constructor>\n" + //$NON-NLS-1$
+ " <property name=\"rarName\">${name}.rar</property>" + //$NON-NLS-1$
"</bean>\n"+ //$NON-NLS-1$
"</deployment>"; //$NON-NLS-1$
Added: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,82 @@
+/*
+ * 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.jboss;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedCommon;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.teiid.jboss.IntegrationPlugin;
+
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+
+public class AdminObjectBuilder {
+
+ public static <T> T buildAO(ManagedCommon mc, Class<T> clazz) {
+
+ try {
+ Object t = clazz.newInstance();
+
+ Map<String, ManagedProperty> managedProperties = mc.getProperties();
+ for (ManagedProperty mp: managedProperties.values()) {
+ MetaValue value = mp.getValue();
+ if (value != null) {
+ MetaType type = value.getMetaType();
+ if (type.isSimple()) {
+ PropertiesUtils.setBeanProperty(t, mp.getName(), ((SimpleValue)value).getValue());
+ }
+ else if (type.isProperties()) {
+
+ }
+ else if (type.isComposite()) {
+ if (value instanceof MapCompositeValueSupport) {
+ MapCompositeValueSupport map = (MapCompositeValueSupport)value;
+ }
+ }
+ else if (type.isCollection()) {
+ List list = new ArrayList();
+ List<ManagedObject> managedObjects = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(value);
+ for (ManagedObject mo:managedObjects) {
+ list.add(buildAO(mo, mo.getAttachment().getClass()));
+ }
+ PropertiesUtils.setBeanProperty(t, mp.getName(), list);
+ }
+ }
+ }
+ return clazz.cast(t);
+ } catch (InstantiationException e) {
+ throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
+ } catch (IllegalAccessException e) {
+ throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
+ }
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -1,39 +0,0 @@
-/*
- * 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.jboss;
-
-import org.jboss.managed.api.ComponentType;
-
-public class ExtendedComponentType extends ComponentType {
- private static final long serialVersionUID = 5526223504408812809L;
-
- private String dsType;
-
- public ExtendedComponentType(String type, String subtype, String dsType) {
- super(type, subtype);
- this.dsType = dsType;
- }
-
- public String getDsType() {
- return this.dsType;
- }
-}
Added: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedPropertyInfo.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedPropertyInfo.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedPropertyInfo.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,28 @@
+/*
+ * 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.jboss;
+
+import org.jboss.managed.api.ManagedComponent;
+
+public interface ExtendedPropertyInfo {
+ void updateProperty(String name, String value, ManagedComponent mc);
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedPropertyInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeployer.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeployer.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,195 @@
+/*
+ * 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.jboss.deployers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryPropertyMetaData;
+import org.teiid.adminapi.ConnectionFactory;
+import org.teiid.adminapi.impl.ConnectionFactoryMetaData;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
+import org.teiid.connector.basic.BasicManagedConnectionFactory;
+import org.teiid.deployers.VDBStatusChecker;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.jboss.IntegrationPlugin;
+
+import com.metamatrix.common.log.LogConstants;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ReflectionHelper;
+
+/**
+ * If the data source's "-ds.xml" file contains couple of extra Teiid Connection Factory properties, this deployer
+ * creates a stateful "Connector" and creates the "ConnectorManager" using the "Connector" created. In this case the
+ * "Connector" is not the JCA component. No lookup done for the "Connector". This way Teiid can combine the creation of
+ * data source and connection factory in one step.
+ */
+public class AutoConnectionFactoryDeployer extends AbstractSimpleRealDeployer<AutoConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
+
+ private ConnectorManagerRepository connectorManagerRepository;
+ private VDBStatusChecker vdbChecker;
+ private ManagedObjectFactory mof;
+
+ public AutoConnectionFactoryDeployer() {
+ super(AutoConnectionFactoryDeploymentGroup.class);
+ setRelativeOrder(3000);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, AutoConnectionFactoryDeploymentGroup group) throws DeploymentException {
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ ConnectionFactoryMetadataGroup cfGroup = new ConnectionFactoryMetadataGroup();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorName = "java:"+data.getJndiName(); //$NON-NLS-1$
+ ConnectorManager cm = null;
+
+ // check if a Teiid connection factory needs to be created for this data source.
+ List<ManagedConnectionFactoryPropertyMetaData> props = data.getManagedConnectionFactoryProperties();
+
+ String cfClass = getPropertyValue("ConnectionFactoryClass", props); //$NON-NLS-1$
+ if (cfClass != null) {
+ Properties teiidProps = convertToProperties(props);
+
+ // This indicates that a Teiid Connection factory
+ Connector connector = buildTeiidConnector(cfClass, teiidProps, connectorName);
+ cm = new ConnectorManager(connectorName, connector, data.getMaxSize());
+
+ cm.start();
+
+ // Add the references to the mgr as loaded.
+ this.connectorManagerRepository.addConnectorManager(connectorName, cm);
+ cfGroup.addConnectionFactory(ConnectionFactoryDeployer.buildCF(data));
+
+ this.vdbChecker.connectorAdded(connectorName);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("connector_started", connectorName)); //$NON-NLS-1$
+ }
+ }
+
+ if (!cfGroup.getConnectionFactories().isEmpty()) {
+ unit.addAttachment(ConnectionFactoryMetadataGroup.class, cfGroup);
+ }
+ }
+
+ private String getPropertyValue(String name, List<ManagedConnectionFactoryPropertyMetaData> props) {
+ for (ManagedConnectionFactoryPropertyMetaData prop:props) {
+ if (prop.getName().equals(name)) {
+ return prop.getValue();
+ }
+ }
+ return null;
+ }
+
+ private Properties convertToProperties(List<ManagedConnectionFactoryPropertyMetaData> props) {
+ Properties convertedProps = new Properties();
+ for (ManagedConnectionFactoryPropertyMetaData prop:props) {
+ convertedProps.setProperty(prop.getName(), prop.getValue());
+ }
+ return convertedProps;
+ }
+
+ private Connector buildTeiidConnector(String cfClass, Properties props, String sourceJndiName) throws DeploymentException {
+ BasicManagedConnectionFactory cf;
+ try {
+ Object o = ReflectionHelper.create(cfClass, null, Thread.currentThread().getContextClassLoader());
+ if(!(o instanceof ConnectorEnvironment)) {
+ throw new DeploymentException(IntegrationPlugin.Util.getString("invalid_class", cfClass));//$NON-NLS-1$
+ }
+ cf = (BasicManagedConnectionFactory)o;
+
+ PropertiesUtils.setBeanProperties(cf, props, null);
+ cf.setSourceJNDIName(sourceJndiName);
+
+ return (Connector)cf.createConnectionFactory();
+
+ } catch (MetaMatrixCoreException e) {
+ throw new DeploymentException(e);
+ } catch (ResourceException e) {
+ throw new DeploymentException(e);
+ }
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.connectorManagerRepository = repo;
+ }
+
+ /*
+ * undeploy covered by the other deployer already.
+ @Override
+ public void undeploy(DeploymentUnit unit, AutoConnectionFactoryDeploymentGroup group) {
+ super.undeploy(unit, group);
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorName = "java:"+data.getJndiName(); //$NON-NLS-1$
+ if (this.connectorManagerRepository != null) {
+ ConnectorManager cm = this.connectorManagerRepository.removeConnectorManager(connectorName);
+ if (cm != null) {
+ cm.stop();
+ this.vdbChecker.connectorRemoved(connectorName);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("connector_stopped", connectorName)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ */
+
+ @Override
+ public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
+ throws DeploymentException {
+
+ ConnectionFactoryMetadataGroup group = unit.getAttachment(ConnectionFactoryMetadataGroup.class);
+ if (group != null) {
+ for (ConnectionFactoryMetaData data : group.getConnectionFactories()) {
+ ManagedObject mo = this.mof.initManagedObject(data, ConnectionFactory.class, data.getName(), data.getName());
+ if (mo == null) {
+ throw new DeploymentException("could not create managed object"); //$NON-NLS-1$
+ }
+ managedObjects.put(mo.getName(), mo);
+ }
+ }
+ }
+
+ public void setVDBStatusChecker(VDBStatusChecker vdbChecker) {
+ this.vdbChecker = vdbChecker;
+ }
+
+ public void setManagedObjectFactory(ManagedObjectFactory mof) {
+ this.mof = mof;
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeployer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeploymentGroup.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeploymentGroup.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeploymentGroup.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss.deployers;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+
+
+(a)XmlAccessorType(XmlAccessType.NONE)
+@XmlRootElement
+public class AutoConnectionFactoryDeploymentGroup implements Serializable {
+ private static final long serialVersionUID = -7650097438654698297L;
+
+ @XmlElements({@XmlElement(name="local-tx-datasource", type=ManagedConnectionFactoryDeploymentMetaData.class),
+ @XmlElement(name="no-tx-datasource", type=ManagedConnectionFactoryDeploymentMetaData.class),
+ @XmlElement(name="xa-datasource", type=ManagedConnectionFactoryDeploymentMetaData.class)})
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = new ArrayList<ManagedConnectionFactoryDeploymentMetaData>();
+
+ public List<ManagedConnectionFactoryDeploymentMetaData> getDeployments() {
+ return Collections.unmodifiableList(deployments);
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryDeploymentGroup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryParserDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryParserDeployer.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryParserDeployer.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.teiid.jboss.deployers;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.sax.SAXSource;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.virtual.VirtualFile;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+
+public class AutoConnectionFactoryParserDeployer extends AbstractVFSParsingDeployer<AutoConnectionFactoryDeploymentGroup> {
+
+ public AutoConnectionFactoryParserDeployer() {
+ super(AutoConnectionFactoryDeploymentGroup.class);
+ setIncludeDeploymentFile(true);
+ setSuffix("-ds.xml"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected AutoConnectionFactoryDeploymentGroup parse(VFSDeploymentUnit unit, VirtualFile file, AutoConnectionFactoryDeploymentGroup root) throws Exception {
+ JAXBContext context = JAXBContext.newInstance(new Class[] {AutoConnectionFactoryDeploymentGroup.class});
+ Unmarshaller um = context.createUnmarshaller();
+ InputStream is = file.openStream();
+
+ try{
+ InputSource input = new InputSource(is);
+ input.setSystemId(file.toURI().toString());
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setEntityResolver(new JBossEntityResolver());
+ SAXSource source = new SAXSource(reader, input);
+ JAXBElement<AutoConnectionFactoryDeploymentGroup> elem = um.unmarshal(source, AutoConnectionFactoryDeploymentGroup.class);
+ AutoConnectionFactoryDeploymentGroup deployment = elem.getValue();
+ return deployment;
+ }
+ finally {
+ if (is != null)
+ is.close();
+ }
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/AutoConnectionFactoryParserDeployer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryDeployer.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -25,37 +25,43 @@
import java.util.Map;
import java.util.Set;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.VDBMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryPropertyMetaData;
+import org.teiid.adminapi.ConnectionFactory;
+import org.teiid.adminapi.impl.ConnectionFactoryMetaData;
+import org.teiid.adminapi.jboss.ManagedUtil;
import org.teiid.connector.api.Connector;
-import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.jboss.IntegrationPlugin;
-import org.teiid.security.SecurityHelper;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+/**
+ * This is a deployer that looks for the teiid connection factories deployed with their own "-ds.xml"
+ * file, then this class creates a ConnectorManager for it. So, the access to the "Connector" is through look-up
+ * in jndi tree for Connector Manager. Connector is JCA component.
+ */
public class ConnectionFactoryDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
- private ManagedObjectFactory mof;
- private SecurityHelper securityHelper;
+ private ManagedObjectFactory mof;
private ConnectorManagerRepository connectorManagerRepository;
- private VDBRepository vdbRepository;
+ private VDBStatusChecker vdbChecker;
public ConnectionFactoryDeployer() {
super(ManagedConnectionFactoryDeploymentGroup.class);
@@ -66,38 +72,30 @@
public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
- ConnectorManagerGroup cmGroup = new ConnectorManagerGroup();
+ ConnectionFactoryMetadataGroup cfGroup = new ConnectionFactoryMetadataGroup();
for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
String connectorDefinition = data.getConnectionDefinition();
+ String connectorName = "java:"+data.getJndiName(); //$NON-NLS-1$
+
if (connectorDefinition.equals(Connector.class.getName())) {
- String connectorName = "java:"+data.getJndiName(); //$NON-NLS-1$
-
- ConnectorManager cm = createConnectorManger(connectorName, data.getMaxSize());
+ ConnectorManager cm = new ConnectorManager(connectorName, data.getMaxSize());
+ // start the connector manager
cm.start();
- cmGroup.addConnectorManager(cm);
// Add the references to the mgr as loaded.
- this.connectorManagerRepository.addConnectorManager(connectorName, cm);
+ this.connectorManagerRepository.addConnectorManager(connectorName, cm);
+ cfGroup.addConnectionFactory(buildCF(data));
- connectorAdded(connectorName);
+ this.vdbChecker.connectorAdded(connectorName);
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("connector_started", connectorName)); //$NON-NLS-1$
}
- else {
- // check if data source is down
- }
}
- if (!cmGroup.getConnectorManagers().isEmpty()) {
- unit.addAttachment(ConnectorManagerGroup.class, cmGroup);
- }
+ if (!cfGroup.getConnectionFactories().isEmpty()) {
+ unit.addAttachment(ConnectionFactoryMetadataGroup.class, cfGroup);
+ }
}
-
-
- ConnectorManager createConnectorManger(String deployedConnectorName, int maxThreads) {
- ConnectorManager mgr = new ConnectorManager(deployedConnectorName, maxThreads);
- return mgr;
- }
public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
this.connectorManagerRepository = repo;
@@ -116,113 +114,93 @@
ConnectorManager cm = this.connectorManagerRepository.removeConnectorManager(connectorName);
if (cm != null) {
cm.stop();
+ this.vdbChecker.connectorRemoved(connectorName);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("connector_stopped", connectorName)); //$NON-NLS-1$
}
}
- connectorRemoved(connectorName);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("connector_stopped", connectorName)); //$NON-NLS-1$
}
}
}
-
+
@Override
- public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
- throws DeploymentException {
+ public void build(DeploymentUnit unit, Set<String> outputs,Map<String, ManagedObject> managedObjects) throws DeploymentException {
+ ConnectionFactoryMetadataGroup group = unit.getAttachment(ConnectionFactoryMetadataGroup.class);
- ConnectorManagerGroup cmGroup = unit.removeAttachment(ConnectorManagerGroup.class);
- if (cmGroup != null) {
- for (ConnectorManager mgr:cmGroup.getConnectorManagers()) {
- ManagedObject mo = this.mof.initManagedObject(mgr, ConnectorManager.class, mgr.getName(), mgr.getName());
- if (mo == null) {
- throw new DeploymentException("could not create managed object"); //$NON-NLS-1$
+ ManagedObject mcfdgMO = managedObjects.get(ManagedConnectionFactoryDeploymentGroup.class.getName());
+ if (mcfdgMO != null) {
+ ManagedProperty deployments = mcfdgMO.getProperty("deployments"); //$NON-NLS-1$
+ if (deployments.getMetaType().isCollection()) {
+ if (deployments.getValue() != null) {
+ MetaValue[] elements = ((CollectionValue)deployments.getValue()).getElements();
+ for (MetaValue element:elements) {
+ ManagedObject managed = (ManagedObject) ((GenericValue)element).getValue();
+
+ ConnectionFactoryMetaData data = group.getConnectionFactory("teiid-cf/"+managed.getName()); //$NON-NLS-1$
+ populateConnectionFactory(data, managed);
+ if (data != null) {
+ ManagedObject mo = this.mof.initManagedObject(data, ConnectionFactory.class, data.getName(), data.getName());
+ if (mo == null) {
+ throw new DeploymentException("could not create managed object"); //$NON-NLS-1$
+ }
+ managedObjects.put(mo.getName(), mo);
+ }
+ }
}
- managedObjects.put(mo.getName(), mo);
}
}
- }
+ }
+
+
public void setManagedObjectFactory(ManagedObjectFactory mof) {
this.mof = mof;
- }
-
- public void setSecurityHelper(SecurityHelper securityHelper) {
- this.securityHelper = securityHelper;
}
+
+ public void setVDBStatusChecker(VDBStatusChecker vdbChecker) {
+ this.vdbChecker = vdbChecker;
+ }
- public void setVDBRepository(VDBRepository repo) {
- this.vdbRepository = repo;
+ static ConnectionFactoryMetaData buildCF(ManagedConnectionFactoryDeploymentMetaData data) {
+ ConnectionFactoryMetaData c = new ConnectionFactoryMetaData();
+ // The name is prefixed here because, the Managed objects map overwrites this MO, with the main
+ // -ds.xml based MO, since they have same names.
+ c.setName("teiid-cf/"+data.getJndiName()); //$NON-NLS-1$
+ c.setRARFileName(data.getRarName());
+ c.setJNDIName("java:"+data.getJndiName()); //$NON-NLS-1$
+
+ List<ManagedConnectionFactoryPropertyMetaData> props = data.getManagedConnectionFactoryProperties();
+ for (ManagedConnectionFactoryPropertyMetaData p:props) {
+ c.addProperty(p.getName(), p.getValue());
+ }
+ return c;
}
- public void connectorAdded(String connectorName) {
- for (VDBMetaData vdb:this.vdbRepository.getVDBs()) {
- if (vdb.getStatus() == VDB.Status.ACTIVE || vdb.isPreview()) {
- continue;
- }
+ private void populateConnectionFactory(ConnectionFactoryMetaData data, ManagedObject managed) {
+ Map<String, ManagedProperty> props = managed.getProperties();
+
+ for (String key:props.keySet()) {
+ ManagedProperty mp = props.get(key);
- for (Model m:vdb.getModels()) {
- ModelMetaData model = (ModelMetaData)m;
- if (model.getErrors().isEmpty()) {
- continue;
+ MetaValue value = mp.getValue();
+ if (value != null) {
+ MetaType type = value.getMetaType();
+ if (type.isSimple()) {
+ data.addProperty(mp.getName(), ManagedUtil.stringValue(value));
}
-
- boolean inUse = false;
- for (String sourceName:model.getSourceNames()) {
- if (connectorName.equals(model.getSourceJndiName(sourceName))) {
- inUse = true;
- }
- }
-
- if (inUse) {
- model.clearErrors();
- for (String sourceName:model.getSourceNames()) {
- if (!connectorName.equals(model.getSourceJndiName(sourceName))) {
- try {
- InitialContext ic = new InitialContext();
- ic.lookup(model.getSourceJndiName(sourceName));
- } catch (NamingException e) {
- String msg = IntegrationPlugin.Util.getString("jndi_not_found", vdb.getName(), vdb.getVersion(), model.getSourceJndiName(sourceName), sourceName); //$NON-NLS-1$
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
- }
+ else if (type.isComposite()) {
+ if (value instanceof MapCompositeValueSupport) {
+ MapCompositeValueSupport map = (MapCompositeValueSupport)value;
+ if (key.equals("config-property") || key.equals("connection-properties") || key.equals("xa-datasource-properties")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ for (String subKey:map.getMetaType().keySet()) {
+ MetaValue subValue = map.get(subKey);
+ if (subValue.getMetaType().isSimple()) {
+ data.addProperty(subKey, ManagedUtil.stringValue(subValue));
+ }
+ }
}
- }
- }
- }
-
- boolean valid = true;
- for (Model m:vdb.getModels()) {
- ModelMetaData model = (ModelMetaData)m;
- if (!model.getErrors().isEmpty()) {
- valid = false;
- break;
- }
- }
-
- if (valid) {
- vdb.setStatus(VDB.Status.ACTIVE);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
- }
-
- }
- }
-
- public void connectorRemoved(String connectorName) {
- for (VDBMetaData vdb:this.vdbRepository.getVDBs()) {
- if (vdb.isPreview()) {
- continue;
- }
- for (Model m:vdb.getModels()) {
- ModelMetaData model = (ModelMetaData)m;
- for (String sourceName:model.getSourceNames()) {
- if (connectorName.equals(model.getSourceJndiName(sourceName))) {
- vdb.setStatus(VDB.Status.INACTIVE);
- String msg = IntegrationPlugin.Util.getString("jndi_not_found", vdb.getName(), vdb.getVersion(), model.getSourceJndiName(sourceName), sourceName); //$NON-NLS-1$
- model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
- LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("vdb_inactivated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
}
}
}
}
- }
-
+ }
}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryMetadataGroup.java (from rev 2076, trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryMetadataGroup.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectionFactoryMetadataGroup.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,49 @@
+/*
+ * 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.jboss.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.adminapi.impl.ConnectionFactoryMetaData;
+
+public class ConnectionFactoryMetadataGroup {
+ private List<ConnectionFactoryMetaData> mgrs = new ArrayList<ConnectionFactoryMetaData>();
+
+ public void addConnectionFactory(ConnectionFactoryMetaData cm) {
+ this.mgrs.add(cm);
+ }
+
+ public List<ConnectionFactoryMetaData> getConnectionFactories(){
+ return this.mgrs;
+ }
+
+ public ConnectionFactoryMetaData getConnectionFactory(String name) {
+ for(ConnectionFactoryMetaData cf: this.mgrs) {
+ if (cf.getName().equals(name)) {
+ return cf;
+ }
+ }
+ return null;
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -1,40 +0,0 @@
-/*
- * 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.jboss.deployers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-
-public class ConnectorManagerGroup {
- private List<ConnectorManager> mgrs = new ArrayList<ConnectorManager>();
-
- public void addConnectorManager(ConnectorManager cm) {
- this.mgrs.add(cm);
- }
-
- public List<ConnectorManager> getConnectorManagers(){
- return this.mgrs;
- }
-}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -314,7 +314,7 @@
}
@Override
- @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
+ @ManagementOperation(description="Terminate the transaction", impact=Impact.ReadOnly)
public void terminateTransaction(String xid) throws AdminException {
this.dqpCore.terminateTransaction(xid);
}
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorDeploymentTemplate.java (from rev 2071, trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorDeploymentTemplate.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorDeploymentTemplate.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,176 @@
+/*
+ * 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.templates.connector;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.DeploymentTemplate;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.jboss.ManagedUtil;
+import org.teiid.connector.api.Connector;
+import org.teiid.jboss.IntegrationPlugin;
+
+/**
+ * The connection factory template implementation. Here the idea is "targetTemplate" is the actual template we store
+ * the information under, which is the "connection factory" that container generates. However, we have got data
+ * passed under Teiid owned template. Now this classe'ss JOB is to transfer the properties from the source template
+ * into target template and write the target template.
+ *
+ * When the properties are written to target template, and source has a new property that is not defined in target, that
+ * property will be written as "config-property"
+ */
+public class ConnectorDeploymentTemplate implements DeploymentTemplate {
+
+ /** The deployment template info. */
+ private DeploymentTemplateInfo info;
+ private DeploymentTemplate targetTemplate;
+
+ /** The file suffix. */
+ private static final String FILE_SUFFIX = "-ds.xml";//$NON-NLS-1$
+
+
+ public String getDeploymentName(String deploymentBaseName) {
+ if (deploymentBaseName == null)
+ throw new IllegalArgumentException("Null base name.");//$NON-NLS-1$
+
+ if(deploymentBaseName.endsWith(FILE_SUFFIX) == false)
+ deploymentBaseName = deploymentBaseName + FILE_SUFFIX;
+
+ return deploymentBaseName;
+ }
+
+ public VirtualFile applyTemplate(DeploymentTemplateInfo sourceInfo) throws Exception {
+ try {
+
+ DeploymentTemplateInfo targetInfo = this.targetTemplate.getInfo();
+
+ // override these properties always.
+ targetInfo.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap(Connector.class.getName()));//$NON-NLS-1$
+ targetInfo.getProperties().get("rar-name").setValue(SimpleValueSupport.wrap(((ConnectorTemplateInfo)getInfo()).getRarName()));//$NON-NLS-1$
+
+
+ //config-properties list
+ List<String> connectorPropNames = RaXmlPropertyConverter.getPropertyNames(((ConnectorTemplateInfo)getInfo()).getRarName());
+ Map<String, String> configProps = ConnectorDeploymentTemplate.propertiesAsMap(sourceInfo, connectorPropNames.toArray(new String[connectorPropNames.size()]), info.getName());
+ configProps.put(ConnectorTemplateInfo.TEMPLATE_NAME, getInfo().getName());
+
+ // template properties specific to the template
+ Map<String, ManagedProperty> propertyMap = targetInfo.getProperties();
+
+ // walk through the supplied properties and assign properly to either template
+ // or config-properties.
+ for (String key:sourceInfo.getProperties().keySet()) {
+ ManagedProperty mp = propertyMap.get(key);
+
+ if (mp != null) {
+ // property found in target, so just add as value
+ MetaValue value = sourceInfo.getProperties().get(key).getValue();
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), value)) {
+ continue;
+ }
+
+ if (value != null) {
+ mp.setValue(value);
+ }
+ }
+ else {
+ // property not found in the target; add as "config-property"
+ mp = sourceInfo.getProperties().get(key);
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), mp.getValue())) {
+ continue;
+ }
+
+ if (mp.getValue() != null) {
+ configProps.put(key, ManagedUtil.stringValue(mp.getValue()));
+ configProps.put(key+".type", mp.getValue().getMetaType().getClassName());//$NON-NLS-1$
+ }
+ }
+ }
+
+ if (configProps.size() > 0) {
+ MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+ targetInfo.getProperties().get("config-property").setValue(metaValue);//$NON-NLS-1$
+ }
+ return this.targetTemplate.applyTemplate(targetInfo);
+
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public DeploymentTemplateInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(DeploymentTemplateInfo info) {
+ this.info = info;
+ }
+
+ public void setTargetTemplate(DeploymentTemplate target) {
+ this.targetTemplate = target;
+ }
+
+ /**
+ * Check to make sure supplied names are extracted from original list. If a mandatory property is missing fail
+ * @param values
+ * @param names
+ * @param templateName
+ * @return
+ * @throws Exception
+ */
+ static Map<String, String> propertiesAsMap(DeploymentTemplateInfo values, String[] names, String templateName) throws Exception {
+ Map<String, String> props = new HashMap<String, String>();
+
+ Map<String, ManagedProperty> sourceProperties = values.getProperties();
+
+ for (String name:names) {
+ ManagedProperty mp = sourceProperties.remove(name);
+ if (mp != null) {
+ if (mp.getValue() != null) {
+ props.put(name, ManagedUtil.stringValue(mp.getValue()));
+ }
+ else {
+ if (mp.isMandatory()) {
+ if( mp.getDefaultValue() != null) {
+ props.put(name, ManagedUtil.stringValue(mp.getDefaultValue()));
+ }
+ else {
+ throw new AdminComponentException(IntegrationPlugin.Util.getString("property_required_not_found", mp.getName(), templateName));//$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ return props;
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorDeploymentTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTemplateInfo.java (from rev 2071, trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTemplateInfo.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTemplateInfo.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,131 @@
+/*
+ * 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.templates.connector;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.teiid.adminapi.jboss.ExtendedPropertyInfo;
+import org.teiid.connector.api.Connector;
+
+/**
+ * This class some magic in it. First off all through the configuration it extends the
+ * NoTxConnectionFactoryTemplate. Then using the JMX adds the properties defined inside a connector
+ * RAR file's ra.xml dynamically the above template. The RAR file name is supplied in the "description"
+ * field of the configuration. Also, it uses the NoTxConnectionFactoryTemplate "applyTemplate" to write
+ * the custom properties that have been added thru JMX as "config-property" in the eventual "-ds.xml" file.
+ */
+public class ConnectorTemplateInfo extends BasicDeploymentTemplateInfo implements ExtendedPropertyInfo {
+
+ private static final long serialVersionUID = 9066758787789280783L;
+ private String rarName;
+ static final String TEMPLATE_NAME = "template-name"; //$NON-NLS-1$
+ private static final String TEIID_PROPERTY = "teiid-property"; //$NON-NLS-1$
+
+
+ public ConnectorTemplateInfo(String name, String description, Map<String, ManagedProperty> properties) {
+ super(name, description, properties);
+ }
+
+ public void start() {
+ populate();
+ }
+
+ @Override
+ public ConnectorTemplateInfo copy() {
+ ConnectorTemplateInfo copy = new ConnectorTemplateInfo(getName(), getDescription(), getProperties());
+ copy.setRarName(getRarName());
+ super.copy(copy);
+ copy.populate();
+
+ ManagedProperty mp = copy.getProperties().get("connection-definition");//$NON-NLS-1$
+ mp.setValue(SimpleValueSupport.wrap(Connector.class.getName()));
+
+ mp = copy.getProperties().get("rar-name");//$NON-NLS-1$
+ mp.setValue(SimpleValueSupport.wrap(getRarName()));
+ return copy;
+ }
+
+ private void populate() {
+ List<ManagedProperty> props = RaXmlPropertyConverter.getAsManagedProperties(getRarName());
+ for (ManagedProperty p:props) {
+ addProperty(p);
+ }
+ addProperty(buildTemplateProperty(getName()));
+ }
+
+ public String getRarName() {
+ return rarName;
+ }
+
+ public void setRarName(String rarName) {
+ this.rarName = rarName;
+ }
+
+ static ManagedProperty buildTemplateProperty(String name) {
+ ManagedProperty mp = buildProperty(TEMPLATE_NAME, SimpleMetaType.STRING, "Template Name", "The Name of the Teiid Connector Template", true, name);//$NON-NLS-1$ //$NON-NLS-2$
+ mp.setField(Fields.READ_ONLY, SimpleValueSupport.wrap(true));
+ return mp;
+ }
+
+ static ManagedProperty buildProperty(String name, SimpleMetaType type, String displayName, String description, boolean mandatory, String value) {
+ DefaultFieldsImpl fields = new DefaultFieldsImpl(name);
+ fields.setDescription(description);
+ fields.setField(Fields.MAPPED_NAME,displayName);
+ fields.setMetaType(type);
+ fields.setField(Fields.MANDATORY, SimpleValueSupport.wrap(mandatory));
+ fields.setField(TEIID_PROPERTY, SimpleValueSupport.wrap(true));
+ if (value != null) {
+ fields.setField(Fields.DEFAULT_VALUE, SimpleValueSupport.wrap(value));
+ }
+ return new ManagedPropertyImpl(fields);
+ }
+
+ static void markAsTeiidProperty(ManagedProperty mp) {
+ mp.setField(TEIID_PROPERTY, SimpleValueSupport.wrap(true));
+ }
+
+ @Override
+ public void updateProperty(String name, String value, ManagedComponent main) {
+ List<String> connectorNames = RaXmlPropertyConverter.getPropertyNames(getRarName());
+ if (connectorNames.contains(name)) {
+ updateManagedConnectionFactory(name, value, main);
+ }
+ }
+
+ static void updateManagedConnectionFactory(String name, String value, ManagedComponent mc) {
+ // Update the Container connection factory
+ MapCompositeValueSupport previousValues = (MapCompositeValueSupport)mc.getProperty("config-property").getValue(); //$NON-NLS-1$
+ if (previousValues != null) {
+ previousValues.put(name, SimpleValueSupport.wrap(value));
+ }
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTemplateInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -1,146 +0,0 @@
-/*
- * 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.templates.connector;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.deployers.spi.management.DeploymentTemplate;
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.virtual.VirtualFile;
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.jboss.ManagedUtil;
-
-/**
- * The connection factory template implementation. Here the idea is "targetTemplate" is the actual template we store
- * the information under, which is the "connection factory" that container generates. However, we have got data
- * passed under Teiid owned template. Now this classe'ss JOB is to transfer the properties from the source template
- * into target template and write the target template.
- *
- * When the properties are written to target template, and source has a new property that is not defined in target, that
- * property will be written as "config-property"
- */
-public class ConnectorTypeTemplate implements DeploymentTemplate {
-
- /** The deployment template info. */
- private DeploymentTemplateInfo info;
- private DeploymentTemplate targetTemplate;
-
- /** The file suffix. */
- private static final String FILE_SUFFIX = "-ds.xml";
-
-
- public String getDeploymentName(String deploymentBaseName) {
- if (deploymentBaseName == null)
- throw new IllegalArgumentException("Null base name.");
-
- if(deploymentBaseName.endsWith(FILE_SUFFIX) == false)
- deploymentBaseName = deploymentBaseName + FILE_SUFFIX;
-
- return deploymentBaseName;
- }
-
- public VirtualFile applyTemplate(DeploymentTemplateInfo sourceInfo) throws Exception {
- try {
-
- ManagedProperty rar = sourceInfo.getProperties().get("rar-name");
- String rarName = ManagedUtil.stringValue(rar.getValue());
- if (!isValidRar(rarName)) {
- throw new AdminProcessingException("Invalid RAR specified; please supply correct RAR file. "+rarName);
- }
-
- DeploymentTemplateInfo targetInfo = this.targetTemplate.getInfo();
-
- // override these properties always.
- targetInfo.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
-
- //config-properties list
- Map<String, String> configProps = new HashMap<String, String>();
-
- // template properties specific to the template
- Map<String, ManagedProperty> propertyMap = targetInfo.getProperties();
-
- // walk through the supplied properties and assign properly to either template
- // or config-properties.
- for (String key:sourceInfo.getProperties().keySet()) {
- ManagedProperty mp = propertyMap.get(key);
-
- if (mp != null) {
- // property found in target, so just add as value
- MetaValue value = sourceInfo.getProperties().get(key).getValue();
- if (ManagedUtil.sameValue(mp.getDefaultValue(), value)) {
- continue;
- }
-
- if (value != null) {
- mp.setValue(value);
- }
- }
- else {
- // property not found in the target; add as "config-property"
- mp = sourceInfo.getProperties().get(key);
- if (ManagedUtil.sameValue(mp.getDefaultValue(), mp.getValue())) {
- continue;
- }
-
- if (mp.getValue() != null) {
- configProps.put(key, ManagedUtil.stringValue(mp.getValue()));
- configProps.put(key+".type", mp.getValue().getMetaType().getClassName());
- }
- }
- }
-
- if (configProps.size() > 0) {
- MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
- targetInfo.getProperties().get("config-property").setValue(metaValue);
- }
- return this.targetTemplate.applyTemplate(targetInfo);
-
- } catch (NoSuchDeploymentException e) {
- throw new AdminComponentException(e.getMessage(), e);
- } catch(Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- private boolean isValidRar(String rarName) {
- return rarName != null;
- }
-
- @Override
- public DeploymentTemplateInfo getInfo() {
- return info;
- }
-
- public void setInfo(DeploymentTemplateInfo info) {
- this.info = info;
- }
-
- public void setTargetTemplate(DeploymentTemplate target) {
- this.targetTemplate = target;
- }
-}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -1,138 +0,0 @@
-/*
- * 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.templates.connector;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.resource.metadata.ConfigPropertyMetaData;
-import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
-import org.jboss.resource.metadata.ConnectorMetaData;
-import org.jboss.resource.metadata.DescriptionMetaData;
-import org.teiid.adminapi.jboss.ManagedUtil;
-
-/**
- * This class some magic in it. First off all through the configuration it extends the
- * NoTxConnectionFactoryTemplate. Then using the JMX adds the properties defined inside a connector
- * RAR file's ra.xml dynamically the above template. The RAR file name is supplied in the "description"
- * field of the configuration. Also, it uses the NoTxConnectionFactoryTemplate "applyTemplate" to write
- * the custom properties that have been added thru JMX as "config-property" in the eventual "-ds.xml" file.
- */
-public class ConnectorTypeTemplateInfo extends BasicDeploymentTemplateInfo {
-
- private static final long serialVersionUID = 9066758787789280783L;
-
- public ConnectorTypeTemplateInfo(String arg0, String arg1, Map<String, ManagedProperty> arg2) {
- super(arg0, arg1, arg2);
- }
-
- public void start() {
- populate();
- }
-
- @Override
- public ConnectorTypeTemplateInfo copy() {
- ConnectorTypeTemplateInfo copy = new ConnectorTypeTemplateInfo(getName(), getDescription(), getProperties());
- super.copy(copy);
- copy.populate();
- return copy;
- }
-
-
- private void populate() {
- try {
- MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
- ObjectName on = new ObjectName("jboss.jca:service=RARDeployment,name='"+getName()+".rar'");
- ConnectorMetaData obj = (ConnectorMetaData)server.getAttribute(on, "MetaData");
- ConnectionDefinitionMetaData metadata = obj.getConnectionDefinition("org.teiid.connector.api.Connector");
- Collection<ConfigPropertyMetaData> props = metadata.getProperties();
- for (ConfigPropertyMetaData p:props) {
- addConnectorProperty(p);
- }
- } catch (MalformedObjectNameException e) {
- //ignore
- } catch (AttributeNotFoundException e) {
- //ignore
- } catch (InstanceNotFoundException e) {
- //ignore
- } catch (MBeanException e) {
- //ignore
- } catch (ReflectionException e) {
- //ignore
- }
- }
-
- private void addConnectorProperty(ConfigPropertyMetaData metadata) {
- SimpleMetaType metaType = SimpleMetaType.resolve(metadata.getType());
-
- DefaultFieldsImpl fields = new DefaultFieldsImpl(metadata.getName());
- DescriptionMetaData descMetadata = metadata.getDescription();
- String description = descMetadata.getDescription();
- if (description != null) {
- ExtendedPropertyMetadata extended = new ExtendedPropertyMetadata(description);
- if (extended.getDescription() != null) {
- fields.setDescription(description);
- }
-
- if (extended.getDisplayName() != null) {
- fields.setField(Fields.MAPPED_NAME, extended.getDisplayName());
- }
-
- if (extended.getAllowed() != null) {
- HashSet<MetaValue> values = new HashSet<MetaValue>();
- for (String value:extended.getAllowed()) {
- values.add(ManagedUtil.wrap(SimpleMetaType.STRING, value));
- }
- fields.setField(Fields.LEGAL_VALUES, values);
- }
- fields.setField(Fields.MANDATORY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isRequired())));
- fields.setField(Fields.READ_ONLY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(!extended.isEditable())));
- fields.setField("advanced", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isAdvanced())));
- fields.setField("masked", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isMasked())));
- }
-
- fields.setMetaType(metaType);
- if (metadata.getValue() != null && metadata.getValue().trim().length() > 0) {
- fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, metadata.getValue()));
- }
-
- ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
- addProperty(dsTypeMP);
- }
-}
Added: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,137 @@
+/*
+ * 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.templates.connector;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.resource.metadata.ConfigPropertyMetaData;
+import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
+import org.jboss.resource.metadata.ConnectorMetaData;
+import org.jboss.resource.metadata.DescriptionMetaData;
+import org.teiid.adminapi.jboss.ManagedUtil;
+import org.teiid.connector.api.Connector;
+
+public class RaXmlPropertyConverter {
+
+
+ public static List<String> getPropertyNames(String rarName){
+ ArrayList<String> names = new ArrayList<String>();
+ Collection<ConfigPropertyMetaData> props = getRarProperties(rarName);
+ if (props != null) {
+ for (ConfigPropertyMetaData p:props) {
+ names.add(p.getName());
+ }
+ }
+ return names;
+ }
+
+ public static List<ManagedProperty> getAsManagedProperties(String rarName){
+ ArrayList<ManagedProperty> managedProperties = new ArrayList<ManagedProperty>();
+ Collection<ConfigPropertyMetaData> props = getRarProperties(rarName);
+ if (props != null) {
+ for (ConfigPropertyMetaData p:props) {
+ managedProperties.add(createConnectorProperty(p));
+ }
+ }
+ return managedProperties;
+ }
+
+
+ private static Collection<ConfigPropertyMetaData> getRarProperties(String rarName){
+ try {
+ MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
+ ObjectName on = new ObjectName("jboss.jca:service=RARDeployment,name='"+rarName+"'");//$NON-NLS-1$ //$NON-NLS-2$
+ ConnectorMetaData obj = (ConnectorMetaData)server.getAttribute(on, "MetaData");//$NON-NLS-1$
+ ConnectionDefinitionMetaData metadata = obj.getConnectionDefinition(Connector.class.getName());
+ return metadata.getProperties();
+ } catch (MalformedObjectNameException e) {
+ //ignore
+ } catch (AttributeNotFoundException e) {
+ //ignore
+ } catch (InstanceNotFoundException e) {
+ //ignore
+ } catch (MBeanException e) {
+ //ignore
+ } catch (ReflectionException e) {
+ //ignore
+ }
+ return null;
+ }
+
+ private static ManagedProperty createConnectorProperty(ConfigPropertyMetaData metadata) {
+ SimpleMetaType metaType = SimpleMetaType.resolve(metadata.getType());
+
+ DefaultFieldsImpl fields = new DefaultFieldsImpl(metadata.getName());
+ DescriptionMetaData descMetadata = metadata.getDescription();
+ String description = descMetadata.getDescription();
+ if (description != null) {
+ ExtendedPropertyMetadata extended = new ExtendedPropertyMetadata(description);
+ if (extended.getDescription() != null) {
+ fields.setDescription(description);
+ }
+
+ if (extended.getDisplayName() != null) {
+ fields.setField(Fields.MAPPED_NAME, extended.getDisplayName());
+ }
+
+ if (extended.getAllowed() != null) {
+ HashSet<MetaValue> values = new HashSet<MetaValue>();
+ for (String value:extended.getAllowed()) {
+ values.add(ManagedUtil.wrap(SimpleMetaType.STRING, value));
+ }
+ fields.setField(Fields.LEGAL_VALUES, values);
+ }
+ fields.setField(Fields.MANDATORY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isRequired())));
+ fields.setField(Fields.READ_ONLY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(!extended.isEditable())));
+ fields.setField("advanced", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isAdvanced())));//$NON-NLS-1$
+ fields.setField("masked", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isMasked())));//$NON-NLS-1$
+ fields.setField("teiid-property", SimpleValueSupport.wrap(true)); //$NON-NLS-1$
+ }
+
+ fields.setMetaType(metaType);
+ if (metadata.getValue() != null && metadata.getValue().trim().length() > 0) {
+ fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, metadata.getValue()));
+ }
+
+ ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
+ return dsTypeMP;
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,63 @@
+/*
+ * 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.templates.connector;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+
+
+public class XaJdbcConnectorTemplate extends org.jboss.resource.deployers.management.DsDataSourceTemplate {
+
+ private static final long serialVersionUID = 1607932913015949359L;
+
+ @Override
+ public VirtualFile applyTemplate(DeploymentTemplateInfo values) throws Exception {
+
+ XaJdbcConnectorTemplateInfo info = (XaJdbcConnectorTemplateInfo)getInfo();
+
+ // combine connection factory specific properties.
+ List<String> connectorPropNames = RaXmlPropertyConverter.getPropertyNames(info.getRarName());
+ Map<String, String> props = ConnectorDeploymentTemplate.propertiesAsMap(values, connectorPropNames.toArray(new String[connectorPropNames.size()]), info.getName());
+ props.put(ConnectorTemplateInfo.TEMPLATE_NAME, getInfo().getName());
+ values.getProperties().get("config-property").setValue(ManagedUtil.compositeValueMap(props));//$NON-NLS-1$
+
+ // combine data source specific properties
+ props = ConnectorDeploymentTemplate.propertiesAsMap(values, XaJdbcConnectorTemplateInfo.EXTENDED_DS_PROPERTIES, info.getName());
+
+ ManagedProperty mp = values.getProperties().remove(XaJdbcConnectorTemplateInfo.ADDITIONAL_DS_PROPS);
+ if (mp != null && mp.getValue() != null) {
+ XaJdbcConnectorTemplateInfo.parseProperties(ManagedUtil.stringValue(mp.getValue()), props);
+ }
+
+ values.getProperties().get("xa-datasource-properties").setValue(ManagedUtil.compositeValueMap(props));//$NON-NLS-1$
+
+ return super.applyTemplate(values);
+ }
+
+
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,155 @@
+/*
+ * 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.templates.connector;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.resource.deployers.management.DsDataSourceTemplateInfo;
+import org.teiid.adminapi.jboss.ExtendedPropertyInfo;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+/**
+ * This template is specific to XA data source combined with Teiid's JDBC connector.
+ */
+public class XaJdbcConnectorTemplateInfo extends DsDataSourceTemplateInfo implements ExtendedPropertyInfo {
+
+ private static final long serialVersionUID = 9066758787789280783L;
+ static final String SERVER_NAME = "ServerName";//$NON-NLS-1$
+ static final String PORT_NUMBER = "PortNumber";//$NON-NLS-1$
+ static final String DATABASE_NAME = "DatabaseName";//$NON-NLS-1$
+ static final String ADDITIONAL_DS_PROPS = "addtional-ds-properties";//$NON-NLS-1$
+
+ static final String[] EXTENDED_DS_PROPERTIES = {SERVER_NAME, PORT_NUMBER,DATABASE_NAME};
+
+ private String rarName;
+
+ public XaJdbcConnectorTemplateInfo(String name, String description, Map<String, ManagedProperty> properties) {
+ super(name, description, properties);
+ }
+
+ public void start() {
+ populate();
+ }
+
+ @Override
+ public XaJdbcConnectorTemplateInfo copy() {
+ XaJdbcConnectorTemplateInfo copy = new XaJdbcConnectorTemplateInfo(getName(), getDescription(), getProperties());
+ copy.setRarName(getRarName());
+ super.copy(copy);
+ copy.populate();
+ return copy;
+ }
+
+ private void populate() {
+ super.start();
+ List<ManagedProperty> props = RaXmlPropertyConverter.getAsManagedProperties(getRarName());
+ for (ManagedProperty p:props) {
+ addProperty(p);
+ }
+
+ ManagedProperty mp = this.getProperties().get("connection-definition");//$NON-NLS-1$
+ mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "javax.sql.DataSource"));//$NON-NLS-1$
+
+ mp = this.getProperties().get("dsType");//$NON-NLS-1$
+ mp.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, "xa-datasource"));//$NON-NLS-1$
+
+
+ ManagedPropertyImpl dsTypeMP = buildConfigProperty();
+ addProperty(dsTypeMP);
+
+ addProperty(ConnectorTemplateInfo.buildTemplateProperty(getName()));
+
+ ConnectorTemplateInfo.markAsTeiidProperty(this.getProperties().get("user-name")); //$NON-NLS-1$
+ ConnectorTemplateInfo.markAsTeiidProperty(this.getProperties().get("password"));//$NON-NLS-1$
+ addProperty(ConnectorTemplateInfo.buildProperty(DATABASE_NAME, SimpleMetaType.STRING,"Database Name","Database Name", false, null));//$NON-NLS-1$ //$NON-NLS-2$
+ addProperty(ConnectorTemplateInfo.buildProperty(PORT_NUMBER, SimpleMetaType.INTEGER,"Database Port", "Database Port",false, null));//$NON-NLS-1$ //$NON-NLS-2$
+ addProperty(ConnectorTemplateInfo.buildProperty(SERVER_NAME, SimpleMetaType.STRING,"Database Server Name", "Database Server Name", false, null));//$NON-NLS-1$ //$NON-NLS-2$
+ addProperty(ConnectorTemplateInfo.buildProperty(ADDITIONAL_DS_PROPS, SimpleMetaType.STRING,"Addtional Data Source Properties", "Addtional Data source properties. (comma separated name value pairs)", false, null));//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ static ManagedPropertyImpl buildConfigProperty() {
+ DefaultFieldsImpl fields = new DefaultFieldsImpl("config-property");//$NON-NLS-1$
+ fields.setDescription("The config-property type"); //$NON-NLS-1$
+ fields.setMetaType(new MapCompositeMetaType (SimpleMetaType.STRING));
+ ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
+ return dsTypeMP;
+ }
+
+
+ public String getRarName() {
+ return rarName;
+ }
+
+ public void setRarName(String rarName) {
+ this.rarName = rarName;
+ }
+
+ @Override
+ public void updateProperty(String name, String value, ManagedComponent main) {
+ List<String> connectorNames = RaXmlPropertyConverter.getPropertyNames(getRarName());
+ if (connectorNames.contains(name)) {
+ ConnectorTemplateInfo.updateManagedConnectionFactory(name, value, main);
+ //ConnectorTemplateInfo.updateConnectionFactory(name, value, cf);
+ }
+ else if (name.equals(DATABASE_NAME)||name.equals(PORT_NUMBER)||name.equals(SERVER_NAME)||name.equals(ADDITIONAL_DS_PROPS)) {
+ Map<String, String> map = new HashMap<String, String>();
+
+ if (name.equals(ADDITIONAL_DS_PROPS)) {
+ parseProperties(value, map);
+ }
+ else {
+ map.put(name, value);
+ }
+
+ // update the container managed object.
+ MapCompositeValueSupport previousValues = (MapCompositeValueSupport)main.getProperty("xa-datasource-properties").getValue(); //$NON-NLS-1$
+ if (previousValues != null) {
+ for (String key:map.keySet()) {
+ previousValues.put(key, SimpleValueSupport.wrap(map.get(key)));
+ }
+ }
+ }
+ }
+
+ static void parseProperties(String str, Map<String, String> props) {
+ str = str.trim();
+ StringTokenizer st = new StringTokenizer(str, ","); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String property = st.nextToken();
+ int index = property.indexOf('=');
+ if (index != -1 && property.length() > (index+1)) {
+ props.put(property.substring(0, index).trim(), property.substring(index+1).trim());
+ }
+ }
+ }
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/XaJdbcConnectorTemplateInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-04-27 22:25:00 UTC (rev 2084)
@@ -26,7 +26,7 @@
engine_stopped=Teiid Engine stopped {0}
admin_connection_closed=Teiid admin connection is already closed.
connector_binding_exists=Connection factory with name "{0}" already exists.
-failed_to_connector_deployer=Failed to find deployer name of the connector. Can not start!
+failed_to_find_connector=Failed to find connector {0}. Can not start!
failed_to_start_connector=Failed to start Connection factory = {0}
failed_to_stop_connector=Failed to start Connection factory = {0}
bad_vdb_extension=The extension of the file name must be either ".vdb" for designer vdb or "xxx-vdb.xml" for dynamic VDBs
@@ -39,15 +39,15 @@
connectionfactory_not_found=Connection factory {0} not found in the configuration.
datasource_not_found=Datasource {0} not found in the configuration.
connector_not_found=Connector {0} not found in the configuration.
-
sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
connector_started= Teiid connector {0} started
connector_stopped=Teiid connector {0} stopped
-vdb_activated={0}.{1} status has been changed to active
-vdb_inactivated={0}.{1} status has been changed to inactive. Check the connector mappings!
-jndi_not_found=For {0}.{1} VDB, JNDI resource "{2}" not found for Source Name "{3}"
+
no_operation=No operation found with given name = {0}
failed_to_remove=Failed to remove the deployment
distibute_failed={0} distribute failed.
deployment_start_failed={0} deployment start failed
-failed_to_convert=Failed to convert from String value to {0} type
\ No newline at end of file
+failed_to_convert=Failed to convert from String value to {0} type
+property_required_not_found="{0}" is required for the connector type "{1}", but was not supplied; There is no default value either.
+invalid_class={0} invalid type of class specified. Must be of type org.teiid.connector.api.ConnectorEnvironment
+class_not_found=Class {0} not found.
\ No newline at end of file
Added: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java (rev 0)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -0,0 +1,115 @@
+/*
+ * 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.deployers;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.runtime.RuntimePlugin;
+
+import com.metamatrix.common.log.LogConstants;
+import com.metamatrix.common.log.LogManager;
+
+public class VDBStatusChecker {
+ private VDBRepository vdbRepository;
+
+ public void connectorAdded(String connectorName) {
+ for (VDBMetaData vdb:this.vdbRepository.getVDBs()) {
+ if (vdb.getStatus() == VDB.Status.ACTIVE || vdb.isPreview()) {
+ continue;
+ }
+
+ for (Model m:vdb.getModels()) {
+ ModelMetaData model = (ModelMetaData)m;
+ if (model.getErrors().isEmpty()) {
+ continue;
+ }
+
+ boolean inUse = false;
+ for (String sourceName:model.getSourceNames()) {
+ if (connectorName.equals(model.getSourceJndiName(sourceName))) {
+ inUse = true;
+ }
+ }
+
+ if (inUse) {
+ model.clearErrors();
+ for (String sourceName:model.getSourceNames()) {
+ if (!connectorName.equals(model.getSourceJndiName(sourceName))) {
+ try {
+ InitialContext ic = new InitialContext();
+ ic.lookup(model.getSourceJndiName(sourceName));
+ } catch (NamingException e) {
+ String msg = RuntimePlugin.Util.getString("jndi_not_found", vdb.getName(), vdb.getVersion(), model.getSourceJndiName(sourceName), sourceName); //$NON-NLS-1$
+ model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
+ }
+ }
+ }
+ }
+ }
+
+ boolean valid = true;
+ for (Model m:vdb.getModels()) {
+ ModelMetaData model = (ModelMetaData)m;
+ if (!model.getErrors().isEmpty()) {
+ valid = false;
+ break;
+ }
+ }
+
+ if (valid) {
+ vdb.setStatus(VDB.Status.ACTIVE);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_activated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+
+ }
+ }
+
+ public void connectorRemoved(String connectorName) {
+ for (VDBMetaData vdb:this.vdbRepository.getVDBs()) {
+ if (vdb.isPreview()) {
+ continue;
+ }
+ for (Model m:vdb.getModels()) {
+ ModelMetaData model = (ModelMetaData)m;
+ for (String sourceName:model.getSourceNames()) {
+ if (connectorName.equals(model.getSourceJndiName(sourceName))) {
+ vdb.setStatus(VDB.Status.INACTIVE);
+ String msg = RuntimePlugin.Util.getString("jndi_not_found", vdb.getName(), vdb.getVersion(), model.getSourceJndiName(sourceName), sourceName); //$NON-NLS-1$
+ model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_inactivated",vdb.getName(), vdb.getVersion())); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+
+ public void setVDBRepository(VDBRepository repo) {
+ this.vdbRepository = repo;
+ }
+}
Property changes on: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2010-04-27 22:25:00 UTC (rev 2084)
@@ -294,4 +294,7 @@
failed_to_deployed=Failed to deploy {0}
invalid_udf_file=No "path" information found to load the FUNCTION model {0}; FUNCTION model must have path information.
failed_matadata_load=Failed to load metadata for VDB {0}.{1}
-vdb_not_found=VDB {0}.{1} not found deployed.
\ No newline at end of file
+vdb_not_found=VDB {0}.{1} not found deployed.
+jndi_not_found=For {0}.{1} VDB, JNDI resource "{2}" not found for Source Name "{3}"
+vdb_activated={0}.{1} status has been changed to active
+vdb_inactivated={0}.{1} status has been changed to inactive. Check the connector mappings!
Modified: trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-04-27 17:56:40 UTC (rev 2083)
+++ trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-04-27 22:25:00 UTC (rev 2084)
@@ -70,7 +70,44 @@
admin.close();
}
- @Test public void testConnectorBinding() throws Exception {
+ @Test public void testLoopbackConnectorBinding() throws Exception {
+ ConnectionFactory binding = admin.getConnectionFactory("loopy"); //$NON-NLS-1$
+
+ if (binding != null) {
+ admin.deleteConnectionFactory("loopy"); //$NON-NLS-1$
+ }
+
+ Properties p = new Properties();
+ p.setProperty("jndi-name", "loopy"); //$NON-NLS-1$ //$NON-NLS-2$
+ p.setProperty("CapabilitiesClass", "org.teiid.connector.jdbc.loopback.LoopbackCapabilities"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ ConnectionFactory cf = admin.addConnectionFactory("loopy","connector-loopback-7.0.0-SNAPSHOT", p); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println(cf.getProperties());
+
+// admin.setConnectionFactoryProperty("loopy", "CapabilitiesClass", "org.teiid.connector.BasicCapabilities");
+// cf = admin.getConnectionFactory("loopy");
+// System.out.println(cf.getProperties());
+ }
+
+ @Test public void testLoopbackUpdate() throws Exception {
+ ConnectionFactory cf = admin.getConnectionFactory("loopy"); //$NON-NLS-1$
+ System.out.println(cf.getProperties());
+
+ admin.setConnectionFactoryProperty("loopy", "CapabilitiesClass", "org.teiid.connector.LoopyCapabilities");
+ cf = admin.getConnectionFactory("loopy");
+ System.out.println(cf.getProperties());
+ }
+
+ @Test public void testGetConnectorFactories() throws Exception {
+ Collection<ConnectionFactory> cfs = admin.getConnectionFactories();
+ for(ConnectionFactory cf:cfs) {
+ System.out.println(cf.getName());
+ }
+ ConnectionFactory cf = admin.getConnectionFactory("products-cf"); //$NON-NLS-1$
+ System.out.println(cf.getName());
+ }
+
+ @Test public void testDSConnectorBinding() throws Exception {
ConnectionFactory binding = admin.getConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
if (binding != null) {
@@ -79,33 +116,40 @@
Properties p = new Properties();
p.setProperty("jndi-name", "test-mysql-cb"); //$NON-NLS-1$ //$NON-NLS-2$
- p.setProperty("rar-name", "connector-jdbc-7.0.0-SNAPSHOT.rar"); //$NON-NLS-1$ //$NON-NLS-2$
- p.setProperty("CapabilitiesClass", "org.teiid.connector.jdbc.derby.DerbyCapabilities"); //$NON-NLS-1$ //$NON-NLS-2$
+ p.setProperty("CapabilitiesClass", "org.teiid.connector.jdbc.mysql.MySQL5Capabilities"); //$NON-NLS-1$ //$NON-NLS-2$
p.setProperty("XaCapable", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- p.setProperty("SourceJNDIName", "java:DerbyDS"); //$NON-NLS-1$ //$NON-NLS-2$
- admin.addConnectionFactory("test-mysql-cb","connector-jdbc-7.0.0-SNAPSHOT", p); //$NON-NLS-1$ //$NON-NLS-2$
+
+ p.setProperty("DatabaseName", "txntest");
+ p.setProperty("PortNumber", "3306");
+ p.setProperty("ServerName", "localhost");
+ p.setProperty("addtional-ds-properties", "foo=bar, t= x");
+ p.setProperty("user-name", "rareddy");
+ p.setProperty("password", "mm");
+ p.setProperty("xa-datasource-class", "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
+ admin.addConnectionFactory("test-mysql-cb","connector-jdbc-xa-7.0.0-SNAPSHOT", p); //$NON-NLS-1$ //$NON-NLS-2$
+
binding = admin.getConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
assertNotNull(binding);
- assertEquals("java:DerbyDS", binding.getPropertyValue("SourceJNDIName")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("org.teiid.connector.jdbc.mysql.MySQL5Capabilities", binding.getPropertyValue("CapabilitiesClass")); //$NON-NLS-1$ //$NON-NLS-2$
admin.stopConnectionFactory("test-mysql-cb");
admin.startConnectionFactory("test-mysql-cb");
- admin.setConnectionFactoryProperty("test-mysql-cb", "SourceJNDIName", "DummyDS"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ admin.setConnectionFactoryProperty("test-mysql-cb", "XaCapable", "false"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
binding = admin.getConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
- assertEquals("DummyDS", binding.getPropertyValue("SourceJNDIName")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("false", binding.getPropertyValue("XaCapable")); //$NON-NLS-1$ //$NON-NLS-2$
- admin.deleteConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
+ //admin.deleteConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
- binding = admin.getConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
+ //binding = admin.getConnectionFactory("test-mysql-cb"); //$NON-NLS-1$
- assertNull(binding);
+ //assertNull(binding);
}
@Test public void testVDBDeploy() throws Exception {
@@ -245,27 +289,13 @@
}
@Test
- public void testWorkmanagerStats() throws Exception {
- WorkerPoolStatistics stats = admin.getWorkManagerStats("runtime"); //$NON-NLS-1$
- System.out.println(stats);
- assertNotNull(stats);
- }
-
- @Test
- public void testConnectionPool() throws Exception {
- ConnectionPoolStatistics stats = admin.getConnectionFactoryStats("mysql-connector-binding"); //$NON-NLS-1$
- System.out.println(stats);
- assertNotNull(stats);
- }
-
- @Test
public void testConnectorTypeProperties() throws Exception {
- Collection<PropertyDefinition> defs = admin.getConnectorPropertyDefinitions("connector-jdbc-7.0.0-SNAPSHOT"); //$NON-NLS-1$
+ Collection<PropertyDefinition> defs = admin.getConnectorTemplatePropertyDefinitions("connector-jdbc-xa-7.0.0-SNAPSHOT"); //$NON-NLS-1$
for (PropertyDefinition pd:defs) {
- System.out.println(pd.getName());
+ System.out.println(pd.getName()+":"+pd.getPropertyTypeClassName());
if (pd.getName().equals("ExtensionTranslationClassName")) { //$NON-NLS-1$
assertEquals("Extension SQL Translation Class", pd.getDisplayName()); //$NON-NLS-1$
- assertEquals(true, pd.isAdvanced());
+ assertEquals(false, pd.isAdvanced());
assertEquals(true, pd.isRequired());
assertEquals(false, pd.isMasked());
assertEquals(true, pd.isModifiable());
@@ -288,36 +318,30 @@
@Test
public void testConnectorTypes() throws Exception {
- Set<String> defs = admin.getConnectorNames();
- assertTrue(defs.contains("connector-salesforce-7.0.0-SNAPSHOT")); //$NON-NLS-1$
- assertTrue(defs.contains("connector-jdbc-7.0.0-SNAPSHOT")); //$NON-NLS-1$
- assertTrue(defs.contains("connector-text-7.0.0-SNAPSHOT")); //$NON-NLS-1$
- assertTrue(defs.contains("connector-loopback-7.0.0-SNAPSHOT")); //$NON-NLS-1$
- assertTrue(defs.contains("connector-ldap-7.0.0-SNAPSHOT")); //$NON-NLS-1$
+ Set<String> defs = admin.getConnectorTemplateNames();
+// assertTrue(defs.contains("connector-salesforce-7.0.0-SNAPSHOT")); //$NON-NLS-1$
+// assertTrue(defs.contains("connector-jdbc-7.0.0-SNAPSHOT")); //$NON-NLS-1$
+// assertTrue(defs.contains("connector-text-7.0.0-SNAPSHOT")); //$NON-NLS-1$
+// assertTrue(defs.contains("connector-loopback-7.0.0-SNAPSHOT")); //$NON-NLS-1$
+// assertTrue(defs.contains("connector-ldap-7.0.0-SNAPSHOT")); //$NON-NLS-1$
System.out.println(defs);
}
+
@Test
- public void testPropertyDefsForDS() throws Exception {
- Collection<PropertyDefinition> defs = admin.getDataSourcePropertyDefinitions();
- System.out.println(defs);
- assertNotNull(defs);
- assertTrue(defs.size() > 1);
- }
-
- @Test
public void testConnectorAddDelete() throws Exception{
File f = new File(UnitTestUtil.getTestDataPath()+"/connector-loopback.rar"); //$NON-NLS-1$
FileInputStream fis = new FileInputStream(f);
admin.addConnector("connector-loopy.rar", fis); //$NON-NLS-1$
fis.close();
- Set<String> names = admin.getConnectorNames();
- assertTrue(names.contains("connector-loopy.rar")); //$NON-NLS-1$
+ Set<String> names = admin.getConnectorTemplateNames();
+ System.out.println(names);
+ assertTrue(names.contains("connector-loopy")); //$NON-NLS-1$
admin.deleteConnector("connector-loopy.rar"); //$NON-NLS-1$
- names = admin.getConnectorNames();
+ names = admin.getConnectorTemplateNames();
//assertTrue(!names.contains("connector-loopy")); //$NON-NLS-1$
}
@@ -390,11 +414,4 @@
admin.removeRoleFromDataPolicy("TransactionsRevisited", 1, "policy1", "FOO");
}
- @Test public void testExportConnectionFactory() throws Exception {
- ObjectConverterUtil.write(admin.exportConnectionFactory("products-cf"), "cf.xml");
- }
-
- @Test public void testExportDataSource() throws Exception {
- ObjectConverterUtil.write(admin.exportDataSource("CustomersDS"), "ds.xml");
- }
}
14 years, 8 months
teiid SVN: r2083 - in trunk: engine/src/main/java/com/metamatrix/query/processor/xml and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-04-27 13:56:40 -0400 (Tue, 27 Apr 2010)
New Revision: 2083
Removed:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/XAJDBCPropertyNames.java
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/DocumentInProgress.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/FakeXMLProcessorEnvironment.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestAddNodeInstruction.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestSAXDocumentInProgress.java
Log:
TEIID-913 cutting out intermediate buffering of results with direct writes to a filestore
Deleted: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/XAJDBCPropertyNames.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/XAJDBCPropertyNames.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/XAJDBCPropertyNames.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Date: Jan 23, 2003
- * Time: 5:38:40 PM
- */
-package org.teiid.connector.jdbc;
-
-/**
- * XAJDBCPropertyNames.
- */
-public class XAJDBCPropertyNames {
-
- /** An XA Transaction-related property. The <code>XADataSource</code>'s unique
- * resource name for the underlying <code>ConnectionPoolDataSource</code> object.
- */
- public static final String DATASOURCE_NAME = "dataSourceName"; //$NON-NLS-1$
-
- public static final String PORT_NUMBER = "portNumber";//$NON-NLS-1$
-
- public static final String SERVER_NAME = "serverName";//$NON-NLS-1$
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/DocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/DocumentInProgress.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/DocumentInProgress.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -25,6 +25,7 @@
import org.xml.sax.SAXException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.FileStore;
/**
* <p>This represents a document in construction. It maintains a reference
@@ -110,13 +111,6 @@
*/
public void markAsFinished() throws MetaMatrixComponentException;
- /**
- * Retrieve the next chunk of document.
- * @param sizeInBytes size of the chunk in bytes. No limit if it is 0.
- * @return character array containing the specfied number of characters, or less if
- * it has reached the end of the document. Return null if there is not enough characters
- * and it has not reached the end of the document.
- */
- public char[] getNextChunk(int sizeInBytes);
-
+ public FileStore getFileStore();
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -84,7 +84,7 @@
// program stack (don't want to start a new doc in the middle of
// recursive processing)
if (!env.isRecursiveProgramInStack()) {
- DocumentInProgress doc = new SAXDocumentInProgress();
+ DocumentInProgress doc = new SAXDocumentInProgress(env.getBufferManager().createFileStore("xml")); //$NON-NLS-1$
//DocumentInProgress doc = new JDOMDocumentInProgress();
env.setDocumentInProgress(doc);
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -22,7 +22,7 @@
package com.metamatrix.query.processor.xml;
-import java.io.CharArrayWriter;
+import java.io.BufferedOutputStream;
import java.util.Iterator;
import javax.xml.transform.OutputKeys;
@@ -36,6 +36,7 @@
import org.xml.sax.SAXException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.query.mapping.xml.MappingNodeConstants;
@@ -52,17 +53,17 @@
private boolean finished;
private String documentEncoding = MappingNodeConstants.Defaults.DEFAULT_DOCUMENT_ENCODING;
private boolean isFormatted = MappingNodeConstants.Defaults.DEFAULT_FORMATTED_DOCUMENT.booleanValue();
- private CharArrayWriter streamResultHolder = new CharArrayWriter();
+ private FileStore store;
-
- public SAXDocumentInProgress() throws MetaMatrixComponentException{
+ public SAXDocumentInProgress(FileStore store) throws MetaMatrixComponentException{
+ this.store = store;
SAXTransformerFactory factory = new TransformerFactoryImpl();
//TODO use standard jaxp to create factory
//SAXTransformerFactory factory = (SAXTransformerFactory)TransformerFactory.newInstance();
try {
//SAX2.0 ContentHandler
handler = factory.newTransformerHandler();
- handler.setResult(new StreamResult(streamResultHolder));
+ handler.setResult(new StreamResult(new BufferedOutputStream(store.createOutputStream())));
} catch (Exception e) {
throw new MetaMatrixComponentException(e);
}
@@ -269,27 +270,6 @@
finished = true;
}
- /**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#getNextChunk(int)
- */
- public char[] getNextChunk(int sizeInBytes) {
- if(sizeInBytes == 0 && !finished) {
- return null;
- }
-
- //the unit of the size is Kb
- if(finished || streamResultHolder.size() >= sizeInBytes){
- char[] chunk = streamResultHolder.toCharArray();
- if(finished){
- streamResultHolder.close();
- }else{
- streamResultHolder.reset();
- }
- return chunk;
- }
- return null;
- }
-
private Element makeElement(NodeDescriptor descripter) {
showState( "makeElement - TOP" ); //$NON-NLS-1$
Element element = new Element(descripter, handler);
@@ -359,5 +339,10 @@
}
}
}
+
+ @Override
+ public FileStore getFileStore() {
+ return this.store;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -28,7 +28,6 @@
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
-import java.nio.charset.Charset;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.ArrayList;
@@ -43,7 +42,6 @@
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import org.teiid.client.lob.LobChunk;
import org.teiid.client.plan.PlanNode;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
@@ -59,15 +57,11 @@
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.Streamable;
import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.ProcessorDataManager;
@@ -95,14 +89,9 @@
// State initialized by processor
private ProcessorDataManager dataMgr;
private BufferManager bufferMgr;
- private int chunkSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
private int nextBatchCount = 1;
- // is document in progress currently?
- boolean docInProgress = false;
- private FileStore docInProgressStore;
-
// Post-processing
private Collection<SQLXML> xmlSchemas;
@@ -119,9 +108,6 @@
*/
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
setContext(context);
- if(context.getStreamingBatchSize() != 0){
- this.chunkSize = context.getStreamingBatchSize();
- }
TempTableStore tempTableStore = new TempTableStoreImpl(bufferMgr, context.getConnectionID(), (TempTableStore)context.getTempTableStore());
//this.dataMgr = new StagingTableDataManager(new TempTableDataManager(dataMgr, tempTableStore), env);
this.dataMgr = new TempTableDataManager(dataMgr, tempTableStore);
@@ -165,137 +151,48 @@
throws MetaMatrixComponentException, MetaMatrixProcessingException, BlockedException {
while(true){
- LobChunk chunk = getNextXMLChunk(this.chunkSize);
-
- if (chunk == null) {
- Assertion.assertTrue(!this.docInProgress);
- TupleBatch batch = new TupleBatch(nextBatchCount++, Collections.EMPTY_LIST);
- batch.setTerminationFlag(true);
- return batch;
- }
-
- XMLType doc = processXML(chunk);
-
- if (doc != null) {
- TupleBatch batch = new TupleBatch(nextBatchCount++, Arrays.asList(Arrays.asList(doc)));
- return batch;
- }
- }
- }
-
- /**
- * <p>Process the XML, using the stack of Programs supplied by the
- * ProcessorEnvironment. With each pass through the loop, the
- * current Program is gotten off the top of the stack, and the
- * current instruction is gotten from that program; each call
- * to an instruction's process method may alter the Program
- * Stack and/or the current instruction pointer of a Program,
- * so it's important that this method's loop refer to the
- * call stack of the ProcessorEnvironment each time, and not
- * cache things in local variables. If the current Program's
- * current instruction is null, then it's time to pop that
- * Program off the stack.</p>
- *
- * <p>This method will return a single tuple (List) for
- * each XML document chunk in the result sets. There may be
- * many XML documents, if the root of the document model has
- * a mapping class (i.e. result set) associated with it.</p>
- *
- */
- private XMLType processXML(LobChunk chunk)
- throws MetaMatrixComponentException, BlockedException {
+ // do the xml processing.
+ ProcessorInstruction inst = env.getCurrentInstruction();
+ while (inst != null){
+ LogManager.logTrace(LogConstants.CTX_XML_PLAN, "Executing instruction", inst); //$NON-NLS-1$
+ this.context = inst.process(this.env, this.context);
- // Note that we need to stream the document right away, as multiple documents
- // results are generated from the same "env" object. So the trick here is either
- // post process will stream it, or save to buffer manager to stream the document
- // right away so that we give way to next batch call. (this due to bad design of xml model)
- // also note that there could be "inst" object alive but no more chunks; that is reason
- // for "if" null block
- XMLType xml = null;
-
- // if the chunk size is less than one chunk unit then send this as string based xml.
- if (!this.docInProgress && chunk.isLast()) {
- xml = new XMLType(new SQLXMLImpl(chunk.getBytes()));
- }
- else {
-
- // if this is the first chunk, then create a tuple source id for this sequence of chunks
- if (!this.docInProgress) {
- this.docInProgress = true;
- this.docInProgressStore = this.bufferMgr.createFileStore("xml"); //$NON-NLS-1$
+ //code to check for end of document, set current doc
+ //to null, and return the finished doc as a single tuple
+ DocumentInProgress doc = env.getDocumentInProgress();
+ if (doc != null && doc.isFinished()) {
+ this.env.setDocumentInProgress(null);
+ XMLType xml = new XMLType(XMLUtil.createSQLXML(doc.getFileStore()));
+ // check to see if we need to do any post validation on the document.
+ if (getContext().validateXML()){
+ Reader reader;
+ try {
+ reader = xml.getCharacterStream();
+ } catch (SQLException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ try {
+ validateDoc(reader);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ TupleBatch batch = new TupleBatch(nextBatchCount++, Arrays.asList(Arrays.asList(xml)));
+ return batch;
+ }
+ inst = env.getCurrentInstruction();
}
- // now save the chunk of data to the buffer manager and move on.
- this.docInProgressStore.write(chunk.getBytes());
- // now document is finished, so create a xml object and return to the client.
- if (chunk.isLast()) {
- // we want this to be naturally feed by chunks whether inside
- // or out side the processor
- xml = new XMLType(XMLUtil.createSQLXML(this.docInProgressStore));
- //reset current document state.
- this.docInProgress = false;
- this.docInProgressStore = null;
- } else {
- return null; //need to continue processing
- }
+ TupleBatch batch = new TupleBatch(nextBatchCount++, Collections.EMPTY_LIST);
+ batch.setTerminationFlag(true);
+ return batch;
}
-
- // check to see if we need to do any post validation on the document.
- if (getContext().validateXML()){
- Reader reader;
- try {
- reader = xml.getCharacterStream();
- } catch (SQLException e) {
- throw new MetaMatrixComponentException(e);
- }
- try {
- validateDoc(reader);
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- }
- }
- }
-
- return xml;
}
-
/**
- * This methods gets the next XML chunk object from the document in progree object. Thi used by the
- * DocInProgressXMLTranslator to tuen this into a reader.
- * @return char[] of data of given size; if less than size is returned, it will be treated as
- * document is finished or null if no chunk is available, just like blocked exception.
- */
- LobChunk getNextXMLChunk(int size) throws MetaMatrixComponentException, MetaMatrixProcessingException, BlockedException {
-
- // do the xml processing.
- ProcessorInstruction inst = env.getCurrentInstruction();
- while (inst != null){
- LogManager.logTrace(LogConstants.CTX_XML_PLAN, "Executing instruction", inst); //$NON-NLS-1$
- this.context = inst.process(this.env, this.context);
-
- //code to check for end of document, set current doc
- //to null, and return the finished doc as a single tuple
- DocumentInProgress doc = env.getDocumentInProgress();
- if (doc != null) {
- //chunk size 0 mean no limit; get the whole document
- char[] chunk = doc.getNextChunk(size);
- if (chunk != null) {
- if (doc.isFinished()) {
- this.env.setDocumentInProgress(null);
- }
- byte[] bytes = new String(chunk).getBytes(Charset.forName(Streamable.ENCODING));
- return new LobChunk(bytes, doc.isFinished());
- }
- }
- inst = env.getCurrentInstruction();
- }
- return null;
- }
-
- /**
* Sets the XML schema
* @param xmlSchema
*/
@@ -518,19 +415,19 @@
* any errors that occur during XML processing
*/
private static class MMErrorHandler implements ErrorHandler{
- ArrayList exceptionList = null;
+ ArrayList<MetaMatrixException> exceptionList = null;
/**
* Keep track of all the exceptions
*/
private void addException(MetaMatrixException me) {
if (exceptionList == null) {
- exceptionList = new ArrayList();
+ exceptionList = new ArrayList<MetaMatrixException>();
}
exceptionList.add(me);
}
- public List getExceptionList() {
+ public List<MetaMatrixException> getExceptionList() {
return exceptionList;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -23,10 +23,10 @@
package com.metamatrix.query.processor.xml;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.Map;
+import java.util.Set;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.BufferManager;
@@ -48,9 +48,9 @@
public static final String JDOM_DOCUMENT_RESULT = "JDOM Document"; //$NON-NLS-1$
/* Stack <ProgramState> */
- private LinkedList programStack = new LinkedList();
+ private LinkedList<ProgramState> programStack = new LinkedList<ProgramState>();
- private Map loadedStagingTables = Collections.synchronizedMap(new HashMap());
+ private Set<String> loadedStagingTables = Collections.synchronizedSet(new HashSet<String>());
private DocumentInProgress documentInProgress;
@@ -101,7 +101,7 @@
public Program getCurrentProgram() {
// jh case 5266
if ( this.programStack.size() > 0 ) {
- ProgramState programState = (ProgramState)this.programStack.getFirst();
+ ProgramState programState = this.programStack.getFirst();
return programState.program;
}
return null;
@@ -127,7 +127,7 @@
* @see com.metamatrix.query.processor.xml.ProcessorEnvironment#incrementCurrentProgramCounter()
*/
public void incrementCurrentProgramCounter() {
- ProgramState programState = (ProgramState)this.programStack.getFirst();
+ ProgramState programState = this.programStack.getFirst();
programState.programCounter++;
// Always leave one Program in the Program stack, even if it is finished
@@ -137,7 +137,7 @@
if(LogManager.isMessageToBeRecorded(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
LogManager.logTrace(com.metamatrix.common.log.LogConstants.CTX_XML_PLAN, new Object[]{"Processor Environment popped program w/ recursion count " + programState.recursionCount, "; " + this.programStack.size(), " programs left."}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- programState = (ProgramState)this.programStack.getFirst();
+ programState = this.programStack.getFirst();
}
}
@@ -171,14 +171,14 @@
* @see com.metamatrix.query.processor.xml.ProcessorEnvironment#getCurrentInstruction()
*/
public ProcessorInstruction getCurrentInstruction() {
- ProgramState programState = (ProgramState)this.programStack.getFirst();
+ ProgramState programState = this.programStack.getFirst();
//Case 5266: account for an empty program on to the stack;
//this is needed to handle an empty sequence or an excluded Choice properly.
if (programState != null && programState.program.getProcessorInstructions().isEmpty()) {
incrementCurrentProgramCounter();
- programState = (ProgramState)this.programStack.getFirst();
+ programState = this.programStack.getFirst();
}
if (programState == null) {
@@ -202,9 +202,9 @@
private ProgramState getProgramState(Program program) {
ProgramState result = null;
- Iterator stackedPrograms = this.programStack.iterator();
+ Iterator<ProgramState> stackedPrograms = this.programStack.iterator();
while (stackedPrograms.hasNext()) {
- ProgramState programState = (ProgramState) stackedPrograms.next();
+ ProgramState programState = stackedPrograms.next();
Program stackedProgram = programState.program;
if (stackedProgram == program) {
result = programState;
@@ -287,7 +287,7 @@
*/
protected void copyIntoClone(XMLProcessorEnvironment clone) {
// Programs - just get the one at the bottom of the stack
- ProgramState initialProgramState = (ProgramState)this.programStack.getLast();
+ ProgramState initialProgramState = this.programStack.getLast();
ProgramState newState = new ProgramState();
newState.program = initialProgramState.program;
newState.programCounter = 0;
@@ -308,11 +308,15 @@
boolean isStagingTableLoaded(String tableName) {
- return Boolean.TRUE.equals(this.loadedStagingTables.get(tableName));
+ return this.loadedStagingTables.contains(tableName);
}
void markStagingTableAsLoaded(String tableName) {
- this.loadedStagingTables.put(tableName, Boolean.TRUE);
+ this.loadedStagingTables.add(tableName);
}
+ public BufferManager getBufferManager() {
+ return bufferMgr;
+ }
+
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -284,6 +284,10 @@
record = new ArrayList(record);
record.set(0, actualDoc);
}
+ if (expectedResults[i].size() == 1) {
+ assertEquals("Row " + i + " does not match expected: ", expectedResults[i].get(0), record.get(0)); //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ }
}
assertEquals("Row " + i + " does not match expected: ", expectedResults[i], record); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/FakeXMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/FakeXMLProcessorEnvironment.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/FakeXMLProcessorEnvironment.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -27,6 +27,8 @@
import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.query.mapping.xml.ResultSetInfo;
/**
@@ -57,4 +59,9 @@
clone.schemaMap = this.schemaMap;
return clone;
}
+
+ @Override
+ public BufferManager getBufferManager() {
+ return BufferManagerFactory.getStandaloneBufferManager();
+ }
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestAddNodeInstruction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestAddNodeInstruction.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestAddNodeInstruction.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -27,6 +27,9 @@
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BufferManagerFactory;
+import com.metamatrix.common.buffer.FileStore;
+import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.query.mapping.xml.MappingNodeConstants;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.util.VariableContext;
@@ -405,7 +408,8 @@
env.pushProgram(program);
- DocumentInProgress doc = new SAXDocumentInProgress();
+ FileStore fs = BufferManagerFactory.getStandaloneBufferManager().createFileStore("test"); //$NON-NLS-1$
+ DocumentInProgress doc = new SAXDocumentInProgress(fs);
env.setDocumentInProgress(doc);
//add fake root, move to child
@@ -419,7 +423,7 @@
doc.moveToParent();
doc.markAsFinished();
- String actualDoc = new String(env.getDocumentInProgress().getNextChunk(1));
+ String actualDoc = new String(ObjectConverterUtil.convertToByteArray(fs.createInputStream(0)));
return actualDoc;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -24,9 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.LinkedList;
import java.util.List;
-import java.util.StringTokenizer;
import junit.framework.TestCase;
@@ -34,7 +32,6 @@
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.common.types.DataTypeManager;
@@ -42,6 +39,8 @@
import com.metamatrix.query.mapping.xml.MappingNodeConstants;
import com.metamatrix.query.mapping.xml.ResultSetInfo;
import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.processor.FakeDataManager;
+import com.metamatrix.query.processor.TestProcessor;
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.util.ResolverVisitor;
import com.metamatrix.query.rewriter.QueryRewriter;
@@ -133,61 +132,10 @@
return crit;
}
- private void compareDocuments(String expectedDoc, String actualDoc) {
- StringTokenizer tokens1 = new StringTokenizer(expectedDoc, "\r\n"); //$NON-NLS-1$
- StringTokenizer tokens2 = new StringTokenizer(actualDoc, "\n");//$NON-NLS-1$
- while(tokens1.hasMoreTokens()){
- String token1 = tokens1.nextToken().trim();
- if(!tokens2.hasMoreTokens()){
- fail("XML doc mismatch: expected=" + token1 + "\nactual=none");//$NON-NLS-1$ //$NON-NLS-2$
- }
- String token2 = tokens2.nextToken().trim();
- assertEquals("XML doc mismatch: ", token1, token2); //$NON-NLS-1$
- }
- if(tokens2.hasMoreTokens()){
- fail("XML doc mismatch: expected=none\nactual=" + tokens2.nextToken().trim());//$NON-NLS-1$
- }
- }
-
- public List helpProcessInstructions(Program prog, XMLProcessorEnvironment env) throws Exception {
- int counter = 0;
- XMLContext context = new XMLContext();
+ public void helpProcessInstructions(Program prog, XMLProcessorEnvironment env, String expected) throws Exception {
env.pushProgram(prog);
-
- DocumentInProgress doc = null;
-
- LinkedList resultDocs = new LinkedList();
-
- ProcessorInstruction inst = env.getCurrentInstruction();
- while (inst != null){
-
- try {
-
- context = inst.process(env, context);
-
- //code to check for end of document, start new one,
- doc = env.getDocumentInProgress();
- if (doc != null){
- if (doc.isFinished()){
- env.setDocumentInProgress(null);
- String docString = new String(doc.getNextChunk(10));
- resultDocs.addLast(docString);
- }
- }
-
- } catch(BlockedException e) {
-
- }
-
- // Catch run away processes
- if(counter++ > 100) {
- break;
- }
-
- inst = env.getCurrentInstruction();
- }
-
- return resultDocs;
+ XMLPlan plan = new XMLPlan(env);
+ TestProcessor.doProcess(plan, new FakeDataManager(), new List[] {Arrays.asList(expected)}, new CommandContext());
}
public Program exampleProgram(FakeMetadataFacade metadata, XMLProcessorEnvironment env) throws Exception{
@@ -361,33 +309,26 @@
Arrays.asList( new Object[] { "002", "Screwdriver", new Integer(100) } ), //$NON-NLS-1$ //$NON-NLS-2$
Arrays.asList( new Object[] { "003", "Goat", new Integer(4) } ) //$NON-NLS-1$ //$NON-NLS-2$
} );
- List resultDocs = helpProcessInstructions(program, env);
-
- String actualDoc = (String)resultDocs.iterator().next();
-
- String expectedDoc =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + //$NON-NLS-1$
- "<Catalogs>\r\n" + //$NON-NLS-1$
- " <Catalog>\r\n" + //$NON-NLS-1$
- " <Items>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"001\">\r\n" + //$NON-NLS-1$
- " <Name>Lamp</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>5</Quantity>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"002\">\r\n" + //$NON-NLS-1$
- " <Name>Screwdriver</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>100</Quantity>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"003\">\r\n" + //$NON-NLS-1$
- " <Name>Goat</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>4</Quantity>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " </Items>\r\n" + //$NON-NLS-1$
- " </Catalog>\r\n" + //$NON-NLS-1$
- "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
-
- //assertEquals("XML doc mismatch: ", expectedDoc, actualDoc); //$NON-NLS-1$
- compareDocuments(expectedDoc, actualDoc);
+ helpProcessInstructions(program, env,
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
+ "<Catalogs>\n" + //$NON-NLS-1$
+ " <Catalog>\n" + //$NON-NLS-1$
+ " <Items>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"001\">\n" + //$NON-NLS-1$
+ " <Name>Lamp</Name>\n" + //$NON-NLS-1$
+ " <Quantity>5</Quantity>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"002\">\n" + //$NON-NLS-1$
+ " <Name>Screwdriver</Name>\n" + //$NON-NLS-1$
+ " <Quantity>100</Quantity>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"003\">\n" + //$NON-NLS-1$
+ " <Name>Goat</Name>\n" + //$NON-NLS-1$
+ " <Quantity>4</Quantity>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " </Items>\n" + //$NON-NLS-1$
+ " </Catalog>\n" + //$NON-NLS-1$
+ "</Catalogs>"); //$NON-NLS-1$
}
public void testProcess2() throws Exception {
@@ -412,24 +353,17 @@
Arrays.asList( new Object[] { "003", "Goat", new Integer(4) } ) //$NON-NLS-1$ //$NON-NLS-2$
} );
- List resultDocs = helpProcessInstructions(program, env);
-
- String actualDoc = (String)resultDocs.iterator().next();
-
- String expectedDoc =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + //$NON-NLS-1$
- "<Catalogs>\r\n" + //$NON-NLS-1$
- " <Catalog>\r\n" + //$NON-NLS-1$
- " <Items>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"002\">\r\n" + //$NON-NLS-1$
- " <Name>Screwdriver</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>100</Quantity>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " </Items>\r\n" + //$NON-NLS-1$
- " </Catalog>\r\n" + //$NON-NLS-1$
- "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
-
- //assertEquals("XML doc mismatch: ", expectedDoc, actualDoc); //$NON-NLS-1$
- compareDocuments(expectedDoc, actualDoc);
+ helpProcessInstructions(program, env,
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
+ "<Catalogs>\n" + //$NON-NLS-1$
+ " <Catalog>\n" + //$NON-NLS-1$
+ " <Items>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"002\">\n" + //$NON-NLS-1$
+ " <Name>Screwdriver</Name>\n" + //$NON-NLS-1$
+ " <Quantity>100</Quantity>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " </Items>\n" + //$NON-NLS-1$
+ " </Catalog>\n" + //$NON-NLS-1$
+ "</Catalogs>"); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestSAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestSAXDocumentInProgress.java 2010-04-26 20:34:52 UTC (rev 2082)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestSAXDocumentInProgress.java 2010-04-27 17:56:40 UTC (rev 2083)
@@ -24,6 +24,8 @@
import junit.framework.TestCase;
+import com.metamatrix.common.buffer.BufferManagerFactory;
+import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.query.mapping.xml.MappingNodeConstants;
public class TestSAXDocumentInProgress extends TestCase {
@@ -34,7 +36,8 @@
}
public void testLargeDocument()throws Exception{
- SAXDocumentInProgress doc = new SAXDocumentInProgress();
+ FileStore fs = BufferManagerFactory.getStandaloneBufferManager().createFileStore("test"); //$NON-NLS-1$
+ SAXDocumentInProgress doc = new SAXDocumentInProgress(fs);
//long startTime = System.currentTimeMillis();
doc.setDocumentFormat(true);
NodeDescriptor descriptor = NodeDescriptor.createNodeDescriptor("Root", null, true, null, null, null,false, null, MappingNodeConstants.NORMALIZE_TEXT_PRESERVE);//$NON-NLS-1$
@@ -44,20 +47,9 @@
doc.addAttribute(descriptor, "test1");//$NON-NLS-1$
descriptor = NodeDescriptor.createNodeDescriptor("a1", null, false, null, null, null,false, null, MappingNodeConstants.NORMALIZE_TEXT_PRESERVE);//$NON-NLS-1$
doc.addAttribute(descriptor, "test2");//$NON-NLS-1$
- int j=1;
- int i=0;
descriptor = NodeDescriptor.createNodeDescriptor("Child", null, true, null, null, null,false, null, MappingNodeConstants.NORMALIZE_TEXT_PRESERVE);//$NON-NLS-1$
- while(true){
+ for (int i = 0; i < 50; i++) {
doc.addElement(descriptor, "test content");//$NON-NLS-1$
- char[] chunk = doc.getNextChunk(100);
- if(chunk != null){
- j++;
- //System.out.println("Got chunk " + (j++) + " length="+chunk.length);//$NON-NLS-1$ //$NON-NLS-2$
- }
- if(j==51){
- break;
- }
- i++;
}
doc.moveToParent();
doc.markAsFinished();
14 years, 8 months
teiid SVN: r2082 - trunk/client/src/main/resources.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-04-26 16:34:52 -0400 (Mon, 26 Apr 2010)
New Revision: 2082
Modified:
trunk/client/src/main/resources/vdb-deployer.xsd
Log:
TEIID-1071: Relaxing the Model count to zero for the tooling. Also adding the path to error to locate the resource that has the problem.
Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd 2010-04-26 20:28:21 UTC (rev 2081)
+++ trunk/client/src/main/resources/vdb-deployer.xsd 2010-04-26 20:34:52 UTC (rev 2082)
@@ -8,7 +8,7 @@
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
- <xs:element name="model" maxOccurs="unbounded">
+ <xs:element name="model" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0"/>
@@ -31,6 +31,7 @@
</xs:restriction>
</xs:simpleType>
</xs:attribute>
+ <xs:attribute name="path" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
14 years, 8 months