diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java index cc5a31a3f..d47b5fbbf 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -340,11 +340,6 @@ public class DatabaseConfig { */ private ClassLoadConfig classLoadConfig = new ClassLoadConfig(); - /** - * The data source JNDI name if using a JNDI DataSource. - */ - private String dataSourceJndiName; - /** * The naming convention. */ @@ -392,12 +387,12 @@ public class DatabaseConfig { * Note: It is possible that multiple servers are sharing the same state file as * long as they are in the same JVM/ClassLoader scope. In this case it is * recommended to use the same uuidNodeId configuration. - * + * * If you have multiple servers in different JVMs, do not share the state * files! */ private String uuidNodeId; - + /** * The clock used for setting the timestamps (e.g. @UpdatedTimestamp) on objects. */ @@ -1761,24 +1756,6 @@ public class DatabaseConfig { this.readOnlyDataSourceConfig = readOnlyDataSourceConfig; } - /** - * Return the JNDI name of the DataSource to use. - */ - public String getDataSourceJndiName() { - return dataSourceJndiName; - } - - /** - * Set the JNDI name of the DataSource to use. - *

- * By default a prefix of "java:comp/env/jdbc/" is used to lookup the - * DataSource. This prefix is not used if dataSourceJndiName starts with - * "java:". - */ - public void setDataSourceJndiName(String dataSourceJndiName) { - this.dataSourceJndiName = dataSourceJndiName; - } - /** * Return a value used to represent TRUE in the database. *

@@ -2061,14 +2038,14 @@ public class DatabaseConfig { public void setUuidStateFile(String uuidStateFile) { this.uuidStateFile = uuidStateFile; } - + /** - * Returns the V1-UUID-NodeId + * Returns the V1-UUID-NodeId */ public String getUuidNodeId() { return uuidNodeId; } - + /** * Sets the V1-UUID-NodeId. */ @@ -2937,7 +2914,6 @@ public class DatabaseConfig { asOfViewSuffix = p.get("asOfViewSuffix", asOfViewSuffix); asOfSysPeriod = p.get("asOfSysPeriod", asOfSysPeriod); historyTableSuffix = p.get("historyTableSuffix", historyTableSuffix); - dataSourceJndiName = p.get("dataSourceJndiName", dataSourceJndiName); jdbcFetchSizeFindEach = p.getInt("jdbcFetchSizeFindEach", jdbcFetchSizeFindEach); jdbcFetchSizeFindList = p.getInt("jdbcFetchSizeFindList", jdbcFetchSizeFindList); databasePlatformName = p.get("databasePlatformName", databasePlatformName); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java index 54bfff518..833f00986 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InitDataSource.java @@ -14,7 +14,6 @@ import javax.sql.DataSource; */ final class InitDataSource { - private final JndiDataSourceLookup jndiDataSourceFactory = new JndiDataSourceLookup(); private final DatabaseConfig config; /** @@ -41,21 +40,9 @@ final class InitDataSource { * Initialise the "main" read write DataSource from configuration. */ private DataSource initDataSource() { - final String jndiName = config.getDataSourceJndiName(); - if (jndiName != null) { - return jndiDataSource(jndiName); - } return createFromConfig(config.getDataSourceConfig(), false); } - private DataSource jndiDataSource(String jndiName) { - DataSource ds = jndiDataSourceFactory.lookup(jndiName); - if (ds == null) { - throw new PersistenceException("JNDI lookup for DataSource " + jndiName + " returned null."); - } - return ds; - } - /** * Initialise the "read only" DataSource from configuration. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/JndiDataSourceLookup.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/JndiDataSourceLookup.java deleted file mode 100644 index 09b2f7a9c..000000000 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/JndiDataSourceLookup.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.ebeaninternal.server.core; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.persistence.PersistenceException; -import javax.sql.DataSource; - -/** - * Helper to lookup a DataSource from JNDI. - */ -class JndiDataSourceLookup { - - /** - * Return the DataSource by JNDI lookup. - *

- * If name is null the 'default' dataSource is returned. - *

- */ - public DataSource lookup(String jndiName) { - try { - Context ctx = new InitialContext(); - DataSource ds = (DataSource) ctx.lookup(jndiName); - if (ds == null) { - throw new PersistenceException("JNDI DataSource [" + jndiName + "] not found?"); - } - return ds; - - } catch (NamingException ex) { - throw new PersistenceException(ex); - } - } -} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java index 413c79cbc..f5edf2688 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JtaTransactionManager.java @@ -27,7 +27,7 @@ public final class JtaTransactionManager implements ExternalTransactionManager { private TransactionScopeManager scope; /** - * Instantiates a new spring aware transaction scope manager. + * Instantiates a new JTA transaction manager. */ public JtaTransactionManager() { } @@ -37,10 +37,8 @@ public final class JtaTransactionManager implements ExternalTransactionManager { */ @Override public void setTransactionManager(Object txnMgr) { - // RB: At this stage not exposing TransactionManager to // the public API and hence the Object type and casting here - this.transactionManager = (TransactionManager) txnMgr; this.scope = transactionManager.scope(); } @@ -72,16 +70,13 @@ public final class JtaTransactionManager implements ExternalTransactionManager { } /** - * Looks for a current Spring managed transaction and wraps/returns that as a Ebean transaction. + * Looks for a current JTA managed transaction and wraps/returns that as an Ebean transaction. *

* Returns null if there is no current spring transaction (lazy loading outside a spring txn etc). - *

*/ @Override public Object getCurrentTransaction() { - TransactionSynchronizationRegistry syncRegistry = getSyncRegistry(); - SpiTransaction t = (SpiTransaction) syncRegistry.getResource(EBEAN_TXN_RESOURCE); if (t != null) { // we have already seen this transaction @@ -122,14 +117,10 @@ public final class JtaTransactionManager implements ExternalTransactionManager { return newTrans; } - /** - * Create a listener to register with JTA to enable Ebean to be - * notified when transactions commit and rollback. + * Create a listener to register with JTA to enable Ebean to be notified when transactions commit and rollback. *

- * This is used by Ebean to notify it's appropriate listeners and maintain it's server - * cache etc. - *

+ * This is used by Ebean to notify its appropriate listeners and maintain its server cache etc. */ private JtaTxnListener createJtaTxnListener(SpiTransaction t) { return new JtaTxnListener(transactionManager, t); @@ -169,7 +160,6 @@ public final class JtaTransactionManager implements ExternalTransactionManager { *

* When Ebean is notified (of the commit/rollback) it can then manage its * cache, notify BeanPersistListeners etc. - *

*/ private static class JtaTxnListener implements Synchronization {