Author: arminw
Date: Wed Dec 20 02:35:49 2006
New Revision: 489021
URL: http://svn.apache.org/viewvc?view=rev&rev=489021
Log:
minor fix
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/UnwrapHelper.java
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/ObjectEnvelope.java
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/UnwrapHelper.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/UnwrapHelper.java?view=diff&rev=489021&r1=489020&r2=489021
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/UnwrapHelper.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/UnwrapHelper.java Wed Dec 20 02:35:49 2006
@@ -28,6 +28,7 @@
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
+import org.apache.ojb.broker.OJBRuntimeException;
/**
* This a helper class make available methods to unwrap {@link java.sql.Connection} and
@@ -50,12 +51,41 @@
{
private Logger log = LoggerFactory.getLogger(UnwrapHelper.class);
- private static final int UNWARP_CONNECTION = 1;
- private static final int UNWARP_STATEMENT = 2;
- private static final Object[] EMPTY_ARG = new Object[]{};
- public static final Class[] EMPTY_TYPE = new Class[]{};
- public static final Integer TYPE_METHOD = new Integer(5);
- public static final Integer TYPE_FIELD = new Integer(6);
+ protected static final int UNWARP_CONNECTION = 1;
+ protected static final int UNWARP_STATEMENT = 2;
+ protected static final Object[] EMPTY_ARG = new Object[]{};
+ protected static final Class[] EMPTY_TYPE = new Class[]{};
+ /**
+ * Indicate method access in unwrap pattern.
+ * @see #addUnwrapPattern(Object[])
+ */
+ public static final Access TYPE_METHOD = new Access(){
+ public boolean isField()
+ {
+ return false;
+ }
+
+ public boolean isMethod()
+ {
+ return true;
+ }
+ };
+ /**
+ * Indicate field access in unwrap pattern.
+ * @see #addUnwrapPattern(Object[])
+ */
+ public static final Access TYPE_FIELD = new Access(){
+ public boolean isField()
+ {
+ return true;
+ }
+
+ public boolean isMethod()
+ {
+ return false;
+ }
+ };
+
/**
* Represents the information of how to unwrap wrapped {@link java.sql.Connection}
* and {@link java.sql.PreparedStatement} instances of popular connection-pool libraries,
@@ -93,6 +123,7 @@
* </code>
*/
private static final Object[][] predefinedPatterns = {
+ {"OJB wrapper", TYPE_METHOD, EMPTY_TYPE, "getInnermostDelegate", null, null, null},
{"common-DBCP", TYPE_METHOD, EMPTY_TYPE, "getInnermostDelegate", TYPE_METHOD, EMPTY_TYPE, "getInnermostDelegate"},
{"JBoss", TYPE_METHOD, EMPTY_TYPE, "getUnderlyingConnection", TYPE_METHOD, EMPTY_TYPE, "getUnderlyingStatement"},
{"enhydra.XAPool", TYPE_FIELD, null, "con", TYPE_FIELD, null, "ps"},
@@ -204,6 +235,17 @@
*/
public void addUnwrapPattern(final Object[] pattern)
{
+ // check method/field access
+ if(pattern[1] != null && !(pattern[1] instanceof Access))
+ {
+ throw new OJBRuntimeException("Can't detect access method, pattern[1] is not of type Access, please use " +
+ "UnwarpHelper#Type_XYZ fields to specify type. Pattern: " + ArrayUtils.toString(pattern));
+ }
+ if(pattern[4] != null && !(pattern[4] instanceof Access))
+ {
+ throw new OJBRuntimeException("Can't detect access method, pattern[4] is not of type Access, please use " +
+ "UnwarpHelper#Type_XYZ fields to specify type. Pattern: " + ArrayUtils.toString(pattern));
+ }
// check connection method argument
Object argType = pattern[2];
if(argType == null)
@@ -284,7 +326,7 @@
protected Object loopUnwrap(Object[][] patterns, final Class classToMatch, final Object toUnwrap, final int type, final List matchedPatterns)
{
- if(classToMatch == null)
+ if(classToMatch == null || toUnwrap == null)
{
return null;
}
@@ -464,5 +506,11 @@
buf.append(ArrayUtils.toString(unwrapPatterns[i]));
}
return buf.toString();
+ }
+
+ static interface Access
+ {
+ boolean isMethod();
+ boolean isField();
}
}
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/ObjectEnvelope.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/ObjectEnvelope.java?view=diff&rev=489021&r1=489020&r2=489021
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/ObjectEnvelope.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/ObjectEnvelope.java Wed Dec 20 02:35:49 2006
@@ -190,12 +190,6 @@
// on reuse of this object, we have to clear the link list
if(linkEntryList.size() > 0) linkEntryList.clear();
}
- else
- {
- myObj = null;
- realObject = null;
- }
- cld = null;
}
private void performImageCleanup(Map imageMap, boolean reuse)
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.