1 /* 2 * $Id: MuleContext.java 20084 2010-11-05 13:19:17Z aperepel $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 package org.mule.api; 11 12 import org.mule.api.client.LocalMuleClient; 13 import org.mule.api.config.MuleConfiguration; 14 import org.mule.api.config.ThreadingProfile; 15 import org.mule.api.context.WorkManager; 16 import org.mule.api.context.notification.ServerNotification; 17 import org.mule.api.context.notification.ServerNotificationListener; 18 import org.mule.api.exception.SystemExceptionHandler; 19 import org.mule.api.expression.ExpressionManager; 20 import org.mule.api.lifecycle.InitialisationException; 21 import org.mule.api.lifecycle.Lifecycle; 22 import org.mule.api.lifecycle.LifecycleManager; 23 import org.mule.api.registry.MuleRegistry; 24 import org.mule.api.registry.RegistrationException; 25 import org.mule.api.registry.Registry; 26 import org.mule.api.security.SecurityManager; 27 import org.mule.context.notification.NotificationException; 28 import org.mule.context.notification.ServerNotificationManager; 29 import org.mule.management.stats.AllStatistics; 30 import org.mule.util.queue.QueueManager; 31 32 import javax.resource.spi.work.WorkListener; 33 import javax.transaction.TransactionManager; 34 35 public interface MuleContext extends Lifecycle 36 { 37 /** 38 * Sets the Jta Transaction Manager to use with this Mule server instance 39 * 40 * @param manager the manager to use 41 * @throws Exception 42 */ 43 void setTransactionManager(TransactionManager manager) throws Exception; 44 45 /** 46 * Returns the Jta transaction manager used by this Mule server instance. or 47 * null if a transaction manager has not been set 48 * 49 * @return the Jta transaction manager used by this Mule server instance. or 50 * null if a transaction manager has not been set 51 */ 52 TransactionManager getTransactionManager(); 53 54 ServerNotificationManager getNotificationManager(); 55 56 /** 57 * Determines if the server has been started 58 * 59 * @return true if the server has been started 60 */ 61 boolean isStarted(); 62 63 /** 64 * Determines if the server has been initialised 65 * 66 * @return true if the server has been initialised 67 */ 68 boolean isInitialised(); 69 70 /** 71 * Determines if the server is being initialised 72 * 73 * @return true if the server is beening initialised 74 */ 75 boolean isInitialising(); 76 77 boolean isDisposed(); 78 79 boolean isDisposing(); 80 81 /** 82 * Registers an intenal server event listener. The listener will be notified 83 * when a particular event happens within the server. Typically this is not 84 * an event in the same sense as an MuleEvent (although there is nothing 85 * stopping the implementation of this class triggering listeners when a 86 * MuleEvent is received). 87 * <p/> 88 * The types of notifications fired is entirely defined by the implementation of 89 * this class 90 * 91 * @param l the listener to register 92 */ 93 void registerListener(ServerNotificationListener l) throws NotificationException; 94 95 /** 96 * Registers an intenal server event listener. The listener will be notified 97 * when a particular event happens within the server. Typically this is not 98 * an event in the same sense as an MuleEvent (although there is nothing 99 * stopping the implementation of this class triggering listeners when a 100 * MuleEvent is received). 101 * <p/> 102 * The types of notifications fired is entirely defined by the implementation of 103 * this class 104 * 105 * @param l the listener to register 106 * @param resourceIdentifier a particular resource name for the given type 107 * of listener For example, the resourceName could be the name of 108 * a service if the listener was a ServiceNotificationListener 109 */ 110 void registerListener(ServerNotificationListener l, String resourceIdentifier) throws NotificationException; 111 112 /** 113 * Unregisters a previously registered listener. If the listener has not 114 * already been registered, this method should return without exception 115 * 116 * @param l the listener to unregister 117 */ 118 void unregisterListener(ServerNotificationListener l); 119 120 /** 121 * Fires a server notification to all regiistered listeners 122 * 123 * @param notification the notification to fire 124 */ 125 void fireNotification(ServerNotification notification); 126 127 /** 128 * Sets the security manager used by this Mule instance to authenticate and 129 * authorise incoming and outgoing event traffic and service invocations 130 * 131 * @param securityManager the security manager used by this Mule instance to 132 * authenticate and authorise incoming and outgoing event traffic 133 * and service invocations 134 * @throws RegistrationException 135 */ 136 void setSecurityManager(SecurityManager securityManager) throws InitialisationException, RegistrationException; 137 138 /** 139 * Gets the security manager used by this Mule instance to authenticate and 140 * authorise incoming and outgoing event traffic and service invocations 141 * 142 * @return he security manager used by this Mule instance to authenticate 143 * and authorise incoming and outgoing event traffic and service 144 * invocations 145 */ 146 SecurityManager getSecurityManager(); 147 148 /** 149 * Obtains a workManager instance that can be used to schedule work in a 150 * thread pool. This will be used primarially by Agents wanting to 151 * schedule work. This work Manager must <b>never</b> be used by provider 152 * implementations as they have their own workManager accible on the 153 * connector. 154 * 155 * @return a workManager instance used by the current MuleManager 156 */ 157 WorkManager getWorkManager(); 158 159 WorkListener getWorkListener(); 160 161 /** 162 * Sets the queue manager used by mule for queuing events. This is used for 163 * service queues 164 * 165 * @param queueManager 166 * @throws RegistrationException 167 * 168 */ 169 void setQueueManager(QueueManager queueManager) throws RegistrationException; 170 171 /** 172 * Gets the queue manager used by mule for queuing events. This is used for 173 * service queues. 174 */ 175 QueueManager getQueueManager(); 176 177 AllStatistics getStatistics(); 178 179 LifecycleManager getLifecycleManager(); 180 181 MuleRegistry getRegistry(); 182 183 MuleConfiguration getConfiguration(); 184 185 ThreadingProfile getDefaultMessageDispatcherThreadingProfile(); 186 187 ThreadingProfile getDefaultMessageRequesterThreadingProfile(); 188 189 ThreadingProfile getDefaultMessageReceiverThreadingProfile(); 190 191 ThreadingProfile getDefaultServiceThreadingProfile(); 192 193 ThreadingProfile getDefaultThreadingProfile(); 194 195 // TODO This should ideally only be available via an Admin interface 196 void addRegistry(Registry registry); 197 198 // TODO This should ideally only be available via an Admin interface 199 void removeRegistry(Registry registry); 200 201 /** 202 * Returns the date when the server was started. 203 * @return the date when the server was started. 204 */ 205 long getStartDate(); 206 207 /** 208 * Returns the Expression Manager configured for this instance of Mule 209 * @return the Expression Manager configured for this instance of Mule 210 * @see org.mule.api.expression.ExpressionManager 211 */ 212 ExpressionManager getExpressionManager(); 213 214 void setExecutionClassLoader(ClassLoader cl); 215 216 ClassLoader getExecutionClassLoader(); 217 218 boolean isStopped(); 219 220 boolean isStopping(); 221 222 boolean isStarting(); 223 224 LocalMuleClient getClient(); 225 226 SystemExceptionHandler getExceptionListener(); 227 228 void setExceptionListener(SystemExceptionHandler exceptionListener); 229 }