[jbosstools-commits] JBoss Tools SVN: r43524 - in workspace/akazakov/db/org.jboss.tools.common.db/src: org/jboss/tools/common/db and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Sep 7 15:56:13 EDT 2012


Author: akazakov
Date: 2012-09-07 15:56:13 -0400 (Fri, 07 Sep 2012)
New Revision: 43524

Added:
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/DBManager.java
Removed:
   workspace/akazakov/db/org.jboss.tools.common.db/src/META-INF/
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java
Modified:
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java
   workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java
Log:
https://issues.jboss.org/browse/JBIDE-12446

Modified: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java	2012-09-07 19:54:43 UTC (rev 43523)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/CommonDbPlugin.java	2012-09-07 19:56:13 UTC (rev 43524)
@@ -1,8 +1,5 @@
 package org.jboss.tools.common.db;
 
-import java.sql.SQLException;
-
-import org.eclipse.swt.widgets.Display;
 import org.jboss.tools.common.log.BaseUIPlugin;
 import org.osgi.framework.BundleContext;
 
@@ -26,21 +23,6 @@
 	 */
 	public void start(BundleContext bundleContext) throws Exception {
 		super.start(bundleContext);
-        Display.getDefault().asyncExec(new Runnable() {
-        	public void run() {
-				try {
-					DBManager.getInstance().start();
-				} catch (InstantiationException e) {
-					logError(e);
-				} catch (IllegalAccessException e) {
-					logError(e);
-				} catch (ClassNotFoundException e) {
-					logError(e);
-				} catch (SQLException e) {
-					logError(e);
-				}
-        	}
-        });
 	}
 
 	/*
@@ -48,7 +30,6 @@
 	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
 	 */
 	public void stop(BundleContext bundleContext) throws Exception {
-		DBManager.getInstance().stop();
 		super.stop(bundleContext);
 	}
 }
\ No newline at end of file

Deleted: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java	2012-09-07 19:54:43 UTC (rev 43523)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java	2012-09-07 19:56:13 UTC (rev 43524)
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.db;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.eclipse.core.runtime.IPath;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.jboss.tools.common.db.test.ModelObject;
-
-/**
- * @author Alexey Kazakov
- */
-public class DBManager {
-
-	private static final String entityManagerFactoryName = "orgJbossToolsCommonDbEntityManagerFactory";
-	private static final String driver = "org.apache.derby.jdbc.ClientDriver";
-	private static final String protocol = "jdbc:derby:";
-	private static final String dbName = "DB/derbyDB";
-	//	String protocol = "jdbc:derby:";
-
-	private static DBManager instance = new DBManager();
-
-	private static boolean started;
-	private String url;
-
-	private EntityManagerFactory emf;
-//	private EntityManager em;
-
-	private DBManager() {
-	}
-
-	public static DBManager getInstance() {
-		return instance;
-	}
-
-	public synchronized void start() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
-		if(started) {
-			return;
-		}
-		CommonDbPlugin.getDefault().getBundle().loadClass(driver).newInstance();
-		Properties props = new Properties();
-		CommonDbPlugin plugin = CommonDbPlugin.getDefault();
-		//The plug-in instance can be null at shutdown, when the plug-in is stopped. 
-		IPath path = plugin.getStateLocation();
-		File file = new File(path.toFile(), dbName); //$NON-NLS-1$
-		String location = file.getAbsolutePath();
-		url = protocol + location + ";create=true";
-		Connection conn = DriverManager.getConnection(url, props);
-		conn.close();
-		started = true;
-		init();
-	}
-
-	public EntityManager createEntityManager() {
-		try {
-			start();
-		} catch (InstantiationException e) {
-			CommonDbPlugin.getDefault().logError(e);
-		} catch (IllegalAccessException e) {
-			CommonDbPlugin.getDefault().logError(e);
-		} catch (ClassNotFoundException e) {
-			CommonDbPlugin.getDefault().logError(e);
-		} catch (SQLException e) {
-			CommonDbPlugin.getDefault().logError(e);
-		}
-		EntityManager em = emf.createEntityManager();
-		return em;
-	}
-
-	private void init() {
-		Map<String, Object> configOverrides = new HashMap<String, Object>();
-		configOverrides.put("javax.persistence.jdbc.url", url);
-
-//		emf = Persistence.createEntityManagerFactory(entityManagerFactoryName, configOverrides);
-
-		Ejb3Configuration cfg = new Ejb3Configuration();
-		Ejb3Configuration configured = cfg.configure(entityManagerFactoryName, configOverrides);
-		configured.addAnnotatedClass(ModelObject.class);
-//		configured.setProperty("javax.persistence.jdbc.driver", driver);
-//		configured.setProperty("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
-//		configured.setProperty("hibernate.hbm2ddl.auto", "create");
-//		configured.setProperty("hibernate.show_sql", "true");
-//		configured.setProperty("hibernate.format_sql", "true");
-		emf = configured.buildEntityManagerFactory();
-	}
-
-	public synchronized void stop() {
-		if(!started) {
-			return;
-		}
-        try {
-        	emf.close();
-            DriverManager.getConnection("jdbc:derby:;shutdown=true");
-        } catch (SQLException e) {
-            if (((e.getErrorCode() != 50000) || (!"XJ015".equals(e.getSQLState()) ))) {
-            	//"Derby did not shut down normally"
-            	CommonDbPlugin.getDefault().logError(e);
-            } else {
-            	started = false;
-            }
-        }
-	}
-}
\ No newline at end of file

Copied: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/DBManager.java (from rev 43522, workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/DBManager.java)
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/DBManager.java	                        (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/DBManager.java	2012-09-07 19:56:13 UTC (rev 43524)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.db.test;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.eclipse.core.runtime.IPath;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.jboss.tools.common.db.CommonDbPlugin;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class DBManager {
+
+	private static final String entityManagerFactoryName = "orgJbossToolsCommonDbEntityManagerFactory";
+	private static final String driver = "org.apache.derby.jdbc.ClientDriver";
+	private static final String protocol = "jdbc:derby:";
+	private static final String dbName = "DB/derbyDB";
+	//	String protocol = "jdbc:derby:";
+
+	private static DBManager instance = new DBManager();
+
+	private static boolean started;
+	private String url;
+
+	private EntityManagerFactory emf;
+//	private EntityManager em;
+
+	private DBManager() {
+	}
+
+	public static DBManager getInstance() {
+		return instance;
+	}
+
+	public synchronized void start() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
+		if(started) {
+			return;
+		}
+		CommonDbPlugin.getDefault().getBundle().loadClass(driver).newInstance();
+		Properties props = new Properties();
+		CommonDbPlugin plugin = CommonDbPlugin.getDefault();
+		//The plug-in instance can be null at shutdown, when the plug-in is stopped. 
+		IPath path = plugin.getStateLocation();
+		File file = new File(path.toFile(), dbName); //$NON-NLS-1$
+		String location = file.getAbsolutePath();
+		url = protocol + location + ";create=true";
+		Connection conn = DriverManager.getConnection(url, props);
+		conn.close();
+		started = true;
+		init();
+	}
+
+	public EntityManager createEntityManager() {
+		try {
+			start();
+		} catch (InstantiationException e) {
+			CommonDbPlugin.getDefault().logError(e);
+		} catch (IllegalAccessException e) {
+			CommonDbPlugin.getDefault().logError(e);
+		} catch (ClassNotFoundException e) {
+			CommonDbPlugin.getDefault().logError(e);
+		} catch (SQLException e) {
+			CommonDbPlugin.getDefault().logError(e);
+		}
+		EntityManager em = emf.createEntityManager();
+		return em;
+	}
+
+	private void init() {
+		Map<String, Object> configOverrides = new HashMap<String, Object>();
+		configOverrides.put("javax.persistence.jdbc.url", url);
+
+//		emf = Persistence.createEntityManagerFactory(entityManagerFactoryName, configOverrides);
+
+		Ejb3Configuration cfg = new Ejb3Configuration();
+		Ejb3Configuration configured = cfg.configure(entityManagerFactoryName, configOverrides);
+		configured.addAnnotatedClass(ModelObject.class);
+//		configured.setProperty("javax.persistence.jdbc.driver", driver);
+//		configured.setProperty("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
+//		configured.setProperty("hibernate.hbm2ddl.auto", "create");
+//		configured.setProperty("hibernate.show_sql", "true");
+//		configured.setProperty("hibernate.format_sql", "true");
+		emf = configured.buildEntityManagerFactory();
+	}
+
+	public synchronized void stop() {
+		if(!started) {
+			return;
+		}
+        try {
+        	emf.close();
+            DriverManager.getConnection("jdbc:derby:;shutdown=true");
+        } catch (SQLException e) {
+            if (((e.getErrorCode() != 50000) || (!"XJ015".equals(e.getSQLState()) ))) {
+            	//"Derby did not shut down normally"
+            	CommonDbPlugin.getDefault().logError(e);
+            } else {
+            	started = false;
+            }
+        }
+	}
+}
\ No newline at end of file


Property changes on: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/DBManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java	2012-09-07 19:54:43 UTC (rev 43523)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/test/StartDBAction.java	2012-09-07 19:56:13 UTC (rev 43524)
@@ -8,7 +8,6 @@
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.jboss.tools.common.db.DBManager;
 
 public class StartDBAction implements IWorkbenchWindowActionDelegate {
 



More information about the jbosstools-commits mailing list