1 25 package org.ofbiz.service.rmi; 26 27 import java.rmi.RemoteException ; 28 import java.rmi.server.RMIClientSocketFactory ; 29 import java.rmi.server.RMIServerSocketFactory ; 30 import java.rmi.server.UnicastRemoteObject ; 31 import java.util.Map ; 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 46 public class RemoteDispatcherImpl extends UnicastRemoteObject implements RemoteDispatcher { 47 48 public static final String module = RemoteDispatcherImpl.class.getName(); 49 private static final boolean exportAll = false; 50 51 protected LocalDispatcher dispatcher = null; 52 53 public RemoteDispatcherImpl(LocalDispatcher dispatcher, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException { 54 super(0, csf, ssf); 55 this.dispatcher = dispatcher; 56 } 57 58 60 public Map runSync(String serviceName, Map context) throws GenericServiceException, RemoteException { 61 this.checkExportFlag(serviceName); 62 return dispatcher.runSync(serviceName, context); 63 } 64 65 public Map runSync(String serviceName, Map context, int transactionTimeout, boolean requireNewTransaction) throws GenericServiceException, RemoteException { 66 this.checkExportFlag(serviceName); 67 return dispatcher.runSync(serviceName, context, transactionTimeout, requireNewTransaction); 68 } 69 70 public void runSyncIgnore(String serviceName, Map context) throws GenericServiceException, RemoteException { 71 this.checkExportFlag(serviceName); 72 dispatcher.runSyncIgnore(serviceName, context); 73 } 74 75 public void runSyncIgnore(String serviceName, Map context, int transactionTimeout, boolean requireNewTransaction) throws GenericServiceException, RemoteException { 76 this.checkExportFlag(serviceName); 77 dispatcher.runSyncIgnore(serviceName, context, transactionTimeout, requireNewTransaction); 78 } 79 80 public void runAsync(String serviceName, Map context, GenericRequester requester, boolean persist, int transactionTimeout, boolean requireNewTransaction) throws GenericServiceException, RemoteException { 81 this.checkExportFlag(serviceName); 82 dispatcher.runAsync(serviceName, context, requester, persist, transactionTimeout, requireNewTransaction); 83 } 84 85 public void runAsync(String serviceName, Map context, GenericRequester requester, boolean persist) throws GenericServiceException, RemoteException { 86 this.checkExportFlag(serviceName); 87 dispatcher.runAsync(serviceName, context, requester, persist); 88 } 89 90 public void runAsync(String serviceName, Map context, GenericRequester requester) throws GenericServiceException, RemoteException { 91 this.checkExportFlag(serviceName); 92 dispatcher.runAsync(serviceName, context, requester); 93 } 94 95 public void runAsync(String serviceName, Map context, boolean persist) throws GenericServiceException, RemoteException { 96 this.checkExportFlag(serviceName); 97 dispatcher.runAsync(serviceName, context, persist); 98 } 99 100 public void runAsync(String serviceName, Map context) throws GenericServiceException, RemoteException { 101 this.checkExportFlag(serviceName); 102 dispatcher.runAsync(serviceName, context); 103 } 104 105 public GenericResultWaiter runAsyncWait(String serviceName, Map context, boolean persist) throws GenericServiceException, RemoteException { 106 this.checkExportFlag(serviceName); 107 return dispatcher.runAsyncWait(serviceName, context, persist); 108 } 109 110 public GenericResultWaiter runAsyncWait(String serviceName, Map context) throws GenericServiceException, RemoteException { 111 this.checkExportFlag(serviceName); 112 return dispatcher.runAsyncWait(serviceName, context); 113 } 114 115 public void schedule(String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime) throws GenericServiceException, RemoteException { 116 this.checkExportFlag(serviceName); 117 dispatcher.schedule(serviceName, context, startTime, frequency, interval, count, endTime); 118 } 119 120 public void schedule(String serviceName, Map context, long startTime, int frequency, int interval, int count) throws GenericServiceException, RemoteException { 121 this.checkExportFlag(serviceName); 122 dispatcher.schedule(serviceName, context, startTime, frequency, interval, count); 123 } 124 125 public void schedule(String serviceName, Map context, long startTime, int frequency, int interval, long endTime) throws GenericServiceException, RemoteException { 126 this.checkExportFlag(serviceName); 127 dispatcher.schedule(serviceName, context, startTime, frequency, interval, endTime); 128 } 129 130 public void schedule(String serviceName, Map context, long startTime) throws GenericServiceException, RemoteException { 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 serviceName) throws GenericServiceException { 140 ModelService model = dispatcher.getDispatchContext().getModelService(serviceName); 141 if (!model.export && !exportAll) { 142 throw new GenericServiceException("Cannot find requested service"); 145 } 146 } 147 148 } 149 | Popular Tags |