diff options
| author | Andrew Donald Kennedy <grkvlt@apache.org> | 2010-09-17 13:41:11 +0000 |
|---|---|---|
| committer | Andrew Donald Kennedy <grkvlt@apache.org> | 2010-09-17 13:41:11 +0000 |
| commit | 2ee8be40abc81649c0f0e29ea912ddc061dafb8a (patch) | |
| tree | 82595d7c92e7cc1f7859499e935deb81372e1f9a /qpid/java | |
| parent | ea8af54b031b99194981207e11ffc36eb4ac26b3 (diff) | |
| download | qpid-python-2ee8be40abc81649c0f0e29ea912ddc061dafb8a.tar.gz | |
QPID-2832: Collate all the LogSubject formatting strings in a static class
Applying patch from <sorins@gmail.com>
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@998125 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
8 files changed, 144 insertions, 124 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java index 536c5cdb0a..088b59ae68 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/BindingLogSubject.java @@ -22,24 +22,12 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.queue.AMQQueue; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.BINDING_FORMAT; public class BindingLogSubject extends AbstractLogSubject { /** - * LOG FORMAT for the ChannelLogSubject, - * Uses a MessageFormat call to insert the requried values according to - * these indicies: - * - * 0 - Virtualhost Name - * 1 - Exchange Type - * 2 - Exchange Name - * 3 - Queue Name - * 4 - Binding RoutingKey - */ - protected static final String BINDING_FORMAT = "vh(/{0})/ex({1}/{2})/qu({3})/rk({4})"; - - /** * Create a BindingLogSubject that Logs in the following format. * * [ vh(/)/ex(amq.direct)/qu(testQueue)/bd(testQueue) ] diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java index 7660804b19..f28873940b 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java @@ -22,22 +22,10 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.AMQChannel; import org.apache.qpid.server.protocol.AMQProtocolSession; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CHANNEL_FORMAT; public class ChannelLogSubject extends AbstractLogSubject { - /** - * LOG FORMAT for the ChannelLogSubject, - * Uses a MessageFormat call to insert the requried values according to - * these indicies: - * - * 0 - Connection ID - * 1 - User ID - * 2 - IP - * 3 - Virtualhost - * 4 - Channel ID - */ - public static final String CHANNEL_FORMAT = ConnectionLogSubject.CONNECTION_FORMAT - + "/ch:{4}"; public ChannelLogSubject(AMQChannel channel) { @@ -64,4 +52,5 @@ public class ChannelLogSubject extends AbstractLogSubject session.getVirtualHost().getName(), channel.getChannelId()); } + } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java index eec7888b2d..a697029d24 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java @@ -24,43 +24,17 @@ import org.apache.qpid.server.protocol.AMQProtocolSession; import java.text.MessageFormat; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SOCKET_FORMAT; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.USER_FORMAT; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.CONNECTION_FORMAT; + /** The Connection LogSubject */ public class ConnectionLogSubject extends AbstractLogSubject { - /** - * 0 - Connection ID - * 1 - Remote Address - */ - public static final String SOCKET_FORMAT = "con:{0}({1})"; - - /** - * LOG FORMAT for the ConnectionLogSubject, - * Uses a MessageFormat call to insert the requried values according to - * these indicies: - * - * 0 - Connection ID - * 1 - User ID - * 2 - IP - */ - public static final String USER_FORMAT = "con:{0}({1}@{2})"; - - /** - * LOG FORMAT for the ConnectionLogSubject, - * Uses a MessageFormat call to insert the required values according to - * these indices: - * - * 0 - Connection ID - * 1 - User ID - * 2 - IP - * 3 - Virtualhost - */ - public static final String CONNECTION_FORMAT = "con:{0}({1}@{2}/{3})"; - - public ConnectionLogSubject(AMQProtocolSession session) { - _session = session; + _session = session; } // The Session this Actor is representing @@ -71,9 +45,9 @@ public class ConnectionLogSubject extends AbstractLogSubject /** * Update the LogString as the Connection process proceeds. - * + * * When the Session has an authorized ID add that to the string. - * + * * When the Session then gains a Vhost add that to the string, at this point * we can set upToDate = true as the _logString will not need to be updated * from this point onwards. @@ -90,40 +64,37 @@ public class ConnectionLogSubject extends AbstractLogSubject * LOG FORMAT used by the AMQPConnectorActor follows * ConnectionLogSubject.CONNECTION_FORMAT : * con:{0}({1}@{2}/{3}) - * - * Uses a MessageFormat call to insert the required values according to - * these indices: - * - * 0 - Connection ID - * 1 - User ID - * 2 - IP - * 3 - Virtualhost + * + * Uses a MessageFormat call to insert the required values + * according to these indices: + * + * 0 - Connection ID 1 - User ID 2 - IP 3 - Virtualhost */ - _logString = "[" + MessageFormat.format(ConnectionLogSubject.CONNECTION_FORMAT, - _session.getSessionID(), - _session.getPrincipal().getName(), + _logString = "[" + MessageFormat.format(CONNECTION_FORMAT, + _session.getSessionID(), + _session.getPrincipal().getName(), _session.getRemoteAddress(), - _session.getVirtualHost().getName()) + _session.getVirtualHost().getName()) + "] "; _upToDate = true; - } + } else { - _logString = "[" + MessageFormat.format(USER_FORMAT, - _session.getSessionID(), - _session.getPrincipal().getName(), + _logString = "[" + MessageFormat.format(USER_FORMAT, + _session.getSessionID(), + _session.getPrincipal().getName(), _session.getRemoteAddress()) + "] "; } - } + } else { - _logString = "[" + MessageFormat.format(SOCKET_FORMAT, - _session.getSessionID(), - _session.getRemoteAddress()) - + "] "; + _logString = "[" + MessageFormat.format(SOCKET_FORMAT, + _session.getSessionID(), + _session.getRemoteAddress()) + + "] "; } } } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java index d954ff64d7..6ab44a92b9 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ExchangeLogSubject.java @@ -22,25 +22,15 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.virtualhost.VirtualHost; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.EXCHANGE_FORMAT; public class ExchangeLogSubject extends AbstractLogSubject { - /** - * LOG FORMAT for the ExchangeLogSubject, - * Uses a MessageFormat call to insert the requried values according to - * these indicies: - * - * 0 - Virtualhost Name - * 1 - Exchange Type - * 2 - Exchange Name - */ - protected static final String BINDING_FORMAT = "vh(/{0})/ex({1}/{2})"; - /** Create an ExchangeLogSubject that Logs in the following format. */ public ExchangeLogSubject(Exchange exchange, VirtualHost vhost) { - setLogStringWithFormat(BINDING_FORMAT, vhost.getName(), + setLogStringWithFormat(EXCHANGE_FORMAT, vhost.getName(), exchange.getTypeShortString(), exchange.getNameShortString()); } } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java new file mode 100644 index 0000000000..ff2bb90140 --- /dev/null +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/LogSubjectFormat.java @@ -0,0 +1,107 @@ +/* + * + * 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. + * + */ + +package org.apache.qpid.server.logging.subjects; + +/** + * LogSubjectFormat class contains a list of formatting string + * that can be statically imported where needed. + * The formatting strings are to be used via a MessageFormat call + * to insert the required values at the corresponding place holder + * indices. + * + */ + +public class LogSubjectFormat +{ + + /** + * LOG FORMAT for the Subscription Log Subject + * 0 - Subscription ID + */ + public static final String SUBSCRIPTION_FORMAT = "sub:{0}"; + + /** + * LOG FORMAT for Connection Log Subject - SOCKET format + * 0 - Connection ID + * 1 - Remote Address + */ + public static final String SOCKET_FORMAT = "con:{0}({1})"; + + /** + * LOG FORMAT for Connection Log Subject - USER format + * 0 - Connection ID + * 1 - User ID + * 2 - IP + */ + public static final String USER_FORMAT = "con:{0}({1}@{2})"; + + /** + * LOG FORMAT for the Connection Log Subject - CON format + * 0 - Connection ID + * 1 - User ID + * 2 - IP + * 3 - Virtualhost + */ + public static final String CONNECTION_FORMAT = "con:{0}({1}@{2}/{3})"; + + /** + * LOG FORMAT for the Channel LogSubject + * 0 - Connection ID + * 1 - User ID + * 2 - IP + * 3 - Virtualhost + * 4 - Channel ID + */ + public static final String CHANNEL_FORMAT = CONNECTION_FORMAT + "/ch:{4}"; + + /** + * LOG FORMAT for the Exchange LogSubject, + * 0 - Virtualhost Name + * 1 - Exchange Type + * 2 - Exchange Name + */ + public static final String EXCHANGE_FORMAT = "vh(/{0})/ex({1}/{2})"; + + /** + * LOG FORMAT for a Binding LogSubject + * 0 - Virtualhost Name + * 1 - Exchange Type + * 2 - Exchange Name + * 3 - Queue Name + * 4 - Binding RoutingKey + */ + public static final String BINDING_FORMAT = "vh(/{0})/ex({1}/{2})/qu({3})/rk({4})"; + + /** + * LOG FORMAT for the MessagesStore LogSubject + * 0 - Virtualhost Name + * 1 - Message Store Type + */ + public static final String STORE_FORMAT = "vh(/{0})/ms({1})"; + + /** + * LOG FORMAT for the Queue LogSubject, + * 0 - Virtualhost name + * 1 - queue name + */ + public static final String QUEUE_FORMAT = "vh(/{0})/qu({1})"; +} diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java index 0417a218ee..3fce13bcb5 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/MessageStoreLogSubject.java @@ -22,24 +22,15 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.virtualhost.VirtualHost; import org.apache.qpid.server.store.MessageStore; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.STORE_FORMAT; public class MessageStoreLogSubject extends AbstractLogSubject { - /** - * LOG FORMAT for the MessagesStoreLogSubject, - * Uses a MessageFormat call to insert the requried values according to - * these indicies: - * - * 0 - Virtualhost Name - * 1 - Message Store Type - */ - protected static final String BINDING_FORMAT = "vh(/{0})/ms({1})"; - /** Create an ExchangeLogSubject that Logs in the following format. */ public MessageStoreLogSubject(VirtualHost vhost, MessageStore store) { - setLogStringWithFormat(BINDING_FORMAT, vhost.getName(), + setLogStringWithFormat(STORE_FORMAT, vhost.getName(), store.getClass().getSimpleName()); } } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java index be96f66074..bfe12f1a60 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/QueueLogSubject.java @@ -21,24 +21,15 @@ package org.apache.qpid.server.logging.subjects; import org.apache.qpid.server.queue.AMQQueue; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.QUEUE_FORMAT; public class QueueLogSubject extends AbstractLogSubject { - /** - * LOG FORMAT for the ExchangeLogSubject, - * Uses a MessageFormat call to insert the requried values according to - * these indicies: - * - * 0 - Virtualhost name - * 1 - queue name - */ - public static final String LOG_FORMAT = "vh(/{0})/qu({1})"; - /** Create an QueueLogSubject that Logs in the following format. */ public QueueLogSubject(AMQQueue queue) { - setLogStringWithFormat(LOG_FORMAT, + setLogStringWithFormat(QUEUE_FORMAT, queue.getVirtualHost().getName(), queue.getName()); } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java index 5d82e97768..8b57647046 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java @@ -24,19 +24,12 @@ import org.apache.qpid.server.subscription.Subscription; import java.text.MessageFormat; +import static org.apache.qpid.server.logging.subjects.LogSubjectFormat.SUBSCRIPTION_FORMAT; + public class SubscriptionLogSubject extends AbstractLogSubject { /** - * LOG FORMAT for the SubscriptionLogSubject, - * Uses a MessageFormat call to insert the required values according to - * these indices: - * - * 0 - Subscription ID - */ - public static final String SUBSCRIPTION_FORMAT = "sub:{0}"; - - /** * Create an QueueLogSubject that Logs in the following format. * * @param subscription @@ -49,7 +42,7 @@ public class SubscriptionLogSubject extends AbstractLogSubject String queueString = new QueueLogSubject(subscription.getQueue()).toLogString(); - _logString = "[" + MessageFormat.format(SubscriptionLogSubject.SUBSCRIPTION_FORMAT, + _logString = "[" + MessageFormat.format(SUBSCRIPTION_FORMAT, subscription.getSubscriptionID()) + "(" // queueString is [vh(/{0})/qu({1}) ] so need to trim |
