[Opensrf-commits] r1088 - trunk/src/java/org/opensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Aug 30 15:02:56 EDT 2007


Author: erickson
Date: 2007-08-30 14:56:46 -0400 (Thu, 30 Aug 2007)
New Revision: 1088

Modified:
   trunk/src/java/org/opensrf/ClientSession.java
   trunk/src/java/org/opensrf/MethodException.java
Log:
added an atomic method for simple, one-off calls

Modified: trunk/src/java/org/opensrf/ClientSession.java
===================================================================
--- trunk/src/java/org/opensrf/ClientSession.java	2007-08-28 00:29:22 UTC (rev 1087)
+++ trunk/src/java/org/opensrf/ClientSession.java	2007-08-30 18:56:46 UTC (rev 1088)
@@ -146,5 +146,19 @@
         if(req == null) return;
         req.setComplete();
     }
+
+    public static Object atomicRequest(String service, String method, Object[] params) throws MethodException {
+        try {
+            ClientSession session = new ClientSession(service);
+            Request osrfRequest = session.request(method, params);
+            Result result = osrfRequest.recv(600000);
+            if(result.getStatusCode() != 200) 
+                throw new MethodException( 
+                    "Request "+service+":"+method+":"+" failed with status code " + result.getStatusCode());
+            return result.getContent();
+        } catch(Exception e) {
+            throw new MethodException(e);
+        }
+    }
 }
 

Modified: trunk/src/java/org/opensrf/MethodException.java
===================================================================
--- trunk/src/java/org/opensrf/MethodException.java	2007-08-28 00:29:22 UTC (rev 1087)
+++ trunk/src/java/org/opensrf/MethodException.java	2007-08-30 18:56:46 UTC (rev 1088)
@@ -7,5 +7,8 @@
     public MethodException(String info) {
         super(info);
     }
+    public MethodException(Throwable cause) {
+        super(cause);
+    }
 }
 



More information about the opensrf-commits mailing list