org.apache.avalon.composition.model.impl
Class DefaultContainmentModel

java.lang.Object
  extended byorg.apache.avalon.composition.model.impl.DefaultDeploymentModel
      extended byorg.apache.avalon.composition.model.impl.DefaultContainmentModel
All Implemented Interfaces:
Commissionable, ContainmentModel, DeploymentModel, Resolver

public class DefaultContainmentModel
extends DefaultDeploymentModel
implements ContainmentModel

Containment model implmentation within which composite models are aggregated as a part of a containment deployment model.

Version:
$Revision: 1.45 $ $Date: 2004/05/09 23:51:08 $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from interface org.apache.avalon.composition.model.ContainmentModel
KEY, SECURE_EXECUTION_KEY
 
Fields inherited from interface org.apache.avalon.composition.model.DeploymentModel
DEPLOYMENT_TIMEOUT_KEY, SEPARATOR
 
Constructor Summary
DefaultContainmentModel(ContainmentContext context, SecurityModel security)
          Creation of a new containment model.
 
Method Summary
 void addCompositionListener(CompositionListener listener)
          Add a composition listener to the model.
 ContainmentModel addContainmentModel(URL url)
          Add a model referenced by a url to this model.
 ContainmentModel addContainmentModel(URL block, URL config)
          Addition of a new subsidiary containment model within the containment context using a supplied url.
 DeploymentModel addModel(DeploymentModel model)
          Addition of a new subsidiary model within the containment context.
 DeploymentModel addModel(DeploymentProfile profile)
          Addition of a new subsidiary model within the containment context using a supplied profile.
 void applyTargets(TargetDirective[] targets)
          Apply a set of override targets.
 void applyTargets(URL config)
          Apply a set of override targets resolvable from a supplied url.
 void assemble()
          Assemble the model.
 void assemble(List subjects)
          Assemble the model.
 void commission()
          Commission the appliance.
 void decommission()
          Decommission the appliance.
 void disassemble()
          Disassemble the model.
 ClassLoaderModel getClassLoaderModel()
          Return the classloader model.
 long getDeploymentTimeout()
          Returns the maximum allowable time for deployment.
 DeploymentModel getModel(DependencyDescriptor dependency)
          Resolve a model capable of supporting the supplied service reference.
 DeploymentModel getModel(ReferenceDescriptor descriptor)
          Resolve a model capable of supporting the supplied service reference.
 DeploymentModel getModel(String path)
          Return a child model relative to a supplied name.
 DeploymentModel[] getModels()
          Return the set of immediate child models nested within this model.
 String getPartition()
          Return the partition name established by this containment context.
 DeploymentModel[] getProviders()
          Return the set of models assigned as providers.
 ServiceModel getServiceModel(Class clazz)
          Return the set of service export directives for a supplied class.
 ServiceModel[] getServiceModels()
          Return the set of service export mappings
 ServiceDescriptor[] getServices()
          Return the set of services produced by the model.
 DeploymentModel[] getShutdownGraph()
          Get the shutdown sequence for the model.
 DeploymentModel[] getStartupGraph()
          Get the startup sequence for the model.
 boolean isaCandidate(DependencyDescriptor dependency)
          Return TRUE is this model is capable of supporting a supplied depedendency.
 boolean isaCandidate(ReferenceDescriptor reference)
          Return TRUE is this model is capable of supporting a supplied service.
 boolean isaCandidate(StageDescriptor stage)
          Return TRUE is this model is capable of supporting a supplied stage dependency.
 boolean isAssembled()
          Returns the assembled state of the model.
 void removeCompositionListener(CompositionListener listener)
          Remove a composition listener from the model.
 void removeModel(String name)
          Removal of a named model for the containment model.
 
Methods inherited from class org.apache.avalon.composition.model.impl.DefaultDeploymentModel
equals, getAccessControlContext, getCategories, getConsumerGraph, getLogger, getMode, getName, getPath, getPermissions, getProviderGraph, getQualifiedName, release, resolve, resolve, setCategories, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.composition.model.DeploymentModel
getAccessControlContext, getCategories, getConsumerGraph, getLogger, getMode, getName, getPath, getProviderGraph, getQualifiedName, setCategories
 
Methods inherited from interface org.apache.avalon.composition.model.Resolver
release, resolve, resolve
 

Constructor Detail

DefaultContainmentModel

public DefaultContainmentModel(ContainmentContext context,
                               SecurityModel security)
                        throws ModelException
Creation of a new containment model.

Parameters:
context - the containment context that establishes the structural association of this containment model within a parent scope
Method Detail

commission

public void commission()
                throws Exception
Commission the appliance.

Specified by:
commission in interface Commissionable
Overrides:
commission in class DefaultDeploymentModel
Throws:
Exception - if a commissioning error occurs

decommission

public void decommission()
Decommission the appliance. Once an appliance is decommissioned it may be re-commissioned.

Specified by:
decommission in interface Commissionable
Overrides:
decommission in class DefaultDeploymentModel

getClassLoaderModel

public ClassLoaderModel getClassLoaderModel()
Return the classloader model.

Specified by:
getClassLoaderModel in interface ContainmentModel
Returns:
the classloader model

getDeploymentTimeout

public long getDeploymentTimeout()
Returns the maximum allowable time for deployment.

Specified by:
getDeploymentTimeout in interface ContainmentModel
Overrides:
getDeploymentTimeout in class DefaultDeploymentModel
Returns:
the maximum time expressed in millisecond of how long a deployment may take.

getServices

public ServiceDescriptor[] getServices()
Return the set of services produced by the model.

Specified by:
getServices in interface DeploymentModel
Returns:
the services

isaCandidate

public boolean isaCandidate(DependencyDescriptor dependency)
Return TRUE is this model is capable of supporting a supplied depedendency.

Specified by:
isaCandidate in interface DeploymentModel
Returns:
true if this model can fulfill the dependency

isaCandidate

public boolean isaCandidate(ReferenceDescriptor reference)
Return TRUE is this model is capable of supporting a supplied service.

Specified by:
isaCandidate in interface DeploymentModel
Parameters:
reference - the service reference descriptor
Returns:
true if this model can fulfill the service

isaCandidate

public boolean isaCandidate(StageDescriptor stage)
Return TRUE is this model is capable of supporting a supplied stage dependency. The containment model implementation will allways return FALSE.

Specified by:
isaCandidate in interface DeploymentModel
Returns:
FALSE containers don't export stage handling

isAssembled

public boolean isAssembled()
Returns the assembled state of the model.

Specified by:
isAssembled in interface DeploymentModel
Returns:
true if this model is assembled

assemble

public void assemble()
              throws AssemblyException
Assemble the model. Model assembly is a process of wiring together candidate service providers with consumers. The assembly implementation will assemble each deployment model contained within this model.

Specified by:
assemble in interface ContainmentModel
Throws:
Exception - if assembly cannot be fulfilled
AssemblyException

assemble

public void assemble(List subjects)
              throws AssemblyException
Assemble the model.

Specified by:
assemble in interface ContainmentModel
Parameters:
subjects - the list of deployment targets making up the assembly chain
Throws:
Exception - if an error occurs during model assembly
AssemblyException

disassemble

public void disassemble()
Disassemble the model.

Specified by:
disassemble in interface ContainmentModel

getProviders

public DeploymentModel[] getProviders()
Return the set of models assigned as providers.

Specified by:
getProviders in interface DeploymentModel
Returns:
the providers consumed by the model
Throws:
IllegalStateException - if the model is not in an assembled state

addCompositionListener

public void addCompositionListener(CompositionListener listener)
Add a composition listener to the model.

Specified by:
addCompositionListener in interface ContainmentModel
Parameters:
listener - the composition listener

removeCompositionListener

public void removeCompositionListener(CompositionListener listener)
Remove a composition listener from the model.

Specified by:
removeCompositionListener in interface ContainmentModel
Parameters:
listener - the composition listener

getServiceModels

public ServiceModel[] getServiceModels()
Return the set of service export mappings

Specified by:
getServiceModels in interface ContainmentModel
Returns:
the set of export directives published by the model

getServiceModel

public ServiceModel getServiceModel(Class clazz)
Return the set of service export directives for a supplied class.

Specified by:
getServiceModel in interface ContainmentModel
Parameters:
clazz - a cleaa identifying the directive
Returns:
the export directives

getStartupGraph

public DeploymentModel[] getStartupGraph()
Get the startup sequence for the model.

Specified by:
getStartupGraph in interface ContainmentModel

getShutdownGraph

public DeploymentModel[] getShutdownGraph()
Get the shutdown sequence for the model.

Specified by:
getShutdownGraph in interface ContainmentModel

addContainmentModel

public ContainmentModel addContainmentModel(URL url)
                                     throws ModelException
Add a model referenced by a url to this model.

Specified by:
addContainmentModel in interface ContainmentModel
Parameters:
url - the url of the model to include
Returns:
the model
Throws:
ModelException - if a model related error occurs

addContainmentModel

public ContainmentModel addContainmentModel(URL block,
                                            URL config)
                                     throws ModelException
Description copied from interface: ContainmentModel
Addition of a new subsidiary containment model within the containment context using a supplied url.

Specified by:
addContainmentModel in interface ContainmentModel
Parameters:
block - a url referencing a containment profile
config - containment configuration targets
Returns:
the model created using the derived profile and configuration
Throws:
ModelException - if an error occurs during model establishment

addModel

public DeploymentModel addModel(DeploymentModel model)
Addition of a new subsidiary model within the containment context.

Specified by:
addModel in interface ContainmentModel
Parameters:
model - a containment or component model
Returns:
the supplied model

addModel

public DeploymentModel addModel(DeploymentProfile profile)
                         throws ModelException
Addition of a new subsidiary model within the containment context using a supplied profile.

Specified by:
addModel in interface ContainmentModel
Parameters:
profile - a containment or deployment profile
Returns:
the model based on the supplied profile
Throws:
ModelException - if an error occurs during model establishment

removeModel

public void removeModel(String name)
                 throws IllegalArgumentException
Removal of a named model for the containment model.

Specified by:
removeModel in interface ContainmentModel
Parameters:
name - the name of the subsidiary model to be removed
Throws:
IllegalArgumentException - if the supplied name is unknown

getPartition

public String getPartition()
Return the partition name established by this containment context.

Specified by:
getPartition in interface ContainmentModel
Returns:
the partition name

getModels

public DeploymentModel[] getModels()
Return the set of immediate child models nested within this model.

Specified by:
getModels in interface ContainmentModel
Returns:
the nested model

getModel

public DeploymentModel getModel(String path)
Return a child model relative to a supplied name.

Specified by:
getModel in interface ContainmentModel
Parameters:
path - a relative or absolute path
Returns:
the named model or null if the name is unknown
Throws:
IllegalArgumentException - if the name if badly formed

getModel

public DeploymentModel getModel(ReferenceDescriptor descriptor)
                         throws AssemblyException
Resolve a model capable of supporting the supplied service reference.

Specified by:
getModel in interface ContainmentModel
Parameters:
descriptor - a service reference descriptor
Returns:
the model or null if unresolvable
Throws:
AssemblyException - if an assembly error occurs

getModel

public DeploymentModel getModel(DependencyDescriptor dependency)
                         throws AssemblyException
Resolve a model capable of supporting the supplied service reference.

Specified by:
getModel in interface ContainmentModel
Parameters:
dependency - a dependency descriptor
Returns:
the model or null if unresolvable
Throws:
AssemblyException - if an assembly error occurs

applyTargets

public void applyTargets(URL config)
                  throws ModelException
Apply a set of override targets resolvable from a supplied url.

Specified by:
applyTargets in interface ContainmentModel
Parameters:
config - a url resolvable to a TargetDirective[]
Throws:
ModelException - if an error occurs

applyTargets

public void applyTargets(TargetDirective[] targets)
Apply a set of override targets.

Specified by:
applyTargets in interface ContainmentModel
Parameters:
targets - a set of target directives


Copyright © The Apache Software Foundation. All Rights Reserved.