001: /*
002: * $Id: LocalDispatcher.java,v 1.5 2004/02/19 18:52:35 ajzeneski Exp $
003: *
004: * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
005: *
006: * Permission is hereby granted, free of charge, to any person obtaining a
007: * copy of this software and associated documentation files (the "Software"),
008: * to deal in the Software without restriction, including without limitation
009: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010: * and/or sell copies of the Software, and to permit persons to whom the
011: * Software is furnished to do so, subject to the following conditions:
012: *
013: * The above copyright notice and this permission notice shall be included
014: * in all copies or substantial portions of the Software.
015: *
016: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023: *
024: */
025: package org.ofbiz.service;
026:
027: import java.util.Map;
028:
029: import org.ofbiz.entity.GenericDelegator;
030: import org.ofbiz.security.Security;
031: import org.ofbiz.service.jms.JmsListenerFactory;
032: import org.ofbiz.service.job.JobManager;
033:
034: /**
035: * Generic Services Local Dispatcher
036: *
037: * @author <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a>
038: * @version $Revision: 1.5 $
039: * @since 2.0
040: */
041: public interface LocalDispatcher {
042:
043: /**
044: * Run the service synchronously and return the result.
045: * @param serviceName Name of the service to run.
046: * @param context Map of name, value pairs composing the context.
047: * @return Map of name, value pairs composing the result.
048: * @throws ServiceAuthException
049: * @throws ServiceValidationException
050: * @throws GenericServiceException
051: */
052: public Map runSync(String serviceName, Map context)
053: throws GenericServiceException;
054:
055: /**
056: * Run the service synchronously with a specified timeout and return the result.
057: * @param serviceName Name of the service to run.
058: * @param context Map of name, value pairs composing the context.
059: * @param transactionTimeout the overriding timeout for the transaction (if we started it).
060: * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
061: * @return Map of name, value pairs composing the result.
062: * @throws ServiceAuthException
063: * @throws ServiceValidationException
064: * @throws GenericServiceException
065: */
066: public Map runSync(String serviceName, Map context,
067: int transactionTimeout, boolean requireNewTransaction)
068: throws ServiceAuthException, ServiceValidationException,
069: GenericServiceException;
070:
071: /**
072: * Run the service synchronously and IGNORE the result.
073: * @param serviceName Name of the service to run.
074: * @param context Map of name, value pairs composing the context.
075: * @throws ServiceAuthException
076: * @throws ServiceValidationException
077: * @throws GenericServiceException
078: */
079: public void runSyncIgnore(String serviceName, Map context)
080: throws GenericServiceException;
081:
082: /**
083: * Run the service synchronously with a specified timeout and IGNORE the result.
084: * @param serviceName Name of the service to run.
085: * @param context Map of name, value pairs composing the context.
086: * @param transactionTimeout the overriding timeout for the transaction (if we started it).
087: * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
088: * @throws ServiceAuthException
089: * @throws ServiceValidationException
090: * @throws GenericServiceException
091: */
092: public void runSyncIgnore(String serviceName, Map context,
093: int transactionTimeout, boolean requireNewTransaction)
094: throws ServiceAuthException, ServiceValidationException,
095: GenericServiceException;
096:
097: /**
098: * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
099: * @param serviceName Name of the service to run.
100: * @param context Map of name, value pairs composing the context.
101: * @param requester Object implementing GenericRequester interface which will receive the result.
102: * @param persist True for store/run; False for run.
103: * @param transactionTimeout the overriding timeout for the transaction (if we started it).
104: * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
105: * @throws ServiceAuthException
106: * @throws ServiceValidationException
107: * @throws GenericServiceException
108: */
109: public void runAsync(String serviceName, Map context,
110: GenericRequester requester, boolean persist,
111: int transactionTimeout, boolean requireNewTransaction)
112: throws ServiceAuthException, ServiceValidationException,
113: GenericServiceException;
114:
115: /**
116: * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
117: * @param serviceName Name of the service to run.
118: * @param context Map of name, value pairs composing the context.
119: * @param requester Object implementing GenericRequester interface which will receive the result.
120: * @param persist True for store/run; False for run.
121: * @throws ServiceAuthException
122: * @throws ServiceValidationException
123: * @throws GenericServiceException
124: */
125: public void runAsync(String serviceName, Map context,
126: GenericRequester requester, boolean persist)
127: throws ServiceAuthException, ServiceValidationException,
128: GenericServiceException;
129:
130: /**
131: * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
132: * This method WILL persist the job.
133: * @param serviceName Name of the service to run.
134: * @param context Map of name, value pairs composing the context.
135: * @param requester Object implementing GenericRequester interface which will receive the result.
136: * @throws ServiceAuthException
137: * @throws ServiceValidationException
138: * @throws GenericServiceException
139: */
140: public void runAsync(String serviceName, Map context,
141: GenericRequester requester) throws ServiceAuthException,
142: ServiceValidationException, GenericServiceException;
143:
144: /**
145: * Run the service asynchronously and IGNORE the result.
146: * @param serviceName Name of the service to run.
147: * @param context Map of name, value pairs composing the context.
148: * @param persist True for store/run; False for run.
149: * @throws ServiceAuthException
150: * @throws ServiceValidationException
151: * @throws GenericServiceException
152: */
153: public void runAsync(String serviceName, Map context,
154: boolean persist) throws ServiceAuthException,
155: ServiceValidationException, GenericServiceException;
156:
157: /**
158: * Run the service asynchronously and IGNORE the result. This method WILL persist the job.
159: * @param serviceName Name of the service to run.
160: * @param context Map of name, value pairs composing the context.
161: * @throws ServiceAuthException
162: * @throws ServiceValidationException
163: * @throws GenericServiceException
164: */
165: public void runAsync(String serviceName, Map context)
166: throws ServiceAuthException, ServiceValidationException,
167: GenericServiceException;
168:
169: /**
170: * Run the service asynchronously.
171: * @param serviceName Name of the service to run.
172: * @param context Map of name, value pairs composing the context.
173: * @param persist True for store/run; False for run.
174: * @return A new GenericRequester object.
175: * @throws ServiceAuthException
176: * @throws ServiceValidationException
177: * @throws GenericServiceException
178: */
179: public GenericResultWaiter runAsyncWait(String serviceName,
180: Map context, boolean persist) throws ServiceAuthException,
181: ServiceValidationException, GenericServiceException;
182:
183: /**
184: * Run the service asynchronously. This method WILL persist the job.
185: * @param serviceName Name of the service to run.
186: * @param context Map of name, value pairs composing the context.
187: * @return A new GenericRequester object.
188: * @throws ServiceAuthException
189: * @throws ServiceValidationException
190: * @throws GenericServiceException
191: */
192: public GenericResultWaiter runAsyncWait(String serviceName,
193: Map context) throws ServiceAuthException,
194: ServiceValidationException, GenericServiceException;
195:
196: /**
197: * Schedule a service to run asynchronously at a specific start time.
198: * @param poolName Name of the service pool to send to.
199: * @param serviceName Name of the service to invoke.
200: * @param context The name/value pairs composing the context.
201: * @param startTime The time to run this service.
202: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
203: * @param interval The interval of the frequency recurrence.
204: * @param count The number of times to repeat.
205: * @param endTime The time in milliseconds the service should expire
206: * @throws ServiceAuthException
207: * @throws ServiceValidationException
208: * @throws GenericServiceException
209: */
210: public void schedule(String poolName, String serviceName,
211: Map context, long startTime, int frequency, int interval,
212: int count, long endTime) throws GenericServiceException;
213:
214: /**
215: * Schedule a service to run asynchronously at a specific start time.
216: * @param serviceName Name of the service to invoke.
217: * @param context The name/value pairs composing the context.
218: * @param startTime The time to run this service.
219: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
220: * @param interval The interval of the frequency recurrence.
221: * @param count The number of times to repeat.
222: * @param endTime The time in milliseconds the service should expire
223: * @throws GenericServiceException
224: */
225: public void schedule(String serviceName, Map context,
226: long startTime, int frequency, int interval, int count,
227: long endTime) throws GenericServiceException;
228:
229: /**
230: * Schedule a service to run asynchronously at a specific start time.
231: * @param serviceName Name of the service to invoke.
232: * @param context The name/value pairs composing the context.
233: * @param startTime The time to run this service.
234: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
235: * @param interval The interval of the frequency recurrence.
236: * @param count The number of times to repeat.
237: * @throws GenericServiceException
238: */
239: public void schedule(String serviceName, Map context,
240: long startTime, int frequency, int interval, int count)
241: throws GenericServiceException;
242:
243: /**
244: * Schedule a service to run asynchronously at a specific start time.
245: * @param serviceName Name of the service to invoke.
246: * @param context The name/value pairs composing the context.
247: * @param startTime The time to run this service.
248: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
249: * @param interval The interval of the frequency recurrence.
250: * @param endTime The time in milliseconds the service should expire
251: * @throws GenericServiceException
252: */
253: public void schedule(String serviceName, Map context,
254: long startTime, int frequency, int interval, long endTime)
255: throws GenericServiceException;
256:
257: /**
258: * Schedule a service to run asynchronously at a specific start time.
259: * @param serviceName Name of the service to invoke.
260: * @param context The name/value pairs composing the context.
261: * @param startTime The time to run this service.
262: * @throws GenericServiceException
263: */
264: public void schedule(String serviceName, Map context, long startTime)
265: throws GenericServiceException;
266:
267: /**
268: * Gets the JobManager associated with this dispatcher
269: * @return JobManager that is associated with this dispatcher
270: */
271: public JobManager getJobManager();
272:
273: /**
274: * Gets the JmsListenerFactory which holds the message listeners.
275: * @return JmsListenerFactory
276: */
277: public JmsListenerFactory getJMSListeneFactory();
278:
279: /**
280: * Gets the GenericEntityDelegator associated with this dispatcher
281: * @return GenericEntityDelegator associated with this dispatcher
282: */
283: public GenericDelegator getDelegator();
284:
285: /**
286: * Gets the Security object associated with this dispatcher
287: * @return Security object associated with this dispatcher
288: */
289: public Security getSecurity();
290:
291: /**
292: * Returns the Name of this local dispatcher
293: * @return String representing the name of this local dispatcher
294: */
295: public String getName();
296:
297: /**
298: * Returns the DispatchContext created by this dispatcher
299: * @return DispatchContext created by this dispatcher
300: */
301: public DispatchContext getDispatchContext();
302:
303: /**
304: * De-Registers this LocalDispatcher with the ServiceDispatcher
305: */
306: public void deregister();
307: }
|