Author: rareddy
Date: 2010-06-17 16:14:18 -0400 (Thu, 17 Jun 2010)
New Revision: 2242
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
Log:
TEIID-1124: when the connection name does not start with the "java:" prefix
automatically add it then do the look up. If in case that is not found, fall back and
lookup with original name supplied.
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-06-17
18:51:53 UTC (rev 2241)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-06-17
20:14:18 UTC (rev 2242)
@@ -67,6 +67,8 @@
*/
public class ConnectorManager {
+ private static final String JAVA_CONTEXT = "java:"; //$NON-NLS-1$
+
public static final int DEFAULT_MAX_THREADS = 20;
private static AtomicInteger ID_SEQUENCE = new AtomicInteger();
@@ -276,9 +278,20 @@
*/
protected Object getConnectionFactory() {
if (this.connectionName != null) {
- try {
- InitialContext ic = new InitialContext();
- return ic.lookup(this.connectionName);
+ String jndiName = this.connectionName;
+ if (!this.connectionName.startsWith(JAVA_CONTEXT)) {
+ jndiName = JAVA_CONTEXT + jndiName;
+ }
+
+ try {
+ InitialContext ic = new InitialContext();
+ try {
+ return ic.lookup(jndiName);
+ } catch (NamingException e) {
+ if (!jndiName.equals(this.connectionName)) {
+ return ic.lookup(this.connectionName);
+ }
+ }
} catch (NamingException e) {
}
}
Show replies by date