Author: arminw
Date: Mon Apr 2 11:17:52 2007
New Revision: 524868
URL: http://svn.apache.org/viewvc?view=rev&rev=524868
Log:
make internal use sequence manager for transient objects pluggable
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/config/repository_database.xml
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/config/repository_database.xml
URL:
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/config/repository_database.xml?view=diff&rev=524868&r1=524867&r2=524868
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/config/repository_database.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/config/repository_database.xml Mon Apr
2 11:17:52 2007
@@ -69,6 +69,14 @@
-->
<attribute attribute-name="initializationCheck"
attribute-value="false" />
+ <!--
+ To create identity objects for transient (non-persist) objects
OJB use
+ a specific sequence manager implementation to generate transient
key values.
+ The default implementation is
org.apache.ojb.broker.util.sequence.SequenceManagerTransientImpl.
+ Use this property to plug in user specific implementations.
+ -->
+ <!--<attribute attribute-name="sequenceManagerTransient"
attribute-value="my.SequenceManagerTransient" />-->
+
<!-- ** Attributes with name prefix "platform." are used to allow
database
platform class specific settings (PlatformXYZImpl classes) -->
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
URL:
http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java?view=diff&rev=524868&r1=524867&r2=524868
==============================================================================
---
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
(original)
+++
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
Mon Apr 2 11:17:52 2007
@@ -19,8 +19,8 @@
import org.apache.commons.collections.map.ReferenceIdentityMap;
import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.ojb.broker.Identity;
import org.apache.ojb.broker.IdentityFactory;
@@ -33,7 +33,8 @@
import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
import org.apache.ojb.broker.metadata.FieldDescriptor;
-import org.apache.ojb.broker.util.BrokerHelper;
+import org.apache.ojb.broker.metadata.SequenceDescriptor;
+import org.apache.ojb.broker.util.ClassHelper;
import org.apache.ojb.broker.util.sequence.SequenceManager;
import org.apache.ojb.broker.util.sequence.SequenceManagerTransientImpl;
@@ -45,6 +46,8 @@
*/
public class IdentityFactoryImpl implements IdentityFactory, PBStateListener
{
+ private static final String PROPERTY_SEQUENCEMANAGER_TRANSIENT =
"sequenceManagerTransient";
+
private PersistenceBrokerInternal broker;
//private final Map persistentIdentityMap;
private final Map transientIdentityMap;
@@ -65,7 +68,24 @@
doesn't improve performance.
*/
//this.persistentIdentityMap = new
ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD,
true);
- this.transientSequenceManager = new
SequenceManagerTransientImpl(broker, null);
+
+ // pluggable sequence manager for transient keys
+ String name =
broker.serviceConnectionManager().getConnectionDescriptor()
+ .getAttribute(PROPERTY_SEQUENCEMANAGER_TRANSIENT);
+ if(StringUtils.isBlank(name))
+ {
+ name = SequenceManagerTransientImpl.class.getName();
+ }
+ try
+ {
+ this.transientSequenceManager = (SequenceManager)
ClassHelper.newInstance(name, new Class[]{PersistenceBroker.class,
SequenceDescriptor.class}, new Object[]{broker, null});
+ }
+ catch(Exception e)
+ {
+ throw new PersistenceBrokerException("Can't create sequence
manager for transient key generation! "
+ + PROPERTY_SEQUENCEMANAGER_TRANSIENT + "=" + name);
+ }
+
broker.addListener(this, true);
}
@@ -102,7 +122,6 @@
cld = broker.getClassDescriptor(realClass);
}
topLevelClass = cld.getTopLevelClass();
- BrokerHelper helper = broker.serviceBrokerHelper();
FieldDescriptor[] fields = cld.getPkFields();
pks = new Object[fields.length];
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]