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 mk...@apache.org on 2005/03/11 19:25:01 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/core/proxy AbstractCollectionProxy.java
mkalen 2005/03/11 10:25:01
Modified: src/java/org/apache/ojb/broker/core/proxy
AbstractCollectionProxy.java
Log:
Merge with OJB_1_0_RELEASE branch: merge JavaDoc and placement of loadProfileIfNeeded (not as important in OJB1.1 but still good to keep it in a central location).
Revision Changes Path
1.5 +17 -16 db-ojb/src/java/org/apache/ojb/broker/core/proxy/AbstractCollectionProxy.java
Index: AbstractCollectionProxy.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/proxy/AbstractCollectionProxy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractCollectionProxy.java 11 Mar 2005 18:07:21 -0000 1.4
+++ AbstractCollectionProxy.java 11 Mar 2005 18:25:01 -0000 1.5
@@ -61,7 +61,7 @@
*/
private transient Object profileKey;
/** Flag set when per-thread metadata profiles are in use. */
- private boolean _perThreadDescriptorsEnabled;
+ private boolean perThreadDescriptorsEnabled;
/** The query that defines the values in the collection */
private Query query;
/** The actual data (if already loaded) */
@@ -98,12 +98,12 @@
public AbstractCollectionProxy(PersistenceConfiguration persistenceConf, Class collClass, Query query)
{
final MetadataManager mm = persistenceConf.getOjb().getMetadataManager();
- _perThreadDescriptorsEnabled = mm.isEnablePerThreadChanges();
- if (_perThreadDescriptorsEnabled)
+ perThreadDescriptorsEnabled = mm.isEnablePerThreadChanges();
+ if (perThreadDescriptorsEnabled)
{
// mkalen: To minimize memory footprint we remember only the OJB profile key
// (instead of all active class-mappings).
- Object key = mm.getCurrentProfileKey();
+ final Object key = mm.getCurrentProfileKey();
if (key == null)
{
// mkalen: Unsupported: using proxies with per-thread metadata changes without profile keys.
@@ -116,6 +116,12 @@
setQuery(query);
}
+ /**
+ * Reactivates metadata profile used when creating proxy, if needed.
+ * Calls to this method should be guarded by checking
+ * {@link #perThreadDescriptorsEnabled} since the profile never
+ * needs to be reloaded if not using pre-thread metadata changes.
+ */
protected void loadProfileIfNeeded()
{
final Object key = getProfileKey();
@@ -166,10 +172,6 @@
PersistenceBroker broker = getBroker();
try
{
- if (_perThreadDescriptorsEnabled)
- {
- loadProfileIfNeeded();
- }
return broker.getCount(getQuery());
}
catch (Exception ex)
@@ -211,10 +213,6 @@
}
else if (size != 0)
{
- if (_perThreadDescriptorsEnabled)
- {
- loadProfileIfNeeded();
- }
result = (Collection) broker.getCollectionByQuery(getCollectionClass(), getQuery());
}
else
@@ -242,7 +240,7 @@
{
CollectionProxyListener listener;
- if (_perThreadDescriptorsEnabled)
+ if (perThreadDescriptorsEnabled)
{
loadProfileIfNeeded();
}
@@ -263,7 +261,7 @@
{
CollectionProxyListener listener;
- if (_perThreadDescriptorsEnabled)
+ if (perThreadDescriptorsEnabled)
{
loadProfileIfNeeded();
}
@@ -462,7 +460,10 @@
protected synchronized PersistenceBroker getBroker() throws PBFactoryException
{
PersistenceBroker broker;
-
+ if (perThreadDescriptorsEnabled)
+ {
+ loadProfileIfNeeded();
+ }
if (getBrokerKey() == null)
{
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org