Revision: 830
http://datanucleus.svn.sourceforge.net/datanucleus/?rev=830&view=rev
Author: andy_jefferson
Date: 2008-04-28 12:20:35 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
[JCA-8] Add attempt at initialising using persistenceUnit in "freezeConfiguration". Who knows if this is used in the same way with JCA PMF but its a random guessing game
Modified Paths:
--------------
platform/jdo.connector/trunk/src/java/org/datanucleus/jdo/connector/ManagedConnectionFactoryImpl.java
Modified: platform/jdo.connector/trunk/src/java/org/datanucleus/jdo/connector/ManagedConnectionFactoryImpl.java
===================================================================
--- platform/jdo.connector/trunk/src/java/org/datanucleus/jdo/connector/ManagedConnectionFactoryImpl.java 2008-04-28 17:08:43 UTC (rev 829)
+++ platform/jdo.connector/trunk/src/java/org/datanucleus/jdo/connector/ManagedConnectionFactoryImpl.java 2008-04-28 19:20:35 UTC (rev 830)
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.Set;
+import javax.jdo.JDOUserException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
@@ -30,9 +31,12 @@
import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
+import org.datanucleus.exceptions.NucleusException;
import org.datanucleus.jdo.AbstractPersistenceManagerFactory;
import org.datanucleus.jdo.LifecycleListenerForClass;
+import org.datanucleus.metadata.PersistenceUnitMetaData;
import org.datanucleus.metadata.TransactionType;
+import org.datanucleus.util.NucleusLogger;
/**
* Implementation of the JCA adapter for use of JPOX in J2EE environments.
@@ -58,8 +62,46 @@
getOMFContext().setConnectionManager(new org.datanucleus.ConnectionManagerImpl(getOMFContext()));
}
+ /**
+ * Freezes the current configuration.
+ * @throws NucleusException if the configuration was invalid or inconsistent in some way
+ */
+ protected void freezeConfiguration()
+ {
+ // Check if we have persistenceUnitName defined so we can pull in the properties for that
+ String persistenceUnitName =
+ (String)getStringProperty("javax.jdo.option.PersistenceUnitName");
+ if (persistenceUnitName != null)
+ {
+ NucleusLogger.JDO.info(">> JCA PMF.freezeConfiguration persistence-unit=" + persistenceUnitName + " START");
+ // Specified to use a "persistence-unit", so take any props defined for the unit
+ try
+ {
+ PersistenceUnitMetaData pumd =
+ omfContext.getMetaDataManager().getMetaDataForPersistenceUnit(persistenceUnitName);
+ if (pumd != null)
+ {
+ // Add the properties for the unit
+ if (pumd.getProperties() != null)
+ {
+ setOptions(pumd.getProperties());
+ }
+ }
+ else
+ {
+ throw new JDOUserException(LOCALISER_JDO.msg("012004", persistenceUnitName));
+ }
+ }
+ catch (NucleusException jpe)
+ {
+ throw new JDOUserException(LOCALISER_JDO.msg("012005", persistenceUnitName));
+ }
+ NucleusLogger.JDO.info(">> JCA PMF.freezeConfiguration persistence-unit=" + persistenceUnitName + " DONE");
+ }
+ }
+
// ----------------------- Setters/Getters for JCA -------------------------
-
+
// --------------- Implementation of ManagedConnectionFactory --------------
/**
@@ -101,7 +143,8 @@
return super.equals(other);
}
- public int hashCode() {
+ public int hashCode()
+ {
return super.hashCode();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|