Author: dgolovin
Date: 2007-08-28 21:12:56 -0400 (Tue, 28 Aug 2007)
New Revision: 3395
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JstFirstRunPlugin.java
Log:
http://jira.jboss.org/jira/browse/RHDS-94
If RHDS is installed by installer, first run find use hsqldb.jar to peconfigure HSQL
driver and create DefaultDS DTP Connection profile. This profile is used as default
Connection profile for Seam Facet Wizard Page. Default DS connection profile parameters is
initialized the same values as it is done in hsqldb-ds.xml from default/deploy directory.
<connection-url>jdbc:hsqldb:.</connection-url> was used as default url.
Modified: trunk/jst/plugins/org.jboss.tools.jst.firstrun/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.firstrun/META-INF/MANIFEST.MF 2007-08-28
16:45:59 UTC (rev 3394)
+++ trunk/jst/plugins/org.jboss.tools.jst.firstrun/META-INF/MANIFEST.MF 2007-08-29
01:12:56 UTC (rev 3395)
@@ -9,7 +9,9 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jdt.launching,
- org.eclipse.jface
+ org.eclipse.jface,
+ org.eclipse.datatools.connectivity,
+ org.eclipse.datatools.connectivity.db.generic
Bundle-Activator: org.jboss.tools.jst.firstrun.JstFirstRunPlugin
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.jst.firstrun
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java 2007-08-28
16:45:59 UTC (rev 3394)
+++
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JBossASAdapterInitializer.java 2007-08-29
01:12:56 UTC (rev 3395)
@@ -13,15 +13,28 @@
import java.io.File;
import java.io.IOException;
+import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.connectivity.ConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.IDBConnectionProfileConstants;
+import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants;
+import org.eclipse.datatools.connectivity.drivers.DriverInstance;
+import org.eclipse.datatools.connectivity.drivers.DriverManager;
+import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants;
+import org.eclipse.datatools.connectivity.drivers.IPropertySet;
+import org.eclipse.datatools.connectivity.drivers.PropertySetImpl;
+import org.eclipse.datatools.connectivity.drivers.models.TemplateDescriptor;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.ui.IStartup;
@@ -43,14 +56,30 @@
public static final String JBOSS_AS_HOME = "../../../../jboss-eap/jboss-as";
// JBoss AS home directory (relative to plugin)- <RHDS_HOME>/jbossas.
- public static final String JBOSS_AS_RUNTIME_TYPE_ID =
"org.jboss.ide.eclipse.as.runtime.42";
+ public static final String JBOSS_AS_RUNTIME_TYPE_ID
+ = "org.jboss.ide.eclipse.as.runtime.42";
+
public static final String JBOSS_AS_TYPE_ID = "org.jboss.ide.eclipse.as.42";
+
public static final String JBOSS_AS_NAME = "JBoss Application Server 4.2";
+
public static final String JBOSS_AS_HOST = "localhost";
+
public static final String JBOSS_AS_DEFAULT_CONFIGURATION_NAME = "default";
public static final String FIRST_START_PREFERENCE_NAME = "FIRST_START";
+
+ public static final String HSQL_DRIVER_DEFINITION_ID
+ = "DriverDefn.Hypersonic DB";
+
+ public static final String HSQL_DRIVER_NAME = "Hypersonic DB";
+
+ public static final String HSQL_DRIVER_TEMPLATE_ID
+ = "org.eclipse.datatools.enablement.hsqldb.1_8.driver";
+
+ public static final String DTP_DB_URL_PROPERTY_ID
+ = "org.eclipse.datatools.connectivity.db.URL";
/**
* @see org.eclipse.ui.IStartup#earlyStartup()
*/
@@ -123,10 +152,83 @@
server.setName(JBOSS_AS_NAME);
server.save(false, progressMonitor);
}
+
+ DriverInstance driver = DriverManager.getInstance()
+ .getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if(driver==null) {
+ TemplateDescriptor descr = TemplateDescriptor
+ .getDriverTemplateDescriptor(HSQL_DRIVER_TEMPLATE_ID);
+ IPropertySet instance = new PropertySetImpl(
+ HSQL_DRIVER_NAME,HSQL_DRIVER_DEFINITION_ID);
+ instance.setName(HSQL_DRIVER_NAME);
+ instance.setID(HSQL_DRIVER_DEFINITION_ID);
+ Properties props = new Properties();
+
+ IConfigurationElement[] template = descr.getProperties();
+ for (int i = 0; i < template.length; i++) {
+ IConfigurationElement prop = template[i];
+ String id = prop.getAttribute("id"); //$NON-NLS-1$
+
+ String value = prop.getAttribute("value"); //$NON-NLS-1$
+ props.setProperty(id, value == null ? new String()
+ : value);
+ }
+ props.setProperty(DTP_DB_URL_PROPERTY_ID, "jdbc:hsqldb:.");
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE,
+ descr.getId());
+ props.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST,
+ jbossASLocation+"/server/default/lib/hsqldb.jar");
+
+ instance.setBaseProperties(props);
+ DriverManager.getInstance().removeDriverInstance(instance.getID());
+ System.gc();
+ DriverManager.getInstance().addDriverInstance(instance);
+
+ }
+
+ driver = DriverManager.getInstance().getDriverInstanceByName(HSQL_DRIVER_NAME);
+ if(driver!=null) {
+ // create profile
+ Properties props = new Properties();
+ props.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID,
+ HSQL_DRIVER_DEFINITION_ID);
+ props.setProperty(
+ IDBConnectionProfileConstants.CONNECTION_PROPERTIES_PROP_ID,
+ "");
+ props.setProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID,
+ driver.getProperty(IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID,
+ driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID,
+ driver.getProperty(IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID,
+ "Default");
+ props.setProperty(IDBDriverDefinitionConstants.PASSWORD_PROP_ID, "");
+ props.setProperty(
+ IDBConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, "false");
+ props.setProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID,
+ driver.getProperty(IDBDriverDefinitionConstants.USERNAME_PROP_ID));
+ props.setProperty(IDBDriverDefinitionConstants.URL_PROP_ID,
+ driver.getProperty(IDBDriverDefinitionConstants.URL_PROP_ID));
+
+ ProfileManager.getInstance().createProfile(
+ "DefaultDS",
+ "The JBoss AS Hypersonic embedded database",
+ IDBConnectionProfileConstants.CONNECTION_PROFILE_ID,
+ props,
+ "", false);
+ }
+
} catch (CoreException e) {
- JstFirstRunPlugin.getPluginLog().log(new
Status(IStatus.ERROR,"org.jboss.tools.jst.first.run","Can't create new
JBoss Server.", e));
+ JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
+ JstFirstRunPlugin.PLUGIN_ID,"Can't create new JBoss Server", e));
} catch (IOException e) {
- JstFirstRunPlugin.getPluginLog().log(new
Status(IStatus.ERROR,"org.jboss.tools.jst.first.run","Can't create new
JBoss Server.", e));
+ JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
+ JstFirstRunPlugin.PLUGIN_ID,"Can't create new JBoss Server", e));
+ } catch (ConnectionProfileException e) {
+ JstFirstRunPlugin.getPluginLog().log(new Status(IStatus.ERROR,
+ JstFirstRunPlugin.PLUGIN_ID,"Can't create new DTP " +
+ "Connection Profile for JBoss AS Hypersonic embedded database", e));
}
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JstFirstRunPlugin.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JstFirstRunPlugin.java 2007-08-28
16:45:59 UTC (rev 3394)
+++
trunk/jst/plugins/org.jboss.tools.jst.firstrun/src/org/jboss/tools/jst/firstrun/JstFirstRunPlugin.java 2007-08-29
01:12:56 UTC (rev 3395)
@@ -21,6 +21,8 @@
*
*/
public class JstFirstRunPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.jboss.tools.jst.firstrun";
static private JstFirstRunPlugin instance;