Interface MultiTenantCloneable<T>
- All Known Subinterfaces:
DataDrivenEnumeration,DataDrivenEnumerationValue,SystemProperty,Translation
- All Known Implementing Classes:
DataDrivenEnumerationImpl,DataDrivenEnumerationValueImpl,MediaImpl,NullSystemProperty,SystemPropertyImpl,TranslationImpl
public interface MultiTenantCloneable<T>
Describes an entity (or @Embeddable) that is able to be cloned for the purpose of multiple tenancy.
- Author:
- Jeff Fischer
-
Method Summary
Modifier and TypeMethodDescription<G extends T>
CreateResponse<G>Clone this entity for the purpose of multiple tenancy.
-
Method Details
-
createOrRetrieveCopyInstance
<G extends T> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException Clone this entity for the purpose of multiple tenancy. Note, extending classes should follow this pattern:public CreateResponse<MyClass> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException { CreateResponse<MyClass> createResponse = super.createOrRetrieveCopyInstance(context); if (createResponse.isAlreadyPopulated()) { return createResponse; } MyClass myClone = createResponse.getClone();Support should also be added for @Embeddable classes that contribute fields (collections or basic) to a cloneable entity://copy extended field values on myClone here
return createResponse; }
public CreateResponse<G extends MyClass> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException { CreateResponsecreateResponse = context.createOrRetrieveCopyInstance(this); MyClass myClone = createResponse.getClone(); //copy extended field values on myClone here
return createResponse; }
- Parameters:
context- a context object providing persistence and library functionality for copying entities- Returns:
- the resulting copy container, possibly already persisted
- Throws:
CloneNotSupportedException- if there's a problem detected with the cloning configuration
-