1 /* 2 * $Id: Service.java 22048 2011-05-31 14:39:03Z dfeist $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.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.service; 12 13 import org.mule.api.MuleContext; 14 import org.mule.api.MuleEvent; 15 import org.mule.api.MuleException; 16 import org.mule.api.NameableObject; 17 import org.mule.api.component.Component; 18 import org.mule.api.construct.FlowConstruct; 19 import org.mule.api.exception.MessagingExceptionHandler; 20 import org.mule.api.lifecycle.Lifecycle; 21 import org.mule.api.lifecycle.LifecycleManager; 22 import org.mule.api.model.Model; 23 import org.mule.api.processor.MessageProcessor; 24 import org.mule.api.routing.OutboundRouterCollection; 25 import org.mule.api.source.MessageSource; 26 import org.mule.management.stats.ServiceStatistics; 27 import org.mule.service.ServiceAsyncReplyCompositeMessageSource; 28 29 import java.io.Serializable; 30 31 /** 32 * <code>Service</code> is the internal representation of a Mule Managed service. It 33 * is responsible for managing the interaction of events to and from the service as 34 * well as managing pooled resources. 35 */ 36 public interface Service extends Serializable, FlowConstruct, Lifecycle, NameableObject 37 { 38 /** 39 * Makes an asynchronous event call to the service. 40 * 41 * @param event the event to consume 42 * @throws MuleException if the event fails to be processed 43 * @deprecated 44 */ 45 @Deprecated 46 void dispatchEvent(MuleEvent event) throws MuleException; 47 48 /** 49 * Makes a synchronous event call to the service. This event will be consumed by 50 * the service and a result returned. 51 * 52 * @param event the event to consume 53 * @return a MuleMessage containing the resulting message and properties 54 * @throws MuleException if the event fails to be processed 55 * @deprecated 56 */ 57 @Deprecated 58 MuleEvent sendEvent(MuleEvent event) throws MuleException; 59 60 /** 61 * Determines whether this service has been started 62 * 63 * @return true is the service is started and ready to receive events 64 */ 65 boolean isStarted(); 66 67 boolean isStopped(); 68 69 /** 70 * Pauses event processing for a single Mule Service. Unlike <code>stop()</code>, a paused 71 * service will still consume messages from the underlying transport, but those 72 * messages will be queued until the service is resumed. 73 */ 74 void pause() throws MuleException; 75 76 /** 77 * Resumes a single Mule Service that has been paused. If the service is not 78 * paused nothing is executed. 79 */ 80 void resume() throws MuleException; 81 82 /** 83 * @return true if the service is in a paused state, false otherwise 84 */ 85 boolean isPaused(); 86 87 MessageSource getMessageSource(); 88 89 /** 90 * Outbound Routers control how events are published by a service once. the 91 * event has been processed. If no router is set. A default will be used that 92 * uses the outboundProvider set on his descriptor to route the event. 93 * 94 * @return the outbound router for this service 95 * @see OutboundRouterCollection 96 */ 97 MessageProcessor getOutboundMessageProcessor(); 98 99 /** 100 * Returns the initial state of this service 101 * 102 * @return the initial state of this service 103 */ 104 String getInitialState(); 105 106 /** 107 * Returns the name of the model that this descriptor is registered with. 108 * @return the name of the model that this descriptor is registered with or null 109 * if this descriptor has not been registered with a model yet 110 */ 111 Model getModel(); 112 113 void setMessageSource(MessageSource messageSource); 114 115 /** 116 * Outbound message processor controls how events are published by a service once the 117 * event has been processed. If no router is set a default will be used that 118 * uses the outboundProvider set on his descriptor to route the event. 119 */ 120 void setOutboundMessageProcessor(MessageProcessor processor); 121 122 /** 123 * Sets the initial state of this service 124 * 125 * @param state the initial state of this service 126 */ 127 void setInitialState(String state); 128 129 void setModel(Model model); 130 131 /** 132 * Returns the Component that is a invoked by a {@link Service} for each incoming 133 * {@link MuleEvent} routed on by the inbound routers. 134 */ 135 Component getComponent(); 136 137 /** 138 * Sets the Component that is a invoked by a {@link Service} for each incoming 139 * {@link MuleEvent} routed on by the inbound routers. 140 */ 141 void setComponent(Component component); 142 143 /** 144 * Returns the Service statistics. This provides Service router and component statistics. 145 */ 146 ServiceStatistics getStatistics(); 147 148 MuleContext getMuleContext(); 149 150 LifecycleManager getLifecycleManager(); 151 152 void setAsyncReplyMessageSource(ServiceAsyncReplyCompositeMessageSource asyncReplyMessageSource); 153 154 ServiceAsyncReplyCompositeMessageSource getAsyncReplyMessageSource(); 155 156 MessagingExceptionHandler getExceptionListener(); 157 158 void setExceptionListener(MessagingExceptionHandler exceptionListener); 159 }