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