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

java.lang.Object
  extended byorg.apache.avalon.composition.model.impl.DefaultModel
      extended byorg.apache.avalon.composition.model.impl.DefaultContainmentModel
All Implemented Interfaces:
ContainmentModel, Model

public class DefaultContainmentModel
extends DefaultModel
implements ContainmentModel

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

Version:
$Revision: 1.13.4.3 $ $Date: 2004/01/12 07:12:01 $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from interface org.apache.avalon.composition.model.ContainmentModel
SEPERATOR
 
Constructor Summary
DefaultContainmentModel(ContainmentContext context)
          Creation of a new containment model.
 
Method Summary
 void addCompositionListener(CompositionEventListener listener)
          Add a composition listener to the model.
 ContainmentModel addContainmentModel(URL block, URL config)
          Addition of a new subsidiary containment model within the containment context using a supplied url.
 Model addModel(Profile profile)
          Addition of a new subsidiary model within the containment context using a supplied profile.
 Model addModel(URL url)
          Add a model referenced by a url to this model.
 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.
 CategoriesDirective getCategories()
          Return the logging categories.
 ClassLoaderModel getClassLoaderModel()
          Return the classloader model.
 Model getModel(DependencyDescriptor dependency)
          Get a local model relative to a supplied service dependency.
 Model getModel(StageDescriptor stage)
          Return a model relative to a supplied stage descriptor.
 Model getModel(String path)
          Return a child model relative to a supplied name.
 Model[] getModels()
          Return the set of immediate child models nested within this model.
 String getPartition()
          Return the partition name established by this containment context.
 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.
 boolean isaCandidate(DependencyDescriptor dependency)
          Return TRUE is this model is capable of supporting a supplied depedendency.
 boolean isaCandidate(StageDescriptor stage)
          Return TRUE is this model is capable of supporting a supplied stage dependency.
 void removeCompositionListener(CompositionEventListener listener)
          Remove a composition listener from the model.
 void removeModel(String name)
          Removal of a named model for the containment model.
 void setCategories(CategoriesDirective categories)
          Set categories.
 String toString()
          Return a simple string represention of the containment model.
 
Methods inherited from class org.apache.avalon.composition.model.impl.DefaultModel
getLogger, getMode, getName, getPath, getQualifiedName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.composition.model.Model
getMode, getName, getPath, getQualifiedName
 

Constructor Detail

DefaultContainmentModel

public DefaultContainmentModel(ContainmentContext context)
                        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

getClassLoaderModel

public ClassLoaderModel getClassLoaderModel()
Return the classloader model.

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

getServices

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

Specified by:
getServices in interface Model
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 Model
Returns:
true if this model can fulfill the dependency

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 Model
Returns:
FALSE containers don't export stage handling support

addCompositionListener

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

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

removeCompositionListener

public void removeCompositionListener(CompositionEventListener 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

getCategories

public CategoriesDirective getCategories()
Return the logging categories.

Specified by:
getCategories in interface ContainmentModel
Returns:
the logging categories

setCategories

public void setCategories(CategoriesDirective categories)
Set categories.

Specified by:
setCategories in interface ContainmentModel
Parameters:
categories - the logging categories

addModel

public Model addModel(URL url)
               throws ModelException
Add a model referenced by a url to this model.

Specified by:
addModel 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 Model addModel(Profile profile)
               throws ModelException
Description copied from interface: ContainmentModel
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 Model[] getModels()
Return the set of immediate child models nested within this model.

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

getModel

public Model 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 Model getModel(DependencyDescriptor dependency)
               throws ModelRuntimeException
Get a local model relative to a supplied service dependency.

Specified by:
getModel in interface ContainmentModel
Parameters:
dependency - the service dependency descriptor
Returns:
a matching model or null if the dependency is unresolvable
Throws:
ModelRuntimeException - if an error occurs during model establishment

getModel

public Model getModel(StageDescriptor stage)
               throws ModelRuntimeException
Return a model relative to a supplied stage descriptor.

Specified by:
getModel in interface ContainmentModel
Parameters:
stage - the stage descriptor
Returns:
model of a an stage handler or null if the stage is unresolvable
Throws:
ModelRuntimeException - if an error occurs during model establishment

toString

public String toString()
Return a simple string represention of the containment model.

Overrides:
toString in class DefaultModel
Returns:
the string representation

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 © Apache Software Foundation. All Rights Reserved.