diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java index 9f3dcfb1e2..479f798fb8 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -126,7 +126,7 @@ public class BrokerService implements Service { private SystemUsage consumerSystemUsaage; private PersistenceAdapter persistenceAdapter; private PersistenceAdapterFactory persistenceFactory; - private DestinationFactory destinationFactory; + protected DestinationFactory destinationFactory; private MessageAuthorizationPolicy messageAuthorizationPolicy; private List transportConnectors = new CopyOnWriteArrayList(); private List networkConnectors = new CopyOnWriteArrayList(); @@ -1370,11 +1370,11 @@ public class BrokerService implements Service { } protected PersistenceAdapter registerPersistenceAdapterMBean(PersistenceAdapter adaptor) throws IOException { - MBeanServer mbeanServer = getManagementContext().getMBeanServer(); - if (mbeanServer != null) { - - - } +// MBeanServer mbeanServer = getManagementContext().getMBeanServer(); +// if (mbeanServer != null) { +// +// +// } return adaptor; } @@ -1487,17 +1487,16 @@ public class BrokerService implements Service { // Add a filter that will stop access to the broker once stopped broker = new MutableBrokerFilter(broker) { public void stop() throws Exception { - setNext(new ErrorBroker("Broker has been stopped: " + this) { + Broker old = this.next.getAndSet(new ErrorBroker("Broker has been stopped: " + this) { // Just ignore additional stop actions. public void stop() throws Exception { } }); - super.stop(); + old.stop(); } }; - RegionBroker rBroker = (RegionBroker)regionBroker; - rBroker.getDestinationStatistics().setEnabled(enableStatistics); +// RegionBroker rBroker = (RegionBroker)regionBroker; if (isUseJmx()) { ManagedRegionBroker managedBroker = (ManagedRegionBroker)regionBroker; @@ -1537,10 +1536,14 @@ public class BrokerService implements Service { configureServices(destinationInterceptors); DestinationInterceptor destinationInterceptor = new CompositeDestinationInterceptor(destinationInterceptors); - RegionBroker regionBroker = null; if (destinationFactory == null) { destinationFactory = new DestinationFactoryImpl(this, getTaskRunnerFactory(), getPersistenceAdapter()); } + return createRegionBroker(destinationInterceptor); + } + + protected Broker createRegionBroker(DestinationInterceptor destinationInterceptor) throws IOException { + RegionBroker regionBroker; if (isUseJmx()) { MBeanServer mbeanServer = getManagementContext().getMBeanServer(); regionBroker = new ManagedRegionBroker(this, mbeanServer, getBrokerObjectName(), getTaskRunnerFactory(), getConsumerSystemUsage(), destinationFactory, @@ -1552,8 +1555,10 @@ public class BrokerService implements Service { regionBroker.setKeepDurableSubsActive(keepDurableSubsActive); regionBroker.setBrokerName(getBrokerName()); - return regionBroker; - } + regionBroker.getDestinationStatistics().setEnabled(enableStatistics); + + return regionBroker; + } /** * Create the default destination interceptor diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java b/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java index 1f304ac9bb..9b5e8f977d 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/MutableBrokerFilter.java @@ -51,7 +51,7 @@ import org.apache.activemq.kaha.Store; */ public class MutableBrokerFilter implements Broker { - private AtomicReference next = new AtomicReference(); + protected AtomicReference next = new AtomicReference(); public MutableBrokerFilter(Broker next) { this.next.set(next); diff --git a/activemq-core/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java b/activemq-core/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java index baf3de7e2d..7b5debe793 100755 --- a/activemq-core/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java +++ b/activemq-core/src/test/java/org/apache/activemq/transport/TransportBrokerTestSupport.java @@ -28,7 +28,7 @@ import org.apache.activemq.broker.TransportConnector; public abstract class TransportBrokerTestSupport extends BrokerTest { - private TransportConnector connector; + protected TransportConnector connector; private ArrayList connections = new ArrayList(); protected void setUp() throws Exception { @@ -49,7 +49,9 @@ public abstract class TransportBrokerTestSupport extends BrokerTest { connection.stop(); iter.remove(); } - connector.stop(); + if( connector!=null ) { + connector.stop(); + } super.tearDown(); }