Class ClassCopierFactoryPipelineImpl
- java.lang.Object
-
- org.glassfish.pfl.dynamic.copyobject.impl.ClassCopierFactoryPipelineImpl
-
- All Implemented Interfaces:
ClassCopierFactory
,PipelineClassCopierFactory
public class ClassCopierFactoryPipelineImpl extends java.lang.Object implements PipelineClassCopierFactory
A factory used for creating ClassCopier instances. An instance of this factory can be created and customized to handle special copying semantics for certain classes. This maintains a cache of ClassCopiers, so that a ClassCopier is never created more than once for a particular class.
-
-
Field Summary
Fields Modifier and Type Field Description private ClassCopierFactory
arrayFactory
private ClassCopier
errorCopier
private CachingClassCopierFactory
factoryCache
private static java.lang.Class<?>[]
immutable
private static java.lang.Class<?>[]
mapClasses
private static java.lang.Class<?>[]
notCopyable
private ClassCopierFactory
ordinaryFactory
private java.util.concurrent.locks.ReentrantReadWriteLock
rwlock
private ClassCopierFactory
specialFactory
-
Constructor Summary
Constructors Constructor Description ClassCopierFactoryPipelineImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassCopier
getClassCopier(java.lang.Class<?> cls)
Analyze cls to determine the appropriate ClassCopier and return the ClassCopier instance.ClassCopier
lookupInCache(java.lang.Class<?> cls)
Look for cls only in the cache; do not create a ClassCopier if there isn't one already in the cache.boolean
reflectivelyCopyable(java.lang.Class<?> cls)
Added this method so reflective copier could check if serializable object contains a transient field of specific type.void
registerImmutable(java.lang.Class<?> cls)
Register an immutable class, so that it will not be copied, but just passed by reference.void
setSpecialClassCopierFactory(ClassCopierFactory ccf)
Set a special ClassCopierFactory to handle some application specific needs.
-
-
-
Field Detail
-
notCopyable
private static final java.lang.Class<?>[] notCopyable
-
immutable
private static final java.lang.Class<?>[] immutable
-
mapClasses
private static final java.lang.Class<?>[] mapClasses
-
factoryCache
private CachingClassCopierFactory factoryCache
-
specialFactory
private ClassCopierFactory specialFactory
-
arrayFactory
private ClassCopierFactory arrayFactory
-
ordinaryFactory
private ClassCopierFactory ordinaryFactory
-
errorCopier
private ClassCopier errorCopier
-
rwlock
private java.util.concurrent.locks.ReentrantReadWriteLock rwlock
-
-
Method Detail
-
reflectivelyCopyable
public boolean reflectivelyCopyable(java.lang.Class<?> cls)
Description copied from interface:PipelineClassCopierFactory
Added this method so reflective copier could check if serializable object contains a transient field of specific type.- Specified by:
reflectivelyCopyable
in interfacePipelineClassCopierFactory
-
lookupInCache
public ClassCopier lookupInCache(java.lang.Class<?> cls)
Look for cls only in the cache; do not create a ClassCopier if there isn't one already in the cache.- Specified by:
lookupInCache
in interfacePipelineClassCopierFactory
-
registerImmutable
public final void registerImmutable(java.lang.Class<?> cls)
Register an immutable class, so that it will not be copied, but just passed by reference.- Specified by:
registerImmutable
in interfacePipelineClassCopierFactory
-
setSpecialClassCopierFactory
public void setSpecialClassCopierFactory(ClassCopierFactory ccf)
Set a special ClassCopierFactory to handle some application specific needs.- Specified by:
setSpecialClassCopierFactory
in interfacePipelineClassCopierFactory
-
getClassCopier
public ClassCopier getClassCopier(java.lang.Class<?> cls) throws ReflectiveCopyException
Analyze cls to determine the appropriate ClassCopier and return the ClassCopier instance. Will only create a ClassCopier for a given Class once.- Specified by:
getClassCopier
in interfaceClassCopierFactory
- Throws:
ReflectiveCopyException
-
-