Author: arminw
Date: Mon Apr 2 11:18:13 2007
New Revision: 524871
URL: http://svn.apache.org/viewvc?view=rev&rev=524871
Log:
make internal use sequence manager for transient objects pluggable
Modified:
db/ojb/trunk/src/config/repository_database.xml
db/ojb/trunk/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
Modified: db/ojb/trunk/src/config/repository_database.xml
URL:
http://svn.apache.org/viewvc/db/ojb/trunk/src/config/repository_database.xml?view=diff&rev=524871&r1=524870&r2=524871
==============================================================================
--- db/ojb/trunk/src/config/repository_database.xml (original)
+++ db/ojb/trunk/src/config/repository_database.xml Mon Apr 2 11:18:13 2007
@@ -1,6 +1,6 @@
<!-- @version $Id: repository_database.xml 513577 2007-03-02 02:33:44 +0100
(Fr, 02 Mrz 2007) arminw $ -->
<!--
-#/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,6 +56,14 @@
<attribute attribute-name="nativeLimitOffset" attribute-value="true" />
+ <!--
+ 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) -->
@@ -188,14 +196,15 @@
<attribute attribute-name="jcs.maxObjects" attribute-value=""/>
</object-cache>
-
- <sequence-manager class="hilo">
+ <!-- alternative sequence manager implementations, see "Sequence
Manager" guide -->
+ <sequence-manager className="memory">
<!-- The attribute 'seq.perField': If set 'true' it's possible to
define per
field-descriptor sequence manager. This way you can use different
sequence
identifier generation strategies. If set 'false' only the default
sequence manager
defined within the jdbc-connection-descriptor is used and all
sequence descriptors defined
on field-descriptor level are ignored -->
<attribute attribute-name="seq.perField" attribute-value="false"/>
+
<!-- attributes supported by SequenceManagerHighLowImpl,
SequenceManagerInMemoryImpl, SequenceManagerNextValImpl
please see "Sequence Manager" guide or/and javadoc of class for
more information -->
Modified:
db/ojb/trunk/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
URL:
http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java?view=diff&rev=524871&r1=524870&r2=524871
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/core/IdentityFactoryImpl.java
Mon Apr 2 11:18:13 2007
@@ -19,6 +19,7 @@
import org.apache.commons.collections.map.ReferenceIdentityMap;
import org.apache.commons.lang.ArrayUtils;
+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;
@@ -27,10 +28,13 @@
import org.apache.ojb.broker.PBStateListener;
import org.apache.ojb.broker.PersistenceBrokerException;
import org.apache.ojb.broker.PersistenceBrokerInternal;
+import org.apache.ojb.broker.platforms.Platform;
import org.apache.ojb.broker.core.proxy.IndirectionHandler;
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.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;
@@ -42,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;
@@ -61,8 +67,26 @@
doesn't improve performance.
*/
//this.persistentIdentityMap = new
ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD,
true);
- this.transientSequenceManager = new SequenceManagerTransientImpl(
- broker.serviceConnectionManager().getSupportedPlatform(),
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[]{Platform.class,
SequenceDescriptor.class},
+ new
Object[]{broker.serviceConnectionManager().getSupportedPlatform(), null});
+ }
+ catch(Exception e)
+ {
+ throw new PersistenceBrokerException("Can't create sequence
manager for transient key generation! "
+ + PROPERTY_SEQUENCEMANAGER_TRANSIENT + "=" + name);
+ }
+
broker.addListener(this, true);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]