KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > service > rmi > RemoteDispatcherImpl


1 /*
2  * $Id: RemoteDispatcherImpl.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2003 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.rmi;
26
27 import java.rmi.RemoteException JavaDoc;
28 import java.rmi.server.RMIClientSocketFactory JavaDoc;
29 import java.rmi.server.RMIServerSocketFactory JavaDoc;
30 import java.rmi.server.UnicastRemoteObject JavaDoc;
31 import java.util.Map JavaDoc;
32
33 import org.ofbiz.service.GenericRequester;
34 import org.ofbiz.service.GenericResultWaiter;
35 import org.ofbiz.service.GenericServiceException;
36 import org.ofbiz.service.LocalDispatcher;
37 import org.ofbiz.service.ModelService;
38
39 /**
40  * Generic Services Remote Dispatcher Implementation
41  *
42  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
43  * @version $Rev: 5462 $
44  * @since 3.0
45  */

46 public class RemoteDispatcherImpl extends UnicastRemoteObject JavaDoc implements RemoteDispatcher {
47
48     public static final String JavaDoc module = RemoteDispatcherImpl.class.getName();
49     private static final boolean exportAll = false;
50
51     protected LocalDispatcher dispatcher = null;
52
53     public RemoteDispatcherImpl(LocalDispatcher dispatcher, RMIClientSocketFactory JavaDoc csf, RMIServerSocketFactory JavaDoc ssf) throws RemoteException JavaDoc {
54         super(0, csf, ssf);
55         this.dispatcher = dispatcher;
56     }
57
58     // RemoteDispatcher methods
59

60     public Map JavaDoc runSync(String JavaDoc serviceName, Map JavaDoc context) throws GenericServiceException, RemoteException JavaDoc {
61         this.checkExportFlag(serviceName);
62         return dispatcher.runSync(serviceName, context);
63     }
64
65     public Map JavaDoc runSync(String JavaDoc serviceName, Map JavaDoc context, int transactionTimeout, boolean requireNewTransaction) throws GenericServiceException, RemoteException JavaDoc {
66         this.checkExportFlag(serviceName);
67         return dispatcher.runSync(serviceName, context, transactionTimeout, requireNewTransaction);
68     }
69
70     public void runSyncIgnore(String JavaDoc serviceName, Map JavaDoc context) throws GenericServiceException, RemoteException JavaDoc {
71         this.checkExportFlag(serviceName);
72         dispatcher.runSyncIgnore(serviceName, context);
73     }
74
75     public void runSyncIgnore(String JavaDoc serviceName, Map JavaDoc context, int transactionTimeout, boolean requireNewTransaction) throws GenericServiceException, RemoteException JavaDoc {
76         this.checkExportFlag(serviceName);
77         dispatcher.runSyncIgnore(serviceName, context, transactionTimeout, requireNewTransaction);
78     }
79
80     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, GenericRequester requester, boolean persist, int transactionTimeout, boolean requireNewTransaction) throws GenericServiceException, RemoteException JavaDoc {
81         this.checkExportFlag(serviceName);
82         dispatcher.runAsync(serviceName, context, requester, persist, transactionTimeout, requireNewTransaction);
83     }
84
85     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, GenericRequester requester, boolean persist) throws GenericServiceException, RemoteException JavaDoc {
86         this.checkExportFlag(serviceName);
87         dispatcher.runAsync(serviceName, context, requester, persist);
88     }
89
90     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, GenericRequester requester) throws GenericServiceException, RemoteException JavaDoc {
91         this.checkExportFlag(serviceName);
92         dispatcher.runAsync(serviceName, context, requester);
93     }
94
95     public void runAsync(String JavaDoc serviceName, Map JavaDoc context, boolean persist) throws GenericServiceException, RemoteException JavaDoc {
96         this.checkExportFlag(serviceName);
97         dispatcher.runAsync(serviceName, context, persist);
98     }
99
100     public void runAsync(String JavaDoc serviceName, Map JavaDoc context) throws GenericServiceException, RemoteException JavaDoc {
101         this.checkExportFlag(serviceName);
102         dispatcher.runAsync(serviceName, context);
103     }
104
105     public GenericResultWaiter runAsyncWait(String JavaDoc serviceName, Map JavaDoc context, boolean persist) throws GenericServiceException, RemoteException JavaDoc {
106         this.checkExportFlag(serviceName);
107         return dispatcher.runAsyncWait(serviceName, context, persist);
108     }
109
110     public GenericResultWaiter runAsyncWait(String JavaDoc serviceName, Map JavaDoc context) throws GenericServiceException, RemoteException JavaDoc {
111         this.checkExportFlag(serviceName);
112         return dispatcher.runAsyncWait(serviceName, context);
113     }
114
115     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, int count, long endTime) throws GenericServiceException, RemoteException JavaDoc {
116         this.checkExportFlag(serviceName);
117         dispatcher.schedule(serviceName, context, startTime, frequency, interval, count, endTime);
118     }
119
120     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, int count) throws GenericServiceException, RemoteException JavaDoc {
121         this.checkExportFlag(serviceName);
122         dispatcher.schedule(serviceName, context, startTime, frequency, interval, count);
123     }
124
125     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime, int frequency, int interval, long endTime) throws GenericServiceException, RemoteException JavaDoc {
126         this.checkExportFlag(serviceName);
127         dispatcher.schedule(serviceName, context, startTime, frequency, interval, endTime);
128     }
129
130     public void schedule(String JavaDoc serviceName, Map JavaDoc context, long startTime) throws GenericServiceException, RemoteException JavaDoc {
131         this.checkExportFlag(serviceName);
132         dispatcher.schedule(serviceName, context, startTime);
133     }
134
135     public void deregister() {
136         dispatcher.deregister();
137     }
138
139     protected void checkExportFlag(String JavaDoc serviceName) throws GenericServiceException {
140         ModelService model = dispatcher.getDispatchContext().getModelService(serviceName);
141         if (!model.export && !exportAll) {
142             // TODO: make this log on the server rather than the client
143
//Debug.logWarning("Attempt to invoke a non-exported service: " + serviceName, module);
144
throw new GenericServiceException("Cannot find requested service");
145         }
146     }
147
148 }
149
Popular Tags