summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-12-06 22:13:57 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-12-06 22:13:57 +0000
commit29ae1eaabfa2d46c3f0728d6b3f9477661f9abd4 (patch)
tree75bed5ff897926821c85a9d4ba9313f92b3a8101 /qpid/java
parent32a91b1044c2fa592cd7e33ea8c54c908b8e04b9 (diff)
downloadqpid-python-29ae1eaabfa2d46c3f0728d6b3f9477661f9abd4.tar.gz
QPID-6263 : [Java Broker] remove ApplicationRegistry
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1643619 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java101
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java135
-rw-r--r--qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java38
3 files changed, 81 insertions, 193 deletions
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java
index 245edc0970..a5a84b019d 100644
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java
+++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/Broker.java
@@ -33,33 +33,45 @@ import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
+import org.apache.qpid.common.QpidProperties;
+import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.configuration.updater.TaskExecutorImpl;
+import org.apache.qpid.server.logging.CompositeStartupMessageLogger;
import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.logging.Log4jMessageLogger;
import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.logging.MessageLogger;
import org.apache.qpid.server.logging.SystemOutMessageLogger;
import org.apache.qpid.server.logging.log4j.LoggingManagementFacade;
import org.apache.qpid.server.logging.messages.BrokerMessages;
import org.apache.qpid.server.model.BrokerShutdownProvider;
+import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.SystemConfig;
import org.apache.qpid.server.plugin.PluggableFactoryLoader;
import org.apache.qpid.server.plugin.SystemConfigFactory;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.registry.IApplicationRegistry;
import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.store.BrokerStoreUpgraderAndRecoverer;
import org.apache.qpid.server.store.DurableConfigurationStore;
+import org.apache.qpid.util.SystemUtils;
public class Broker implements BrokerShutdownProvider
{
private static final Logger LOGGER = Logger.getLogger(Broker.class);
private volatile Thread _shutdownHookThread;
- private volatile IApplicationRegistry _applicationRegistry;
private EventLogger _eventLogger;
private boolean _configuringOwnLogging = false;
private final TaskExecutor _taskExecutor = new TaskExecutorImpl();
private final boolean _exitJVMOnShutdownWithNonZeroExitCode;
+ private SystemConfig _systemConfig;
+
+ private org.apache.qpid.server.model.Broker _broker;
+
+ private DurableConfigurationStore _store;
+
+
public Broker()
{
this(false);
@@ -96,10 +108,22 @@ public class Broker implements BrokerShutdownProvider
{
try
{
- if (_applicationRegistry != null)
+ try
+ {
+ if (_broker != null)
+ {
+ _broker.close();
+ }
+ }
+ finally
{
- _applicationRegistry.close();
+ if(_systemConfig != null)
+ {
+ _systemConfig.close();
+ }
}
+ _store = null;
+ _broker = null;
_taskExecutor.stop();
}
@@ -169,21 +193,67 @@ public class Broker implements BrokerShutdownProvider
LogRecorder logRecorder = new LogRecorder();
_taskExecutor.start();
- SystemConfig systemConfig = configFactory.newInstance(_taskExecutor, _eventLogger, logRecorder, options, this);
- systemConfig.open();
- DurableConfigurationStore store = systemConfig.getConfigurationStore();
+ _systemConfig = configFactory.newInstance(_taskExecutor, _eventLogger, logRecorder, options, this);
+ _systemConfig.open();
+ _store = _systemConfig.getConfigurationStore();
- _applicationRegistry = new ApplicationRegistry(store, systemConfig);
try
{
- _applicationRegistry.initialise(options);
+ // Create the RootLogger to be used during broker operation
+ boolean statusUpdatesEnabled = Boolean.parseBoolean(System.getProperty(BrokerProperties.PROPERTY_STATUS_UPDATES, "true"));
+ MessageLogger messageLogger = new Log4jMessageLogger(statusUpdatesEnabled);
+ final EventLogger eventLogger = _systemConfig.getEventLogger();
+ eventLogger.setMessageLogger(messageLogger);
+
+ //Create the composite (log4j+SystemOut MessageLogger to be used during startup
+ MessageLogger[] messageLoggers = {new SystemOutMessageLogger(), messageLogger};
+
+ CompositeStartupMessageLogger startupMessageLogger = new CompositeStartupMessageLogger(messageLoggers);
+ EventLogger startupLogger = new EventLogger(startupMessageLogger);
+
+ startupLogger.message(BrokerMessages.STARTUP(QpidProperties.getReleaseVersion(),
+ QpidProperties.getBuildVersion()));
+
+ startupLogger.message(BrokerMessages.PLATFORM(System.getProperty("java.vendor"),
+ System.getProperty("java.runtime.version",
+ System.getProperty("java.version")),
+ SystemUtils.getOSName(),
+ SystemUtils.getOSVersion(),
+ SystemUtils.getOSArch()));
+
+ startupLogger.message(BrokerMessages.MAX_MEMORY(Runtime.getRuntime().maxMemory()));
+
+ BrokerStoreUpgraderAndRecoverer upgrader = new BrokerStoreUpgraderAndRecoverer(_systemConfig);
+ org.apache.qpid.server.model.Broker broker = upgrader.perform(_store);
+ _broker = broker;
+
+ broker.setEventLogger(startupLogger);
+ broker.open();
+
+ if (broker.getState() == State.ACTIVE)
+ {
+ startupLogger.message(BrokerMessages.READY());
+ broker.setEventLogger(eventLogger);
+ }
}
catch(Exception e)
{
LOGGER.fatal("Exception during startup", e);
try
{
- _applicationRegistry.close();
+ try
+ {
+ if (_broker != null)
+ {
+ _broker.close();
+ }
+ }
+ finally
+ {
+ _systemConfig.close();
+ }
+ _store = null;
+ _broker = null;
}
catch(Exception ce)
{
@@ -297,15 +367,6 @@ public class Broker implements BrokerShutdownProvider
}
}
- public org.apache.qpid.server.model.Broker getBroker()
- {
- if (_applicationRegistry == null)
- {
- return null;
- }
- return _applicationRegistry.getBroker();
- }
-
private class ShutdownService implements Runnable
{
public void run()
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
deleted file mode 100644
index d32f0299d5..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- *
- * 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.registry;
-
-import org.apache.log4j.Logger;
-
-import org.apache.qpid.common.QpidProperties;
-import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.server.logging.CompositeStartupMessageLogger;
-import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.logging.Log4jMessageLogger;
-import org.apache.qpid.server.logging.MessageLogger;
-import org.apache.qpid.server.logging.SystemOutMessageLogger;
-import org.apache.qpid.server.logging.messages.BrokerMessages;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.SystemConfig;
-import org.apache.qpid.server.store.BrokerStoreUpgraderAndRecoverer;
-import org.apache.qpid.server.store.DurableConfigurationStore;
-import org.apache.qpid.util.SystemUtils;
-
-
-/**
- * An abstract application registry that provides access to configuration information and handles the
- * construction and caching of configurable objects.
- * <p>
- * Subclasses should handle the construction of the "registered objects" such as the exchange registry.
- */
-public class ApplicationRegistry implements IApplicationRegistry
-{
- private static final Logger _logger = Logger.getLogger(ApplicationRegistry.class);
-
- private final SystemConfig _systemConfig;
-
- private Broker _broker;
-
- private DurableConfigurationStore _store;
-
- public ApplicationRegistry(DurableConfigurationStore store, SystemConfig systemConfig)
- {
- _store = store;
- _systemConfig = systemConfig;
- }
-
- public void initialise(BrokerOptions brokerOptions) throws Exception
- {
- // Create the RootLogger to be used during broker operation
- boolean statusUpdatesEnabled = Boolean.parseBoolean(System.getProperty(BrokerProperties.PROPERTY_STATUS_UPDATES, "true"));
- MessageLogger messageLogger = new Log4jMessageLogger(statusUpdatesEnabled);
- final EventLogger eventLogger = _systemConfig.getEventLogger();
- eventLogger.setMessageLogger(messageLogger);
-
- //Create the composite (log4j+SystemOut MessageLogger to be used during startup
- MessageLogger[] messageLoggers = {new SystemOutMessageLogger(), messageLogger};
-
- CompositeStartupMessageLogger startupMessageLogger = new CompositeStartupMessageLogger(messageLoggers);
- EventLogger startupLogger = new EventLogger(startupMessageLogger);
-
- logStartupMessages(startupLogger);
-
- BrokerStoreUpgraderAndRecoverer upgrader = new BrokerStoreUpgraderAndRecoverer(_systemConfig);
- Broker broker = upgrader.perform(_store);
- _broker = broker;
-
- broker.setEventLogger(startupLogger);
- broker.open();
-
- if (broker.getState() == State.ACTIVE)
- {
- startupLogger.message(BrokerMessages.READY());
- broker.setEventLogger(eventLogger);
- }
- }
-
- public void close()
- {
- if (_logger.isInfoEnabled())
- {
- _logger.info("Shutting down ApplicationRegistry:" + this);
- }
- try
- {
- if (_broker != null)
- {
- _broker.close();
- }
- }
- finally
- {
- _systemConfig.close();
- }
- _store = null;
- _broker = null;
- }
-
-
- private void logStartupMessages(EventLogger eventLogger)
- {
- eventLogger.message(BrokerMessages.STARTUP(QpidProperties.getReleaseVersion(), QpidProperties.getBuildVersion()));
-
- eventLogger.message(BrokerMessages.PLATFORM(System.getProperty("java.vendor"),
- System.getProperty("java.runtime.version", System.getProperty("java.version")),
- SystemUtils.getOSName(),
- SystemUtils.getOSVersion(),
- SystemUtils.getOSArch()));
-
- eventLogger.message(BrokerMessages.MAX_MEMORY(Runtime.getRuntime().maxMemory()));
- }
-
- @Override
- public Broker getBroker()
- {
- return _broker;
- }
-
-}
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
deleted file mode 100644
index fb588875a6..0000000000
--- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * 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.registry;
-
-import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.stats.StatisticsGatherer;
-
-public interface IApplicationRegistry
-{
-
- void initialise(BrokerOptions brokerOptions) throws Exception;
-
- /**
- * Shutdown this Registry
- */
- void close();
-
- Broker getBroker();
-}