diff --git a/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java b/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java
index dcd407e8b2..4c66207630 100644
--- a/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java
+++ b/acl/src/main/java/org/springframework/security/acls/domain/ObjectIdentityImpl.java
@@ -34,37 +34,36 @@ import org.springframework.util.ClassUtils;
public class ObjectIdentityImpl implements ObjectIdentity {
//~ Instance fields ================================================================================================
- private Class> javaType;
+ private final String type;
private Serializable identifier;
//~ Constructors ===================================================================================================
- public ObjectIdentityImpl(String javaType, Serializable identifier) {
- Assert.hasText(javaType, "Java Type required");
+ public ObjectIdentityImpl(String type, Serializable identifier) {
+ Assert.hasText(type, "Type required");
Assert.notNull(identifier, "identifier required");
- try {
- this.javaType = ClassUtils.forName(javaType, ClassUtils.getDefaultClassLoader());
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException("Unable to load javaType: " + javaType, e);
- }
-
this.identifier = identifier;
+ this.type = type;
}
+ /**
+ * Constructor which uses the name of the supplied class as the type property.
+ */
public ObjectIdentityImpl(Class> javaType, Serializable identifier) {
Assert.notNull(javaType, "Java Type required");
Assert.notNull(identifier, "identifier required");
- this.javaType = javaType;
+ this.type = javaType.getName();
this.identifier = identifier;
}
/**
* Creates the ObjectIdentityImpl based on the passed
* object instance. The passed object must provide a getId()
- * method, otherwise an exception will be thrown. The object passed will
- * be considered the {@link #javaType}, so if more control is required,
- * an alternate constructor should be used instead.
+ * method, otherwise an exception will be thrown.
+ *
+ * The class name of the object passed will be considered the {@link #type}, so if more control is required,
+ * a different constructor should be used.
*
* @param object the domain object instance to create an identity for.
*
@@ -73,12 +72,13 @@ public class ObjectIdentityImpl implements ObjectIdentity {
public ObjectIdentityImpl(Object object) throws IdentityUnavailableException {
Assert.notNull(object, "object cannot be null");
- this.javaType = ClassUtils.getUserClass(object.getClass());
+ Class> typeClass = ClassUtils.getUserClass(object.getClass());
+ type = typeClass.getName();
Object result;
try {
- Method method = this.javaType.getMethod("getId", new Class[] {});
+ Method method = typeClass.getMethod("getId", new Class[] {});
result = method.invoke(object, new Object[] {});
} catch (Exception e) {
throw new IdentityUnavailableException("Could not extract identity from object " + object, e);
@@ -123,15 +123,15 @@ public class ObjectIdentityImpl implements ObjectIdentity {
}
}
- return javaType.equals(other.javaType);
+ return type.equals(other.type);
}
public Serializable getIdentifier() {
return identifier;
}
- public Class> getJavaType() {
- return javaType;
+ public String getType() {
+ return type;
}
/**
@@ -141,7 +141,7 @@ public class ObjectIdentityImpl implements ObjectIdentity {
*/
public int hashCode() {
int code = 31;
- code ^= this.javaType.hashCode();
+ code ^= this.type.hashCode();
code ^= this.identifier.hashCode();
return code;
@@ -150,7 +150,7 @@ public class ObjectIdentityImpl implements ObjectIdentity {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.getClass().getName()).append("[");
- sb.append("Java Type: ").append(this.javaType.getName());
+ sb.append("Type: ").append(this.type);
sb.append("; Identifier: ").append(this.identifier).append("]");
return sb.toString();
diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java b/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java
index a79869edeb..5e176d22dd 100644
--- a/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java
+++ b/acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java
@@ -365,11 +365,10 @@ public final class BasicLookupStrategy implements LookupStrategy {
Set parentsToLookup = (Set) jdbcTemplate.query(sql,
new PreparedStatementSetter() {
- public void setValues(PreparedStatement ps)
- throws SQLException {
+ public void setValues(PreparedStatement ps) throws SQLException {
for (int i = 0; i < objectIdentities.length; i++) {
// Determine prepared statement values for this iteration
- String javaType = objectIdentities[i].getJavaType().getName();
+ String javaType = objectIdentities[i].getType();
// No need to check for nulls, as guaranteed non-null by ObjectIdentity.getIdentifier() interface contract
String identifier = objectIdentities[i].getIdentifier().toString();
diff --git a/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java b/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
index e0500355bb..67139d88e1 100644
--- a/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
+++ b/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
@@ -72,7 +72,7 @@ public class JdbcAclService implements AclService {
//~ Methods ========================================================================================================
public List
- * As implementations of ObjectIdentity are used as the key to represent
+ * As implementations of ObjectIdentity are used as the key to represent
* domain objects in the ACL subsystem, it is essential that implementations provide
* methods so that object-equality rather than reference-equality can be relied upon
- * reliably. In other words, the ACL subsystem can consider two
- * ObjectIdentitys equal if identity1.equals(identity2), rather than
+ * reliably. In other words, the ACL subsystem can consider two
+ * ObjectIdentitys equal if identity1.equals(identity2), rather than
* reference-equality of identity1==identity2.
* Because ACLs are largely immutable, it is strongly recommended to use
* a synthetic identifier (such as a database sequence number for the primary key). Do not use an identifier with
- * business meaning, as that business meaning may change in the future such change will cascade to the ACL
+ * business meaning, as that business meaning may change in the future such change will cascade to the ACL
* subsystem data.