01: /*
02: * $Id: Component.java 11414 2008-03-18 03:16:19Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.api.component;
12:
13: import org.mule.api.MuleEvent;
14: import org.mule.api.MuleException;
15: import org.mule.api.MuleMessage;
16: import org.mule.api.lifecycle.Lifecycle;
17: import org.mule.api.routing.InboundRouterCollection;
18: import org.mule.api.service.Service;
19: import org.mule.management.stats.ComponentStatistics;
20:
21: /**
22: * A <code>Component</code> is a invoked by a {@link Service} for each incoming
23: * {@link MuleEvent} routed on by the {@link InboundRouterCollection}. A component
24: * processes a {@link MuleEvent} by invoking the component instance that has been
25: * configured, optionally returning a result. <p/> Implementations of
26: * <code>Component</code> can use different types of component implementation,
27: * implement component instance pooling or implement <em>bindings</em> which allow
28: * for service composition.
29: */
30: public interface Component extends Lifecycle {
31:
32: /**
33: * Invokes the component
34: *
35: * @param event the event used to invoke the component
36: * @return the return event from the component
37: * @throws MuleException if the call fails
38: */
39: MuleMessage onCall(MuleEvent event) throws MuleException;
40:
41: /**
42: * Component statistics are used to gather component statistics such as
43: * sync/async invocation counts and total and average execution time.
44: *
45: * @return
46: */
47: ComponentStatistics getStatistics();
48:
49: /**
50: * @param service
51: */
52: void setService(Service service);
53:
54: /**
55: * @return
56: */
57: Service getService();
58:
59: }
|