001: /*******************************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: *******************************************************************************/package org.ofbiz.service;
019:
020: import java.util.Map;
021:
022: import org.ofbiz.entity.GenericDelegator;
023: import org.ofbiz.security.Security;
024: import org.ofbiz.service.jms.JmsListenerFactory;
025: import org.ofbiz.service.job.JobManager;
026:
027: /**
028: * Generic Services Local Dispatcher
029: */
030: public interface LocalDispatcher {
031:
032: /**
033: * Run the service synchronously and return the result.
034: * @param serviceName Name of the service to run.
035: * @param context Map of name, value pairs composing the context.
036: * @return Map of name, value pairs composing the result.
037: * @throws ServiceAuthException
038: * @throws ServiceValidationException
039: * @throws GenericServiceException
040: */
041: public Map runSync(String serviceName, Map context)
042: throws GenericServiceException;
043:
044: /**
045: * Run the service synchronously with a specified timeout and return the result.
046: * @param serviceName Name of the service to run.
047: * @param context Map of name, value pairs composing the context.
048: * @param transactionTimeout the overriding timeout for the transaction (if we started it).
049: * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
050: * @return Map of name, value pairs composing the result.
051: * @throws ServiceAuthException
052: * @throws ServiceValidationException
053: * @throws GenericServiceException
054: */
055: public Map runSync(String serviceName, Map context,
056: int transactionTimeout, boolean requireNewTransaction)
057: throws ServiceAuthException, ServiceValidationException,
058: GenericServiceException;
059:
060: /**
061: * Run the service synchronously and IGNORE the result.
062: * @param serviceName Name of the service to run.
063: * @param context Map of name, value pairs composing the context.
064: * @throws ServiceAuthException
065: * @throws ServiceValidationException
066: * @throws GenericServiceException
067: */
068: public void runSyncIgnore(String serviceName, Map context)
069: throws GenericServiceException;
070:
071: /**
072: * Run the service synchronously with a specified timeout 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: * @param transactionTimeout the overriding timeout for the transaction (if we started it).
076: * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
077: * @throws ServiceAuthException
078: * @throws ServiceValidationException
079: * @throws GenericServiceException
080: */
081: public void runSyncIgnore(String serviceName, Map context,
082: int transactionTimeout, boolean requireNewTransaction)
083: throws ServiceAuthException, ServiceValidationException,
084: GenericServiceException;
085:
086: /**
087: * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
088: * @param serviceName Name of the service to run.
089: * @param context Map of name, value pairs composing the context.
090: * @param requester Object implementing GenericRequester interface which will receive the result.
091: * @param persist True for store/run; False for run.
092: * @param transactionTimeout the overriding timeout for the transaction (if we started it).
093: * @param requireNewTransaction if true we will suspend and create a new transaction so we are sure to start.
094: * @throws ServiceAuthException
095: * @throws ServiceValidationException
096: * @throws GenericServiceException
097: */
098: public void runAsync(String serviceName, Map context,
099: GenericRequester requester, boolean persist,
100: int transactionTimeout, boolean requireNewTransaction)
101: throws ServiceAuthException, ServiceValidationException,
102: GenericServiceException;
103:
104: /**
105: * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
106: * @param serviceName Name of the service to run.
107: * @param context Map of name, value pairs composing the context.
108: * @param requester Object implementing GenericRequester interface which will receive the result.
109: * @param persist True for store/run; False for run.
110: * @throws ServiceAuthException
111: * @throws ServiceValidationException
112: * @throws GenericServiceException
113: */
114: public void runAsync(String serviceName, Map context,
115: GenericRequester requester, boolean persist)
116: throws ServiceAuthException, ServiceValidationException,
117: GenericServiceException;
118:
119: /**
120: * Run the service asynchronously, passing an instance of GenericRequester that will receive the result.
121: * This method WILL persist the job.
122: * @param serviceName Name of the service to run.
123: * @param context Map of name, value pairs composing the context.
124: * @param requester Object implementing GenericRequester interface which will receive the result.
125: * @throws ServiceAuthException
126: * @throws ServiceValidationException
127: * @throws GenericServiceException
128: */
129: public void runAsync(String serviceName, Map context,
130: GenericRequester requester) throws ServiceAuthException,
131: ServiceValidationException, GenericServiceException;
132:
133: /**
134: * Run the service asynchronously and IGNORE the result.
135: * @param serviceName Name of the service to run.
136: * @param context Map of name, value pairs composing the context.
137: * @param persist True for store/run; False for run.
138: * @throws ServiceAuthException
139: * @throws ServiceValidationException
140: * @throws GenericServiceException
141: */
142: public void runAsync(String serviceName, Map context,
143: boolean persist) throws ServiceAuthException,
144: ServiceValidationException, GenericServiceException;
145:
146: /**
147: * Run the service asynchronously and IGNORE the result. This method WILL persist the job.
148: * @param serviceName Name of the service to run.
149: * @param context Map of name, value pairs composing the context.
150: * @throws ServiceAuthException
151: * @throws ServiceValidationException
152: * @throws GenericServiceException
153: */
154: public void runAsync(String serviceName, Map context)
155: throws ServiceAuthException, ServiceValidationException,
156: GenericServiceException;
157:
158: /**
159: * Run the service asynchronously.
160: * @param serviceName Name of the service to run.
161: * @param context Map of name, value pairs composing the context.
162: * @param persist True for store/run; False for run.
163: * @return A new GenericRequester object.
164: * @throws ServiceAuthException
165: * @throws ServiceValidationException
166: * @throws GenericServiceException
167: */
168: public GenericResultWaiter runAsyncWait(String serviceName,
169: Map context, boolean persist) throws ServiceAuthException,
170: ServiceValidationException, GenericServiceException;
171:
172: /**
173: * Run the service asynchronously. This method WILL persist the job.
174: * @param serviceName Name of the service to run.
175: * @param context Map of name, value pairs composing the context.
176: * @return A new GenericRequester object.
177: * @throws ServiceAuthException
178: * @throws ServiceValidationException
179: * @throws GenericServiceException
180: */
181: public GenericResultWaiter runAsyncWait(String serviceName,
182: Map context) throws ServiceAuthException,
183: ServiceValidationException, GenericServiceException;
184:
185: /**
186: * Register a callback listener on a specific service.
187: * @param serviceName Name of the service to link callback to.
188: * @param cb The callback implementation.
189: */
190: public void registerCallback(String serviceName,
191: GenericServiceCallback cb);
192:
193: /**
194: * Schedule a service to run asynchronously at a specific start time.
195: * @param poolName Name of the service pool to send to.
196: * @param serviceName Name of the service to invoke.
197: * @param context The name/value pairs composing the context.
198: * @param startTime The time to run this service.
199: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
200: * @param interval The interval of the frequency recurrence.
201: * @param count The number of times to repeat.
202: * @param endTime The time in milliseconds the service should expire
203: * @param maxRetry The number of times we should retry on failure
204: * @throws ServiceAuthException
205: * @throws ServiceValidationException
206: * @throws GenericServiceException
207: */
208: public void schedule(String poolName, String serviceName,
209: Map context, long startTime, int frequency, int interval,
210: int count, long endTime, int maxRetry)
211: throws GenericServiceException;
212:
213: /**
214: * Schedule a service to run asynchronously at a specific start time.
215: * @param jobName Name of the job
216: * @param poolName Name of the service pool to send to.
217: * @param serviceName Name of the service to invoke.
218: * @param context The name/value pairs composing the context.
219: * @param startTime The time to run this service.
220: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
221: * @param interval The interval of the frequency recurrence.
222: * @param count The number of times to repeat.
223: * @param endTime The time in milliseconds the service should expire
224: * @param maxRetry The number of times we should retry on failure
225: * @throws ServiceAuthException
226: * @throws ServiceValidationException
227: * @throws GenericServiceException
228: */
229: public void schedule(String jobName, String poolName,
230: String serviceName, Map context, long startTime,
231: int frequency, int interval, int count, long endTime,
232: int maxRetry) throws GenericServiceException;
233:
234: /**
235: * Schedule a service to run asynchronously at a specific start time.
236: * @param serviceName Name of the service to invoke.
237: * @param context The name/value pairs composing the context.
238: * @param startTime The time to run this service.
239: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
240: * @param interval The interval of the frequency recurrence.
241: * @param count The number of times to repeat.
242: * @param endTime The time in milliseconds the service should expire
243: * @throws GenericServiceException
244: */
245: public void schedule(String serviceName, Map context,
246: long startTime, int frequency, int interval, int count,
247: long endTime) throws GenericServiceException;
248:
249: /**
250: * Schedule a service to run asynchronously at a specific start time.
251: * @param serviceName Name of the service to invoke.
252: * @param context The name/value pairs composing the context.
253: * @param startTime The time to run this service.
254: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
255: * @param interval The interval of the frequency recurrence.
256: * @param count The number of times to repeat.
257: * @throws GenericServiceException
258: */
259: public void schedule(String serviceName, Map context,
260: long startTime, int frequency, int interval, int count)
261: throws GenericServiceException;
262:
263: /**
264: * Schedule a service to run asynchronously at a specific start time.
265: * @param serviceName Name of the service to invoke.
266: * @param context The name/value pairs composing the context.
267: * @param startTime The time to run this service.
268: * @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
269: * @param interval The interval of the frequency recurrence.
270: * @param endTime The time in milliseconds the service should expire
271: * @throws GenericServiceException
272: */
273: public void schedule(String serviceName, Map context,
274: long startTime, int frequency, int interval, long endTime)
275: throws GenericServiceException;
276:
277: /**
278: * Schedule a service to run asynchronously at a specific start time.
279: * @param serviceName Name of the service to invoke.
280: * @param context The name/value pairs composing the context.
281: * @param startTime The time to run this service.
282: * @throws GenericServiceException
283: */
284: public void schedule(String serviceName, Map context, long startTime)
285: throws GenericServiceException;
286:
287: /**
288: * Adds a rollback service to the current TX using the ServiceXaWrapper
289: * @param serviceName
290: * @param context
291: * @param persist
292: * @throws GenericServiceException
293: */
294: public void addRollbackService(String serviceName, Map context,
295: boolean persist) throws GenericServiceException;
296:
297: /**
298: * Adds a commit service to the current TX using the ServiceXaWrapper
299: * @param serviceName
300: * @param context
301: * @param persist
302: * @throws GenericServiceException
303: */
304: public void addCommitService(String serviceName, Map context,
305: boolean persist) throws GenericServiceException;
306:
307: /**
308: * Gets the JobManager associated with this dispatcher
309: * @return JobManager that is associated with this dispatcher
310: */
311: public JobManager getJobManager();
312:
313: /**
314: * Gets the JmsListenerFactory which holds the message listeners.
315: * @return JmsListenerFactory
316: */
317: public JmsListenerFactory getJMSListeneFactory();
318:
319: /**
320: * Gets the GenericEntityDelegator associated with this dispatcher
321: * @return GenericEntityDelegator associated with this dispatcher
322: */
323: public GenericDelegator getDelegator();
324:
325: /**
326: * Gets the Security object associated with this dispatcher
327: * @return Security object associated with this dispatcher
328: */
329: public Security getSecurity();
330:
331: /**
332: * Returns the Name of this local dispatcher
333: * @return String representing the name of this local dispatcher
334: */
335: public String getName();
336:
337: /**
338: * Returns the DispatchContext created by this dispatcher
339: * @return DispatchContext created by this dispatcher
340: */
341: public DispatchContext getDispatchContext();
342:
343: /**
344: * De-Registers this LocalDispatcher with the ServiceDispatcher
345: */
346: public void deregister();
347: }
|