From fc104f63b8c3b5a537c9e97ec08f0a2122fbb075 Mon Sep 17 00:00:00 2001 From: erik Date: Sun, 4 Apr 2010 12:16:22 +0000 Subject: [PATCH] --- .../hibernate/HibernateJpaCustomizer.java | 31 ---------- .../hibernate/HibernateTables.java | 20 ------- .../toplink/JndiSessionCustomizer.java | 59 ------------------- .../toplink/ToplinkJpaCustomizer.java | 30 ---------- .../persistence/toplink/ToplinkTables.java | 20 ------- 5 files changed, 160 deletions(-) delete mode 100644 trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java delete mode 100644 trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java delete mode 100644 trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java delete mode 100644 trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java delete mode 100644 trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java diff --git a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java b/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java deleted file mode 100644 index fa4def8f..00000000 --- a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.wamblee.support.persistence.hibernate; - -import java.util.Map; - -import org.dbunit.dataset.filter.ITableFilterSimple; -import org.wamblee.support.persistence.JpaCustomizer; -import org.wamblee.support.persistence.PersistenceUnitDescription; - -public class HibernateJpaCustomizer implements JpaCustomizer { - - public HibernateJpaCustomizer() { - // Empty - } - - @Override - public void customize(PersistenceUnitDescription aPersistenceUnit, Map aJpaProperties) { - // Hibernate: Override transaction type and datasource - aJpaProperties.put("javax.persistence.transactionType", "RESOURCE_LOCAL"); - aJpaProperties.put("javax.persistence.jtaDataSource", null); - aJpaProperties.put("javax.persistence.nonJtaDataSource", aPersistenceUnit.getJndiName()); - - // Hibernate schema generation - aJpaProperties.put("hibernate.hbm2ddl.auto", "create"); - } - - @Override - public ITableFilterSimple getJpaTables() { - return new HibernateTables(); - } - -} diff --git a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java b/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java deleted file mode 100644 index 4b2c8a09..00000000 --- a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.wamblee.support.persistence.hibernate; - -import java.util.Arrays; -import java.util.List; - -import org.dbunit.dataset.DataSetException; -import org.dbunit.dataset.filter.ITableFilterSimple; - -/** - * Toplink-specific tables. - */ -public class HibernateTables implements ITableFilterSimple { - - private static final List TABLES = Arrays.asList(new String[] { "" } ); - - public boolean accept(String aTableName) throws DataSetException { - return TABLES.contains(aTableName); - } - -} diff --git a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java b/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java deleted file mode 100644 index 541eb504..00000000 --- a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.wamblee.support.persistence.toplink; - -import javax.naming.Context; -import javax.naming.InitialContext; - -import org.eclipse.persistence.config.SessionCustomizer; -import org.eclipse.persistence.sessions.DatabaseLogin; -import org.eclipse.persistence.sessions.JNDIConnector; -import org.eclipse.persistence.sessions.Session; -import org.eclipse.persistence.sessions.server.ServerSession; - -/** - * See http://wiki.eclipse.org/Customizing_the_EclipseLink_Application_(ELUG) Use for clients that would like to use a - * JTA SE pu instead of a RESOURCE_LOCAL SE pu. - * - * This utility also makes sure that using a persistence.xml with a JTA datasource works in a standalone Java SE - * environment together with our JNDI stub. - */ -public class JndiSessionCustomizer - implements SessionCustomizer { - - public JndiSessionCustomizer() { - // Empty. - } - - /** - * Get a dataSource connection and set it on the session with lookupType=STRING_LOOKUP - */ - public void customize(Session session) throws Exception { - JNDIConnector connector = null; - Context context = null; - try { - context = new InitialContext(); - if(null != context) { - connector = (JNDIConnector)session.getLogin().getConnector(); // possible CCE - // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP - // Note: if both jta and non-jta elements exist this will only change the first one - and may still result in - // the COMPOSITE_NAME_LOOKUP being set - // Make sure only jta-data-source is in persistence.xml with no non-jta-data-source property set - connector.setLookupType(JNDIConnector.STRING_LOOKUP); - - // Or, if you are specifying both JTA and non-JTA in your persistence.xml then set both connectors to be safe - JNDIConnector writeConnector = (JNDIConnector)session.getLogin().getConnector(); - writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - JNDIConnector readConnector = - (JNDIConnector)((DatabaseLogin)((ServerSession)session).getReadConnectionPool().getLogin()).getConnector(); - readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - - System.out.println("JndiSessionCustomizer: configured " + connector.getName()); - } - else { - throw new Exception("JndiSessionCustomizer: Context is null"); - } - } - catch(Exception e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java b/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java deleted file mode 100644 index fb4c681c..00000000 --- a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.wamblee.support.persistence.toplink; - -import java.util.Map; - -import org.dbunit.dataset.filter.ITableFilterSimple; -import org.wamblee.support.persistence.JpaCustomizer; -import org.wamblee.support.persistence.PersistenceUnitDescription; - -public class ToplinkJpaCustomizer implements JpaCustomizer { - - public ToplinkJpaCustomizer() { - // Empty - } - - @Override - public void customize(PersistenceUnitDescription aPersistenceUnit, Map aJpaProperties) { - // Hack to make JNDI lookup of the datasource work with toplink - aJpaProperties.put("eclipselink.session.customizer", JndiSessionCustomizer.class - .getName()); - - // DDL generation for toplink - aJpaProperties.put("eclipselink.ddl-generation", "create-tables"); - } - - @Override - public ITableFilterSimple getJpaTables() { - return new ToplinkTables(); - } - -} diff --git a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java b/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java deleted file mode 100644 index cd3a0562..00000000 --- a/trunk/support/test/enterprise/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.wamblee.support.persistence.toplink; - -import java.util.Arrays; -import java.util.List; - -import org.dbunit.dataset.DataSetException; -import org.dbunit.dataset.filter.ITableFilterSimple; - -/** - * Toplink-specific tables. - */ -public class ToplinkTables implements ITableFilterSimple { - - private static final List TABLES = Arrays.asList(new String[] { "SEQUENCE" } ); - - public boolean accept(String aTableName) throws DataSetException { - return TABLES.contains(aTableName); - } - -} -- 2.31.1