KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > service > LocalDispatcher


1 /*
2  * $Id: LocalDispatcher.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.service;
26
27 import java.util.Map JavaDoc;
28
29 import org.ofbiz.entity.GenericDelegator;
30 import org.ofbiz.security.Security;
31 import org.ofbiz.service.jms.JmsListenerFactory;
32 import org.ofbiz.service.job.JobManager;
33
34 /**
35  * Generic Services Local Dispatcher
36  *
37  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
38  * @version $Rev: 5462 $
39  * @since 2.0
40  */

41 public interface LocalDispatcher {
42
43     /**
44      * Run the service synchronously and return the result.
45      * @param serviceName Name of the service to run.
46      * @param context Map of name, value pairs composing the context.
47      * @return Map of name, value pairs composing the result.
48      * @throws ServiceAuthException
49      * @throws ServiceValidationException
50      * @throws GenericServiceException
51      */

52     public Map JavaDoc runSync(String JavaDoc serviceName, Map JavaDoc context) throws GenericServiceException;
53
54     /**
55      * Run the service synchronously with a specified timeout and return the result.
56      * @param serviceName Name of the service to run.
57      * @param context Map of name, value pairs composing the context.
58      * @param transactionTimeout the overriding timeout for the transaction (if we started it).
59      * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
60      * @return Map of name, value pairs composing the result.
61      * @throws ServiceAuthException
62      * @throws ServiceValidationException
63      * @throws GenericServiceException
64      */

65     public Map JavaDoc runSync(String JavaDoc serviceName, Map JavaDoc context, int transactionTimeout, boolean requireNewTransaction) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
66
67     /**
68      * Run the service synchronously and IGNORE the result.
69      * @param serviceName Name of the service to run.
70      * @param context Map of name, value pairs composing the context.
71      * @throws ServiceAuthException
72      * @throws ServiceValidationException
73      * @throws GenericServiceException
74      */

75     public void runSyncIgnore(String JavaDoc serviceName, Map JavaDoc context) throws GenericServiceException;
76
77     /**
78      * Run the service synchronously with a specified timeout and IGNORE the result.
79      * @param serviceName Name of the service to run.
80      * @param context Map of name, value pairs composing the context.
81      * @param transactionTimeout the overriding timeout for the transaction (if we started it).
82      * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
83      * @throws ServiceAuthException
84      * @throws ServiceValidationException
85      * @throws GenericServiceException
86      */

87     public void runSyncIgnore(String JavaDoc serviceName, Map JavaDoc context, int transactionTimeout, boolean requireNewTransaction) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
88     
89     /**
90      * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
91      * @param serviceName Name of the service to run.
92      * @param context Map of name, value pairs composing the context.
93      * @param requester Object implementing GenericRequester interface which will receive the result.
94      * @param persist True for store/run; False for run.
95      * @param transactionTimeout the overriding timeout for the transaction (if we started it).
96      * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
97      * @throws ServiceAuthException
98      * @throws ServiceValidationException
99      * @throws GenericServiceException
100      */

101     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, GenericRequester requester, boolean persist, int transactionTimeout, boolean requireNewTransaction) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
102
103     /**
104      * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
105      * @param serviceName Name of the service to run.
106      * @param context Map of name, value pairs composing the context.
107      * @param requester Object implementing GenericRequester interface which will receive the result.
108      * @param persist True for store/run; False for run.
109      * @throws ServiceAuthException
110      * @throws ServiceValidationException
111      * @throws GenericServiceException
112      */

113     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, GenericRequester requester, boolean persist) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
114
115     /**
116      * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
117      * This method WILL persist the job.
118      * @param serviceName Name of the service to run.
119      * @param context Map of name, value pairs composing the context.
120      * @param requester Object implementing GenericRequester interface which will receive the result.
121      * @throws ServiceAuthException
122      * @throws ServiceValidationException
123      * @throws GenericServiceException
124      */

125     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, GenericRequester requester) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
126
127     /**
128      * Run the service asynchronously and IGNORE the result.
129      * @param serviceName Name of the service to run.
130      * @param context Map of name, value pairs composing the context.
131      * @param persist True for store/run; False for run.
132      * @throws ServiceAuthException
133      * @throws ServiceValidationException
134      * @throws GenericServiceException
135      */

136     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, boolean persist) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
137
138     /**
139      * Run the service asynchronously and IGNORE the result. This method WILL persist the job.
140      * @param serviceName Name of the service to run.
141      * @param context Map of name, value pairs composing the context.
142      * @throws ServiceAuthException
143      * @throws ServiceValidationException
144      * @throws GenericServiceException
145      */

146     public void runAsync(String JavaDoc serviceName, Map JavaDoc context) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
147
148     /**
149      * Run the service asynchronously.
150      * @param serviceName Name of the service to run.
151      * @param context Map of name, value pairs composing the context.
152      * @param persist True for store/run; False for run.
153      * @return A new GenericRequester object.
154      * @throws ServiceAuthException
155      * @throws ServiceValidationException
156      * @throws GenericServiceException
157      */

158     public GenericResultWaiter runAsyncWait(String JavaDoc serviceName, Map JavaDoc context, boolean persist) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
159
160     /**
161      * Run the service asynchronously. This method WILL persist the job.
162      * @param serviceName Name of the service to run.
163      * @param context Map of name, value pairs composing the context.
164      * @return A new GenericRequester object.
165      * @throws ServiceAuthException
166      * @throws ServiceValidationException
167      * @throws GenericServiceException
168      */

169     public GenericResultWaiter runAsyncWait(String JavaDoc serviceName, Map JavaDoc context) throws ServiceAuthException, ServiceValidationException, GenericServiceException;
170
171     /**
172      * Register a callback listener on a specific service.
173      * @param serviceName Name of the service to link callback to.
174      * @param cb The callback implementation.
175      */

176     public void registerCallback(String JavaDoc serviceName, GenericServiceCallback cb);
177
178     /**
179      * Schedule a service to run asynchronously at a specific start time.
180      * @param poolName Name of the service pool to send to.
181      * @param serviceName Name of the service to invoke.
182      * @param context The name/value pairs composing the context.
183      * @param startTime The time to run this service.
184      * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
185      * @param interval The interval of the frequency recurrence.
186      * @param count The number of times to repeat.
187      * @param endTime The time in milliseconds the service should expire
188      * @param maxRetry The number of times we should retry on failure
189      * @throws ServiceAuthException
190      * @throws ServiceValidationException
191      * @throws GenericServiceException
192      */

193     public void schedule(String JavaDoc poolName, String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws GenericServiceException;
194
195
196     /**
197      * Schedule a service to run asynchronously at a specific start time.
198      * @param serviceName Name of the service to invoke.
199      * @param context The name/value pairs composing the context.
200      * @param startTime The time to run this service.
201      * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
202      * @param interval The interval of the frequency recurrence.
203      * @param count The number of times to repeat.
204      * @param endTime The time in milliseconds the service should expire
205      * @throws GenericServiceException
206      */

207     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, int count, long endTime) throws GenericServiceException;
208
209     /**
210      * Schedule a service to run asynchronously at a specific start time.
211      * @param serviceName Name of the service to invoke.
212      * @param context The name/value pairs composing the context.
213      * @param startTime The time to run this service.
214      * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
215      * @param interval The interval of the frequency recurrence.
216      * @param count The number of times to repeat.
217      * @throws GenericServiceException
218      */

219     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, int count) throws GenericServiceException;
220
221     /**
222      * Schedule a service to run asynchronously at a specific start time.
223      * @param serviceName Name of the service to invoke.
224      * @param context The name/value pairs composing the context.
225      * @param startTime The time to run this service.
226      * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
227      * @param interval The interval of the frequency recurrence.
228      * @param endTime The time in milliseconds the service should expire
229      * @throws GenericServiceException
230      */

231     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, long endTime) throws GenericServiceException;
232
233     /**
234      * Schedule a service to run asynchronously at a specific start time.
235      * @param serviceName Name of the service to invoke.
236      * @param context The name/value pairs composing the context.
237      * @param startTime The time to run this service.
238      * @throws GenericServiceException
239      */

240     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime) throws GenericServiceException;
241
242     /**
243      * Gets the JobManager associated with this dispatcher
244      * @return JobManager that is associated with this dispatcher
245      */

246     public JobManager getJobManager();
247
248     /**
249      * Gets the JmsListenerFactory which holds the message listeners.
250      * @return JmsListenerFactory
251      */

252     public JmsListenerFactory getJMSListeneFactory();
253
254     /**
255      * Gets the GenericEntityDelegator associated with this dispatcher
256      * @return GenericEntityDelegator associated with this dispatcher
257      */

258     public GenericDelegator getDelegator();
259
260     /**
261      * Gets the Security object associated with this dispatcher
262      * @return Security object associated with this dispatcher
263      */

264     public Security getSecurity();
265
266     /**
267      * Returns the Name of this local dispatcher
268      * @return String representing the name of this local dispatcher
269      */

270     public String JavaDoc getName();
271
272     /**
273      * Returns the DispatchContext created by this dispatcher
274      * @return DispatchContext created by this dispatcher
275      */

276     public DispatchContext getDispatchContext();
277
278     /**
279      * De-Registers this LocalDispatcher with the ServiceDispatcher
280      */

281     public void deregister();
282 }
283
284
Popular Tags