Spring Security Framework

org.springframework.security.acls.objectidentity
Class ObjectIdentityImpl

java.lang.Object
  extended by org.springframework.security.acls.objectidentity.ObjectIdentityImpl
All Implemented Interfaces:
Serializable, ObjectIdentity

public class ObjectIdentityImpl
extends Object
implements ObjectIdentity

Simple implementation of ObjectIdentity.

Uses Strings to store the identity of the domain object instance. Also offers a constructor that uses reflection to build the identity information.

Version:
$Id$
Author:
Ben Alex
See Also:
Serialized Form

Constructor Summary
ObjectIdentityImpl(Class javaType, Serializable identifier)
           
ObjectIdentityImpl(Object object)
          Creates the ObjectIdentityImpl based on the passed object instance.
ObjectIdentityImpl(String javaType, Serializable identifier)
           
 
Method Summary
 boolean equals(Object arg0)
          Important so caching operates properly.
 Serializable getIdentifier()
          Obtains the actual identifier.
 Class getJavaType()
          Obtains the Java type represented by the domain object.
 int hashCode()
          Important so caching operates properly.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectIdentityImpl

public ObjectIdentityImpl(String javaType,
                          Serializable identifier)

ObjectIdentityImpl

public ObjectIdentityImpl(Class javaType,
                          Serializable identifier)

ObjectIdentityImpl

public ObjectIdentityImpl(Object object)
                   throws IdentityUnavailableException
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 javaType, so if more control is required, an alternate constructor should be used instead.

Parameters:
object - the domain object instance to create an identity for
Throws:
IdentityUnavailableException - if identity could not be extracted
Method Detail

equals

public boolean equals(Object arg0)
Important so caching operates properly.

Considers an object of the same class equal if it has the same classname and id properties.

Note that this class uses string equality for the identifier field, which ensures it better supports differences between LookupStrategy requirements and the domain object represented by this ObjectIdentityImpl.

Specified by:
equals in interface ObjectIdentity
Overrides:
equals in class Object
Parameters:
arg0 - object to compare
Returns:
true if the presented object matches this object
See Also:
Object.equals(Object)

getIdentifier

public Serializable getIdentifier()
Description copied from interface: ObjectIdentity
Obtains the actual identifier. This identifier must not be reused to represent other domain objects with the same javaType.

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 subsystem data.

Specified by:
getIdentifier in interface ObjectIdentity
Returns:
the identifier (unique within this javaType; never null)

getJavaType

public Class getJavaType()
Description copied from interface: ObjectIdentity
Obtains the Java type represented by the domain object. The Java type can be an interface or a class, but is most often the domain object implementation class.

Specified by:
getJavaType in interface ObjectIdentity
Returns:
the Java type of the domain object (never null)

hashCode

public int hashCode()
Important so caching operates properly.

Specified by:
hashCode in interface ObjectIdentity
Overrides:
hashCode in class Object
Returns:
the hash
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.