ariba.util.core
Class ClassExtensionRegistry

java.lang.Object
  extended by ariba.util.core.ClassExtensionRegistry

public class ClassExtensionRegistry
extends java.lang.Object

The ClassExtensionRegistry class provides a convenient and consistent way to cache ClassExtension subclasses. All ClassExtensions must know the class for which they are implemented so that the FieldPath can compare its _previousCalssExtension's class and possible avoid a hash lookup. The ClassExtensionRegistry allows for registering ClassExtension instances by targetClass (where targetClass may be an interface). The lookup algorithm for a ClassExtension for a given class is recursive. Upon looking up a ClassExtension for a given target object, the ClassExtensionRegistry will recurse up the target object's superclass chain and interface inheritance graph until it finds a match. To avoid doing this recursion each time, a clone of the ClassExtension is registered for each subclass as the recursion unwinds. The next time the target object's ClassExtension is sought, it will be found immediately without recursion. Of course, this applies for all subclasses between the base class and the target object as those wil have been cloned/registered along the way.


Constructor Summary
ClassExtensionRegistry()
          constructred ClassExtensionRegistry.
ClassExtensionRegistry(boolean addToGlobalRegistries)
          Constructs a ClassExtensionRegistry.
 
Method Summary
 java.lang.Object[] get()
          Return an array of ClassExtension representing all the extensions that have been registered.
 ClassExtension get(java.lang.Class targetClass)
          Lookup a classExtension whose class matches the class of target.
 ClassExtension get(java.lang.Object target)
          Return the closest fitting ClassExtension for the given target Object, which must be non-null.
 ClassExtension getClassExtension(java.lang.Class targetClass)
          Deprecated. use get(Object)
static java.util.List getClassExtensions(java.lang.Class targetClass)
           
 ClassExtension registerClassExtension(java.lang.Class targetClass, ClassExtension classExtension)
          Allow a ClassExtension implementation to be registered/cached for a given base class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassExtensionRegistry

public ClassExtensionRegistry()
constructred ClassExtensionRegistry.


ClassExtensionRegistry

public ClassExtensionRegistry(boolean addToGlobalRegistries)
Constructs a ClassExtensionRegistry.

Parameters:
addToGlobalRegistries - whether to add myself to the global list of ClassExtensionRegistries.
Method Detail

getClassExtensions

public static java.util.List getClassExtensions(java.lang.Class targetClass)

registerClassExtension

public ClassExtension registerClassExtension(java.lang.Class targetClass,
                                             ClassExtension classExtension)
Allow a ClassExtension implementation to be registered/cached for a given base class. Note that the classExtension is cloned before caching the cloned version.

Parameters:
targetClass - the class for which the classExtension applies.
classExtension - the classExtension to be registered.
Returns:
returns the cloned version of the classExtension whose class has been set to targetClass.

getClassExtension

public ClassExtension getClassExtension(java.lang.Class targetClass)
Deprecated. use get(Object)


get

public ClassExtension get(java.lang.Class targetClass)
Lookup a classExtension whose class matches the class of target. If no classExtension is located for the target's class, then we recurse up the class' interface graph and superclass chain until a match is found. Once found, copies of the classExtension are registered for each subclass in the recursion. This avoids future recursions for the target's class and its superclasses.

Parameters:
targetClass - the for which the classExtension applies.
Returns:
the ClassExtension which was located with the class ivar set appropriately (to targetClass)

get

public ClassExtension get(java.lang.Object target)
Return the closest fitting ClassExtension for the given target Object, which must be non-null. It appears that null can be returned if no registered extensions are found for target. If the target is a kind of ClassProxy, we use its RealClass instead of its Class, so we lookup based on the object the proxy represents, rather than on the proxy class itself; this is much more functional and helps proxies play the role of their classes without breakage or instantiation.


get

public java.lang.Object[] get()
Return an array of ClassExtension representing all the extensions that have been registered.



AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.