1 /* 2 * $Id: UMOModel.java 7963 2007-08-21 08:53:15Z dirk.olmes $ 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 11 package org.mule.umo.model; 12 13 import org.mule.umo.UMOComponent; 14 import org.mule.umo.UMODescriptor; 15 import org.mule.umo.UMOException; 16 import org.mule.umo.UMOSession; 17 import org.mule.umo.lifecycle.Initialisable; 18 import org.mule.umo.lifecycle.Lifecycle; 19 import org.mule.umo.lifecycle.UMOLifecycleAdapterFactory; 20 21 import java.beans.ExceptionListener; 22 import java.util.Iterator; 23 import java.util.List; 24 25 /** 26 * The <code>UMOModel</code> encapsulates and manages the runtime behaviour of a 27 * Mule Server instance. It is responsible for maintaining the UMOs instances and 28 * their configuration. 29 */ 30 public interface UMOModel extends Lifecycle, Initialisable 31 { 32 33 /** 34 * Sets the model's name. It is poosible to configure more than one model in a 35 * config file. The name can then be used to reference the Model use when 36 * starting the server 37 * 38 * @param name the model's name 39 */ 40 void setName(String name); 41 42 /** 43 * The model's name. It is poosible to configure more than one model in a config 44 * file. The name can then be used to reference the Model use when starting the 45 * server 46 * 47 * @return the model's name 48 */ 49 String getName(); 50 51 /** 52 * Returns the model type name. This is a friendly identifier that is used to 53 * look up the SPI class for the model 54 * 55 * @return the model type 56 */ 57 String getType(); 58 59 /** 60 * The entry point resolver is used to determine the method to be called on a 61 * component when an event is received for it. 62 * 63 * @return Returns the entryPointResolver. 64 */ 65 UMOEntryPointResolver getEntryPointResolver(); 66 67 /** 68 * This will be used to build entry points on the components registered with the 69 * model. 70 * 71 * @param entryPointResolver The entryPointResolver to set. This will be used to 72 * build entry points on the components registered with the model. 73 */ 74 void setEntryPointResolver(UMOEntryPointResolver entryPointResolver); 75 76 /** 77 * Registers a <code>UMODescriptor</code> with the <code>MuleManager</code>. 78 * The manager will take care of creating the Mule UMO and, it's component and 79 * proxies. 80 * 81 * @param descriptor the <code>UMODescriptor</code> to register 82 */ 83 UMOComponent registerComponent(UMODescriptor descriptor) throws UMOException; 84 85 /** 86 * Unregisters a component From the model 87 * 88 * @param descriptor the descriptor of the componnt to remove 89 * @throws UMOException if the component is not registered or it failed to be 90 * disposing or the descriptor is null 91 */ 92 void unregisterComponent(UMODescriptor descriptor) throws UMOException; 93 94 /** 95 * Determines if a UMO component descriptor by the given name is regestered with 96 * the model 97 * 98 * @param name the name of the UMO 99 * @return true if the UMO's descriptor has benn registered with the model 100 * @see UMODescriptor 101 */ 102 boolean isComponentRegistered(String name); 103 104 /** 105 * The lifecycle adapter is used by the model to translate Mule lifecycle event 106 * to events that UMO components registered with the model understand. The 107 * <code>UMOLifecycleAdapterFactory</code> is used by the model to instanciate 108 * LifecycleAdapters. 109 * 110 * @return Returns the lifecycleAdapterFactory used by this Model. 111 * @see UMOLifecycleAdapterFactory 112 * @see org.mule.umo.lifecycle.UMOLifecycleAdapter 113 */ 114 UMOLifecycleAdapterFactory getLifecycleAdapterFactory(); 115 116 /** 117 * Sets the lifecycleAdapterFactory on the model. 118 * 119 * @param lifecycleAdapterFactory The lifecycleAdapterFactory to set on this 120 * model. 121 * @see UMOLifecycleAdapterFactory 122 * @see org.mule.umo.lifecycle.UMOLifecycleAdapter 123 */ 124 void setLifecycleAdapterFactory(UMOLifecycleAdapterFactory lifecycleAdapterFactory); 125 126 /** 127 * Returns the Component for the given Mule name. 128 * 129 * @param muleName the Name of the Mule Component to obtain a session for 130 * @return a UMOSession for the given name or null if the component is not 131 * registered 132 */ 133 UMOSession getComponentSession(String muleName); 134 135 /** 136 * A convenience method to set a list of components on the model. This method 137 * will most likely be used when the model is being constructed from an IoC 138 * container 139 * 140 * @param descriptors 141 * @throws UMOException 142 */ 143 void setComponents(List descriptors) throws UMOException; 144 145 /** 146 * The exception strategy to use by components managed by the model. The 147 * exception strategy is used when an exception occurs while processing the 148 * current event for a component. A component can define it's own exception 149 * strategy, but if it doesn't this implmentation will be used. 150 * 151 * @return the default exception strategy for this model. 152 * @see ExceptionListener 153 */ 154 ExceptionListener getExceptionListener(); 155 156 /** 157 * The exception strategy to use by components managed by the model. The 158 * exception strategy is used when an exception occurs while processing the 159 * current event for a component. A component can define it's own exception 160 * strategy, but if it doesn't this implmentation will be used. 161 * 162 * @param listener the default exception strategy for this model. 163 * @see ExceptionListener 164 */ 165 void setExceptionListener(ExceptionListener listener); 166 167 /** 168 * Returns a descriptor for the given component name 169 * 170 * @param name the name of the component 171 * @return a descriptor for the given component name or null if there is no 172 * component registered by that name 173 * @see UMODescriptor 174 */ 175 UMODescriptor getDescriptor(String name); 176 177 /** 178 * Returns the UMOComponent object for the given component name 179 * 180 * @param name the name of the component 181 * @return the UMOComponent object for the given component name or null if there 182 * is no component registered by that name 183 * @see UMOComponent 184 */ 185 UMOComponent getComponent(String name); 186 187 /** 188 * Stops a single Mule Component. This can be useful when stopping and starting 189 * some Mule UMOs while letting others continue. When a component is stopped all 190 * listeners for that component are unregistered. 191 * 192 * @param name the name of the Mule UMO to stop 193 * @throws UMOException if the MuleUMO is not registered or the component failed 194 * to stop 195 */ 196 void stopComponent(String name) throws UMOException; 197 198 /** 199 * Starts a single Mule Component. This can be useful when stopping and starting 200 * some Mule UMOs while letting others continue. 201 * 202 * @param name the name of the Mule UMO to start 203 * @throws UMOException if the MuleUMO is not registered or the component failed 204 * to start 205 */ 206 void startComponent(String name) throws UMOException; 207 208 /** 209 * Pauses event processing for a single Mule Component. Unlike stopComponent(), a 210 * paused component will still consume messages from the underlying transport, 211 * but those messages will be queued until the component is resumed. In order to 212 * persist these queued messages you can set the 'recoverableMode' property on 213 * the Muleconfiguration to true. this causes all internal queues to store their 214 * state. 215 * 216 * @param name the name of the Mule UMO to stop 217 * @throws UMOException if the MuleUMO is not registered or the component failed 218 * to pause. 219 * @see org.mule.config.MuleConfiguration 220 */ 221 void pauseComponent(String name) throws UMOException; 222 223 /** 224 * Resumes a single Mule Component that has been paused. If the component is not 225 * paused nothing is executed. 226 * 227 * @param name the name of the Mule UMO to resume 228 * @throws UMOException if the MuleUMO is not registered or the component failed 229 * to resume 230 */ 231 void resumeComponent(String name) throws UMOException; 232 233 /** 234 * Gets an iterator of all component names registered in the model 235 * 236 * @return an iterator of all component names 237 */ 238 Iterator getComponentNames(); 239 }