[jbosstools-commits] JBoss Tools SVN: r43481 - in workspace/akazakov/db: org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db and 3 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 6 16:45:24 EDT 2012
Author: akazakov
Date: 2012-09-06 16:45:24 -0400 (Thu, 06 Sep 2012)
New Revision: 43481
Added:
workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/persistence.xml
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java
Modified:
workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/MANIFEST.MF
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDbPlugin.java
workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF
Log:
Share project "org.jboss.tools.cdi.db" into "https://svn.jboss.org/repos/jbosstools"
https://issues.jboss.org/browse/JBIDE-12446
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/MANIFEST.MF
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/MANIFEST.MF 2012-09-06 19:44:48 UTC (rev 43480)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/MANIFEST.MF 2012-09-06 20:45:24 UTC (rev 43481)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Db
+Bundle-Name: CDI DB
Bundle-SymbolicName: org.jboss.tools.cdi.db;singleton:=true
Bundle-Version: 1.4.0.qualifier
Bundle-Activator: org.jboss.tools.cdi.db.CDIDbPlugin
@@ -10,3 +10,5 @@
org.jboss.tools.cdi.core
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Red Hat, Inc.
+Bundle-ClassPath: .
Added: workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/persistence.xml
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/persistence.xml (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/persistence.xml 2012-09-06 20:45:24 UTC (rev 43481)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Persistence deployment descriptor for dev profile -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+
+ <persistence-unit name="orgJbossToolsCdiDbEntityManagerFactory" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <!--jta-data-source>java:/orgJbossToolsCommonDbDatasource</jta-data-source-->
+ <properties>
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
+
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
+ <!--property name="hibernate.hbm2ddl.auto" value="update"/-->
+ <property name="hibernate.hbm2ddl.auto" value="create">
+ <property name="hibernate.show_sql" value="true"/>
+ <property name="hibernate.format_sql" value="true"/>
+ <!--property name="jboss.entity.manager.factory.jndi.name" value="java:/orgJbossToolsCdiDbEntityManagerFactory"/-->
+ </properties>
+ </persistence-unit>
+
+</persistence>
\ No newline at end of file
Property changes on: workspace/akazakov/db/org.jboss.tools.cdi.db/META-INF/persistence.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java 2012-09-06 20:45:24 UTC (rev 43481)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.cdi.db;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.cdi.db.entity.BeanEntity;
+import org.jboss.tools.cdi.db.entity.TypeEntity;
+import org.jboss.tools.common.db.AbstractDBManager;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class CDIDBManager extends AbstractDBManager {
+
+ private static final String ENTITY_MANAGER_FACTORY_NAME = "orgJbossToolsCdiDbEntityManagerFactory";
+ private static final String DB_NAME = "DB/derbyDB";
+
+ private static final CDIDBManager instance = new CDIDBManager();
+
+ private CDIDBManager() {
+ }
+
+ public static CDIDBManager getInstance() {
+ return instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.db.AbstractDBManager#getEntityManagerFactoryName()
+ */
+ @Override
+ protected String getEntityManagerFactoryName() {
+ return ENTITY_MANAGER_FACTORY_NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.db.AbstractDBManager#getDBPath()
+ */
+ @Override
+ protected String getDBPath() {
+ CDIDbPlugin plugin = CDIDbPlugin.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(), DB_NAME);
+ String location = file.getAbsolutePath();
+ return location;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.db.AbstractDBManager#getAnnotatedClasses()
+ */
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[]{BeanEntity.class, TypeEntity.class};
+ }
+}
\ No newline at end of file
Property changes on: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDbPlugin.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDbPlugin.java 2012-09-06 19:44:48 UTC (rev 43480)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDbPlugin.java 2012-09-06 20:45:24 UTC (rev 43481)
@@ -1,5 +1,8 @@
package org.jboss.tools.cdi.db;
+import java.sql.SQLException;
+
+import org.eclipse.swt.widgets.Display;
import org.jboss.tools.common.log.BaseUIPlugin;
import org.osgi.framework.BundleContext;
@@ -18,24 +21,34 @@
* The constructor
*/
public CDIDbPlugin() {
+ plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
+ public void start(BundleContext bundleContext) throws Exception {
+ super.start(bundleContext);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ CDIDBManager.getInstance().start();
+ } catch (InstantiationException | IllegalAccessException
+ | ClassNotFoundException | SQLException e) {
+ logError(e);
+ }
+ }
+ });
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
+ public void stop(BundleContext bundleContext) throws Exception {
+ CDIDBManager.getInstance().stop();
+ super.stop(bundleContext);
}
/**
Added: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java 2012-09-06 20:45:24 UTC (rev 43481)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.cdi.db.entity;
+
+/**
+ * @author Alexey Kazakov
+ */
+ at Entity
+public class BeanEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ private long id;
+ private String name;
+
+ /**
+ * @return the id
+ */
+ @Id
+ @GeneratedValue
+ @Column
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the name
+ */
+ @Column
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java 2012-09-06 20:45:24 UTC (rev 43481)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * 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.cdi.db.entity;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class TypeEntity {
+
+}
\ No newline at end of file
Property changes on: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF 2012-09-06 19:44:48 UTC (rev 43480)
+++ workspace/akazakov/db/org.jboss.tools.common.db/META-INF/MANIFEST.MF 2012-09-06 20:45:24 UTC (rev 43481)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: CommonDb
Bundle-SymbolicName: org.jboss.tools.common.db;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 3.4.0.qualifier
Bundle-Activator: org.jboss.tools.common.db.CommonDbPlugin
Bundle-Vendor: Red Hat, Inc.
Require-Bundle: org.eclipse.core.runtime,
@@ -10,7 +10,354 @@
org.jboss.tools.common
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Export-Package: org.jboss.tools.common.db
+Export-Package: antlr,
+ antlr.ASdebug,
+ antlr.actions.cpp,
+ antlr.actions.csharp,
+ antlr.actions.java,
+ antlr.actions.python,
+ antlr.build,
+ antlr.collections,
+ antlr.collections.impl,
+ antlr.debug,
+ antlr.debug.misc,
+ antlr.preprocessor,
+ javassist,
+ javassist.bytecode,
+ javassist.bytecode.analysis,
+ javassist.bytecode.annotation,
+ javassist.bytecode.stackmap,
+ javassist.compiler,
+ javassist.compiler.ast,
+ javassist.convert,
+ javassist.expr,
+ javassist.runtime,
+ javassist.scopedpool,
+ javassist.tools,
+ javassist.tools.reflect,
+ javassist.tools.rmi,
+ javassist.tools.web,
+ javassist.util,
+ javassist.util.proxy,
+ javax.persistence,
+ javax.persistence.criteria,
+ javax.persistence.metamodel,
+ javax.persistence.spi,
+ javax.transaction,
+ javax.transaction.xa,
+ org.apache.derby.authentication,
+ org.apache.derby.catalog,
+ org.apache.derby.catalog.types,
+ org.apache.derby.client,
+ org.apache.derby.client.am,
+ org.apache.derby.client.am.stmtcache,
+ org.apache.derby.client.net,
+ org.apache.derby.database,
+ org.apache.derby.diag,
+ org.apache.derby.drda,
+ org.apache.derby.iapi.db,
+ org.apache.derby.iapi.error,
+ org.apache.derby.iapi.jdbc,
+ org.apache.derby.iapi.reference,
+ org.apache.derby.iapi.security,
+ org.apache.derby.iapi.services.cache,
+ org.apache.derby.iapi.services.classfile,
+ org.apache.derby.iapi.services.compiler,
+ org.apache.derby.iapi.services.context,
+ org.apache.derby.iapi.services.crypto,
+ org.apache.derby.iapi.services.daemon,
+ org.apache.derby.iapi.services.diag,
+ org.apache.derby.iapi.services.i18n,
+ org.apache.derby.iapi.services.info,
+ org.apache.derby.iapi.services.io,
+ org.apache.derby.iapi.services.jmx,
+ org.apache.derby.iapi.services.loader,
+ org.apache.derby.iapi.services.locks,
+ org.apache.derby.iapi.services.memory,
+ org.apache.derby.iapi.services.monitor,
+ org.apache.derby.iapi.services.property,
+ org.apache.derby.iapi.services.stream,
+ org.apache.derby.iapi.services.timer,
+ org.apache.derby.iapi.services.uuid,
+ org.apache.derby.iapi.sql,
+ org.apache.derby.iapi.sql.compile,
+ org.apache.derby.iapi.sql.conn,
+ org.apache.derby.iapi.sql.depend,
+ org.apache.derby.iapi.sql.dictionary,
+ org.apache.derby.iapi.sql.execute,
+ org.apache.derby.iapi.sql.execute.xplain,
+ org.apache.derby.iapi.store.access,
+ org.apache.derby.iapi.store.access.conglomerate,
+ org.apache.derby.iapi.store.access.xa,
+ org.apache.derby.iapi.store.raw,
+ org.apache.derby.iapi.store.raw.data,
+ org.apache.derby.iapi.store.raw.log,
+ org.apache.derby.iapi.store.raw.xact,
+ org.apache.derby.iapi.store.replication.master,
+ org.apache.derby.iapi.store.replication.slave,
+ org.apache.derby.iapi.tools.i18n,
+ org.apache.derby.iapi.types,
+ org.apache.derby.iapi.util,
+ org.apache.derby.impl.db,
+ org.apache.derby.impl.drda,
+ org.apache.derby.impl.io,
+ org.apache.derby.impl.io.vfmem,
+ org.apache.derby.impl.jdbc,
+ org.apache.derby.impl.jdbc.authentication,
+ org.apache.derby.impl.load,
+ org.apache.derby.impl.services.bytecode,
+ org.apache.derby.impl.services.cache,
+ org.apache.derby.impl.services.daemon,
+ org.apache.derby.impl.services.jce,
+ org.apache.derby.impl.services.jmx,
+ org.apache.derby.impl.services.jmxnone,
+ org.apache.derby.impl.services.locks,
+ org.apache.derby.impl.services.monitor,
+ org.apache.derby.impl.services.reflect,
+ org.apache.derby.impl.services.stream,
+ org.apache.derby.impl.services.timer,
+ org.apache.derby.impl.services.uuid,
+ org.apache.derby.impl.sql,
+ org.apache.derby.impl.sql.catalog,
+ org.apache.derby.impl.sql.compile,
+ org.apache.derby.impl.sql.conn,
+ org.apache.derby.impl.sql.depend,
+ org.apache.derby.impl.sql.execute,
+ org.apache.derby.impl.sql.execute.rts,
+ org.apache.derby.impl.sql.execute.xplain,
+ org.apache.derby.impl.store.access,
+ org.apache.derby.impl.store.access.btree,
+ org.apache.derby.impl.store.access.btree.index,
+ org.apache.derby.impl.store.access.conglomerate,
+ org.apache.derby.impl.store.access.heap,
+ org.apache.derby.impl.store.access.sort,
+ org.apache.derby.impl.store.raw,
+ org.apache.derby.impl.store.raw.data,
+ org.apache.derby.impl.store.raw.log,
+ org.apache.derby.impl.store.raw.xact,
+ org.apache.derby.impl.store.replication,
+ org.apache.derby.impl.store.replication.buffer,
+ org.apache.derby.impl.store.replication.master,
+ org.apache.derby.impl.store.replication.net,
+ org.apache.derby.impl.store.replication.slave,
+ org.apache.derby.impl.tools.dblook,
+ org.apache.derby.impl.tools.ij,
+ org.apache.derby.impl.tools.planexporter,
+ org.apache.derby.impl.tools.sysinfo,
+ org.apache.derby.io,
+ org.apache.derby.jdbc,
+ org.apache.derby.mbeans,
+ org.apache.derby.mbeans.drda,
+ org.apache.derby.osgi,
+ org.apache.derby.security,
+ org.apache.derby.shared.common.error,
+ org.apache.derby.shared.common.i18n,
+ org.apache.derby.tools,
+ org.apache.derby.vti,
+ org.dom4j,
+ org.dom4j.bean,
+ org.dom4j.datatype,
+ org.dom4j.dom,
+ org.dom4j.dtd,
+ org.dom4j.io,
+ org.dom4j.jaxb,
+ org.dom4j.rule,
+ org.dom4j.rule.pattern,
+ org.dom4j.swing,
+ org.dom4j.tree,
+ org.dom4j.util,
+ org.dom4j.xpath,
+ org.dom4j.xpp,
+ org.hibernate,
+ org.hibernate.action.internal,
+ org.hibernate.action.spi,
+ org.hibernate.annotations,
+ org.hibernate.annotations.common,
+ org.hibernate.annotations.common.annotationfactory,
+ org.hibernate.annotations.common.reflection,
+ org.hibernate.annotations.common.reflection.java,
+ org.hibernate.annotations.common.reflection.java.generics,
+ org.hibernate.annotations.common.util,
+ org.hibernate.annotations.common.util.impl,
+ org.hibernate.bytecode.buildtime.internal,
+ org.hibernate.bytecode.buildtime.spi,
+ org.hibernate.bytecode.instrumentation.internal,
+ org.hibernate.bytecode.instrumentation.internal.javassist,
+ org.hibernate.bytecode.instrumentation.spi,
+ org.hibernate.bytecode.internal.javassist,
+ org.hibernate.bytecode.spi,
+ org.hibernate.cache,
+ org.hibernate.cache.internal,
+ org.hibernate.cache.spi,
+ org.hibernate.cache.spi.access,
+ org.hibernate.cache.spi.entry,
+ org.hibernate.cfg,
+ org.hibernate.cfg.annotations,
+ org.hibernate.cfg.annotations.reflection,
+ org.hibernate.cfg.beanvalidation,
+ org.hibernate.classic,
+ org.hibernate.collection.internal,
+ org.hibernate.collection.spi,
+ org.hibernate.context,
+ org.hibernate.context.internal,
+ org.hibernate.context.spi,
+ org.hibernate.criterion,
+ org.hibernate.dialect,
+ org.hibernate.dialect.function,
+ org.hibernate.dialect.lock,
+ org.hibernate.dialect.pagination,
+ org.hibernate.dialect.resolver,
+ org.hibernate.ejb,
+ org.hibernate.ejb.cfg.spi,
+ org.hibernate.ejb.connection,
+ org.hibernate.ejb.criteria,
+ org.hibernate.ejb.criteria.expression,
+ org.hibernate.ejb.criteria.expression.function,
+ org.hibernate.ejb.criteria.path,
+ org.hibernate.ejb.criteria.predicate,
+ org.hibernate.ejb.event,
+ org.hibernate.ejb.instrument,
+ org.hibernate.ejb.internal,
+ org.hibernate.ejb.metamodel,
+ org.hibernate.ejb.packaging,
+ org.hibernate.ejb.util,
+ org.hibernate.engine,
+ org.hibernate.engine.internal,
+ org.hibernate.engine.jdbc,
+ org.hibernate.engine.jdbc.batch.internal,
+ org.hibernate.engine.jdbc.batch.spi,
+ org.hibernate.engine.jdbc.internal,
+ org.hibernate.engine.jdbc.internal.proxy,
+ org.hibernate.engine.jdbc.spi,
+ org.hibernate.engine.loading.internal,
+ org.hibernate.engine.profile,
+ org.hibernate.engine.query.spi,
+ org.hibernate.engine.query.spi.sql,
+ org.hibernate.engine.spi,
+ org.hibernate.engine.transaction.internal,
+ org.hibernate.engine.transaction.internal.jdbc,
+ org.hibernate.engine.transaction.internal.jta,
+ org.hibernate.engine.transaction.spi,
+ org.hibernate.engine.transaction.synchronization.internal,
+ org.hibernate.engine.transaction.synchronization.spi,
+ org.hibernate.event.internal,
+ org.hibernate.event.service.internal,
+ org.hibernate.event.service.spi,
+ org.hibernate.event.spi,
+ org.hibernate.exception,
+ org.hibernate.exception.internal,
+ org.hibernate.exception.spi,
+ org.hibernate.hql.internal,
+ org.hibernate.hql.internal.antlr,
+ org.hibernate.hql.internal.ast,
+ org.hibernate.hql.internal.ast.exec,
+ org.hibernate.hql.internal.ast.tree,
+ org.hibernate.hql.internal.ast.util,
+ org.hibernate.hql.internal.classic,
+ org.hibernate.hql.spi,
+ org.hibernate.id,
+ org.hibernate.id.enhanced,
+ org.hibernate.id.factory,
+ org.hibernate.id.factory.internal,
+ org.hibernate.id.factory.spi,
+ org.hibernate.id.insert,
+ org.hibernate.id.uuid,
+ org.hibernate.integrator.internal,
+ org.hibernate.integrator.spi,
+ org.hibernate.internal,
+ org.hibernate.internal.jaxb,
+ org.hibernate.internal.jaxb.cfg,
+ org.hibernate.internal.jaxb.mapping.hbm,
+ org.hibernate.internal.jaxb.mapping.orm,
+ org.hibernate.internal.util,
+ org.hibernate.internal.util.beans,
+ org.hibernate.internal.util.collections,
+ org.hibernate.internal.util.compare,
+ org.hibernate.internal.util.config,
+ org.hibernate.internal.util.io,
+ org.hibernate.internal.util.jndi,
+ org.hibernate.internal.util.xml,
+ org.hibernate.jdbc,
+ org.hibernate.jmx,
+ org.hibernate.loader,
+ org.hibernate.loader.collection,
+ org.hibernate.loader.criteria,
+ org.hibernate.loader.custom,
+ org.hibernate.loader.custom.sql,
+ org.hibernate.loader.entity,
+ org.hibernate.loader.hql,
+ org.hibernate.lob,
+ org.hibernate.mapping,
+ org.hibernate.metadata,
+ org.hibernate.metamodel,
+ org.hibernate.metamodel.binding,
+ org.hibernate.metamodel.domain,
+ org.hibernate.metamodel.relational,
+ org.hibernate.metamodel.relational.state,
+ org.hibernate.metamodel.source,
+ org.hibernate.metamodel.source.annotations,
+ org.hibernate.metamodel.source.annotations.attribute,
+ org.hibernate.metamodel.source.annotations.attribute.type,
+ org.hibernate.metamodel.source.annotations.entity,
+ org.hibernate.metamodel.source.annotations.global,
+ org.hibernate.metamodel.source.annotations.xml,
+ org.hibernate.metamodel.source.annotations.xml.filter,
+ org.hibernate.metamodel.source.annotations.xml.mocker,
+ org.hibernate.metamodel.source.binder,
+ org.hibernate.metamodel.source.hbm,
+ org.hibernate.metamodel.source.internal,
+ org.hibernate.param,
+ org.hibernate.persister.collection,
+ org.hibernate.persister.entity,
+ org.hibernate.persister.internal,
+ org.hibernate.persister.spi,
+ org.hibernate.pretty,
+ org.hibernate.property,
+ org.hibernate.proxy,
+ org.hibernate.proxy.dom4j,
+ org.hibernate.proxy.map,
+ org.hibernate.proxy.pojo,
+ org.hibernate.proxy.pojo.javassist,
+ org.hibernate.secure.internal,
+ org.hibernate.service,
+ org.hibernate.service.classloading.internal,
+ org.hibernate.service.classloading.spi,
+ org.hibernate.service.config.internal,
+ org.hibernate.service.config.spi,
+ org.hibernate.service.internal,
+ org.hibernate.service.jdbc.connections.internal,
+ org.hibernate.service.jdbc.connections.spi,
+ org.hibernate.service.jdbc.dialect.internal,
+ org.hibernate.service.jdbc.dialect.spi,
+ org.hibernate.service.jmx.internal,
+ org.hibernate.service.jmx.spi,
+ org.hibernate.service.jndi,
+ org.hibernate.service.jndi.internal,
+ org.hibernate.service.jndi.spi,
+ org.hibernate.service.jta.platform.internal,
+ org.hibernate.service.jta.platform.spi,
+ org.hibernate.service.spi,
+ org.hibernate.sql,
+ org.hibernate.sql.ordering.antlr,
+ org.hibernate.stat,
+ org.hibernate.stat.internal,
+ org.hibernate.stat.spi,
+ org.hibernate.tool.hbm2ddl,
+ org.hibernate.tool.instrument,
+ org.hibernate.tool.instrument.javassist,
+ org.hibernate.transaction,
+ org.hibernate.transform,
+ org.hibernate.tuple,
+ org.hibernate.tuple.component,
+ org.hibernate.tuple.entity,
+ org.hibernate.type,
+ org.hibernate.type.descriptor,
+ org.hibernate.type.descriptor.java,
+ org.hibernate.type.descriptor.sql,
+ org.hibernate.usertype,
+ org.jboss.logging,
+ org.jboss.tools.common.db,
+ org.jboss.tools.common.db.test
Bundle-ClassPath: .,
lib/antlr-2.7.7.jar,
lib/derby.jar,
Added: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java (rev 0)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java 2012-09-06 20:45:24 UTC (rev 43481)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.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.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class AbstractDBManager {
+
+ protected static final String driver = "org.apache.derby.jdbc.ClientDriver";
+ protected static final String protocol = "jdbc:derby:";
+
+ protected boolean started;
+ protected String url;
+
+ protected EntityManagerFactory emf;
+
+ protected abstract String getEntityManagerFactoryName();
+
+ protected abstract String getDBPath();
+
+ protected abstract Class[] getAnnotatedClasses();
+
+ public synchronized void start() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
+ if(started) {
+ return;
+ }
+ CommonDbPlugin.getDefault().getBundle().loadClass(driver).newInstance();
+ Properties props = new Properties();
+ url = protocol + getDBPath();
+ Connection conn = DriverManager.getConnection(url + ";create=true", props);
+ conn.close();
+ started = true;
+ init();
+ }
+
+ public EntityManager createEntityManager() {
+ try {
+ start();
+ } catch (InstantiationException | IllegalAccessException
+ | ClassNotFoundException | 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(getEntityManagerFactoryName(), configOverrides);
+ Class[] annotatedClasses = getAnnotatedClasses();
+ for (Class annotatedClass : annotatedClasses) {
+ configured.addAnnotatedClass(annotatedClass);
+ }
+// 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(url);
+ } 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/AbstractDBManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
More information about the jbosstools-commits
mailing list