Author: kfujino Date: Thu May 21 09:48:19 2015 New Revision: 1680786 URL: http://svn.apache.org/r1680786 Log: Use StringManager to provide i18n support in the org.apache.catalina.tribes.group package.
Added: tomcat/trunk/java/org/apache/catalina/tribes/group/LocalStrings.properties (with props) Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/ChannelCoordinator.java tomcat/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java tomcat/trunk/java/org/apache/catalina/tribes/group/RpcChannel.java Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/ChannelCoordinator.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/ChannelCoordinator.java?rev=1680786&r1=1680785&r2=1680786&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/group/ChannelCoordinator.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/group/ChannelCoordinator.java Thu May 21 09:48:19 2015 @@ -31,6 +31,7 @@ import org.apache.catalina.tribes.transp import org.apache.catalina.tribes.transport.nio.NioReceiver; import org.apache.catalina.tribes.util.Arrays; import org.apache.catalina.tribes.util.Logs; +import org.apache.catalina.tribes.util.StringManager; /** @@ -39,6 +40,7 @@ import org.apache.catalina.tribes.util.L * This is the last interceptor in the chain. */ public class ChannelCoordinator extends ChannelInterceptorBase implements MessageListener { + protected static final StringManager sm = StringManager.getManager(ChannelCoordinator.class); private ChannelReceiver clusterReceiver; private ChannelSender clusterSender; private MembershipService membershipService; @@ -140,7 +142,7 @@ public class ChannelCoordinator extends if (svc == 0 ) return;//nothing to start if (svc == (svc & startLevel)) { - throw new ChannelException("Channel already started for level:"+svc); + throw new ChannelException(sm.getString("channelCoordinator.alreadyStarted", svc)); } //must start the receiver first so that we can coordinate the port it @@ -174,8 +176,7 @@ public class ChannelCoordinator extends } if (!valid) { - throw new IllegalArgumentException("Invalid start level, valid levels are:" + - "SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ"); + throw new IllegalArgumentException(sm.getString("channelCoordinator.invalid.startLevel")); } startLevel = (startLevel | svc); }catch ( ChannelException cx ) { @@ -226,8 +227,7 @@ public class ChannelCoordinator extends membershipService.stop(MembershipService.MBR_TX); } if ( !valid) { - throw new IllegalArgumentException("Invalid start level, valid levels are:" + - "SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ"); + throw new IllegalArgumentException(sm.getString("channelCoordinator.invalid.startLevel")); } startLevel = (startLevel & (~svc)); Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java?rev=1680786&r1=1680785&r2=1680786&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java Thu May 21 09:48:19 2015 @@ -44,6 +44,7 @@ import org.apache.catalina.tribes.io.Cha import org.apache.catalina.tribes.io.XByteBuffer; import org.apache.catalina.tribes.util.Arrays; import org.apache.catalina.tribes.util.Logs; +import org.apache.catalina.tribes.util.StringManager; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -56,6 +57,7 @@ import org.apache.juli.logging.LogFactor */ public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel { private static final Log log = LogFactory.getLog(GroupChannel.class); + protected static final StringManager sm = StringManager.getManager(GroupChannel.class); /** * Flag to determine if the channel manages its own heartbeat @@ -200,11 +202,11 @@ public class GroupChannel extends Channe @Override public UniqueId send(Member[] destination, Serializable msg, int options, ErrorHandler handler) throws ChannelException { - if ( msg == null ) throw new ChannelException("Cant send a NULL message"); + if ( msg == null ) throw new ChannelException(sm.getString("groupChannel.nullMessage")); XByteBuffer buffer = null; try { if (destination == null || destination.length == 0) { - throw new ChannelException("No destination given"); + throw new ChannelException(sm.getString("groupChannel.noDestination")); } ChannelData data = new ChannelData(true);//generates a unique Id data.setAddress(getLocalMember(false)); @@ -274,7 +276,7 @@ public class GroupChannel extends Channe fwd = XByteBuffer.deserialize(msg.getMessage().getBytesDirect(), 0, msg.getMessage().getLength()); }catch (Exception sx) { - log.error("Unable to deserialize message:"+msg,sx); + log.error(sm.getString("groupChannel.unable.deserialize", msg),sx); return; } } @@ -310,7 +312,7 @@ public class GroupChannel extends Channe } catch ( Exception x ) { //this could be the channel listener throwing an exception, we should log it //as a warning. - if ( log.isWarnEnabled() ) log.warn("Error receiving message:",x); + if ( log.isWarnEnabled() ) log.warn(sm.getString("groupChannel.receiving.error"),x); throw new RemoteProcessException("Exception:"+x.getMessage(),x); } } @@ -330,7 +332,7 @@ public class GroupChannel extends Channe new RpcMessage.NoRpcChannelReply(msg.rpcId, msg.uuid); send(new Member[]{destination},reply,Channel.SEND_OPTIONS_ASYNCHRONOUS); } catch ( Exception x ) { - log.error("Unable to find rpc channel, failed to send NoRpcChannelReply.",x); + log.error(sm.getString("groupChannel.sendFail.noRpcChannelReply"),x); } } @@ -404,7 +406,8 @@ public class GroupChannel extends Channe }//end if first = first.getNext(); }//while - if ( conflicts.length() > 0 ) throw new ChannelException("Interceptor option flag conflict: "+conflicts.toString()); + if ( conflicts.length() > 0 ) throw new ChannelException(sm.getString("groupChannel.optionFlag.conflict", + conflicts.toString())); } @@ -535,7 +538,8 @@ public class GroupChannel extends Channe if (!this.channelListeners.contains(channelListener) ) { this.channelListeners.add(channelListener); } else { - throw new IllegalArgumentException("Listener already exists:"+channelListener+"["+channelListener.getClass().getName()+"]"); + throw new IllegalArgumentException(sm.getString("groupChannel.listener.alreadyExist", + channelListener,channelListener.getClass().getName())); } } @@ -695,7 +699,7 @@ public class GroupChannel extends Channe // In the highly unlikely event it was a different trigger, // simply ignore it and continue. } catch ( Exception x ) { - log.error("Unable to send heartbeat through Tribes interceptor stack. Will try to sleep again.",x); + log.error(sm.getString("groupChannel.unable.sendHeartbeat"),x); }//catch }//while }//run Added: tomcat/trunk/java/org/apache/catalina/tribes/group/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/LocalStrings.properties?rev=1680786&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/group/LocalStrings.properties (added) +++ tomcat/trunk/java/org/apache/catalina/tribes/group/LocalStrings.properties Thu May 21 09:48:19 2015 @@ -0,0 +1,26 @@ +# 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. + +channelCoordinator.alreadyStarted=Channel already started for level:{0} +channelCoordinator.invalid.startLevel=Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ +groupChannel.nullMessage=Can't send a NULL message +groupChannel.noDestination=No destination given +groupChannel.unable.deserialize=Unable to deserialize message:{0} +groupChannel.receiving.error=Error receiving message: +groupChannel.sendFail.noRpcChannelReply=Unable to find rpc channel, failed to send NoRpcChannelReply. +groupChannel.optionFlag.conflict=Interceptor option flag conflict: {0} +groupChannel.listener.alreadyExist=Listener already exists:{0}[{1}] +groupChannel.unable.sendHeartbeat=Unable to send heartbeat through Tribes interceptor stack. Will try to sleep again. +rpcChannel.replyFailed=Unable to send back reply in RpcChannel. Propchange: tomcat/trunk/java/org/apache/catalina/tribes/group/LocalStrings.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/RpcChannel.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/RpcChannel.java?rev=1680786&r1=1680785&r2=1680786&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/tribes/group/RpcChannel.java (original) +++ tomcat/trunk/java/org/apache/catalina/tribes/group/RpcChannel.java Thu May 21 09:48:19 2015 @@ -27,6 +27,7 @@ import org.apache.catalina.tribes.Channe import org.apache.catalina.tribes.ErrorHandler; import org.apache.catalina.tribes.Member; import org.apache.catalina.tribes.UniqueId; +import org.apache.catalina.tribes.util.StringManager; import org.apache.catalina.tribes.util.UUIDGenerator; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -36,6 +37,7 @@ import org.apache.juli.logging.LogFactor */ public class RpcChannel implements ChannelListener{ private static final Log log = LogFactory.getLog(RpcChannel.class); + protected static final StringManager sm = StringManager.getManager(RpcChannel.class); public static final int FIRST_REPLY = 1; public static final int MAJORITY_REPLY = 2; @@ -161,7 +163,7 @@ public class RpcChannel implements Chann if (excallback != null && !asyncReply) { excallback.replyFailed(rmsg.message, reply, sender, x); } else { - log.error("Unable to send back reply in RpcChannel.",x); + log.error(sm.getString("rpcChannel.replyFailed"),x); } } if (finished && excallback != null && !asyncReply) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org