Package com.tangosol.coherence.rest.util
Class PartialObject
java.lang.Object
com.tangosol.coherence.rest.util.PartialObject
Base class for dynamically generated partial classes.
- Author:
- as 2011.06.29
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Class loader implementation that is used to define and load partial classes. -
Field Summary
Modifier and TypeFieldDescriptionprotected Map
Property values for this object.protected static Map
<PartialObject.PartialClassLoader, ConcurrentHashMap<String, Class>> Partial classes cache.protected static Map
<ClassLoader, PartialObject.PartialClassLoader> ClassLoader instances that is used to define and load partial classes.protected static Map
<PartialObject.PartialClassLoader, ConcurrentHashMap<String, Constructor>> Partial class constructors cache. -
Constructor Summary
ConstructorDescriptionConstruct a PartialObject instance.PartialObject
(Map mapProperties) Construct a PartialObject instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
castReturnValue
(org.objectweb.asm.tree.MethodNode mn) Cast a return value into an appropriate type.protected static void
copyClassAnnotations
(org.objectweb.asm.tree.ClassNode cnSource, org.objectweb.asm.tree.ClassNode cnTarget) Copy class-level annotations.static PartialObject
Create a PartialObject instance based on an already extracted set of properties.static Object
create
(Object oSource, PropertySet propertySet) Create a PartialObject instance.protected static Class
createClass
(org.objectweb.asm.tree.ClassNode cn) Create partial class based on partial class definition.protected static void
createConstructors
(org.objectweb.asm.tree.ClassNode cn) Implement partial class constructors.protected static String
createKey
(Class clzSource, PropertySet propertySet) Create key for the partial class/constructor cache.static <T> Class
createPartialClass
(Class clzSource, PropertySet<T> propertySet) Create a partial class for the specified source class and property set.protected static org.objectweb.asm.tree.MethodNode
findProperty
(List<org.objectweb.asm.tree.ClassNode> listClassNodes, String sName) Attempt to find a property with a given name in one of the specified class definitions.protected static org.objectweb.asm.tree.MethodNode
findProperty
(org.objectweb.asm.tree.ClassNode cn, String sName) Attempt to find a property getter with a given name in the specified class definitions.Get a property value.protected static org.objectweb.asm.tree.ClassNode
getClassNode
(Class clz) Return a class definition for the specified class.static Class
getPartialClass
(Class clzSource, PropertySet propertySet) Return a partial class for the specified source class and property set.protected static PartialObject.PartialClassLoader
Return a PartialClassLoader corresponding to the Context ClassLoader.protected static ConcurrentHashMap
<String, Class> Return the partial class map corresponding to the PartialClassLoader.protected static ConcurrentHashMap
<String, Constructor> Return the partial constructor map corresponding to the PartialClassLoader.protected static boolean
Determine if a method represents a property.toString()
-
Field Details
-
s_mapPartialClasses
protected static Map<PartialObject.PartialClassLoader,ConcurrentHashMap<String, s_mapPartialClassesClass>> Partial classes cache. -
s_mapPartialConstructors
protected static Map<PartialObject.PartialClassLoader,ConcurrentHashMap<String, s_mapPartialConstructorsConstructor>> Partial class constructors cache. -
s_mapPartialClassLoaders
ClassLoader instances that is used to define and load partial classes. Since their can be multiple applications in a single JVM, each context ClassLoader should have its own PartialClassLoader -
m_mapProperties
Property values for this object.
-
-
Constructor Details
-
PartialObject
public PartialObject()Construct a PartialObject instance. -
PartialObject
Construct a PartialObject instance.- Parameters:
mapProperties
- map containing property values for this partial object
-
-
Method Details
-
get
Get a property value.- Parameters:
sName
- property name- Returns:
- property value, or null if the property does not exist
-
toString
-
create
Create a PartialObject instance.- Parameters:
oSource
- object to extract properties frompropertySet
- properties to extract- Returns:
- partial object containing the supplied subset of properties of the specified object
-
create
public static PartialObject create(Class clzSource, PropertySet propertySet, Map<String, Object> mapProperties) Create a PartialObject instance based on an already extracted set of properties.- Parameters:
clzSource
- class of the object properties were extracted frompropertySet
- extracted propertiesmapProperties
- extracted property values- Returns:
- partial object containing the supplied subset of properties of the specified object
-
getPartialClass
Return a partial class for the specified source class and property set.- Parameters:
clzSource
- source class to base the partial class onpropertySet
- a set of properties to define- Returns:
- class containing only the specified set of properties
-
createPartialClass
Create a partial class for the specified source class and property set.- Parameters:
clzSource
- a source class to base partial the class onpropertySet
- a set of properties to define- Returns:
- class containing only the specified set of properties
-
createKey
Create key for the partial class/constructor cache.- Parameters:
clzSource
- source class to base the partial class onpropertySet
- a set of properties to define- Returns:
- lookup key
-
copyClassAnnotations
protected static void copyClassAnnotations(org.objectweb.asm.tree.ClassNode cnSource, org.objectweb.asm.tree.ClassNode cnTarget) Copy class-level annotations.- Parameters:
cnSource
- source class to copy annotations fromcnTarget
- target class to copy annotations to
-
createConstructors
protected static void createConstructors(org.objectweb.asm.tree.ClassNode cn) Implement partial class constructors.- Parameters:
cn
- partial class
-
castReturnValue
protected static void castReturnValue(org.objectweb.asm.tree.MethodNode mn) Cast a return value into an appropriate type.- Parameters:
mn
- method whose return value needs to be casted
-
createClass
Create partial class based on partial class definition.- Parameters:
cn
- partial class definition- Returns:
- partial class
-
findProperty
protected static org.objectweb.asm.tree.MethodNode findProperty(List<org.objectweb.asm.tree.ClassNode> listClassNodes, String sName) Attempt to find a property with a given name in one of the specified class definitions.- Parameters:
listClassNodes
- class definitions to searchsName
- method name- Returns:
- method definition if found, null otherwise
-
findProperty
protected static org.objectweb.asm.tree.MethodNode findProperty(org.objectweb.asm.tree.ClassNode cn, String sName) Attempt to find a property getter with a given name in the specified class definitions.- Parameters:
cn
- class definition to searchsName
- method name- Returns:
- method definition if found, null otherwise
-
isMatch
Determine if a method represents a property.- Parameters:
sMethodName
- name of the methodsPropertyName
- name of the property- Returns:
- true if the specified method represents the specified property, false otherwise
-
getClassNode
Return a class definition for the specified class.- Parameters:
clz
- class to get a definition for- Returns:
- class definition for the specified class
-
getPartialClassLoader
Return a PartialClassLoader corresponding to the Context ClassLoader.- Returns:
- PartialClassLoader
-
getPartialClassMap
protected static ConcurrentHashMap<String,Class> getPartialClassMap(PartialObject.PartialClassLoader loader) Return the partial class map corresponding to the PartialClassLoader.- Parameters:
loader
- the PartialClassLoader corresponding to which the partial class map is required- Returns:
- the map of Partial classes corresponding to the PartialClassLoader
-
getPartialConstructorMap
protected static ConcurrentHashMap<String,Constructor> getPartialConstructorMap(PartialObject.PartialClassLoader loader) Return the partial constructor map corresponding to the PartialClassLoader.- Parameters:
loader
- the PartialClassLoader corresponding to which the partial constructor map is required- Returns:
- the map of Partial constructors corresponding to the PartialClassLoader
-