You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/09/02 22:33:07 UTC
svn commit: r572145 -
/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
Author: aadamchik
Date: Sun Sep 2 13:33:06 2007
New Revision: 572145
URL: http://svn.apache.org/viewvc?rev=572145&view=rev
Log:
DataSource loading diagnostics
Modified:
cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java?rev=572145&r1=572144&r2=572145&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java (original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java Sun Sep 2 13:33:06 2007
@@ -218,7 +218,9 @@
.getEntityResolver()
.getClassDescriptorMap();
FaultFactory faultFactory = new SingletonFaultFactory();
- descriptors.addFactory(new JpaClassDescriptorFactory(descriptors, faultFactory));
+ descriptors.addFactory(new JpaClassDescriptorFactory(
+ descriptors,
+ faultFactory));
configuration.addDomain(domain);
EntityMapLoader loader = new EntityMapLoader(unit);
@@ -242,6 +244,13 @@
DataSource dataSource = isJTA ? unit.getJtaDataSource() : unit
.getNonJtaDataSource();
+ if (dataSource == null) {
+ String jta = isJTA ? "JTA" : "non-JTA";
+ logger.warn("NULL "
+ + jta
+ + " DataSource returned from PersistenceUnitInfo");
+ }
+
DbAdapter adapter = createCustomAdapter(loader.getContext(), unit);
DataNode node = new DataNode(name);
if (adapter == null) {
@@ -424,6 +433,10 @@
return unitLoader;
}
+ protected String getDefaultProperty(String key) {
+ return defaultProperties.getProperty(key);
+ }
+
// TODO: andrus, 4/29/2006 - this is copied from non-public conf.NodeDataSource. In
// Cayenne > 1.2 make it public.
class NodeDataSource implements DataSource {
@@ -434,34 +447,40 @@
this.node = node;
}
+ private DataSource getDataSource() {
+ DataSource ds = node.getDataSource();
+
+ if (ds == null) {
+ throw new IllegalStateException("DataNode has null DataSource");
+ }
+
+ return ds;
+ }
+
public Connection getConnection() throws SQLException {
- return node.getDataSource().getConnection();
+ return getDataSource().getConnection();
}
public Connection getConnection(String username, String password)
throws SQLException {
- return node.getDataSource().getConnection(username, password);
+ return getDataSource().getConnection(username, password);
}
public PrintWriter getLogWriter() throws SQLException {
- return node.getDataSource().getLogWriter();
+ return getDataSource().getLogWriter();
}
public void setLogWriter(PrintWriter out) throws SQLException {
- node.getDataSource().setLogWriter(out);
+ getDataSource().setLogWriter(out);
}
public void setLoginTimeout(int seconds) throws SQLException {
- node.getDataSource().setLoginTimeout(seconds);
+ getDataSource().setLoginTimeout(seconds);
}
public int getLoginTimeout() throws SQLException {
- return node.getDataSource().getLoginTimeout();
+ return getDataSource().getLoginTimeout();
}
- }
-
- protected String getDefaultProperty(String key) {
- return defaultProperties.getProperty(key);
}
class LazyConfiguration extends Configuration {