summaryrefslogtreecommitdiff
path: root/qpid/java/broker
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-08-06 09:43:12 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-08-06 09:43:12 +0000
commitc1dd3ceae904404af5e36bbddfd5a043e397fffe (patch)
treeb22222734b7722c974e9d83495755e2497ff2073 /qpid/java/broker
parentfff1166174f6b2aeb7ebfe14eee9007093423869 (diff)
downloadqpid-python-c1dd3ceae904404af5e36bbddfd5a043e397fffe.tar.gz
QPID-2002 : Completion of BrokerLoggingTest, the shutdown tests have been excluded due to QPID-2031. An update to the LogMessages.vm templates and ApplicationRegistry was requried. This is because BrokerMessages is loaded before the ApplicationRegistry is initialised. As a result the NullApplicationRegistry is created which should not be used. The AR is loaded to discover the current Locale. There were a couple of options here. Either always use the Default Locale and have the AR loading set that or add the ability to check if the AR has been configured. I chose the latter as knowing if an AR exists may be useful for our testing framework.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@801575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java24
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java24
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java3
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java44
-rw-r--r--qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm17
5 files changed, 100 insertions, 12 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
index 34125ae25a..ff604bdc82 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
@@ -52,6 +52,7 @@ import org.apache.qpid.server.protocol.AMQPFastProtocolHandler;
import org.apache.qpid.server.protocol.AMQPProtocolProvider;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.server.transport.QpidAcceptor;
import java.io.File;
import java.io.IOException;
@@ -71,7 +72,7 @@ public class Main
private static final String DEFAULT_CONFIG_FILE = "etc/config.xml";
- private static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
+ public static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
public static final String QPID_HOME = "QPID_HOME";
private static final int IPV4_ADDRESS_LENGTH = 4;
@@ -273,6 +274,11 @@ public class Main
ApplicationRegistry.initialise(config);
+ // We have already loaded the BrokerMessages class by this point so we
+ // need to refresh the locale setting incase we had a different value in
+ // the configuration.
+ BrokerMessages.reload();
+
// AR.initialise() sets its own actor so we now need to set the actor
// for the remainder of the startup
CurrentActor.set(new BrokerActor(config.getRootMessageLogger()));
@@ -292,6 +298,8 @@ public class Main
_brokerLogger.info("Starting Qpid Broker " + QpidProperties.getReleaseVersion()
+ " build: " + QpidProperties.getBuildVersion());
+ CurrentActor.get().message(BrokerMessages.BRK_1001(QpidProperties.getReleaseVersion(),QpidProperties.getBuildVersion()));
+
ByteBuffer.setUseDirectBuffers(serverConfig.getEnableDirectBuffers());
// the MINA default is currently to use the pooled allocator although this may change in future
@@ -400,7 +408,7 @@ public class Main
bindAddress = new InetSocketAddress(InetAddress.getByAddress(parseIP(bindAddr)), port);
}
- bind(acceptor, bindAddress, handler, sconfig);
+ bind(new QpidAcceptor(acceptor,"TCP"), bindAddress, handler, sconfig);
//fixme qpid.AMQP should be using qpidproperties to get value
_brokerLogger.info("Qpid.AMQP listening on non-SSL address " + bindAddress);
@@ -412,7 +420,7 @@ public class Main
try
{
- bind(acceptor, new InetSocketAddress(config.getSSLPort()), handler, sconfig);
+ bind(new QpidAcceptor(acceptor, "TCP/SSL"), new InetSocketAddress(config.getSSLPort()), handler, sconfig);
//fixme qpid.AMQP should be using qpidproperties to get value
_brokerLogger.info("Qpid.AMQP listening on SSL port " + config.getSSLPort());
@@ -427,6 +435,9 @@ public class Main
//fixme qpid.AMQP should be using qpidproperties to get value
_brokerLogger.info("Qpid Broker Ready :" + QpidProperties.getReleaseVersion()
+ " build: " + QpidProperties.getBuildVersion());
+
+ CurrentActor.get().message(BrokerMessages.BRK_1004());
+
}
catch (Exception e)
{
@@ -446,9 +457,11 @@ public class Main
*
* @throws IOException from the acceptor.bind command
*/
- private void bind(IoAcceptor acceptor, InetSocketAddress bindAddress, AMQPFastProtocolHandler handler, SocketAcceptorConfig sconfig) throws IOException
+ private void bind(QpidAcceptor acceptor, InetSocketAddress bindAddress, AMQPFastProtocolHandler handler, SocketAcceptorConfig sconfig) throws IOException
{
- acceptor.bind(bindAddress, handler, sconfig);
+ acceptor.getIoAcceptor().bind(bindAddress, handler, sconfig);
+
+ CurrentActor.get().message(BrokerMessages.BRK_1002(acceptor.toString(), bindAddress.getPort()));
ApplicationRegistry.getInstance().addAcceptor(bindAddress, acceptor);
}
@@ -491,6 +504,7 @@ public class Main
{
if (logConfigFile.exists() && logConfigFile.canRead())
{
+ CurrentActor.get().message(BrokerMessages.BRK_1007(logConfigFile.getAbsolutePath()));
System.out.println("Configuring logger using configuration file " + logConfigFile.getAbsolutePath());
if (logWatchTime > 0)
{
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
index edad8e53aa..b6137e83de 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
@@ -26,7 +26,6 @@ import java.util.Map;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.log4j.Logger;
-import org.apache.mina.common.IoAcceptor;
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.management.ManagedObjectRegistry;
import org.apache.qpid.server.plugins.PluginManager;
@@ -36,7 +35,9 @@ import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.logging.messages.BrokerMessages;
import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.transport.QpidAcceptor;
/**
* An abstract application registry that provides access to configuration information and handles the
@@ -58,7 +59,7 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
public static final String DEFAULT_APPLICATION_REGISTRY = "org.apache.qpid.server.util.NullApplicationRegistry";
public static String _APPLICATION_REGISTRY = DEFAULT_APPLICATION_REGISTRY;
- protected final Map<InetSocketAddress, IoAcceptor> _acceptors = new HashMap<InetSocketAddress, IoAcceptor>();
+ protected final Map<InetSocketAddress, QpidAcceptor> _acceptors = new HashMap<InetSocketAddress, QpidAcceptor>();
protected ManagedObjectRegistry _managedObjectRegistry;
@@ -115,6 +116,16 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
}
}
+ public static boolean isConfigured()
+ {
+ return isConfigured(DEFAULT_INSTANCE);
+ }
+
+ public static boolean isConfigured(int instanceID)
+ {
+ return _instanceMap.containsKey(instanceID);
+ }
+
/**
* Method to cleanly shutdown the default registry running in this JVM
*/
@@ -236,6 +247,8 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
}
// _pluginManager.close();
+
+ CurrentActor.get().message(BrokerMessages.BRK_1005());
}
private void unbind()
@@ -244,8 +257,9 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
{
for (InetSocketAddress bindAddress : _acceptors.keySet())
{
- IoAcceptor acceptor = _acceptors.get(bindAddress);
- acceptor.unbind(bindAddress);
+ QpidAcceptor acceptor = _acceptors.get(bindAddress);
+ acceptor.getIoAcceptor().unbind(bindAddress);
+ CurrentActor.get().message(BrokerMessages.BRK_1003(acceptor.toString(), bindAddress.getPort()));
}
}
}
@@ -255,7 +269,7 @@ public abstract class ApplicationRegistry implements IApplicationRegistry
return _configuration;
}
- public void addAcceptor(InetSocketAddress bindAddress, IoAcceptor acceptor)
+ public void addAcceptor(InetSocketAddress bindAddress, QpidAcceptor acceptor)
{
synchronized (_acceptors)
{
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
index 7d17639f22..ddb3fce5d2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
@@ -34,6 +34,7 @@ import org.apache.qpid.server.security.access.ACLManager;
import org.apache.qpid.server.security.access.ACLPlugin;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.transport.QpidAcceptor;
import org.apache.mina.common.IoAcceptor;
public interface IApplicationRegistry
@@ -77,6 +78,6 @@ public interface IApplicationRegistry
* @param bindAddress The address that the acceptor has been bound with
* @param acceptor The acceptor in use
*/
- void addAcceptor(InetSocketAddress bindAddress, IoAcceptor acceptor);
+ void addAcceptor(InetSocketAddress bindAddress, QpidAcceptor acceptor);
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
new file mode 100644
index 0000000000..61cc7cdeb6
--- /dev/null
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/QpidAcceptor.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.transport;
+
+import org.apache.mina.common.IoAcceptor;
+
+public class QpidAcceptor
+{
+ IoAcceptor _acceptor;
+ String _protocol;
+ public QpidAcceptor(IoAcceptor acceptor, String protocol)
+ {
+ _acceptor = acceptor;
+ _protocol = protocol;
+ }
+
+ public IoAcceptor getIoAcceptor()
+ {
+ return _acceptor;
+ }
+
+ public String toString()
+ {
+ return _protocol;
+ }
+}
diff --git a/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
index 10be2299e9..e2fe7ec3c2 100644
--- a/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
+++ b/qpid/java/broker/src/velocity/templates/org/apache/qpid/server/logging/messages/LogMessages.vm
@@ -45,7 +45,21 @@ public class ${type.name}Messages
static
{
- Locale currentLocale = ApplicationRegistry.getInstance().getConfiguration().getLocale();
+ reload();
+ }
+
+ public static void reload()
+ {
+ Locale currentLocale;
+
+ if (ApplicationRegistry.isConfigured())
+ {
+ currentLocale = ApplicationRegistry.getInstance().getConfiguration().getLocale();
+ }
+ else
+ {
+ currentLocale = Locale.getDefault();
+ }
_messages = ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.LogMessages",
currentLocale);
@@ -54,6 +68,7 @@ public class ${type.name}Messages
_formatter.setLocale(currentLocale);
}
+
##
## The list stored under key 'list' in the 'type' HashMap contains all the
## log messages that this class should contain. So for each entry in the list