1 /* 2 * $Id: Component.java 11414 2008-03-18 03:16:19Z 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 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 /** 34 * Invokes the component 35 * 36 * @param event the event used to invoke the component 37 * @return the return event from the component 38 * @throws MuleException if the call fails 39 */ 40 MuleMessage onCall(MuleEvent event) throws MuleException; 41 42 /** 43 * Component statistics are used to gather component statistics such as 44 * sync/async invocation counts and total and average execution time. 45 * 46 * @return 47 */ 48 ComponentStatistics getStatistics(); 49 50 /** 51 * @param service 52 */ 53 void setService(Service service); 54 55 /** 56 * @return 57 */ 58 Service getService(); 59 60 }