You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2004/08/14 10:37:40 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker PersistenceBrokerFactory.java
tomdz 2004/08/14 01:37:40
Modified: src/java/org/apache/ojb/broker/metadata MetadataManager.java
src/java/org/apache/ojb/broker PersistenceBrokerFactory.java
Log:
To preserve 1.0 behavior the OJB instance in the PBF is now created automatic upon request if none was set yet
The MetadataManager.getInstance now uses the OJB instance in the PBF instead of a separate singleton
Revision Changes Path
1.21 +4 -8 db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java
Index: MetadataManager.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/MetadataManager.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- MetadataManager.java 11 Aug 2004 00:41:47 -0000 1.20
+++ MetadataManager.java 14 Aug 2004 08:37:40 -0000 1.21
@@ -23,6 +23,7 @@
import org.apache.commons.lang.SerializationUtils;
import org.apache.ojb.broker.PBKey;
+import org.apache.ojb.broker.PersistenceBrokerFactory;
import org.apache.ojb.broker.core.PersistenceBrokerConfiguration;
import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
import org.apache.ojb.broker.util.logging.Logger;
@@ -124,7 +125,6 @@
private static final String MSG_STR = "* Can't find DescriptorRepository for current thread, use default one *";
private static ThreadLocal threadedRepository = new ThreadLocal();
- private static MetadataManager singleton;
private Hashtable metadataProfiles;
private DescriptorRepository globalRepository;
@@ -166,12 +166,8 @@
*/
public static synchronized MetadataManager getInstance()
{
- // lazy initialization
- if (singleton == null)
- {
- singleton = new MetadataManager();
- }
- return singleton;
+ // we use the setup'd OJB instance
+ return PersistenceBrokerFactory.getOjb().getMetadataManager();
}
public PersistenceConfigurationDescriptor getConfigurationFor(PBKey key)
1.25 +13 -7 db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerFactory.java
Index: PersistenceBrokerFactory.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PersistenceBrokerFactory.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- PersistenceBrokerFactory.java 11 Aug 2004 00:41:49 -0000 1.24
+++ PersistenceBrokerFactory.java 14 Aug 2004 08:37:40 -0000 1.25
@@ -44,6 +44,12 @@
public static OJB getOjb()
{
+ // To preserve OJB 1.0 behavior, we create a default OJB instance if the
+ // OJB instance is request but hasn't been configured yet
+ if (ojb == null)
+ {
+ ojb = new OJB();
+ }
return ojb;
}
@@ -63,7 +69,7 @@
*/
public static void setDefaultKey(PBKey key)
{
- ojb.getMetadataManager().setDefaultPBKey(key);
+ getOjb().getMetadataManager().setDefaultPBKey(key);
}
/**
@@ -71,7 +77,7 @@
*/
public static PBKey getDefaultKey()
{
- return ojb.getMetadataManager().getDefaultPBKey();
+ return getOjb().getMetadataManager().getDefaultPBKey();
}
/**
@@ -79,7 +85,7 @@
*/
public static PersistenceBroker defaultPersistenceBroker() throws PBFactoryException
{
- return ojb.lookupBroker();
+ return getOjb().lookupBroker();
}
/**
@@ -89,7 +95,7 @@
String user, String password)
throws PBFactoryException
{
- return ojb.lookupBroker(jcdAlias, user, password);
+ return getOjb().lookupBroker(jcdAlias, user, password);
}
/**
@@ -98,7 +104,7 @@
public static PersistenceBroker createPersistenceBroker(PBKey key)
throws PBFactoryException
{
- return ojb.lookupBroker(key);
+ return getOjb().lookupBroker(key);
}
/**
@@ -106,7 +112,7 @@
*/
public synchronized static void releaseAllInstances()
{
- List list = ojb.getConfigurations();
+ List list = getOjb().getConfigurations();
for (int i = 0; i < list.size(); i++)
{
((PersistenceConfiguration) list.get(i)).getPersistenceBrokerFactory().releaseAllInstances();
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org