public abstract class AbstractDeployer<D extends BaseDefinition> extends java.lang.Object implements ResourceDeployer<D>, DeploymentValidator
ResourceDeployer
interface. It provides
the basic support for calling CrudRepository methods and sending deployment messages.Modifier and Type | Field and Description |
---|---|
protected ParsingContext |
definitionKind
Used in exception messages as well as indication to the parser.
|
protected XDParser |
parser |
Modifier | Constructor and Description |
---|---|
protected |
AbstractDeployer(ZooKeeperConnection zkConnection,
org.springframework.data.repository.PagingAndSortingRepository<D,java.lang.String> repository,
XDParser parser,
ParsingContext parsingContext) |
Modifier and Type | Method and Description |
---|---|
protected D |
afterSave(D savedDefinition)
Callback method that subclasses may override to get a chance to act on newly saved definitions.
|
protected D |
basicDeploy(java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> properties)
Provides basic deployment behavior, whereby running state of deployed definitions is not persisted.
|
protected void |
beforeDelete(D definition)
Callback method that subclasses may override to get a chance to act on definitions that are about to be deleted.
|
protected abstract D |
createDefinition(java.lang.String name,
java.lang.String definition) |
protected java.util.List<ModuleDefinition> |
createModuleDefinitions(java.util.List<ModuleDescriptor> moduleDescriptors)
Create a list of ModuleDefinitions given the results of parsing the definition.
|
void |
delete(java.lang.String name)
Delete the Definition using the provided name.
|
void |
deleteAll()
Delete all the definitions
|
java.lang.Iterable<D> |
findAll() |
org.springframework.data.domain.Page<D> |
findAll(org.springframework.data.domain.Pageable pageable)
Return a slice of all definitions.
|
D |
findOne(java.lang.String name)
Retrieves a single Definition or null if none is found.
|
protected org.springframework.data.repository.CrudRepository<D,java.lang.String> |
getDefinitionRepository() |
protected abstract java.lang.String |
getDeploymentPath(D definition)
Return the ZooKeeper path used for deployment requests for the
given definition.
|
protected ZooKeeperConnection |
getZooKeeperConnection()
Return the ZooKeeper connection.
|
D |
save(D definition) |
protected void |
throwAlreadyDeployedException(java.lang.String name) |
protected void |
throwDefinitionAlreadyExistsException(D definition) |
protected void |
throwDefinitionNotDeployable(java.lang.String name) |
protected void |
throwNoSuchDefinitionException(java.lang.String name) |
protected void |
throwNoSuchDefinitionException(java.lang.String name,
java.lang.String definitionKind) |
protected void |
throwNotDeployedException(java.lang.String name) |
void |
validateBeforeDelete(java.lang.String name)
Validate before deletion of the definition.
|
void |
validateBeforeSave(java.lang.String name,
java.lang.String definition)
Validate before saving the definitions.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deploy, undeploy, undeployAll
validateBeforeDeploy, validateBeforeUndeploy
protected final XDParser parser
protected final ParsingContext definitionKind
protected AbstractDeployer(ZooKeeperConnection zkConnection, org.springframework.data.repository.PagingAndSortingRepository<D,java.lang.String> repository, XDParser parser, ParsingContext parsingContext)
public D save(D definition)
save
in interface ResourceDeployer<D extends BaseDefinition>
public void validateBeforeSave(java.lang.String name, java.lang.String definition)
DeploymentValidator
validateBeforeSave
in interface DeploymentValidator
name
- the deployment unit namedefinition
- the definitionprotected java.util.List<ModuleDefinition> createModuleDefinitions(java.util.List<ModuleDescriptor> moduleDescriptors)
moduleDescriptors
- The list of ModuleDescriptors resulting from parsing the definition.protected ZooKeeperConnection getZooKeeperConnection()
protected D afterSave(D savedDefinition)
protected void throwDefinitionAlreadyExistsException(D definition)
protected void throwNoSuchDefinitionException(java.lang.String name)
protected void throwDefinitionNotDeployable(java.lang.String name)
protected void throwNoSuchDefinitionException(java.lang.String name, java.lang.String definitionKind)
protected void throwNotDeployedException(java.lang.String name)
protected void throwAlreadyDeployedException(java.lang.String name)
public D findOne(java.lang.String name)
ResourceDeployer
findOne
in interface ResourceDeployer<D extends BaseDefinition>
name
- of the definition to find. Must not be null.public java.lang.Iterable<D> findAll()
findAll
in interface ResourceDeployer<D extends BaseDefinition>
public org.springframework.data.domain.Page<D> findAll(org.springframework.data.domain.Pageable pageable)
ResourceDeployer
findAll
in interface ResourceDeployer<D extends BaseDefinition>
public void deleteAll()
ResourceDeployer
deleteAll
in interface ResourceDeployer<D extends BaseDefinition>
protected org.springframework.data.repository.CrudRepository<D,java.lang.String> getDefinitionRepository()
protected D basicDeploy(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> properties)
NoSuchDefinitionException
- if there is no definition by the given nameprotected abstract D createDefinition(java.lang.String name, java.lang.String definition)
protected abstract java.lang.String getDeploymentPath(D definition)
definition
- definition for which to obtain pathpublic void validateBeforeDelete(java.lang.String name)
DeploymentValidator
validateBeforeDelete
in interface DeploymentValidator
name
- the deployment unit namepublic void delete(java.lang.String name)
ResourceDeployer
undeployed
as
part of that process.delete
in interface ResourceDeployer<D extends BaseDefinition>
name
- the name of the definition to deleteprotected void beforeDelete(D definition)