[teiid-commits] teiid SVN: r3743 - in branches/7.6.x: runtime/src/main/java/org/teiid/deployers and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Dec 15 10:40:26 EST 2011


Author: shawkins
Date: 2011-12-15 10:40:25 -0500 (Thu, 15 Dec 2011)
New Revision: 3743

Modified:
   branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/vdbs.xml
   branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
   branches/7.6.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties
Log:
TEIID-1867 adding source name validation to the creation of connector managers

Modified: branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/vdbs.xml
===================================================================
--- branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/vdbs.xml	2011-12-15 14:25:36 UTC (rev 3742)
+++ branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/vdbs.xml	2011-12-15 15:40:25 UTC (rev 3743)
@@ -103,7 +103,7 @@
                     </para>
                     <para>
                     The name of the model is used as a 
-                    top level schema name for all of the  metadata imported from the 
+                    top level schema name for all of the metadata imported from the 
                     connector.  The name should be unique among all Models in the VDB and 
                     should not contain the '.' character.
                     </para>
@@ -123,6 +123,7 @@
             
             <itemizedlist>
                 <title>Source Element</title>
+                <para>A source is a named binding of a translator and connection source to a model.</para>
                 <listitem>
                     <para>
                     <emphasis>name</emphasis>
@@ -131,7 +132,9 @@
                     The name of the source to use for this 
                     model. This can be any name you like, but will typically be the same 
                     as the model name.  Having a name different than the model name is 
-                    only useful in multi-source scenarios.	
+                    only useful in multi-source scenarios.	In multi-source, the source names under a given model must
+                    be unique.  If you have the same source bound to multiple models it may have the same name
+                    for each.  An exception will be raised if the same source name is used for different sources.
                     </para>
                 </listitem>
                 <listitem>

Modified: branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2011-12-15 14:25:36 UTC (rev 3742)
+++ branches/7.6.x/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java	2011-12-15 15:40:25 UTC (rev 3743)
@@ -176,13 +176,23 @@
 		IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map = new IdentityHashMap<Translator, ExecutionFactory<Object, Object>>();
 		
 		for (Model model:deployment.getModels()) {
-			for (String source:model.getSourceNames()) {
-				if (cmr.getConnectorManager(source) != null) {
+			List<String> sourceNames = model.getSourceNames();
+			if (sourceNames.size() != new HashSet<String>(sourceNames).size()) {
+				throw new DeploymentException(RuntimePlugin.Util.getString("duplicate_source_name", model.getName(), deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+			}
+			for (String source:sourceNames) {
+				ConnectorManager cm = cmr.getConnectorManager(source);
+				String name = model.getSourceTranslatorName(source);
+				String connection = model.getSourceConnectionJndiName(source);
+				if (cm != null) {
+					if (!cm.getTranslatorName().equals(name)
+							|| !cm.getConnectionName().equals(connection)) {
+						throw new DeploymentException(RuntimePlugin.Util.getString("source_name_mismatch", source, deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+					}
 					continue;
 				}
 
-				String name = model.getSourceTranslatorName(source);
-				ConnectorManager cm = new ConnectorManager(name, model.getSourceConnectionJndiName(source));
+				cm = new ConnectorManager(name, connection);
 				ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo, deployment, map, new HashSet<String>());
 				cm.setExecutionFactory(ef);
 				cm.setModelName(model.getName());

Modified: branches/7.6.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- branches/7.6.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties	2011-12-15 14:25:36 UTC (rev 3742)
+++ branches/7.6.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties	2011-12-15 15:40:25 UTC (rev 3743)
@@ -49,6 +49,8 @@
 SocketClientInstance.invalid_sessionkey=Invalid session key used during handshake
 SSLAwareChannelHandler.channel_closed=Channel closed
 
+duplicate_source_name=Source names are not unique for model {0} in {1}.{2}
+source_name_mismatch=There are different sources with the name {0} in {1}.{2}
 invlaid_vdb_file=Invalid VDB file deployment failed {0}
 redeploying_vdb=Re-deploying VDB {0}
 validity_errors_in_vdb=VDB has validity errors; failed to deploy - {0}



More information about the teiid-commits mailing list