org.mule.impl.model
Class AbstractModel

java.lang.Object
  extended byorg.mule.impl.model.AbstractModel
All Implemented Interfaces:
Disposable, Initialisable, Lifecycle, Startable, Stoppable, UMOModel
Direct Known Subclasses:
DirectModel, JcaModel, PipelineModel, SedaModel, StreamingModel

public abstract class AbstractModel
extends Object
implements UMOModel

MuleModel is the default implementation of the UMOModel. The model encapsulates and manages the runtime behaviour of a Mule Server instance. It is responsible for maintaining the UMOs instances and their configuration.


Field Summary
protected  Map descriptors
          Collection for mule descriptors registered in this Manager
protected  Log logger
          logger used by this class
 
Constructor Summary
AbstractModel()
          Default constructor
 
Method Summary
protected abstract  UMOComponent createComponent(UMODescriptor descriptor)
           
 void dispose()
          Destroys any current components
 UMOComponent getComponent(String name)
          Returns the UMOComponent object for the given component name
 Iterator getComponentNames()
          Gets an iterator of all component names registered in the model
 UMOSession getComponentSession(String muleName)
          Returns a valid component for the given Mule name
 UMODescriptor getDescriptor(String name)
          Returns a descriptor for the given component name
 UMOEntryPointResolver getEntryPointResolver()
          The entry point resolver is used to determine the method to be called on a component when an event is received for it.
 ExceptionListener getExceptionListener()
          The exception strategy to use by components managed by the model.
 UMOLifecycleAdapterFactory getLifecycleAdapterFactory()
          The lifecycle adapter is used by the model to translate Mule lifecycle event to events that UMO components registered with the model understand.
 String getName()
          The model's name.
 void initialise()
          Method used to perform any initialisation work.
 boolean isComponentRegistered(String name)
          Determines if a UMO component descriptor by the given name is regestered with the model
 void pauseComponent(String name)
          Pauses event processing for a single Mule Component.
 UMOComponent registerComponent(UMODescriptor descriptor)
          Registers a UMODescriptor with the MuleManager.
 void resumeComponent(String name)
          Resumes a single Mule Component that has been paused.
 void setComponents(List descriptors)
          A convenience method to set a list of components on the model.
 void setEntryPointResolver(UMOEntryPointResolver entryPointResolver)
          This will be used to build entry points on the components registered with the model.
 void setExceptionListener(ExceptionListener exceptionListener)
          The exception strategy to use by components managed by the model.
 void setLifecycleAdapterFactory(UMOLifecycleAdapterFactory lifecycleAdapterFactory)
          Sets the lifecycleAdapterFactory on the model.
 void setName(String name)
          Sets the model's name.
 void start()
          Starts all registered components
 void startComponent(String name)
          Starts a single Mule Component.
 void stop()
          Stops any registered components
 void stopComponent(String name)
          Stops a single Mule Component.
 void unregisterComponent(UMODescriptor descriptor)
          Unregisters a component From the model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.umo.model.UMOModel
getType
 

Field Detail

logger

protected transient Log logger
logger used by this class


descriptors

protected Map descriptors
Collection for mule descriptors registered in this Manager

Constructor Detail

AbstractModel

public AbstractModel()
Default constructor

Method Detail

getName

public String getName()
Description copied from interface: UMOModel
The model's name. It is poosible to configure more than one model in a config file. The name can then be used to reference the Model use when starting the server

Specified by:
getName in interface UMOModel
Returns:
the model's name

setName

public void setName(String name)
Description copied from interface: UMOModel
Sets the model's name. It is poosible to configure more than one model in a config file. The name can then be used to reference the Model use when starting the server

Specified by:
setName in interface UMOModel
Parameters:
name - the model's name

getEntryPointResolver

public UMOEntryPointResolver getEntryPointResolver()
Description copied from interface: UMOModel
The entry point resolver is used to determine the method to be called on a component when an event is received for it.

Specified by:
getEntryPointResolver in interface UMOModel
Returns:
Returns the entryPointResolver.

setEntryPointResolver

public void setEntryPointResolver(UMOEntryPointResolver entryPointResolver)
Description copied from interface: UMOModel
This will be used to build entry points on the components registered with the model.

Specified by:
setEntryPointResolver in interface UMOModel
Parameters:
entryPointResolver - The entryPointResolver to set. This will be used to build entry points on the components registered with the model.

isComponentRegistered

public boolean isComponentRegistered(String name)
Description copied from interface: UMOModel
Determines if a UMO component descriptor by the given name is regestered with the model

Specified by:
isComponentRegistered in interface UMOModel
Parameters:
name - the name of the UMO
Returns:
true if the UMO's descriptor has benn registered with the model
See Also:
UMODescriptor

registerComponent

public UMOComponent registerComponent(UMODescriptor descriptor)
                               throws UMOException
Description copied from interface: UMOModel
Registers a UMODescriptor with the MuleManager. The manager will take care of creating the Mule UMO and, it's component and proxies.

Specified by:
registerComponent in interface UMOModel
Parameters:
descriptor - the UMODescriptor to register
Throws:
UMOException

unregisterComponent

public void unregisterComponent(UMODescriptor descriptor)
                         throws UMOException
Description copied from interface: UMOModel
Unregisters a component From the model

Specified by:
unregisterComponent in interface UMOModel
Parameters:
descriptor - the descriptor of the componnt to remove
Throws:
UMOException - if the component is not registered or it failed to be disposing or the descriptor is null

getLifecycleAdapterFactory

public UMOLifecycleAdapterFactory getLifecycleAdapterFactory()
Description copied from interface: UMOModel
The lifecycle adapter is used by the model to translate Mule lifecycle event to events that UMO components registered with the model understand. The UMOLifecycleAdapterFactory is used by the model to instanciate LifecycleAdapters.

Specified by:
getLifecycleAdapterFactory in interface UMOModel
Returns:
Returns the lifecycleAdapterFactory used by this Model.
See Also:
UMOLifecycleAdapterFactory, UMOLifecycleAdapter

setLifecycleAdapterFactory

public void setLifecycleAdapterFactory(UMOLifecycleAdapterFactory lifecycleAdapterFactory)
Description copied from interface: UMOModel
Sets the lifecycleAdapterFactory on the model.

Specified by:
setLifecycleAdapterFactory in interface UMOModel
Parameters:
lifecycleAdapterFactory - The lifecycleAdapterFactory to set on this model.
See Also:
UMOLifecycleAdapterFactory, UMOLifecycleAdapter

dispose

public void dispose()
Destroys any current components

Specified by:
dispose in interface Disposable

getComponentSession

public UMOSession getComponentSession(String muleName)
Returns a valid component for the given Mule name

Specified by:
getComponentSession in interface UMOModel
Parameters:
muleName - the Name of the Mule for which the component is required
Returns:
a component for the specified name

stop

public void stop()
          throws UMOException
Stops any registered components

Specified by:
stop in interface Stoppable
Throws:
UMOException - if a Component fails tcomponent

start

public void start()
           throws UMOException
Starts all registered components

Specified by:
start in interface Startable
Throws:
UMOException - if any of the components fail to start

startComponent

public void startComponent(String name)
                    throws UMOException
Starts a single Mule Component. This can be useful when stopping and starting some Mule UMOs while letting others continue

Specified by:
startComponent in interface UMOModel
Parameters:
name - the name of the Mule UMO to start
Throws:
UMOException - if the MuleUMO is not registered or the component failed to start

stopComponent

public void stopComponent(String name)
                   throws UMOException
Stops a single Mule Component. This can be useful when stopping and starting some Mule UMOs while letting others continue.

Specified by:
stopComponent in interface UMOModel
Parameters:
name - the name of the Mule UMO to stop
Throws:
UMOException - if the MuleUMO is not registered

pauseComponent

public void pauseComponent(String name)
                    throws UMOException
Pauses event processing for a single Mule Component. Unlike stopComponent(), a paused component will still consume messages from the underlying transport, but those messages will be queued until the component is resumed.

In order to persist these queued messages you can set the 'recoverableMode' property on the Muleconfiguration to true. this causes all internal queues to store their state.

Specified by:
pauseComponent in interface UMOModel
Parameters:
name - the name of the Mule UMO to stop
Throws:
UMOException - if the MuleUMO is not registered or the component failed to pause.
See Also:
MuleConfiguration

resumeComponent

public void resumeComponent(String name)
                     throws UMOException
Resumes a single Mule Component that has been paused. If the component is not paused nothing is executed.

Specified by:
resumeComponent in interface UMOModel
Parameters:
name - the name of the Mule UMO to resume
Throws:
UMOException - if the MuleUMO is not registered or the component failed to resume

setComponents

public void setComponents(List descriptors)
                   throws UMOException
Description copied from interface: UMOModel
A convenience method to set a list of components on the model. This method will most likely be used when the model is being constructed from an IoC container

Specified by:
setComponents in interface UMOModel
Parameters:
descriptors -
Throws:
UMOException

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown

getExceptionListener

public ExceptionListener getExceptionListener()
Description copied from interface: UMOModel
The exception strategy to use by components managed by the model. The exception strategy is used when an exception occurs while processing the current event for a component. A component can define it's own exception strategy, but if it doesn't this implmentation will be used.

Specified by:
getExceptionListener in interface UMOModel
Returns:
the default exception strategy for this model.
See Also:
ExceptionListener

setExceptionListener

public void setExceptionListener(ExceptionListener exceptionListener)
Description copied from interface: UMOModel
The exception strategy to use by components managed by the model. The exception strategy is used when an exception occurs while processing the current event for a component. A component can define it's own exception strategy, but if it doesn't this implmentation will be used.

Specified by:
setExceptionListener in interface UMOModel
Parameters:
exceptionListener - the default exception strategy for this model.
See Also:
ExceptionListener

getDescriptor

public UMODescriptor getDescriptor(String name)
Description copied from interface: UMOModel
Returns a descriptor for the given component name

Specified by:
getDescriptor in interface UMOModel
Parameters:
name - the name of the component
Returns:
a descriptor for the given component name or null if there is no component registered by that name
See Also:
UMODescriptor

getComponent

public UMOComponent getComponent(String name)
Description copied from interface: UMOModel
Returns the UMOComponent object for the given component name

Specified by:
getComponent in interface UMOModel
Parameters:
name - the name of the component
Returns:
the UMOComponent object for the given component name or null if there is no component registered by that name
See Also:
UMOComponent

getComponentNames

public Iterator getComponentNames()
Gets an iterator of all component names registered in the model

Specified by:
getComponentNames in interface UMOModel
Returns:
an iterator of all component names

createComponent

protected abstract UMOComponent createComponent(UMODescriptor descriptor)


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.