public class InstantiationPolicy extends CoreInstantiationPolicy implements java.lang.Cloneable, java.io.Serializable
So, here is how it works:
If there is no method specified
- all the other settings are ignored and
- the descriptor class's default constructor is invoked.
If a factory is specified
- the factoryClass and factoryClassMethod are ignored and
- the method is invoked on the factory.
If neither a factory nor a factoryClass are specified
- the factoryClassMethod is ignored and
- the method is invoked on the descriptor class (as a static).
If only the factoryClass is specified
- the factory is created by invoking the factoryClass' default (zero-argument) constructor and
- the method is invoked on the resulting factory.
If both the factoryClass and the factoryClassMethod are specified
- the factory is created by invoking the factoryClassMethod on the factoryClass (as a static) and
- the method is invoked on the resulting factory.
The only thing we can't support in the current configuration is invoking a static on some, client-specified, factoryClass to build new instances of the descriptor class; and it's debatable whether that is desirable...
It might be reasonable to rework this into a number of different classes that implement an interface...
Constructor and Description |
---|
InstantiationPolicy()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
buildNewInstance()
Build and return a new instance, using the appropriate mechanism.
|
java.lang.Object |
clone()
INTERNAL:
Clones the InstantiationPolicy
|
void |
convertClassNamesToClasses(java.lang.ClassLoader classLoader)
INTERNAL:
Convert all the class-name-based settings in this InstantiationPolicy to actual class-based
settings.
|
java.lang.Object |
getFactory() |
java.lang.Class |
getFactoryClass() |
java.lang.String |
getFactoryClassName() |
java.lang.String |
getFactoryMethodName() |
java.lang.String |
getMethodName() |
void |
initialize(AbstractSession session)
If necessary, initialize the factory and the method.
|
boolean |
isUsingDefaultConstructor()
If no method name is specified, they we have to use the default (zero-argument) constructor.
|
void |
setDescriptor(ClassDescriptor descriptor) |
void |
setMethodName(java.lang.String methodName) |
java.lang.String |
toString() |
void |
useDefaultConstructorInstantiationPolicy() |
void |
useFactoryInstantiationPolicy(java.lang.Class factoryClass,
java.lang.String methodName) |
void |
useFactoryInstantiationPolicy(java.lang.Class factoryClass,
java.lang.String methodName,
java.lang.String factoryMethodName) |
void |
useFactoryInstantiationPolicy(java.lang.Object factory,
java.lang.String methodName) |
void |
useFactoryInstantiationPolicy(java.lang.String factoryClassName,
java.lang.String methodName) |
void |
useFactoryInstantiationPolicy(java.lang.String factoryClassName,
java.lang.String methodName,
java.lang.String factoryMethodName) |
void |
useMethodInstantiationPolicy(java.lang.String staticMethodName) |
public java.lang.Object buildNewInstance() throws DescriptorException
buildNewInstance
in class CoreInstantiationPolicy
DescriptorException
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String getFactoryMethodName()
public java.lang.Object getFactory()
public java.lang.Class getFactoryClass()
public java.lang.String getFactoryClassName()
public java.lang.String getMethodName()
public void initialize(AbstractSession session) throws DescriptorException
DescriptorException
public boolean isUsingDefaultConstructor()
public void setDescriptor(ClassDescriptor descriptor)
public void setMethodName(java.lang.String methodName)
public void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
classLoader
- public java.lang.String toString()
toString
in class java.lang.Object
public void useDefaultConstructorInstantiationPolicy()
public void useFactoryInstantiationPolicy(java.lang.Class factoryClass, java.lang.String methodName)
public void useFactoryInstantiationPolicy(java.lang.Class factoryClass, java.lang.String methodName, java.lang.String factoryMethodName)
public void useFactoryInstantiationPolicy(java.lang.String factoryClassName, java.lang.String methodName)
useFactoryInstantiationPolicy
in class CoreInstantiationPolicy
public void useFactoryInstantiationPolicy(java.lang.String factoryClassName, java.lang.String methodName, java.lang.String factoryMethodName)
public void useFactoryInstantiationPolicy(java.lang.Object factory, java.lang.String methodName)
public void useMethodInstantiationPolicy(java.lang.String staticMethodName)
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference