Skip to content

Commit

Permalink
TEIIDDDES-879: Remove designer.core dependency from datatools.connect…
Browse files Browse the repository at this point in the history
…ivity

* The datatools.connectivity bundles should be at the foot of the plugin
  dependency tree and should not depend on the designer.core plugin.

* Since the plugin also lives in a different feature, it makes sense to
  avoid this cross-dependency.

* ConnectivityUtil
 * Since the TeiidJDBCConnection is the only class that requires the
   getTeiidDriver() method, it is better to locate it here.
  • Loading branch information
Paul Richardson committed Jun 19, 2013
1 parent baa99e0 commit 4703cbc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.103.0,4.0.0)",
org.eclipse.datatools.connectivity.sqm.server.ui;bundle-version="[1.1.100,2.0.0)",
org.teiid.datatools.connectivity.model;bundle-version="[8.1.0,9.0.0)",
org.eclipse.equinox.security;bundle-version="[1.1.100,2.0.0)",
org.teiid.designer.spi;bundle-version="[8.1.0,9.0.0)",
org.teiid.designer.core;bundle-version="[8.1.0,9.0.0)"
org.teiid.designer.spi;bundle-version="[8.1.0,9.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.datatools.modelbase.dbdefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package org.teiid.datatools.connectivity;

import java.sql.Driver;
import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
Expand All @@ -24,6 +25,7 @@
import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.teiid.datatools.connectivity.security.impl.EquinoxSecureStorageProvider;
import org.teiid.datatools.connectivity.spi.ISecureStorageProvider;
import org.teiid.designer.runtime.registry.TeiidRuntimeRegistry;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;

/**
Expand Down Expand Up @@ -293,4 +295,25 @@ public static String buildSecureStorageKey(Class<?> klazz, String connectURL) {
public static ISecureStorageProvider getSecureStorageProvider() {
return EquinoxSecureStorageProvider.getInstance();
}

/**
* Find a Teiid {@link Driver} for the given server version.
*
* The driver class should be provided as a check to ensure the class name
* is as expected.
*
* @param teiidServerVersion
* @param driverClass
*
* @return the Teiid {@link Driver}
* @throws Exception
*/
public static Driver getTeiidDriver(ITeiidServerVersion teiidServerVersion, String driverClass) throws Exception {
Driver driver = TeiidRuntimeRegistry.getInstance().getTeiidDriver(teiidServerVersion);
if (driver != null && driver.getClass().getName().equals(driverClass))
return driver;

String msg = "No Teiid Driver ( "+ driverClass + " ) available for version " + teiidServerVersion; //$NON-NLS-1$//$NON-NLS-2$
throw new IllegalStateException(msg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCConnectionProfileConstants;
import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;

Expand Down Expand Up @@ -84,13 +83,12 @@ protected Object createConnection( ClassLoader cl ) throws Throwable {
String teiidVersion = props.getProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
if (teiidVersion != null) {
ITeiidServerVersion teiidServerVersion = new TeiidServerVersion(teiidVersion);
Driver jdbcDriver = ModelerCore.getTeiidDriver(teiidServerVersion, driverClass);
Driver jdbcDriver = ConnectivityUtil.getTeiidDriver(teiidServerVersion, driverClass);
if (jdbcDriver != null) {
return jdbcDriver.connect(connectURL, connectionProps);
}
}

throw new Exception("Cannot find Teiid Driver"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.teiid.designer.core;

import java.io.File;
import java.sql.Driver;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -2136,26 +2135,6 @@ public static ITeiidServerVersion getTeiidServerVersion() {
return defaultTeiidServer.getServerVersion();
}

/**
* Find a Teiid {@link Driver} for the given server version.
*
* The driver class should be provided as a check to ensure the class name
* is as expected.
*
* @param teiidServerVersion
* @param driverClass
*
* @return the Teiid {@link Driver}
* @throws Exception
*/
public static Driver getTeiidDriver(ITeiidServerVersion teiidServerVersion, String driverClass) throws Exception {
Driver driver = TeiidRuntimeRegistry.getInstance().getTeiidDriver(teiidServerVersion);
if (driver != null && driver.getClass().getName().equals(driverClass))
return driver;

throw new IllegalStateException(Util.getString(I18N_PREFIX + "noTeiidDriver", driverClass, teiidServerVersion));
}

/**
* Add a listener to be notified in the event the default server
* version is changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,5 +966,4 @@ VdbHelper.errorWithFileLookupInFolder=Error with file lookup in folder: {0}
VdbHelper.errorWithJarLookupInFolder=Error with jar file lookup in folder: {0}
VdbHelper.errorCountingFolderFiles=Error counting files in folder: {0}

ModelerCore.noDefaultServer=No default server defined
ModelerCore.noTeiidDriver=No Teiid Driver ({0}) available for version {1}
ModelerCore.noDefaultServer=No default server defined

0 comments on commit 4703cbc

Please sign in to comment.