This closes #3311
This commit is contained in:
commit
0c5921eef6
|
@ -109,7 +109,6 @@ public class Run extends LockAbstract {
|
|||
|
||||
server = BrokerFactory.createServer(broker.server, securityManager, activateCallback);
|
||||
|
||||
managementContext.start();
|
||||
server.createComponents();
|
||||
AtomicBoolean serverActivationFailed = new AtomicBoolean(false);
|
||||
server.getServer().registerActivationFailureListener(exception -> serverActivationFailed.set(true));
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
|||
public class FileBroker implements Broker {
|
||||
|
||||
private final String configurationUrl;
|
||||
private ActivateCallback activateCallback;
|
||||
private final ActivateCallback activateCallback;
|
||||
|
||||
private boolean started;
|
||||
|
||||
|
|
|
@ -17,18 +17,17 @@
|
|||
package org.apache.activemq.artemis.core.server.management;
|
||||
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
|
||||
import org.apache.activemq.artemis.core.config.JMXConnectorConfiguration;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
import org.apache.activemq.artemis.core.server.ServiceComponent;
|
||||
import org.apache.activemq.artemis.core.server.management.impl.HawtioSecurityControlImpl;
|
||||
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
||||
|
||||
public class ManagementContext implements ServiceComponent {
|
||||
private AtomicBoolean isStarted = new AtomicBoolean(false);
|
||||
|
||||
private volatile boolean isStarted = false;
|
||||
private JMXAccessControlList accessControlList;
|
||||
private JMXConnectorConfiguration jmxConnectorConfiguration;
|
||||
private ManagementConnector mBeanServer;
|
||||
|
@ -37,6 +36,14 @@ public class ManagementContext implements ServiceComponent {
|
|||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
if (isStarted) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (isStarted) {
|
||||
return;
|
||||
}
|
||||
isStarted = true;
|
||||
if (accessControlList != null) {
|
||||
//if we are configured then assume we want to use the guard so set the system property
|
||||
System.setProperty("javax.management.builder.initial", ArtemisMBeanServerBuilder.class.getCanonicalName());
|
||||
|
@ -49,12 +56,19 @@ public class ManagementContext implements ServiceComponent {
|
|||
mBeanServer = new ManagementConnector(jmxConnectorConfiguration, securityManager);
|
||||
mBeanServer.start();
|
||||
}
|
||||
isStarted.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (isStarted.getAndSet(false)) {
|
||||
if (!isStarted) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (!isStarted) {
|
||||
return;
|
||||
}
|
||||
isStarted = false;
|
||||
if (mBeanServer != null) {
|
||||
mBeanServer.stop();
|
||||
}
|
||||
|
@ -70,7 +84,7 @@ public class ManagementContext implements ServiceComponent {
|
|||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return isStarted.get();
|
||||
return isStarted;
|
||||
}
|
||||
|
||||
public void setAccessControlList(JMXAccessControlList accessControlList) {
|
||||
|
|
Loading…
Reference in New Issue