View Javadoc

1   /*
2    * $Id: UMOComponent.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;
12  
13  import org.mule.umo.lifecycle.Initialisable;
14  import org.mule.umo.lifecycle.Lifecycle;
15  
16  import java.io.Serializable;
17  
18  /**
19   * <code>UMOComponent</code> is the interal repesentation of a Mule Managed
20   * component. It is responsible for managing the interaction of events to and from
21   * the component as well as managing pooled resources.
22   */
23  
24  public interface UMOComponent extends Serializable, Lifecycle, Initialisable
25  {
26      /**
27       * @return the UMODescriptor associated with the component
28       * @see UMODescriptor
29       */
30      UMODescriptor getDescriptor();
31  
32      /**
33       * Makes an asynhronous event call to the component.
34       * 
35       * @param event the event to consume
36       * @throws UMOException if the event fails to be processed
37       */
38      void dispatchEvent(UMOEvent event) throws UMOException;
39  
40      /**
41       * Makes a synhronous event call to the component. This event will be consumed by
42       * the component and a result returned.
43       * 
44       * @param event the event to consume
45       * @return a UMOMessage containing the resulting message and properties
46       * @throws UMOException if the event fails to be processed
47       */
48      UMOMessage sendEvent(UMOEvent event) throws UMOException;
49  
50      /**
51       * Determines whether this component has been started
52       * 
53       * @return true is the component is started andready to receive events
54       */
55      boolean isStarted();
56  
57      /**
58       * Gets the underlying instance for this component. When the component
59       * implementation provides pooling there is no 1:1 mapping between UMOComponent
60       * and instance, so this method would return an object in initial state. If the
61       * underlying component is managed in Spring or another IoC container, then the
62       * object instance from the corresponding container will be returned.
63       * 
64       * @return the underlying instance for this component
65       */
66      Object getInstance() throws UMOException;
67  
68      /**
69       * Pauses event processing for a single Mule Component. Unlike stop(), a paused
70       * component will still consume messages from the underlying transport, but those
71       * messages will be queued until the component is resumed.
72       */
73      void pause() throws UMOException;
74  
75      /**
76       * Resumes a single Mule Component that has been paused. If the component is not
77       * paused nothing is executed.
78       */
79      void resume() throws UMOException;
80  
81      /**
82       * True if the component is in a paused state, false otherwise
83       * 
84       * @return True if the component is in a paused state, false otherwise
85       */
86      boolean isPaused();
87  }