Author: kfujino
Date: Thu May 21 09:51:41 2015
New Revision: 1680790

URL: http://svn.apache.org/r1680790
Log:
Use StringManager to provide i18n support in the org.apache.catalina.tribes.io 
package.

Added:
    tomcat/trunk/java/org/apache/catalina/tribes/io/LocalStrings.properties   
(with props)
Modified:
    tomcat/trunk/java/org/apache/catalina/tribes/io/BufferPool.java
    tomcat/trunk/java/org/apache/catalina/tribes/io/ObjectReader.java
    tomcat/trunk/java/org/apache/catalina/tribes/io/ReplicationStream.java
    tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java

Modified: tomcat/trunk/java/org/apache/catalina/tribes/io/BufferPool.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/BufferPool.java?rev=1680790&r1=1680789&r2=1680790&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/BufferPool.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/BufferPool.java Thu May 21 
09:51:41 2015
@@ -17,6 +17,7 @@
 package org.apache.catalina.tribes.io;
 
 
+import org.apache.catalina.tribes.util.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -30,6 +31,8 @@ public class BufferPool {
 
     public static final int DEFAULT_POOL_SIZE = 100*1024*1024; //100MB
 
+    protected static final StringManager sm = 
StringManager.getManager(BufferPool.class);
+
 
 
     protected static volatile BufferPool instance = null;
@@ -59,9 +62,7 @@ public class BufferPool {
                 if (instance == null) {
                    BufferPoolAPI pool = new BufferPool15Impl();
                    pool.setMaxSize(DEFAULT_POOL_SIZE);
-                   log.info("Created a buffer pool with max size:" +
-                           DEFAULT_POOL_SIZE + " bytes of type: " +
-                           pool.getClass().getName());
+                   log.info(sm.getString("bufferPool.created", 
DEFAULT_POOL_SIZE, pool.getClass().getName()));
                    instance = new BufferPool(pool);
                 }
             }

Added: tomcat/trunk/java/org/apache/catalina/tribes/io/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/LocalStrings.properties?rev=1680790&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/LocalStrings.properties 
(added)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/LocalStrings.properties Thu 
May 21 09:51:41 2015
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+bufferPool.created=Created a buffer pool with max size:{0} bytes of type: {1}
+objectReader.retrieveFailed.socketReceiverBufferSize=Unable to retrieve the 
socket receiver buffer size, setting to default 43800 bytes.
+replicationStream.conflict=conflicting non-public interface class loaders
+xByteBuffer.size.larger.buffer=Size is larger than existing buffer.
+xByteBuffer.unableTrim=Can''t trim more bytes than are available. length:{0} 
trim:{1}
+xByteBuffer.discarded.invalidHeader=Discarded the package, invalid header
+xByteBuffer.no.package=No package exists in XByteBuffer
+xByteBuffer.unableCreate=Unable to create data package, buffer is too small.
+xByteBuffer.wrong.class=Message has the wrong class. It should implement 
Serializable, instead it is:{0}
\ No newline at end of file

Propchange: 
tomcat/trunk/java/org/apache/catalina/tribes/io/LocalStrings.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/catalina/tribes/io/ObjectReader.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/ObjectReader.java?rev=1680790&r1=1680789&r2=1680790&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/ObjectReader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/ObjectReader.java Thu May 
21 09:51:41 2015
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
 
 import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.util.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -37,6 +38,7 @@ import org.apache.juli.logging.LogFactor
 public class ObjectReader {
 
     private static final Log log = LogFactory.getLog(ObjectReader.class);
+    protected static final StringManager sm = 
StringManager.getManager(ObjectReader.class);
 
     private XByteBuffer buffer;
 
@@ -65,7 +67,7 @@ public class ObjectReader {
             this.buffer = new XByteBuffer(socket.getReceiveBufferSize(), true);
         }catch ( IOException x ) {
             //unable to get buffer size
-            log.warn("Unable to retrieve the socket receiver buffer size, 
setting to default 43800 bytes.");
+            
log.warn(sm.getString("objectReader.retrieveFailed.socketReceiverBufferSize"));
             this.buffer = new XByteBuffer(43800,true);
         }
     }

Modified: tomcat/trunk/java/org/apache/catalina/tribes/io/ReplicationStream.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/ReplicationStream.java?rev=1680790&r1=1680789&r2=1680790&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/ReplicationStream.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/ReplicationStream.java Thu 
May 21 09:51:41 2015
@@ -25,6 +25,8 @@ import java.io.ObjectStreamClass;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
 
+import org.apache.catalina.tribes.util.StringManager;
+
 /**
  * Custom subclass of <code>ObjectInputStream</code> that loads from the
  * class loader for this web application.  This allows classes defined only
@@ -35,6 +37,7 @@ import java.lang.reflect.Proxy;
  */
 public final class ReplicationStream extends ObjectInputStream {
 
+    protected static final StringManager sm = 
StringManager.getManager(ReplicationStream.class);
 
     /**
      * The class loader we will use to resolve classes.
@@ -119,7 +122,7 @@ public final class ReplicationStream ext
                 if (hasNonPublicInterface) {
                     if (nonPublicLoader != cl.getClassLoader()) {
                         throw new IllegalAccessError(
-                                "conflicting non-public interface class 
loaders");
+                                sm.getString("replicationStream.conflict"));
                     }
                 } else {
                     nonPublicLoader = cl.getClassLoader();

Modified: tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java?rev=1680790&r1=1680789&r2=1680790&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java Thu May 21 
09:51:41 2015
@@ -27,6 +27,7 @@ import java.io.Serializable;
 import java.nio.ByteBuffer;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.catalina.tribes.util.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -49,6 +50,7 @@ import org.apache.juli.logging.LogFactor
 public class XByteBuffer {
 
     private static final Log log = LogFactory.getLog(XByteBuffer.class);
+    protected static final StringManager sm = 
StringManager.getManager(XByteBuffer.class);
 
     /**
      * This is a package header, 7 bytes (FLT2002)
@@ -106,13 +108,13 @@ public class XByteBuffer {
     }
 
     public void setLength(int size) {
-        if ( size > buf.length ) throw new 
ArrayIndexOutOfBoundsException("Size is larger than existing buffer.");
+        if ( size > buf.length ) throw new 
ArrayIndexOutOfBoundsException(sm.getString("xByteBuffer.size.larger.buffer"));
         bufSize = size;
     }
 
     public void trim(int length) {
         if ( (bufSize - length) < 0 )
-            throw new ArrayIndexOutOfBoundsException("Can't trim more bytes 
than are available. length:"+bufSize+" trim:"+length);
+            throw new 
ArrayIndexOutOfBoundsException(sm.getString("xByteBuffer.unableTrim", bufSize, 
length));
         bufSize -= length;
     }
 
@@ -159,7 +161,7 @@ public class XByteBuffer {
         if ( discard ) {
             if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, 
START_DATA) == -1)) {
                 bufSize = 0;
-                log.error("Discarded the package, invalid header");
+                log.error(sm.getString("xByteBuffer.discarded.invalidHeader"));
                 return false;
             }
         }
@@ -226,7 +228,7 @@ public class XByteBuffer {
         if ( discard ) {
             if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, 
START_DATA) == -1)) {
                 bufSize = 0;
-                log.error("Discarded the package, invalid header");
+                log.error(sm.getString("xByteBuffer.discarded.invalidHeader"));
                 return false;
             }
         }
@@ -305,7 +307,7 @@ public class XByteBuffer {
     public XByteBuffer extractDataPackage(boolean clearFromBuffer) {
         int psize = countPackages(true);
         if (psize == 0) {
-            throw new java.lang.IllegalStateException("No package exists in 
XByteBuffer");
+            throw new 
java.lang.IllegalStateException(sm.getString("xByteBuffer.no.package"));
         }
         int size = toInt(buf, START_DATA.length);
         XByteBuffer xbuf = BufferPool.getBufferPool().getBuffer(size,false);
@@ -351,7 +353,7 @@ public class XByteBuffer {
 
     public static byte[] createDataPackage(byte[] data, int doff, int dlength, 
byte[] buffer, int bufoff) {
         if ( (buffer.length-bufoff) > getDataPackageLength(dlength) ) {
-            throw new ArrayIndexOutOfBoundsException("Unable to create data 
package, buffer is too small.");
+            throw new 
ArrayIndexOutOfBoundsException(sm.getString("xByteBuffer.unableCreate"));
         }
         System.arraycopy(START_DATA, 0, buffer, bufoff, START_DATA.length);
         toBytes(data.length,buffer, bufoff+START_DATA.length);
@@ -554,7 +556,7 @@ public class XByteBuffer {
         } else if (message instanceof Serializable)
             return (Serializable) message;
         else {
-            throw new ClassCastException("Message has the wrong class. It 
should implement Serializable, instead it is:"+message.getClass().getName());
+            throw new 
ClassCastException(sm.getString("xByteBuffer.wrong.class", 
message.getClass().getName()));
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to