Author: curtisr7
Date: Mon Aug 8 15:32:39 2011
New Revision: 1154992
URL: http://svn.apache.org/viewvc?rev=1154992&view=rev
Log:
OPENJPA-2035: Backing out previous changes.
Removed:
openjpa/trunk/openjpa-kernel/src/test/java/org/apache/openjpa/kernel/
Modified:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Id.java
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
Modified:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java?rev=1154992&r1=1154991&r2=1154992&view=diff
==============================================================================
---
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java
(original)
+++
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java
Mon Aug 8 15:32:39 2011
@@ -18,11 +18,10 @@
*/
package org.apache.openjpa.kernel;
-import java.security.AccessController;
import java.util.BitSet;
+import java.util.Map;
import org.apache.openjpa.datacache.DataCache;
-import org.apache.openjpa.lib.util.J2DoPrivHelper;
import org.apache.openjpa.meta.ClassMetaData;
import org.apache.openjpa.meta.FieldMetaData;
@@ -37,8 +36,7 @@ public class PCDataImpl
extends AbstractPCData {
private final Object _oid;
- private transient Class<?> _type;
- private String _typeStr;
+ private final Class<?> _type;
private final String _cache;
private final Object[] _data;
private final BitSet _loaded;
@@ -56,7 +54,6 @@ public class PCDataImpl
public PCDataImpl(Object oid, ClassMetaData meta, String name) {
_oid = oid;
_type = meta.getDescribedType();
- _typeStr = _type.getName();
_cache = name;
int len = meta.getFields().length;
@@ -69,21 +66,8 @@ public class PCDataImpl
}
public Class<?> getType() {
- if (_type == null) {
- ClassLoader ccl =
AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
- try {
- _type = ccl.loadClass(_typeStr);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
return _type;
}
-
- public void setType(Class<?> t){
- _type = t;
- _typeStr = t.getName();
- }
public BitSet getLoaded() {
return _loaded;
Modified:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Id.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Id.java?rev=1154992&r1=1154991&r2=1154992&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Id.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Id.java
Mon Aug 8 15:32:39 2011
@@ -84,7 +84,7 @@ public final class Id
else {
int dash = str.indexOf(TYPE_VALUE_SEP);
try {
- setManagedInstanceType(Class.forName(str.substring(0, dash),
true, loader));
+ type = Class.forName(str.substring(0, dash), true, loader);
} catch (Throwable t) {
throw new UserException(_loc.get("string-id", str), t);
}
Modified:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java?rev=1154992&r1=1154991&r2=1154992&view=diff
==============================================================================
---
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
(original)
+++
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/OpenJPAId.java
Mon Aug 8 15:32:39 2011
@@ -19,9 +19,7 @@
package org.apache.openjpa.util;
import java.io.Serializable;
-import java.security.AccessController;
-import org.apache.openjpa.lib.util.J2DoPrivHelper;
import org.apache.openjpa.lib.util.ReferenceMap;
import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
@@ -31,17 +29,16 @@ import org.apache.openjpa.lib.util.concu
* @author Steve Kim
*/
@SuppressWarnings("serial")
-public abstract class OpenJPAId implements Comparable, Serializable {
+public abstract class OpenJPAId
+ implements Comparable, Serializable {
public static final char TYPE_VALUE_SEP = '-';
// cache the types' generated hash codes
private static ConcurrentReferenceHashMap _typeCache =
new ConcurrentReferenceHashMap(ReferenceMap.WEAK, ReferenceMap.HARD);
- private transient Class<?> _type;
- private String _typeStr;
-
- protected boolean _subs = true;
+ protected Class type;
+ protected boolean subs = true;
// type hash is based on the least-derived non-object class so that
// user-given ids with non-exact types match ids with exact types
@@ -50,31 +47,20 @@ public abstract class OpenJPAId implemen
protected OpenJPAId() {
}
- protected OpenJPAId(Class<?> type) {
- _type = type;
- _typeStr = type.getName();
-
+ protected OpenJPAId(Class type) {
+ this.type = type;
}
- protected OpenJPAId(Class<?> type, boolean subs) {
- _type = type;
- _typeStr = type.getName();
- _subs = subs;
+ protected OpenJPAId(Class type, boolean subs) {
+ this.type = type;
+ this.subs = subs;
}
/**
* Return the persistent class which this id instance represents.
*/
- public final Class<?> getType() {
- if (_type == null) {
- ClassLoader ccl =
AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
- try {
- _type = ccl.loadClass(_typeStr);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- return _type;
+ public Class getType() {
+ return type;
}
/**
@@ -82,22 +68,22 @@ public abstract class OpenJPAId implemen
* Defaults to true.
*/
public boolean hasSubclasses() {
- return _subs;
+ return subs;
}
/**
* Set the exact type of the described instance once it is known.
*/
- public void setManagedInstanceType(Class<?> type) {
+ public void setManagedInstanceType(Class type) {
setManagedInstanceType(type, false);
}
/**
* Set the exact type of the described instance once it is known.
*/
- public void setManagedInstanceType(Class<?> type, boolean subs) {
- _type = type;
- _subs = subs;
+ public void setManagedInstanceType(Class type, boolean subs) {
+ this.type = type;
+ this.subs = subs;
}
/**
@@ -121,16 +107,16 @@ public abstract class OpenJPAId implemen
*/
public int hashCode() {
if (_typeHash == 0) {
- Integer typeHashInt = (Integer) _typeCache.get(getType());
+ Integer typeHashInt = (Integer) _typeCache.get(type);
if (typeHashInt == null) {
- Class<?> base = getType();
- Class<?> superclass = base.getSuperclass();
+ Class base = type;
+ Class superclass = base.getSuperclass();
while (superclass != null && superclass != Object.class) {
base = base.getSuperclass();
superclass = base.getSuperclass();
}
_typeHash = base.hashCode();
- _typeCache.put(getType(), Integer.valueOf(_typeHash));
+ _typeCache.put(type, Integer.valueOf(_typeHash));
} else {
_typeHash = typeHashInt.intValue();
}
@@ -145,12 +131,12 @@ public abstract class OpenJPAId implemen
return false;
OpenJPAId id = (OpenJPAId) o;
- return idEquals(id)
- && (id.getType().isAssignableFrom(getType()) || (_subs &&
getType().isAssignableFrom(id.getType())));
+ return idEquals(id) && (id.type.isAssignableFrom(type)
+ || (subs && type.isAssignableFrom(id.type)));
}
public String toString() {
- return getType().getName() + TYPE_VALUE_SEP + getIdObject();
+ return type.getName() + TYPE_VALUE_SEP + getIdObject();
}
public int compareTo(Object other) {
@@ -158,6 +144,6 @@ public abstract class OpenJPAId implemen
return 0;
if (other == null)
return 1;
- return ((Comparable) getIdObject()).compareTo(((OpenJPAId)
other).getIdObject());
- }
+ return ((Comparable) getIdObject()).compareTo(((OpenJPAId)
other).getIdObject ());
+ }
}