Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125334 Details for
Bug 253606
Support handling of Transient Connection Profile instance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
updated patch with tweak for dispose
clipboard.txt (text/plain), 14.32 KB, created by
Brian Fitzpatrick
on 2009-02-10 18:32:13 EST
(
hide
)
Description:
updated patch with tweak for dispose
Filename:
MIME Type:
Creator:
Brian Fitzpatrick
Created:
2009-02-10 18:32:13 EST
Size:
14.32 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.datatools.connectivity >Index: src/org/eclipse/datatools/connectivity/IConnectionProfile.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/IConnectionProfile.java,v >retrieving revision 1.9 >diff -u -r1.9 IConnectionProfile.java >--- src/org/eclipse/datatools/connectivity/IConnectionProfile.java 16 Apr 2008 06:26:17 -0000 1.9 >+++ src/org/eclipse/datatools/connectivity/IConnectionProfile.java 10 Feb 2009 23:29:37 -0000 >@@ -61,6 +61,11 @@ > */ > static final String INSTANCE_ID_PROPERTY_ID = "instanceID"; //$NON-NLS-1$ > >+ /** >+ * Transient marker for profile instance. >+ */ >+ static final String TRANSIENT_PROPERTY_ID = "isTransient"; //$NON-NLS-1$ >+ > // Connection states > > /** >Index: src/org/eclipse/datatools/connectivity/ProfileManager.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/ProfileManager.java,v >retrieving revision 1.13 >diff -u -r1.13 ProfileManager.java >--- src/org/eclipse/datatools/connectivity/ProfileManager.java 25 Jan 2008 21:52:32 -0000 1.13 >+++ src/org/eclipse/datatools/connectivity/ProfileManager.java 10 Feb 2009 23:29:37 -0000 >@@ -134,6 +134,11 @@ > public IConnectionProfile getProfileByFullPath(String path ) { > return InternalProfileManager.getInstance().getProfileByFullPath(path); > } >+ >+ public IConnectionProfile createTransientProfile(String providerID, Properties baseProperties) throws ConnectionProfileException { >+ return InternalProfileManager.getInstance().createTransientProfile(null, null, providerID, baseProperties); >+ } >+ > /** > * Create connection profile > * >@@ -143,10 +148,10 @@ > * @param baseProperties > * @throws ConnectionProfileException > */ >- public void createProfile(String name, String description, >+ public IConnectionProfile createProfile(String name, String description, > String providerID, Properties baseProperties) > throws ConnectionProfileException { >- InternalProfileManager.getInstance().createProfile(name, description, >+ return InternalProfileManager.getInstance().createProfile(name, description, > providerID, baseProperties); > } > >@@ -160,10 +165,10 @@ > * @param parentProfile > * @throws ConnectionProfileException > */ >- public void createProfile(String name, String description, >+ public IConnectionProfile createProfile(String name, String description, > String providerID, Properties baseProperties, String parentProfile) > throws ConnectionProfileException { >- InternalProfileManager.getInstance().createProfile(name, description, >+ return InternalProfileManager.getInstance().createProfile(name, description, > providerID, baseProperties, parentProfile); > } > >@@ -178,10 +183,10 @@ > * @param autoConnect > * @throws ConnectionProfileException > */ >- public void createProfile(String name, String description, >+ public IConnectionProfile createProfile(String name, String description, > String providerID, Properties baseProperties, String parentProfile, > boolean autoConnect) throws ConnectionProfileException { >- InternalProfileManager.getInstance().createProfile(name, description, >+ return InternalProfileManager.getInstance().createProfile(name, description, > providerID, baseProperties, parentProfile, autoConnect); > } > >Index: src/org/eclipse/datatools/connectivity/DriverConnectionBase.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/DriverConnectionBase.java,v >retrieving revision 1.6 >diff -u -r1.6 DriverConnectionBase.java >--- src/org/eclipse/datatools/connectivity/DriverConnectionBase.java 27 Oct 2006 21:01:10 -0000 1.6 >+++ src/org/eclipse/datatools/connectivity/DriverConnectionBase.java 10 Feb 2009 23:29:37 -0000 >@@ -31,9 +31,9 @@ > */ > public abstract class DriverConnectionBase extends VersionProviderConnection { > >- private DriverInstance mDriver; >- private Object mConnection; >- private Throwable mConnectException; >+ protected DriverInstance mDriver; >+ protected Object mConnection; >+ protected Throwable mConnectException; > > public DriverConnectionBase(IConnectionProfile profile, Class factoryClass) { > super(profile, factoryClass); >Index: src/org/eclipse/datatools/connectivity/internal/InternalProfileManager.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/internal/InternalProfileManager.java,v >retrieving revision 1.30 >diff -u -r1.30 InternalProfileManager.java >--- src/org/eclipse/datatools/connectivity/internal/InternalProfileManager.java 8 Jan 2009 16:30:05 -0000 1.30 >+++ src/org/eclipse/datatools/connectivity/internal/InternalProfileManager.java 10 Feb 2009 23:29:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004-2008 Sybase, Inc. and others. >+ * Copyright (c) 2004-2009 Sybase, Inc. and others. > * > * All rights reserved. This program and the accompanying materials are made > * available under the terms of the Eclipse Public License v1.0 which >@@ -10,6 +10,7 @@ > * IBM Corporation - fix for defect #223855 > * IBM Corporation - fix for defect #241713 > * Actuate Corporation - fix for bug #247587 >+ * brianf - added Transient profile functionality for bug 253606 > ******************************************************************************/ > package org.eclipse.datatools.connectivity.internal; > >@@ -23,6 +24,7 @@ > import java.util.ArrayList; > import java.util.Arrays; > import java.util.Collection; >+import java.util.Collections; > import java.util.HashMap; > import java.util.HashSet; > import java.util.Iterator; >@@ -76,6 +78,8 @@ > > private IConnectionProfile[] mProfiles = null; > >+ private List mTransientProfiles = null; >+ > private Set mRepositories = new HashSet(); > > private boolean mIsDirty = false; >@@ -455,6 +459,62 @@ > } > > /** >+ * Create transient connection profile >+ * >+ * @param name >+ * @param description >+ * @param providerID >+ * @param baseProperties >+ * @throws ConnectionProfileException >+ */ >+ public IConnectionProfile createTransientProfile(String name, String description, >+ String providerID, Properties baseProperties) throws ConnectionProfileException { >+ String transientName = name; >+ if (transientName == null) { >+ transientName = "Transient." + providerID; //$NON-NLS-1$ >+ } >+ transientName = findUniqueTransientProfileName(transientName, providerID); >+ ConnectionProfile profile = new ConnectionProfile(transientName, description, >+ providerID, "", false, UUID.createUUID() //$NON-NLS-1$ >+ .toString()); >+ baseProperties.setProperty(IConnectionProfile.TRANSIENT_PROPERTY_ID, ""); //$NON-NLS-1$ >+ profile.setBaseProperties(baseProperties); >+ profile.setCreated(); >+ if (mTransientProfiles == null) { >+ synchronized (this) { >+ if (mTransientProfiles == null) { >+ mTransientProfiles = Collections.synchronizedList( new ArrayList() ); >+ } >+ } >+ } >+ mTransientProfiles.add(profile); >+ return profile; >+ } >+ >+ /** >+ * Private method to avoid name collisions >+ * @param name >+ * @param providerID >+ * @return >+ */ >+ private String findUniqueTransientProfileName(String name, String providerID) { >+ if (mTransientProfiles != null) { >+ synchronized(mTransientProfiles) { >+ Iterator iter = mTransientProfiles.iterator(); >+ int count = 0; >+ while (iter.hasNext()) { >+ IConnectionProfile profile = (IConnectionProfile) iter.next(); >+ if (profile.getProviderId().equalsIgnoreCase(providerID)) { >+ count++; >+ } >+ } >+ return name + count; >+ } >+ } >+ return name; >+ } >+ >+ /** > * Create connection profile > * > * @param name >@@ -856,10 +916,8 @@ > > // Changed to fix bug 247599 > //cps[index] = profile; >- if(cps[index] != profile) { >- removeProfile(cps[index]); >- addProfile(profile); >- } >+ removeProfile(cps[index]); >+ addProfile(profile); > > mIsDirty = true; > >@@ -1097,6 +1155,16 @@ > } > > /* package */void dispose() { >+ if (mTransientProfiles != null) { >+ synchronized (mTransientProfiles) { >+ if (mTransientProfiles != null) { >+ Iterator transientIter = mTransientProfiles.iterator(); >+ while (transientIter.hasNext()) { >+ ((ConnectionProfile)transientIter.next()).dispose(); >+ } >+ } >+ } >+ } > if (mProfiles == null) { > return; > } >Index: src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java >=================================================================== >RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity/src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java,v >retrieving revision 1.1 >diff -u -r1.1 JDBCConnection.java >--- src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java 18 Dec 2007 00:17:50 -0000 1.1 >+++ src/org/eclipse/datatools/connectivity/drivers/jdbc/JDBCConnection.java 10 Feb 2009 23:29:37 -0000 >@@ -11,6 +11,10 @@ > ******************************************************************************/ > package org.eclipse.datatools.connectivity.drivers.jdbc; > >+import java.io.File; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.net.URLClassLoader; > import java.sql.Connection; > import java.sql.DatabaseMetaData; > import java.sql.Driver; >@@ -21,6 +25,8 @@ > import org.eclipse.datatools.connectivity.DriverConnectionBase; > import org.eclipse.datatools.connectivity.IConnectionProfile; > import org.eclipse.datatools.connectivity.Version; >+import org.eclipse.datatools.connectivity.drivers.DriverMgmtMessages; >+import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants; > import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin; > > /** >@@ -44,17 +50,123 @@ > private Version mTechVersion = Version.NULL_VERSION; > private Version mServerVersion = Version.NULL_VERSION; > private String mServerName; >+ >+ private boolean mHasDriver = true; > > public JDBCConnection(IConnectionProfile profile, Class factoryClass) { > super(profile, factoryClass); > } > >+ public void open() { >+ if (mConnection != null) { >+ close(); >+ } >+ >+ mConnection = null; >+ mConnectException = null; >+ >+ try { >+ if (getDriverDefinition() != null) >+ super.open(); >+ } catch (Exception e) { >+ if (e.getMessage().equalsIgnoreCase(ConnectivityPlugin.getDefault().getResourceString("DriverConnectionBase.error.driverDefinitionNotSpecified"))) //$NON-NLS-1$ >+ { >+ if (profileHasDriverDetails()) { >+ mHasDriver = false; >+ } >+ else { >+ e.printStackTrace(); >+ } >+ } >+ else >+ e.printStackTrace(); >+ } >+ internalCreateConnection(); >+ } >+ >+ public String[] getJarListAsArray(String jarList) { >+ if (jarList != null) { >+ if (jarList.length() == 0) >+ return new String[0]; >+ String[] paths = parseString(jarList, >+ IDriverMgmtConstants.PATH_DELIMITER); >+ return paths; >+ } >+ return null; >+ } >+ >+ public ClassLoader createClassLoader(ClassLoader parentCL) throws Exception { >+ Properties props = getConnectionProfile().getBaseProperties(); >+ String jarList = >+ props.getProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST); >+ if ((jarList == null || jarList.trim().length() == 0)) { >+ throw new Exception( >+ DriverMgmtMessages.getString("DriverInstance.error.jarListNotDefined")); //$NON-NLS-1$ >+ } >+ >+ String[] jarStrings = getJarListAsArray(jarList); >+ URL[] jars = new URL[jarStrings.length]; >+ for (int index = 0, count = jars.length; index < count; ++index) { >+ try { >+ jars[index] = new File(jarStrings[index]).toURL(); >+ } >+ catch (MalformedURLException e) { >+ throw new Exception(DriverMgmtMessages.getString("DriverInstance.error.invalidClassPath"), e); //$NON-NLS-1$ >+ } >+ } >+ if (parentCL == null) { >+ return URLClassLoader.newInstance(jars); >+ } >+ return URLClassLoader.newInstance(jars, parentCL); >+ } >+ >+ private void internalCreateConnection() { >+ try { >+ ClassLoader parentCL = getParentClassLoader(); >+ ClassLoader driverCL = createClassLoader(parentCL); >+ >+ mConnection = createConnection(driverCL); >+ >+ if (mConnection == null) { >+ // Connect attempt failed without throwing an exception. >+ // We'll generate one for them. >+ throw new Exception(ConnectivityPlugin.getDefault().getResourceString("DriverConnectionBase.error.unknown")); //$NON-NLS-1$ >+ } >+ >+ initVersions(); >+ updateVersionCache(); >+ } >+ catch (Throwable t) { >+ mConnectException = t; >+ clearVersionCache(); >+ } >+ } >+ >+ private boolean profileHasDriverDetails() { >+ Properties props = getConnectionProfile().getBaseProperties(); >+ String driverClass = >+ props.getProperty(IJDBCConnectionProfileConstants.DRIVER_CLASS_PROP_ID); >+ String jarList = >+ props.getProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST); >+ if (driverClass != null && jarList != null) { >+ return true; >+ } >+ return false; >+ } >+ > protected Object createConnection(ClassLoader cl) throws Throwable { > Properties props = getConnectionProfile().getBaseProperties(); > Properties connectionProps = new Properties(); >- >- String driverClass = getDriverDefinition().getProperty( >+ >+// boolean hasDriver = (getDriverDefinition() != null); >+ String driverClass = null; >+ if (mHasDriver) >+ driverClass = getDriverDefinition().getProperty( > IJDBCConnectionProfileConstants.DRIVER_CLASS_PROP_ID); >+ else >+ driverClass = >+ props.getProperty(IJDBCConnectionProfileConstants.DRIVER_CLASS_PROP_ID); >+ > String connectURL = props > .getProperty(IJDBCConnectionProfileConstants.URL_PROP_ID); > String uid = props >@@ -84,7 +196,7 @@ > addPairs = addPairs + pairs[i]; > } > } >- >+ > Driver jdbcDriver = (Driver) cl.loadClass(driverClass).newInstance(); > return jdbcDriver.connect(connectURL, connectionProps); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253606
:
121959
|
122596
|
122597
|
122600
|
123417
|
123777
|
125313
| 125334 |
125398