org.mule
Class DefaultMuleContext

java.lang.Object
  extended by org.mule.DefaultMuleContext
All Implemented Interfaces:
Disposable, Initialisable, Lifecycle, Startable, Stoppable, MuleContext

public class DefaultMuleContext
extends Object
implements MuleContext


Field Summary
protected  LifecycleManager lifecycleManager
          LifecycleManager for the MuleContext.
protected  ServerNotificationManager notificationManager
           
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
DefaultMuleContext(MuleConfiguration config, WorkManager workManager, javax.resource.spi.work.WorkListener workListener, LifecycleManager lifecycleManager, ServerNotificationManager notificationManager)
           
 
Method Summary
 void addRegistry(long id, Registry registry)
           
protected  void checkLifecycleForPropertySet(String propertyName, String phase)
           
protected  RegistryBroker createRegistryBroker()
           
protected  MuleRegistry createRegistryHelper(Registry registry)
           
 void deregister()
           
 void dispose()
          A lifecycle method where implementor should free up any resources.
 void fireNotification(ServerNotification notification)
          Fires a server notification to all registered org.mule.api.context.notification.listener.CustomNotificationListener notificationManager.
 MuleConfiguration getConfiguration()
           
 ThreadingProfile getDefaultMessageDispatcherThreadingProfile()
           
 ThreadingProfile getDefaultMessageReceiverThreadingProfile()
           
 ThreadingProfile getDefaultMessageRequesterThreadingProfile()
           
 ThreadingProfile getDefaultServiceThreadingProfile()
           
 ThreadingProfile getDefaultThreadingProfile()
           
 ExpressionManager getExpressionManager()
          Returns the Expression Manager configured for this instance of Mule
 LifecycleManager getLifecycleManager()
           
 ServerNotificationManager getNotificationManager()
           
 QueueManager getQueueManager()
          Gets the queue manager used by mule for queuing events.
 MuleRegistry getRegistry()
           
 String getRegistryId()
           
 SecurityManager getSecurityManager()
          Gets the security manager used by this Mule instance to authenticate and authorise incoming and outgoing event traffic and service invocations
 long getStartDate()
          Returns the long date when the server was started
 AllStatistics getStatistics()
          Gets all statisitcs for this instance
 TransactionManager getTransactionManager()
          Returns the Jta transaction manager used by this Mule server instance.
 javax.resource.spi.work.WorkListener getWorkListener()
           
 WorkManager getWorkManager()
          Obtains a workManager instance that can be used to schedule work in a thread pool.
 void initialise()
          Method used to perform any initialisation work.
 boolean isDisposed()
           
 boolean isDisposing()
           
 boolean isInitialised()
          Determines if the server has been initialised
 boolean isInitialising()
          Determines if the server is being initialised
 boolean isStarted()
          Determines if the server has been started
protected  boolean isStarting()
           
protected  boolean isStopped()
           
protected  boolean isStopping()
           
 void register()
           
 void registerListener(ServerNotificationListener l)
          Registers an intenal server event listener.
 void registerListener(ServerNotificationListener l, String resourceIdentifier)
          Registers an intenal server event listener.
 void removeRegistry(long id)
           
 void setQueueManager(QueueManager queueManager)
          Sets the queue manager used by mule for queuing events.
 void setSecurityManager(SecurityManager securityManager)
          Sets the security manager used by this Mule instance to authenticate and authorise incoming and outgoing event traffic and service invocations
 void setTransactionManager(TransactionManager manager)
          Sets the Jta Transaction Manager to use with this Mule server instance
 void start()
           
 void stop()
          Stops the MuleManager which stops all sessions and connectors
 void unregisterListener(ServerNotificationListener l)
          Unregisters a previously registered listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lifecycleManager

protected LifecycleManager lifecycleManager
LifecycleManager for the MuleContext. Note: this is NOT the same lifecycle manager as the one in the Registry.


notificationManager

protected ServerNotificationManager notificationManager
Constructor Detail

DefaultMuleContext

public DefaultMuleContext(MuleConfiguration config,
                          WorkManager workManager,
                          javax.resource.spi.work.WorkListener workListener,
                          LifecycleManager lifecycleManager,
                          ServerNotificationManager notificationManager)
Method Detail

createRegistryBroker

protected RegistryBroker createRegistryBroker()

createRegistryHelper

protected MuleRegistry createRegistryHelper(Registry registry)

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
RecoverableException - if an error occurs that can be recovered from

start

public void start()
           throws MuleException
Specified by:
start in interface Startable
Throws:
MuleException

stop

public void stop()
          throws MuleException
Stops the MuleManager which stops all sessions and connectors

Specified by:
stop in interface Stoppable
Throws:
MuleException - if either any of the sessions or connectors fail to stop

dispose

public void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable

isInitialised

public boolean isInitialised()
Determines if the server has been initialised

Specified by:
isInitialised in interface MuleContext
Returns:
true if the server has been initialised

isInitialising

public boolean isInitialising()
Determines if the server is being initialised

Specified by:
isInitialising in interface MuleContext
Returns:
true if the server is beening initialised

isStopped

protected boolean isStopped()

isStopping

protected boolean isStopping()

isStarted

public boolean isStarted()
Determines if the server has been started

Specified by:
isStarted in interface MuleContext
Returns:
true if the server has been started

isStarting

protected boolean isStarting()

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface MuleContext

isDisposing

public boolean isDisposing()
Specified by:
isDisposing in interface MuleContext

getLifecycleManager

public LifecycleManager getLifecycleManager()
Specified by:
getLifecycleManager in interface MuleContext

getStatistics

public AllStatistics getStatistics()
Gets all statisitcs for this instance

Specified by:
getStatistics in interface MuleContext
Returns:
all statisitcs for this instance

registerListener

public void registerListener(ServerNotificationListener l)
                      throws NotificationException
Description copied from interface: MuleContext
Registers an intenal server event listener. The listener will be notified when a particular event happens within the server. Typically this is not an event in the same sense as an MuleEvent (although there is nothing stopping the implementation of this class triggering listeners when a MuleEvent is received).

The types of notifications fired is entirely defined by the implementation of this class

Specified by:
registerListener in interface MuleContext
Parameters:
l - the listener to register
Throws:
NotificationException

registerListener

public void registerListener(ServerNotificationListener l,
                             String resourceIdentifier)
                      throws NotificationException
Description copied from interface: MuleContext
Registers an intenal server event listener. The listener will be notified when a particular event happens within the server. Typically this is not an event in the same sense as an MuleEvent (although there is nothing stopping the implementation of this class triggering listeners when a MuleEvent is received).

The types of notifications fired is entirely defined by the implementation of this class

Specified by:
registerListener in interface MuleContext
Parameters:
l - the listener to register
resourceIdentifier - a particular resource name for the given type of listener For example, the resourceName could be the name of a service if the listener was a ServiceNotificationListener
Throws:
NotificationException

unregisterListener

public void unregisterListener(ServerNotificationListener l)
Description copied from interface: MuleContext
Unregisters a previously registered listener. If the listener has not already been registered, this method should return without exception

Specified by:
unregisterListener in interface MuleContext
Parameters:
l - the listener to unregister

fireNotification

public void fireNotification(ServerNotification notification)
Fires a server notification to all registered org.mule.api.context.notification.listener.CustomNotificationListener notificationManager.

Specified by:
fireNotification in interface MuleContext
Parameters:
notification - the notification to fire. This must be of type CustomNotification otherwise an exception will be thrown.
Throws:
UnsupportedOperationException - if the notification fired is not a CustomNotification

setSecurityManager

public void setSecurityManager(SecurityManager securityManager)
                        throws RegistrationException
Sets the security manager used by this Mule instance to authenticate and authorise incoming and outgoing event traffic and service invocations

Specified by:
setSecurityManager in interface MuleContext
Parameters:
securityManager - the security manager used by this Mule instance to authenticate and authorise incoming and outgoing event traffic and service invocations
Throws:
RegistrationException

getSecurityManager

public SecurityManager getSecurityManager()
Gets the security manager used by this Mule instance to authenticate and authorise incoming and outgoing event traffic and service invocations

Specified by:
getSecurityManager in interface MuleContext
Returns:
he security manager used by this Mule instance to authenticate and authorise incoming and outgoing event traffic and service invocations

getWorkManager

public WorkManager getWorkManager()
Obtains a workManager instance that can be used to schedule work in a thread pool. This will be used primarially by Agents wanting to schedule work. This work Manager must never be used by provider implementations as they have their own workManager accible on the connector.

If a workManager has not been set by the time the initialise() method has been called a default MuleWorkManager will be created using the DefaultThreadingProfile on the MuleConfiguration object.

Specified by:
getWorkManager in interface MuleContext
Returns:
a workManager instance used by the current MuleManager
See Also:
ThreadingProfile, DefaultMuleConfiguration

getWorkListener

public javax.resource.spi.work.WorkListener getWorkListener()
Specified by:
getWorkListener in interface MuleContext

getQueueManager

public QueueManager getQueueManager()
Description copied from interface: MuleContext
Gets the queue manager used by mule for queuing events. This is used for service queues.

Specified by:
getQueueManager in interface MuleContext
Returns:

setQueueManager

public void setQueueManager(QueueManager queueManager)
                     throws RegistrationException
Description copied from interface: MuleContext
Sets the queue manager used by mule for queuing events. This is used for service queues

Specified by:
setQueueManager in interface MuleContext
Throws:
RegistrationException

getConfiguration

public MuleConfiguration getConfiguration()
Specified by:
getConfiguration in interface MuleContext
Returns:
the MuleConfiguration for this MuleManager. This object is immutable once the manager has initialised.

getNotificationManager

public ServerNotificationManager getNotificationManager()
Specified by:
getNotificationManager in interface MuleContext

setTransactionManager

public void setTransactionManager(TransactionManager manager)
                           throws RegistrationException
Sets the Jta Transaction Manager to use with this Mule server instance

Specified by:
setTransactionManager in interface MuleContext
Parameters:
manager - the manager to use
Throws:
Exception
RegistrationException

getTransactionManager

public TransactionManager getTransactionManager()
Returns the Jta transaction manager used by this Mule server instance. or null if a transaction manager has not been set

Specified by:
getTransactionManager in interface MuleContext
Returns:
the Jta transaction manager used by this Mule server instance. or null if a transaction manager has not been set

register

public void register()
              throws RegistrationException
Throws:
RegistrationException

deregister

public void deregister()
                throws RegistrationException
Throws:
RegistrationException

getRegistryId

public String getRegistryId()

checkLifecycleForPropertySet

protected void checkLifecycleForPropertySet(String propertyName,
                                            String phase)
                                     throws IllegalStateException
Throws:
IllegalStateException

getRegistry

public MuleRegistry getRegistry()
Specified by:
getRegistry in interface MuleContext

getDefaultMessageDispatcherThreadingProfile

public ThreadingProfile getDefaultMessageDispatcherThreadingProfile()
Specified by:
getDefaultMessageDispatcherThreadingProfile in interface MuleContext

getDefaultMessageRequesterThreadingProfile

public ThreadingProfile getDefaultMessageRequesterThreadingProfile()
Specified by:
getDefaultMessageRequesterThreadingProfile in interface MuleContext

getDefaultMessageReceiverThreadingProfile

public ThreadingProfile getDefaultMessageReceiverThreadingProfile()
Specified by:
getDefaultMessageReceiverThreadingProfile in interface MuleContext

getDefaultServiceThreadingProfile

public ThreadingProfile getDefaultServiceThreadingProfile()
Specified by:
getDefaultServiceThreadingProfile in interface MuleContext

getDefaultThreadingProfile

public ThreadingProfile getDefaultThreadingProfile()
Specified by:
getDefaultThreadingProfile in interface MuleContext

addRegistry

public void addRegistry(long id,
                        Registry registry)
Specified by:
addRegistry in interface MuleContext

removeRegistry

public void removeRegistry(long id)
Specified by:
removeRegistry in interface MuleContext

getStartDate

public long getStartDate()
Returns the long date when the server was started

Specified by:
getStartDate in interface MuleContext
Returns:
the long date when the server was started

getExpressionManager

public ExpressionManager getExpressionManager()
Returns the Expression Manager configured for this instance of Mule

Specified by:
getExpressionManager in interface MuleContext
Returns:
the Expression Manager configured for this instance of Mule
See Also:
ExpressionManager


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