Skip to content

Commit

Permalink
i18n changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaikiran authored and stuartwdouglas committed Apr 30, 2012
1 parent d95beb2 commit 2bae86e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jboss/ejb/client/ClusterContext.java
Expand Up @@ -326,7 +326,7 @@ public void registerEJBReceiver(final EJBReceiver receiver) {
if (ejbReceiverContext != null) {
// add it to our connected nodes
this.connectedNodes.add(nodeName);
logger.info(this + " Added a new EJB receiver in cluster context " + clusterName + " for node " + nodeName + ". Total nodes in cluster context = " + this.connectedNodes.size());
logger.debug(this + " Added a new EJB receiver in cluster context " + clusterName + " for node " + nodeName + ". Total nodes in cluster context = " + this.connectedNodes.size());
}
}

Expand Down
66 changes: 65 additions & 1 deletion src/main/java/org/jboss/ejb/client/Logs.java
Expand Up @@ -25,12 +25,15 @@
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Cause;
import org.jboss.logging.LogMessage;
import org.jboss.logging.Logger;
import org.jboss.logging.Message;
import org.jboss.logging.MessageLogger;
import org.jboss.remoting3.Channel;

import static org.jboss.logging.Logger.Level.*;

Expand All @@ -40,8 +43,9 @@
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@MessageLogger(projectCode = "EJBCLIENT")
interface Logs extends BasicLogger {
public interface Logs extends BasicLogger {
Logs MAIN = Logger.getMessageLogger(Logs.class, "org.jboss.ejb.client");
Logs REMOTING = Logger.getMessageLogger(Logs.class, "org.jboss.ejb.client.remoting");
Logs TXN = Logger.getMessageLogger(Logs.class, "org.jboss.ejb.client.txn");

// Greeting
Expand All @@ -61,6 +65,66 @@ interface Logs extends BasicLogger {
@Message(id = 2, value = "Bean interface type cannot be null")
IllegalArgumentException nullViewType();

@LogMessage(level = INFO)
@Message(id = 3, value = "Incorrect max-allowed-connected-nodes value %s specified for cluster named %s. Defaulting to %s")
void incorrectMaxAllowedConnectedNodesValueForCluster(final String value, final String clusterName, final String fallbackDefaultValue);

@LogMessage(level = INFO)
@Message(id = 4, value = "Incorrect connection timeout value %s specified for cluster named %s. Defaulting to %s")
void incorrectConnectionTimeoutValueForCluster(final String value, final String clusterName, final String fallbackDefaultValue);

@LogMessage(level = INFO)
@Message(id = 5, value = "Incorrect connection timeout value %s specified for node %s in cluster named %s. Defaulting to %s")
void incorrectConnectionTimeoutValueForNodeInCluster(final String value, final String nodeName, final String clusterName, final String fallbackDefaultValue);

@LogMessage(level = INFO)
@Message(id = 6, value = "No host/port configured for connection named %s. Skipping connection creation")
void skippingConnectionCreationDueToMissingHostOrPort(final String connectionName);

@LogMessage(level = INFO)
@Message(id = 7, value = "Incorrect port value %s specified for connection named %s. Skipping connection creation")
void skippingConnectionCreationDueToInvalidPortNumber(final String port, final String connectionName);

@LogMessage(level = INFO)
@Message(id = 8, value = "Incorrect connection timeout value %s specified for connection named %s. Defaulting to %s")
void incorrectConnectionTimeoutValueForConnection(final String value, final String connectionName, final String fallbackDefaultValue);

@LogMessage(level = INFO)
@Message(id = 9, value = "Incorrect invocation timeout value %s specified. Defaulting to %s")
void incorrectInvocationTimeoutValue(final String value, final String fallbackDefaultValue);

@LogMessage(level = INFO)
@Message(id = 10, value = "Incorrect reconnect tasks timeout value %s specified. Defaulting to %s")
void incorrectReconnectTasksTimeoutValue(final String value, final String fallbackDefaultValue);

@LogMessage(level = INFO)
@Message(id = 11, value = "Discarding result for invocation id %s since no waiting context found")
void discardingInvocationResult(final short invocationId);

@LogMessage(level = INFO)
@Message(id = 12, value = "Cannot create a EJB receiver for %s since there was no match for a target destination")
void cannotCreateEJBReceiverDueToUnknownTarget(final String clusterNode);

@LogMessage(level = INFO)
@Message(id = 13, value = "Successful version handshake completed for receiver context %s on channel %s")
void successfulVersionHandshake(final EJBReceiverContext receiverContext, final Channel channel);

@LogMessage(level = INFO)
@Message(id = 14, value = "Version handshake not completed for receiver context %s. Closing receiver context")
void versionHandshakeNotCompleted(final EJBReceiverContext receiverContext);

@LogMessage(level = INFO)
@Message(id = 15, value = "Initial module availability report for %s wasn't received during the receiver context association")
void initialModuleAvailabilityReportNotReceived(final EJBReceiver ejbReceiver);

@LogMessage(level = INFO)
@Message(id = 16, value = "Channel %s can no longer process messages")
void channelCanNoLongerProcessMessages(final Channel channel);

@LogMessage(level = INFO)
@Message(id = 17, value = "Received server version %s and marshalling strategies %s")
void receivedServerVersionAndMarshallingStrategies(final String version, final String marshallingStrategies);

// Proxy API errors

@Message(id = 100, value = "Object '%s' is not a valid proxy object")
Expand Down
Expand Up @@ -177,7 +177,7 @@ private void parseProperties() {
try {
invocationTimeout = Long.parseLong(invocationTimeoutValue.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect invocation timeout value " + invocationTimeoutValue + " specified. Falling back to default invocation timeout value " + this.invocationTimeout + " milli seconds");
Logs.MAIN.incorrectInvocationTimeoutValue(invocationTimeoutValue, String.valueOf(this.invocationTimeout));
}
}

Expand All @@ -187,7 +187,7 @@ private void parseProperties() {
try{
this.reconnectTasksTimeout = Long.parseLong(reconnectTasksTimeoutValue.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect reconnect tasks timeout value " + reconnectTasksTimeoutValue + " specified. Falling back to default reconnect tasks timeout value " + this.reconnectTasksTimeout + " milli seconds");
Logs.MAIN.incorrectReconnectTasksTimeoutValue(reconnectTasksTimeoutValue, String.valueOf(this.reconnectTasksTimeout));
}
}

Expand Down Expand Up @@ -298,7 +298,7 @@ private ClusterConfiguration createClusterConfiguration(final String clusterName
try {
maxAllowedConnectedNodes = Long.parseLong(maxConnectedNodesStringVal.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect max-allowed-connected-nodes value: " + maxConnectedNodesStringVal + " specified for cluster named " + clusterName + ". Defaulting to " + maxAllowedConnectedNodes);
Logs.MAIN.incorrectMaxAllowedConnectedNodesValueForCluster(maxConnectedNodesStringVal, clusterName, String.valueOf(maxAllowedConnectedNodes));
}
}
// get the connection creation options applicable for all the nodes (unless explicitly overridden) in this
Expand All @@ -316,8 +316,7 @@ private ClusterConfiguration createClusterConfiguration(final String clusterName
try {
connectionTimeout = Long.parseLong(connectionTimeoutValue.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect timeout value " + connectionTimeoutValue + " specified for cluster named "
+ clusterName + ". Falling back to default connection timeout value " + DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS + " milli seconds");
Logs.MAIN.incorrectConnectionTimeoutValueForCluster(connectionTimeoutValue, clusterName, String.valueOf(DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS));
}
}
// cluster node selector for this cluster
Expand Down Expand Up @@ -405,8 +404,7 @@ private ClusterNodeConfiguration createClusterNodeConfiguration(final ClusterCon
try {
connectionTimeout = Long.parseLong(connectionTimeoutValue.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect timeout value " + connectionTimeoutValue + " specified for node named " + nodeName + " in cluster "
+ clusterName + ". Falling back to default connection timeout value " + connectionTimeout + " milli seconds");
Logs.MAIN.incorrectConnectionTimeoutValueForNodeInCluster(connectionTimeoutValue, nodeName, clusterName, String.valueOf(connectionTimeout));
}
}

Expand Down Expand Up @@ -457,20 +455,20 @@ private RemotingConnectionConfiguration createConnectionConfiguration(final Stri
// get "host" for the connection
final String host = connectionSpecificProps.get("host");
if (host == null || host.trim().isEmpty()) {
logger.info("No host configured for connection named " + connectionName + ". Skipping connection creation");
Logs.MAIN.skippingConnectionCreationDueToMissingHostOrPort(connectionName);
return null;
}
// get "port" for the connection
final String portStringVal = connectionSpecificProps.get("port");
if (portStringVal == null || portStringVal.trim().isEmpty()) {
logger.info("No port configured for connection named " + connectionName + ". Skipping connection creation");
Logs.MAIN.skippingConnectionCreationDueToMissingHostOrPort(connectionName);
return null;
}
final Integer port;
try {
port = Integer.parseInt(portStringVal.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect port value: " + portStringVal + " specified for connection named " + connectionName + ". Skipping connection creation");
Logs.MAIN.skippingConnectionCreationDueToInvalidPortNumber(portStringVal, connectionName);
return null;
}
// get connect options for the connection
Expand All @@ -485,8 +483,7 @@ private RemotingConnectionConfiguration createConnectionConfiguration(final Stri
try {
connectionTimeout = Long.parseLong(connectionTimeoutValue.trim());
} catch (NumberFormatException nfe) {
logger.info("Incorrect timeout value " + connectionTimeoutValue + " specified for connection named "
+ connectionName + ". Falling back to default connection timeout value " + DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS + " milli secondss");
Logs.MAIN.incorrectConnectionTimeoutValueForConnection(connectionTimeoutValue, connectionName, String.valueOf(DEFAULT_CONNECTION_TIMEOUT_IN_MILLIS));
}
}
// create the CallbackHandler for this connection configuration
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.EJBReceiverContext;
import org.jboss.ejb.client.EJBReceiverInvocationContext;
import org.jboss.ejb.client.Logs;
import org.jboss.logging.Logger;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.remoting3.Channel;
Expand Down Expand Up @@ -199,7 +200,7 @@ void resultReady(final short invocationId, final EJBReceiverInvocationContext.Re
future.setResult(resultProducer);
}
} else {
logger.info("Discarding result for invocation id " + invocationId + " since no waiting context found");
Logs.REMOTING.discardingInvocationResult(invocationId);
}
}

Expand Down Expand Up @@ -367,7 +368,7 @@ public void handleError(Channel channel, IOException error) {

@Override
public void handleEnd(Channel channel) {
logger.info("Channel " + channel + " can no longer process messages");
Logs.REMOTING.channelCanNoLongerProcessMessages(channel);
// close the channel and let the CloseHandler handle the cleanup
try {
channel.close();
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.jboss.ejb.client.ClusterNodeManager;
import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.EJBReceiver;
import org.jboss.ejb.client.Logs;
import org.jboss.logging.Logger;
import org.jboss.remoting3.Connection;
import org.jboss.remoting3.Endpoint;
Expand Down Expand Up @@ -71,7 +72,7 @@ public String getNodeName() {
@Override
public EJBReceiver getEJBReceiver() {
if (!this.clusterNode.isDestinationResolved()) {
logger.info("Cannot create a EJB receiver for " + this.clusterNode + " since there was no match for a target destination");
Logs.REMOTING.cannotCreateEJBReceiverDueToUnknownTarget(this.clusterNode.toString());
return null;
}
Connection connection = null;
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.jboss.ejb.client.EJBReceiver;
import org.jboss.ejb.client.EJBReceiverContext;
import org.jboss.ejb.client.EJBReceiverInvocationContext;
import org.jboss.ejb.client.Logs;
import org.jboss.ejb.client.StatefulEJBLocator;
import org.jboss.ejb.client.TransactionID;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -159,10 +160,10 @@ public void handleClose(final Channel closed, final IOException exception) {
synchronized (this.channelAssociations) {
this.channelAssociations.put(context, channelAssociation);
}
logger.info("Successful version handshake completed for receiver context " + context + " on channel " + compatibleChannel);
Logs.REMOTING.successfulVersionHandshake(context, compatibleChannel);
} else {
// no version handshake done. close the context
logger.info("Version handshake not completed for receiver context " + context + " by receiver " + this + " . Closing the receiver context");
Logs.REMOTING.versionHandshakeNotCompleted(context);
context.close();
}
} catch (InterruptedException e) {
Expand All @@ -179,7 +180,7 @@ public void handleClose(final Channel closed, final IOException exception) {
if (!initialReportAvailable) {
// let's log a message and just return back. Don't close the context since it's *not* an error
// that the module report wasn't available in that amount of time.
logger.info("Initial module availability report for " + this + " wasn't received during the receiver context association");
Logs.REMOTING.initialModuleAvailabilityReportNotReceived(this);
}
} catch (InterruptedException e) {
logger.debug("Caught InterruptedException while waiting for initial module availability report for " + this, e);
Expand Down
Expand Up @@ -22,6 +22,7 @@

package org.jboss.ejb.client.remoting;

import org.jboss.ejb.client.Logs;
import org.jboss.logging.Logger;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.SimpleDataInput;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void handleError(final Channel channel, final IOException error) {

@Override
public void handleEnd(final Channel channel) {
logger.info("Channel end notification received. No more communication will happen on channel " + channel);
Logs.REMOTING.channelCanNoLongerProcessMessages(channel);
try {
channel.close();
} catch (IOException ioe) {
Expand All @@ -98,7 +99,7 @@ public void handleMessage(final Channel channel, final MessageInputStream messag
for (int i = 0; i < serverMarshallerCount; i++) {
serverMarshallerStrategies[i] = simpleDataInput.readUTF();
}
logger.info("Received server version " + serverVersion + " and marshalling strategies " + Arrays.toString(serverMarshallerStrategies));
Logs.REMOTING.receivedServerVersionAndMarshallingStrategies(String.valueOf(serverVersion), Arrays.toString(serverMarshallerStrategies));

} catch (IOException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 2bae86e

Please sign in to comment.