Package com.tangosol.coherence.rest.util
Class PartialObject
- java.lang.Object
-
- com.tangosol.coherence.rest.util.PartialObject
-
public class PartialObject extends Object
Base class for dynamically generated partial classes.- Author:
- as 2011.06.29
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PartialObject.PartialClassLoader
Class loader implementation that is used to define and load partial classes.
-
Field Summary
Fields Modifier and Type Field Description protected Map
m_mapProperties
Property values for this object.protected static Map<PartialObject.PartialClassLoader,ConcurrentHashMap<String,Class>>
s_mapPartialClasses
Partial classes cache.protected static Map<ClassLoader,PartialObject.PartialClassLoader>
s_mapPartialClassLoaders
ClassLoader instances that is used to define and load partial classes.protected static Map<PartialObject.PartialClassLoader,ConcurrentHashMap<String,Constructor>>
s_mapPartialConstructors
Partial class constructors cache.
-
Constructor Summary
Constructors Constructor Description PartialObject()
Construct a PartialObject instance.PartialObject(Map mapProperties)
Construct a PartialObject instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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(Class clzSource, PropertySet propertySet, Map<String,Object> mapProperties)
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.Object
get(String sName)
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
getPartialClassLoader()
Return a PartialClassLoader corresponding to the Context ClassLoader.protected static ConcurrentHashMap<String,Class>
getPartialClassMap(PartialObject.PartialClassLoader loader)
Return the partial class map corresponding to the PartialClassLoader.protected static ConcurrentHashMap<String,Constructor>
getPartialConstructorMap(PartialObject.PartialClassLoader loader)
Return the partial constructor map corresponding to the PartialClassLoader.protected static boolean
isMatch(String sMethodName, String sPropertyName)
Determine if a method represents a property.String
toString()
-
-
-
Field Detail
-
s_mapPartialClasses
protected static Map<PartialObject.PartialClassLoader,ConcurrentHashMap<String,Class>> s_mapPartialClasses
Partial classes cache.
-
s_mapPartialConstructors
protected static Map<PartialObject.PartialClassLoader,ConcurrentHashMap<String,Constructor>> s_mapPartialConstructors
Partial class constructors cache.
-
s_mapPartialClassLoaders
protected static Map<ClassLoader,PartialObject.PartialClassLoader> 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
protected Map m_mapProperties
Property values for this object.
-
-
Constructor Detail
-
PartialObject
public PartialObject()
Construct a PartialObject instance.
-
PartialObject
public PartialObject(Map mapProperties)
Construct a PartialObject instance.- Parameters:
mapProperties
- map containing property values for this partial object
-
-
Method Detail
-
get
public Object get(String sName)
Get a property value.- Parameters:
sName
- property name- Returns:
- property value, or null if the property does not exist
-
create
public static Object create(Object oSource, PropertySet propertySet)
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
public static Class getPartialClass(Class clzSource, PropertySet propertySet)
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
public static <T> Class createPartialClass(Class clzSource, PropertySet<T> propertySet)
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
protected static String createKey(Class clzSource, PropertySet propertySet)
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
protected static Class createClass(org.objectweb.asm.tree.ClassNode cn)
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
protected static boolean isMatch(String sMethodName, String sPropertyName)
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
protected static org.objectweb.asm.tree.ClassNode getClassNode(Class clz)
Return a class definition for the specified class.- Parameters:
clz
- class to get a definition for- Returns:
- class definition for the specified class
-
getPartialClassLoader
protected static PartialObject.PartialClassLoader 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
-
-