View Javadoc

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