public final class ComponentTypeImpl extends java.lang.Object implements ComponentType
Modifier and Type | Field and Description |
---|---|
protected ConfigContextImpl |
configContext
The config context
|
protected DataCache<java.lang.Object> |
dataCache
data cache
|
protected java.util.Map<java.lang.String,ResourceIndex<java.lang.Object>> |
indices
Indices
|
protected boolean |
initialized
whether the component type has been initialized
|
protected boolean |
isChildTypeDef |
protected boolean |
isParentTypeDef |
protected boolean |
loaded
Whether components have been loaded
|
protected DataCache<Metadata> |
metadataCache
Metadata cache
|
protected PersistenceHandler |
persistenceHandler
The persistence handler for this type
|
protected java.lang.String |
session
The session that this component type operates on.
|
protected ResourceTypeDef |
typedef
Definition of this type
|
Constructor and Description |
---|
ComponentTypeImpl(ConfigContextImpl configContext, ResourceTypeDef typedef)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
_putRaw(Ref ref, java.lang.Object data, Metadata md)
The most basic update/create operation, that only updates the necessary data structures.
|
void |
_removeRaw(Ref instanceId)
The most basic delete operation that only updates the necessary data structures.
|
void |
clone(Ref sourceref, Ref targetref, java.util.Map<Ref,Ref> refmap)
Clones a resource to the given identity
|
void |
componentCreatedInCore(Ref ref) |
void |
componentDeletedInCore(Ref ref) |
void |
componentRenamedInCore(Ref currentInstanceId, Ref newInstanceId) |
void |
componentUpdatedInCore(Ref ref) |
Summary |
computeSummary(Ref ref, java.lang.Object data) |
void |
create(Ref ref, java.lang.Object data)
create a new resource
|
void |
createBare(Ref ref, java.lang.Object data)
Creates a new resource instance from scratch.
|
void |
createWithDigest(Ref ref, java.lang.Object data, Digest digest)
Creates resource with the given digest.
|
void |
delete(Ref instanceId)
Deletes the instance with the given instance id.
|
boolean |
exists(Ref instanceId)
Returns whether the instance with the given instance id exists.
|
java.util.Set<Ref> |
getInstanceIds()
Returns a set of instance ids of all the components.
|
java.util.Set<Ref> |
getInstanceIds(ResourceQuery query)
Returns the list of instance ids (java.lang.String) of component instances that satisfy the given filter criteria.
|
Metadata |
getMetadata(Ref instanceId)
Returns the metadata for a given instance
|
int |
getNumInstances()
Returns the number of instances of this type
|
int |
getNumInstances(java.lang.String keyName, java.lang.Object keyValue)
Returns the number of components that has the given keyValue for the given key.
|
ResourceIndex |
getResourceIndex(java.lang.String keyName)
Returns the resource index associated with the given key
|
ResourceTypeDef |
getTypeDef()
Returns the definition for this component type
|
java.lang.String |
getTypeId()
Returns the id of this type
|
<T> T |
getValue(Ref instanceId)
Returns the data value for the given instance
|
<T> T |
getValue(Ref instanceId, boolean returnCopy)
Returns the data value for the given instance
|
void |
init()
Initializes the Component type for use.
|
boolean |
isInitialized()
Returns true if this component type is initialized
|
void |
purge()
internal use only.
|
void |
rename(Ref currentInstanceId, Ref newInstanceId)
Renames an instance
|
java.util.Set<Ref> |
searchInstanceIds(java.lang.String keyName, java.lang.Object keyValue)
returns a set of component ids that has the given keyValue for the given key.
|
void |
shutdown()
Shutsdown this component.
|
void |
update(Ref ref, java.lang.Object newData)
Updates a component with a new value whose digest, and metadata is not known
|
void |
validateForClone(Ref sourceref, Ref targetref)
Validates that a resource can be cloned
|
void |
validateForDelete(Ref ref)
Validates that the given component can be deleted.
|
void |
validateForRename(Ref oldInstanceId, Ref newInstanceId)
Validates that the identity of the given component instance can be changed (moved or renamed)
|
protected final java.lang.String session
protected final ResourceTypeDef typedef
protected final boolean isParentTypeDef
protected final boolean isChildTypeDef
protected final java.util.Map<java.lang.String,ResourceIndex<java.lang.Object>> indices
protected final DataCache<java.lang.Object> dataCache
protected final PersistenceHandler persistenceHandler
protected final ConfigContextImpl configContext
protected boolean initialized
protected boolean loaded
public ComponentTypeImpl(ConfigContextImpl configContext, ResourceTypeDef typedef) throws java.lang.Exception
configContext
- the config context of this componenttypedef
- definition for this typejava.lang.Exception
public void _putRaw(Ref ref, java.lang.Object data, Metadata md) throws java.lang.Exception
java.lang.Exception
public void _removeRaw(Ref instanceId) throws java.lang.Exception
NotFoundException
DeleteException
java.lang.Exception
public void init() throws java.lang.Exception
public void shutdown()
public void validateForDelete(Ref ref) throws NotFoundException, DeleteException
NotFoundException
DeleteException
public void validateForRename(Ref oldInstanceId, Ref newInstanceId) throws ValidationException
oldInstanceId
-newInstanceId
-ValidationException
public void validateForClone(Ref sourceref, Ref targetref) throws ValidationException
sourceref
-targetref
-ValidationException
public java.util.Set<Ref> getInstanceIds(ResourceQuery query)
getInstanceIds
in interface ComponentType
query
-public java.lang.String getTypeId()
public ResourceTypeDef getTypeDef()
getTypeDef
in interface BaseType
getTypeDef
in interface ComponentType
public int getNumInstances()
getNumInstances
in interface BaseType
public boolean isInitialized()
isInitialized
in interface BaseType
public ResourceIndex getResourceIndex(java.lang.String keyName)
public boolean exists(Ref instanceId)
public <T> T getValue(Ref instanceId) throws NotFoundException
getValue
in interface BaseType
NotFoundException
public <T> T getValue(Ref instanceId, boolean returnCopy) throws NotFoundException
getValue
in interface ComponentType
NotFoundException
public Metadata getMetadata(Ref instanceId) throws NotFoundException
BaseType
getMetadata
in interface BaseType
NotFoundException
public java.util.Set<Ref> getInstanceIds()
getInstanceIds
in interface BaseType
public java.util.Set<Ref> searchInstanceIds(java.lang.String keyName, java.lang.Object keyValue)
searchInstanceIds
in interface BaseType
keyName
-keyValue
-public int getNumInstances(java.lang.String keyName, java.lang.Object keyValue)
keyName
-keyValue
-public void create(Ref ref, java.lang.Object data) throws ValidationException, CreateException
create
in interface BaseType
ref
- reference of the new instance .data
- the data used to initialize the instance.ValidationException
- if the validation of the data, or reference fails, or if the instance already existsCreateException
- if there are any other errors during the operation (serialization, etc)public void createBare(Ref ref, java.lang.Object data) throws ValidationException, CreateException
ref
- reference to the resourcedata
- the data used to initialize the component.ValidationException
CreateException
public void createWithDigest(Ref ref, java.lang.Object data, Digest digest) throws ValidationException, CreateException
ref
-data
-digest
-ValidationException
CreateException
public void delete(Ref instanceId) throws NotFoundException, DeleteException
delete
in interface BaseType
instanceId
- Id of the instance to be deleted.NotFoundException
DeleteException
public void update(Ref ref, java.lang.Object newData) throws ValidationException, UpdateException
update
in interface BaseType
ref
- Id of the instance to be deleted.newData
-ValidationException
UpdateException
NotFoundException
- if the instance does not exist.public void clone(Ref sourceref, Ref targetref, java.util.Map<Ref,Ref> refmap) throws ValidationException, CreateException
clone
in interface ComponentType
sourceref
- the sourcetargetref
- the targetrefmap
- any reference mappings that needs to be performed automaticallyValidationException
CreateException
NotFoundException
public void rename(Ref currentInstanceId, Ref newInstanceId) throws ValidationException, UpdateException
rename
in interface ComponentType
currentInstanceId
- the current identity of the instancenewInstanceId
- the new identity of the instance.ValidationException
UpdateException
NotFoundException
public void purge()
public void componentCreatedInCore(Ref ref) throws java.lang.Exception
java.lang.Exception
public void componentDeletedInCore(Ref ref) throws java.lang.Exception
java.lang.Exception
public void componentUpdatedInCore(Ref ref) throws java.lang.Exception
java.lang.Exception