org.apache.avalon.activation.appliance.impl
Class AbstractBlock

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.activation.appliance.impl.AbstractAppliance
          extended byorg.apache.avalon.activation.appliance.impl.AbstractBlock
All Implemented Interfaces:
Appliance, Block, Composite, CompositionEventListener, Deployable, Disposable, Engine, EventListener, Home, LogEnabled
Direct Known Subclasses:
CompositeBlock

public abstract class AbstractBlock
extends AbstractAppliance
implements Block, Composite, CompositionEventListener

The AbstractBlock is responsible for the management of the assembly of the subsidiary appliances, the coordination of the deployment, decommissioning and eventual dissassembly of contained appliances, and the overall management of a containment context.

Version:
$Revision: 1.10 $ $Date: 2004/01/01 13:05:05 $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from interface org.apache.avalon.activation.appliance.Appliance
MBEAN_SERVER_KEY
 
Method Summary
 void assemble()
          Assemble the appliance.
 Appliance createAppliance(Model model)
          Create a new appliance.
static Block createRootBlock(ServiceContext services, ContainmentModel model)
          Create a root containment block.
 void decommission()
          Decommission the block.
 void deploy()
          Deploy the appliance.
 void disassemble()
          Disassemble the appliance.
 void dispose()
           
 ContainmentModel getContainmentModel()
          Return the containment metamodel associated with the block.
 Appliance[] getProviders()
          Returns the set of appliances instances that provide services to the set of appliances managed by this container.
 boolean isAssembled()
          Returns the assembled state of the appliance.
 Appliance locate(DependencyDescriptor dependency)
          Return an appliance relative to a supplied dependency descriptor.
 Appliance locate(DependencyModel dependency)
          Return an appliance relative to a supplied dependency model.
 Appliance locate(StageDescriptor stage)
          Return an appliance relative to a supplied stage descriptor.
 Appliance locate(StageModel stage)
          Return an appliance relative to a supplied stage model.
 Appliance locate(String source)
          Return an appliance relative to a specific path.
 void modelAdded(CompositionEvent event)
          Notify the listener that a model has been added to a source containment model.
 void modelRemoved(CompositionEvent event)
          Notify the listener that a model has been removed from a source containment model.
abstract  void release(Object instance)
          Release an object
abstract  Object resolve()
          Resolve a object to a value.
 String toString()
           
 
Methods inherited from class org.apache.avalon.activation.appliance.impl.AbstractAppliance
getModel, isEnabled
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.activation.appliance.Appliance
getModel, isEnabled
 

Method Detail

createRootBlock

public static Block createRootBlock(ServiceContext services,
                                    ContainmentModel model)
                             throws Exception
Create a root containment block.

Parameters:
services - the service context
model - the root containment model
Returns:
the appliance
Throws:
Exception

getContainmentModel

public ContainmentModel getContainmentModel()
Return the containment metamodel associated with the block.

Specified by:
getContainmentModel in interface Block
Returns:
the containment model

modelAdded

public void modelAdded(CompositionEvent event)
Notify the listener that a model has been added to a source containment model.

Specified by:
modelAdded in interface CompositionEventListener
Parameters:
event - the containment event raised by the source containment model

modelRemoved

public void modelRemoved(CompositionEvent event)
Notify the listener that a model has been removed from a source containment model.

Specified by:
modelRemoved in interface CompositionEventListener
Parameters:
event - the containment event raised by the source containment model

locate

public Appliance locate(DependencyModel dependency)
                 throws NoProviderDefinitionException,
                        ApplianceException
Return an appliance relative to a supplied dependency model.

Specified by:
locate in interface Engine
Parameters:
dependency - the dependency model
Returns:
the appliance
Throws:
NoProviderDefinitionException - if no provider an be found for the supplied dependency
ApplianceException - if an error occurs during appliance resolution

locate

public Appliance locate(DependencyDescriptor dependency)
                 throws NoProviderDefinitionException,
                        ApplianceException
Return an appliance relative to a supplied dependency descriptor.

Specified by:
locate in interface Engine
Parameters:
dependency - the dependency descriptor
Returns:
the appliance
Throws:
NoProviderDefinitionException - if no provider an be found for the supplied dependency
ApplianceException - if an error occurs during appliance resolution

locate

public Appliance locate(StageModel stage)
                 throws NoProviderDefinitionException,
                        ApplianceException
Return an appliance relative to a supplied stage model.

Specified by:
locate in interface Engine
Parameters:
stage - the stage model
Returns:
the appliance
Throws:
NoProviderDefinitionException - if no provider an be found for the supplied stage
ApplianceException - if an error occurs during appliance resolution

locate

public Appliance locate(StageDescriptor stage)
                 throws NoProviderDefinitionException,
                        ApplianceException
Return an appliance relative to a supplied stage descriptor.

Specified by:
locate in interface Engine
Parameters:
stage - the stage descriptor
Returns:
the appliance
Throws:
NoProviderDefinitionException - if no provider an be found for the supplied stage
ApplianceException - if an error occurs during appliance resolution
Exception - if an error occurs

locate

public Appliance locate(String source)
                 throws IllegalArgumentException,
                        ApplianceException
Return an appliance relative to a specific path.

Specified by:
locate in interface Engine
Parameters:
source - the appliance path
Returns:
the appliance
Throws:
IllegalArgumentException - if the supplied path is invalid
ApplianceException - if an error occurs during appliance resolution

isAssembled

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

Specified by:
isAssembled in interface Composite
Returns:
true if this appliance is assembled

assemble

public void assemble()
              throws AssemblyException
Assemble the appliance.

Specified by:
assemble in interface Composite
Throws:
ApplianceException - if an error occurs during appliance assembly
AssemblyException

disassemble

public void disassemble()
Disassemble the appliance.

Specified by:
disassemble in interface Composite

getProviders

public Appliance[] getProviders()
Returns the set of appliances instances that provide services to the set of appliances managed by this container.

Specified by:
getProviders in interface Composite
Returns:
an empty set of consumed appliance instances

deploy

public void deploy()
            throws Exception
Deploy the appliance. If the deployment policy is startup an initial instance of a component will be deployed.

Specified by:
deploy in interface Deployable
Throws:
Exception - if a deployment error occurs

decommission

public void decommission()
Decommission the block. Under the decommissioning phase, all active components will be taken down.

Specified by:
decommission in interface Deployable

resolve

public abstract Object resolve()
                        throws Exception
Resolve a object to a value.

Specified by:
resolve in interface Home
Returns:
the resolved object
Throws:
Exception - if an error occurs

release

public abstract void release(Object instance)
Release an object

Specified by:
release in interface Home
Parameters:
instance - the object to be released

dispose

public void dispose()
Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractAppliance

createAppliance

public Appliance createAppliance(Model model)
                          throws ApplianceException
Create a new appliance.

Parameters:
model - the component model
Returns:
the appliance
Throws:
ApplianceException

toString

public String toString()
Overrides:
toString in class AbstractAppliance


Copyright © Apache Software Foundation. All Rights Reserved.