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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Mar 19 11:59:58 EDT 2008


Author: erickson
Date: 2008-03-19 11:25:38 -0400 (Wed, 19 Mar 2008)
New Revision: 1288

Modified:
   trunk/src/java/org/opensrf/ClientSession.java
   trunk/src/java/org/opensrf/Message.java
   trunk/src/java/org/opensrf/Request.java
   trunk/src/java/org/opensrf/Session.java
Log:
added session/request locale support

Modified: trunk/src/java/org/opensrf/ClientSession.java
===================================================================
--- trunk/src/java/org/opensrf/ClientSession.java	2008-03-19 14:10:08 UTC (rev 1287)
+++ trunk/src/java/org/opensrf/ClientSession.java	2008-03-19 15:25:38 UTC (rev 1288)
@@ -36,10 +36,21 @@
 
     /**
      * Creates a new client session.  Initializes the 
-     * @param service The remove service.
+     * @param service The remote service.
      */
     public ClientSession(String service) throws ConfigException {
+        this(service, null);
+    }
+
+    /**
+     * Creates a new client session.  Initializes the 
+     * @param service The remote service.
+     * @param locale The locale for this session.
+     */
+    public ClientSession(String service, String locale) throws ConfigException {
         this.service = service;
+        if(locale != null) 
+            setLocale(locale);
 
         /** generate the remote node string */
         domain = (String) Config.global().getFirst("/domain");

Modified: trunk/src/java/org/opensrf/Message.java
===================================================================
--- trunk/src/java/org/opensrf/Message.java	2008-03-19 14:10:08 UTC (rev 1287)
+++ trunk/src/java/org/opensrf/Message.java	2008-03-19 15:25:38 UTC (rev 1288)
@@ -17,13 +17,15 @@
     private String type;
     /** message payload */
     private Object payload;
+    /** message locale */
+    private String locale;
 
     /** Create a registry for the osrfMessage object */
     private static OSRFRegistry registry = 
         OSRFRegistry.registerObject(
             "osrfMessage", 
             OSRFRegistry.WireProtocol.HASH, 
-            new String[] {"threadTrace", "type", "payload"});
+            new String[] {"threadTrace", "type", "payload", "locale"});
 
     /**
      * @param id This message's ID
@@ -44,7 +46,19 @@
         setPayload(payload);
     }
 
+    /**
+     * @param id This message's ID
+     * @param type The type of message
+     * @param payload The message payload
+     * @param locale The message locale
+     */
+    public Message(int id, String type, Object payload, String locale) {
+        this(id, type, payload);
+        setPayload(payload);
+        setLocale(locale);
+    }
 
+
     public int getId() {
         return id;
     }   
@@ -54,6 +68,9 @@
     public Object getPayload() {
         return payload;
     }
+    public String getLocale() {
+        return locale;
+    }
     public void setId(int id) {
         this.id = id;
     }
@@ -63,6 +80,9 @@
     public void setPayload(Object p) {
         payload = p;
     }
+    public void setLocale(String l) {
+        locale = l;
+    }
 
     /**
      * Implements the generic get() API required by OSRFSerializable
@@ -74,6 +94,8 @@
             return getType().toString();
         if("payload".equals(field))
             return getPayload();
+        if("locale".equals(field))
+            return getLocale();
         return null;
     }
 

Modified: trunk/src/java/org/opensrf/Request.java
===================================================================
--- trunk/src/java/org/opensrf/Request.java	2008-03-19 14:10:08 UTC (rev 1287)
+++ trunk/src/java/org/opensrf/Request.java	2008-03-19 15:25:38 UTC (rev 1288)
@@ -59,7 +59,7 @@
      * Sends the request to the server.
      */
     public void send() throws SessionException {
-        session.send(new Message(id, Message.REQUEST, method));
+        session.send(new Message(id, Message.REQUEST, method, session.getLocale()));
     }
 
     /**

Modified: trunk/src/java/org/opensrf/Session.java
===================================================================
--- trunk/src/java/org/opensrf/Session.java	2008-03-19 14:10:08 UTC (rev 1287)
+++ trunk/src/java/org/opensrf/Session.java	2008-03-19 15:25:38 UTC (rev 1288)
@@ -24,6 +24,11 @@
     /** The address of the remote party we are communicating with */
     private String remoteNode;
 
+    /** Session locale */
+    protected String locale;
+    /** Default session locale */
+    protected static String defaultLocale = "en_US";
+
     /** 
      * The thread is used to link messages to a given session. 
      * In other words, each session has a unique thread, and all messages 
@@ -121,8 +126,43 @@
     public void setThread(String thread) {
         this.thread = thread;
     }
+
+    /**
+     * Get locale.
+     * @return locale as String.
+     */
+    public String getLocale() {
+        if(locale == null)
+            return defaultLocale;
+        return locale;
+    }
     
     /**
+     * Set locale.
+     * @param locale the value to set.
+     */
+    public void setLocale(String locale) {
+        this.locale = locale;
+    }
+
+    /**
+     * Get defaultLocale.
+     * @return defaultLocale as String.
+     */
+    public String getDefaultLocale() {
+        return defaultLocale;
+    }
+    
+    /**
+     * Set defaultLocale.
+     * @param defaultLocale the value to set.
+     */
+    public void setDefaultLocale(String defaultLocale) {
+        this.defaultLocale = defaultLocale;
+    }
+
+    
+    /**
      * Get connectState.
      * @return connectState as ConnectState.
      */



More information about the opensrf-commits mailing list