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 ar...@apache.org on 2007/02/07 00:43:08 UTC
svn commit: r504373 - in /db/ojb/trunk/src:
java/org/apache/ojb/broker/metadata/ test/org/apache/ojb/
Author: arminw
Date: Tue Feb 6 15:43:07 2007
New Revision: 504373
URL: http://svn.apache.org/viewvc?view=rev&rev=504373
Log:
add support for attribute 'state-detection' used by odmg-api
add support to specifyPersistentField implementation class on ClassDescriptor and FieldDescriptor level
Modified:
db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
db/ojb/trunk/src/test/org/apache/ojb/repository.dtd
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java Tue Feb 6 15:43:07 2007
@@ -162,6 +162,12 @@
*/
private boolean acceptLocks = true;
/**
+ * If the used API supports object state detection, this attribute
+ * indicate wether or not class should be included in object
+ * state detection.
+ */
+ private boolean stateDetection = true;
+ /**
* if true instances of this class are always refreshed
* even if they are already in the cache.
* false by default.
@@ -1855,6 +1861,32 @@
public ClassDescriptor getTopLevelClassDescriptor()
{
return getRepository().getTopLevelDescriptor(getClassOfObject());
+ }
+
+ /**
+ * Returns whether or not this class should be included in
+ * object state detection. Default state is <em>true</em>.
+ *
+ * @return If <em>true</em> the class will be included in
+ * automatic object state detection.
+ * @see #setStateDetection(boolean)
+ */
+ public boolean isStateDetection()
+ {
+ return stateDetection;
+ }
+
+ /**
+ * If the used API supports object state detection (e.g. ODMG-api does),
+ * this attribute indicate whether or not this class should be included in object
+ * state detection (automatic check for changed object fields).
+ *
+ * @param stateDetection Set <em>true</em> if automatic state detection should
+ * be enabled.
+ */
+ public void setStateDetection(boolean stateDetection)
+ {
+ this.stateDetection = stateDetection;
}
/**
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java Tue Feb 6 15:43:07 2007
@@ -60,6 +60,12 @@
*/
private IsolationLevels globalIsolationLevel = IsolationLevels.READ_UNCOMMITTED;
/**
+ * If the used API supports object state detection, this attribute
+ * indicate wether or not mapped classes should be included in object
+ * state detection.
+ */
+ private boolean stateDetection = true;
+ /**
* This table holds all known Mapping descriptions.
* Key values are the respective Class objects
*/
@@ -855,6 +861,32 @@
}
}
}
+ }
+
+ /**
+ * Returns whether or not mapped classes should be included in
+ * object state detection. Default state is <em>true</em>.
+ *
+ * @return If <em>true</em> the classes will be included in
+ * automatic object state detection.
+ * @see #setStateDetection(boolean)
+ */
+ public boolean isStateDetection()
+ {
+ return stateDetection;
+ }
+
+ /**
+ * If the used API supports object state detection (e.g. ODMG-api does),
+ * this attribute indicate whether or not this mapped classes should be
+ * included in object state detection (automatic check for changed object fields).
+ *
+ * @param stateDetection Set <em>true</em> if automatic state detection should
+ * be enabled.
+ */
+ public void setStateDetection(boolean stateDetection)
+ {
+ this.stateDetection = stateDetection;
}
protected void finalize() throws Throwable
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Tue Feb 6 15:43:07 2007
@@ -81,6 +81,12 @@
// if false then it is the responsibility of the
// dbms to update all lock columns eg using triggers
private boolean updateLock = true;
+ /**
+ * If the used API supports object state detection, this attribute
+ * indicate wether or not this field should be included in object
+ * state detection.
+ */
+ private boolean stateDetection = true;
private String m_access;
private SequenceDescriptor sequenceDescriptor;
@@ -569,6 +575,31 @@
public boolean isLobFieldType()
{
return getJdbcType().getFieldType().isLobField();
+ }
+
+ /**
+ * Returns whether or not this field should be included in
+ * object state detection. Default state is <em>true</em>.
+ *
+ * @return If <em>true</em> the field will be included in
+ * automatic object state detection.
+ * @see #setStateDetection(boolean)
+ */
+ public boolean isStateDetection()
+ {
+ return stateDetection;
+ }
+
+ /**
+ * If the used API supports object state detection (e.g. ODMG-api does),
+ * this attribute indicate whether or not this field should be included in object
+ * state detection (automatic check for changed object fields).
+ *
+ * @param stateDetection
+ */
+ public void setStateDetection(boolean stateDetection)
+ {
+ this.stateDetection = stateDetection;
}
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryElements.java Tue Feb 6 15:43:07 2007
@@ -86,6 +86,8 @@
public static final int PRECISION = 53;
public static final int SCALE = 54;
public static final int ACCESS = 99;
+ public static final int STATE_DETECTION = 140;
+ public static final int FIELD_CLASS = 141;
// public static final int CON_MAX_ACTIVE = 55;
// public static final int CON_MAX_IDLE = 56;
@@ -158,7 +160,7 @@
public static final int VALIDATOR = 139;
// maintain a next id to keep track where we are
- static final int _NEXT = 140;
+ static final int _NEXT = 142;
// String constants
public static final String TAG_ACCESS = "access";
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryTags.java Tue Feb 6 15:43:07 2007
@@ -154,6 +154,8 @@
table.put("attribute-value", new Integer(ATTRIBUTE_VALUE));
table.put("documentation", new Integer(DOCUMENTATION));
table.put("accept-locks", new Integer(ACCEPT_LOCKS));
+ table.put("state-detection", new Integer(STATE_DETECTION));
+ table.put("field-class", new Integer(FIELD_CLASS));
table.put("sequence-manager", new Integer(SEQUENCE_MANAGER));
Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java Tue Feb 6 15:43:07 2007
@@ -20,6 +20,7 @@
import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.ojb.broker.util.ConvertHelper;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
import org.apache.commons.lang.StringUtils;
@@ -167,6 +168,15 @@
version+". Please update your repository.dtd and your repository.xml"+
" version attribute entry");
}
+ // set state-detection attribute
+ String stateDetectionStr = atts.getValue(RepositoryTags.getTagById(STATE_DETECTION));
+ if (stateDetectionStr != null)
+ {
+ boolean stateDetection = ConvertHelper.toBooleanPrimitiv(stateDetectionStr);
+ if (isDebug) logger.debug(" " + RepositoryTags.getTagById(STATE_DETECTION) + ": " + stateDetection);
+ m_repository.setStateDetection(stateDetection);
+ }
+
break;
}
case CLASS_DESCRIPTOR:
@@ -296,15 +306,29 @@
// set refresh attribute
String refresh = atts.getValue(RepositoryTags.getTagById(REFRESH));
- if (isDebug) logger.debug(" " + RepositoryTags.getTagById(REFRESH) + ": " + refresh);
- b = (Boolean.valueOf(refresh)).booleanValue();
- m_CurrentCLD.setAlwaysRefresh(b);
-
- // TODO: remove this or make offical feature
- // persistent field
- String pfClassName = atts.getValue("persistent-field-class");
- if (isDebug) logger.debug(" persistent-field-class: " + pfClassName);
- m_CurrentCLD.setPersistentFieldClassName(pfClassName);
+ if(refresh != null)
+ {
+ if (isDebug) logger.debug(" " + RepositoryTags.getTagById(REFRESH) + ": " + refresh);
+ b = (Boolean.valueOf(refresh)).booleanValue();
+ m_CurrentCLD.setAlwaysRefresh(b);
+ }
+
+ // persistent field class name
+ String pfClassName = atts.getValue(RepositoryTags.getTagById(FIELD_CLASS));
+ if(pfClassName != null)
+ {
+ if (isDebug) logger.debug(" " + RepositoryTags.getTagById(FIELD_CLASS) + ": " + pfClassName);
+ m_CurrentCLD.setPersistentFieldClassName(pfClassName);
+ }
+
+ // set state-detection attribute
+ String stateDetectionStr = atts.getValue(RepositoryTags.getTagById(STATE_DETECTION));
+ if (stateDetectionStr != null)
+ {
+ boolean stateDetection = ConvertHelper.toBooleanPrimitiv(stateDetectionStr);
+ if (isDebug) logger.debug(" " + RepositoryTags.getTagById(STATE_DETECTION) + ": " + stateDetection);
+ m_CurrentCLD.setStateDetection(stateDetection);
+ }
// set batch attribute
String batchable = atts.getValue(RepositoryTags.getTagById(BATCHABLE));
@@ -419,11 +443,11 @@
String strId = atts.getValue(RepositoryTags.getTagById(ID));
m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId));
+ String strAccess = atts.getValue(RepositoryTags.getTagById(ACCESS));
+
String fieldName = atts.getValue(RepositoryTags.getTagById(FIELD_NAME));
if (isDebug) logger.debug(" " + RepositoryTags.getTagById(FIELD_NAME) + ": " + fieldName);
- String strAccess = atts.getValue(RepositoryTags.getTagById(ACCESS));
-
if (fieldName.equals(ClassDescriptor.OJB_CONCRETE_CLASS))
{
m_CurrentFLD = new DiscriminatorFieldDescriptor(m_CurrentCLD);
@@ -437,17 +461,27 @@
else
{
m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
- String classname = m_CurrentCLD.getClassNameOfObject();
- PersistentField pf = fieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),ClassHelper.getClass(classname),fieldName);
+ // set the PersistentField
+ String persistentFieldClassName = atts.getValue(RepositoryTags.getTagById(FIELD_CLASS));
+ if (persistentFieldClassName != null)
+ {
+ if (isDebug) logger.debug(" " + RepositoryTags.getTagById(FIELD_CLASS) + ": " + persistentFieldClassName);
+ }
+ else
+ {
+ persistentFieldClassName = m_CurrentCLD.getPersistentFieldClassName();
+ }
+ Class objectClass = m_CurrentCLD.getClassOfObject();
+ PersistentField pf = fieldFactory.createPersistentField(
+ persistentFieldClassName, objectClass, fieldName);
m_CurrentFLD.setPersistentField(pf);
}
-
+
m_CurrentFLD.setAccess(strAccess);
m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
-
// prepare for custom attributes
this.m_CurrentAttrContainer = this.m_CurrentFLD;
-
+
String columnName = atts.getValue(RepositoryTags.getTagById(COLUMN_NAME));
if (isDebug) logger.debug(" " + RepositoryTags.getTagById(COLUMN_NAME) + ": " + columnName);
m_CurrentFLD.setColumnName(columnName);
@@ -539,6 +573,15 @@
if (isDebug) logger.debug(" " + RepositoryTags.getTagById(SCALE) + ": " + i);
m_CurrentFLD.setScale(i);
m_CurrentFLD.setScaleSpecified(true);
+ }
+
+ // set state-detection attribute
+ String stateDetectionStr = atts.getValue(RepositoryTags.getTagById(STATE_DETECTION));
+ if (stateDetectionStr != null)
+ {
+ boolean stateDetection = ConvertHelper.toBooleanPrimitiv(stateDetectionStr);
+ if (isDebug) logger.debug(" " + RepositoryTags.getTagById(STATE_DETECTION) + ": " + stateDetection);
+ m_CurrentFLD.setStateDetection(stateDetection);
}
break;
Modified: db/ojb/trunk/src/test/org/apache/ojb/repository.dtd
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/repository.dtd?view=diff&rev=504373&r1=504372&r2=504373
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/repository.dtd (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/repository.dtd Tue Feb 6 15:43:07 2007
@@ -45,12 +45,17 @@
by OJB's pessimistic locking api. All jdbc-connection-descriptor or class-descriptor
that do not define a specific isolation level will use this.
Note: This does NOT touch the jdbc-level of the connection.
+
+ The state-detection attribute is used by API's supporting automatic state detection
+ of persistence capable objects. The attribute indicate whether or not mapped classes should
+ be included in object state detection (automatic detection of changed object fields).
-->
<!ATTLIST descriptor-repository
version (1.1) #REQUIRED
isolation-level (read-uncommitted | read-committed | repeatable-read |
serializable | optimistic | none) "read-uncommitted"
proxy-prefetching-limit CDATA "50"
+ state-detection (true | false) "true"
>
<!--
@@ -140,8 +145,8 @@
default-connection (true | false) "false"
platform (Db2 | Hsqldb | Informix | MsAccess | MsSQLServer |
MySQL | Oracle | PostgreSQL | Sybase | SybaseASE |
- SybaseASA | Sapdb | Firebird | Axion | NonstopSql |
- Oracle9i | MaxDB ) "Hsqldb"
+ SybaseASA | Sapdb | Firebird | Axion |
+ Oracle9i | MaxDB | Derby) "Hsqldb"
jdbc-level (1.0 | 2.0 | 3.0) "2.0"
batch-mode (true | false) "false"
useAutoCommit (0 | 1 | 2) "1"
@@ -358,6 +363,13 @@
The refresh attribute can be set to true to force OJB to refresh
instances when loaded from cache. It's set to false by default.
+ The state-detection attribute is used by API's supporting automatic state detection
+ of persistence capable objects. The attribute indicate whether or not this class should
+ be included in object state detection (automatic detection of changed object fields).
+
+ The field-class attribute can be used to override the <code>PersistentField</code>
+ implementation class.
+
The 'batchable' attribute signal whether or not it is allowed to bunch this class
in a sql-batch. Note: Be aware of side-effects when mix batchable
and non batchable classes, e.g. class non batchable, reference batchable
@@ -379,6 +391,8 @@
factory-class CDATA #IMPLIED
factory-method CDATA #IMPLIED
refresh (true | false) "false"
+ state-detection (true | false) "true"
+ field-class CDATA #IMPLIED
batchable (true | false) "true"
>
@@ -553,6 +567,15 @@
corresponding Java attribute. Hence the name of such a field does not
refer to a Java attribute of the class, but is used as a unique
identifier only.
+
+ The state-detection attribute is used by API's supporting automatic state detection
+ of persistence capable objects. The attribute indicate whether or not this field should
+ be included in object state detection (automatic detection of changed object fields).
+ If in the <em>state-detection</em> is generally disabled or in the associated
+ class-descriptor, this setting will (normally) be ignored.
+
+ The field-class attribute can be used to override the <code>PersistentField</code>
+ implementation class.
-->
<!ATTLIST field-descriptor
id CDATA #IMPLIED
@@ -578,6 +601,8 @@
precision CDATA #IMPLIED
scale CDATA #IMPLIED
access (readonly | readwrite | anonymous) "readwrite"
+ state-detection (true | false) "true"
+ field-class CDATA #IMPLIED
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org