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  SystemExceptionHandler exceptionListener
          Global exception handler which handles "system" exceptions (i.e., when no message is involved).
protected  MuleContextLifecycleManager lifecycleManager
          LifecycleManager for the MuleContext.
protected  LocalMuleClient localMuleClient
           
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, MuleContextLifecycleManager lifecycleManager, ServerNotificationManager notificationManager)
           
 
Method Summary
 void addRegistry(Registry registry)
           
protected  SplashScreen buildShutdownSplash()
           
protected  SplashScreen buildStartupSplash()
           
protected  void checkLifecycleForPropertySet(String propertyName, String phase)
           
protected  DefaultRegistryBroker createRegistryBroker()
           
protected  MuleRegistry createRegistryHelper(DefaultRegistryBroker registry)
           
 void dispose()
          A lifecycle method where implementor should free up any resources.
 void fireNotification(ServerNotification notification)
          Fires a server notification to all registered CustomNotificationListener notificationManager.
 LocalMuleClient getClient()
           
 String getClusterId()
           
 int getClusterNodeId()
           
 MuleConfiguration getConfiguration()
           
 Map<QName,Set<Object>> getConfigurationAnnotations()
          Return all annotations seen in the configuration
 DataTypeConversionResolver getDataTypeConverterResolver()
           
 MessagingExceptionHandler getDefaultExceptionStrategy()
           
 ThreadingProfile getDefaultMessageDispatcherThreadingProfile()
           
 ThreadingProfile getDefaultMessageReceiverThreadingProfile()
           
 ThreadingProfile getDefaultMessageRequesterThreadingProfile()
           
 ThreadingProfile getDefaultServiceThreadingProfile()
           
 ThreadingProfile getDefaultThreadingProfile()
           
 EndpointFactory getEndpointFactory()
          Returns the EndpointFactory configured for this instance of Mule
 SystemExceptionHandler getExceptionListener()
           
 ClassLoader getExecutionClassLoader()
           
 ExpressionLanguage getExpressionLanguage()
          Expression Language for evaluating expressions using Mule as the context
 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()
           
 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 statistics for this instance
 SingleResourceTransactionFactoryManager getTransactionFactoryManager()
           
 TransactionManager getTransactionManager()
          Returns the Jta transaction manager used by this Mule server instance.
 String getUniqueIdString()
          Generate a unique ID string; this will begin with the cluster node ID followed by a dash, e.g.
 javax.resource.spi.work.WorkListener getWorkListener()
           
 WorkManager getWorkManager()
          Obtains a workManager instance that can be used to schedule work in a thread pool.
 void handleException(Exception e)
           
 void handleException(Exception e, RollbackSourceCallback rollbackMethod)
           
 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 isPrimaryPollingInstance()
           
 boolean isStarted()
          Determines if the server has been started
 boolean isStarting()
           
 boolean isStopped()
           
 boolean isStopping()
           
 void registerListener(ServerNotificationListener l)
          Registers an intenal server event listener.
 void registerListener(ServerNotificationListener l, String resourceIdentifier)
          Registers an intenal server event listener.
 void removeRegistry(Registry registry)
           
 void setClusterId(String clusterId)
           
 void setClusterNodeId(int clusterNodeId)
           
 void setExceptionListener(SystemExceptionHandler exceptionListener)
           
 void setExecutionClassLoader(ClassLoader cl)
           
 void setObjectStore(String name, ListableObjectStore<Serializable> store)
           
 void setPollingController(PollingController pollingController)
           
 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 MuleContext 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 MuleContextLifecycleManager lifecycleManager
LifecycleManager for the MuleContext. Note: this is NOT the same lifecycle manager as the one in the Registry.


notificationManager

protected ServerNotificationManager notificationManager

localMuleClient

protected LocalMuleClient localMuleClient

exceptionListener

protected SystemExceptionHandler exceptionListener
Global exception handler which handles "system" exceptions (i.e., when no message is involved).

Constructor Detail

DefaultMuleContext

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

createRegistryBroker

protected DefaultRegistryBroker createRegistryBroker()

createRegistryHelper

protected MuleRegistry createRegistryHelper(DefaultRegistryBroker 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 MuleContext 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

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

isStopping

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

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

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

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 statistics for this instance

Specified by:
getStatistics in interface MuleContext
Returns:
all statistics 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 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

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:
RegistrationException - if a transaction manager has already been set

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

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

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

setExecutionClassLoader

public void setExecutionClassLoader(ClassLoader cl)
Specified by:
setExecutionClassLoader in interface MuleContext

getExecutionClassLoader

public ClassLoader getExecutionClassLoader()
Specified by:
getExecutionClassLoader in interface MuleContext

addRegistry

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

removeRegistry

public void removeRegistry(Registry registry)
Specified by:
removeRegistry in interface MuleContext

buildStartupSplash

protected SplashScreen buildStartupSplash()

buildShutdownSplash

protected SplashScreen buildShutdownSplash()

getClient

public LocalMuleClient getClient()
Specified by:
getClient in interface MuleContext

handleException

public void handleException(Exception e,
                            RollbackSourceCallback rollbackMethod)
Specified by:
handleException in interface MuleContext

handleException

public void handleException(Exception e)
Specified by:
handleException in interface MuleContext

getExceptionListener

public SystemExceptionHandler getExceptionListener()
Specified by:
getExceptionListener in interface MuleContext

setExceptionListener

public void setExceptionListener(SystemExceptionHandler exceptionListener)
Specified by:
setExceptionListener in interface MuleContext

getEndpointFactory

public EndpointFactory getEndpointFactory()
Description copied from interface: MuleContext
Returns the EndpointFactory configured for this instance of Mule

Specified by:
getEndpointFactory in interface MuleContext
Returns:
the EndpointFactory configured for this instance of Mule
See Also:
EndpointFactory

setObjectStore

public void setObjectStore(String name,
                           ListableObjectStore<Serializable> store)
                    throws RegistrationException
Specified by:
setObjectStore in interface MuleContext
Throws:
RegistrationException

getClusterId

public String getClusterId()
Specified by:
getClusterId in interface MuleContext
Returns:
the ID of the cluster the current instance belongs to. Returns the empty string if this instance isn't part of a cluster.

setClusterId

public void setClusterId(String clusterId)

getClusterNodeId

public int getClusterNodeId()
Specified by:
getClusterNodeId in interface MuleContext
Returns:
the cluster node ID for the current instance belongs to. Returns 0 if this instance isn't part of a cluster.

setClusterNodeId

public void setClusterNodeId(int clusterNodeId)

setPollingController

public void setPollingController(PollingController pollingController)

isPrimaryPollingInstance

public boolean isPrimaryPollingInstance()
Specified by:
isPrimaryPollingInstance in interface MuleContext
Returns:
true if this instance in the designated poller. This will always be true unless the instance is part of a cluster.

getUniqueIdString

public String getUniqueIdString()
Description copied from interface: MuleContext
Generate a unique ID string; this will begin with the cluster node ID followed by a dash, e.g. "3-XXXYYY"

Specified by:
getUniqueIdString in interface MuleContext

getConfigurationAnnotations

public Map<QName,Set<Object>> getConfigurationAnnotations()
Description copied from interface: MuleContext
Return all annotations seen in the configuration

Specified by:
getConfigurationAnnotations in interface MuleContext

getDefaultExceptionStrategy

public MessagingExceptionHandler getDefaultExceptionStrategy()
Specified by:
getDefaultExceptionStrategy in interface MuleContext
Returns:
default exception strategy. If no default exception strategy was configured it returns DefaultMessagingExceptionStrategy

getTransactionFactoryManager

public SingleResourceTransactionFactoryManager getTransactionFactoryManager()
Specified by:
getTransactionFactoryManager in interface MuleContext
Returns:
single resource transaction factory manager. Used to retrieve a transaction factory for each transactional resource (i.e jdbc DataSource, jms Connection)

getDataTypeConverterResolver

public DataTypeConversionResolver getDataTypeConverterResolver()
Specified by:
getDataTypeConverterResolver in interface MuleContext
Returns:
a non null DataTypeConversionResolver instance to resolve implicit data type conversions

getExpressionLanguage

public ExpressionLanguage getExpressionLanguage()
Description copied from interface: MuleContext
Expression Language for evaluating expressions using Mule as the context

Specified by:
getExpressionLanguage in interface MuleContext
Returns:


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.