Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.apache.activemq.artemis.cli.factory.jmx.ManagementFactory;
import org.apache.activemq.artemis.cli.factory.security.SecurityManagerFactory;
import org.apache.activemq.artemis.components.ExternalComponent;
import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.management.ManagementContext;
import org.apache.activemq.artemis.dto.BrokerDTO;
import org.apache.activemq.artemis.dto.ComponentDTO;
Expand Down Expand Up @@ -81,7 +83,33 @@ public Object execute(ActionContext context) throws Exception {

ActiveMQSecurityManager security = SecurityManagerFactory.create(broker.security);

server = BrokerFactory.createServer(broker.server, security);
ActivateCallback activateCallback = new ActivateCallback() {
@Override
public void preActivate() {
try {
managementContext.start();
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.unableStartManagementContext(e);
return;
}
try {
server.getServer().getManagementService().registerHawtioSecurity(managementContext.getArtemisMBeanServerGuard());
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.unableToDeployHawtioMBean(e);
}
}

@Override
public void deActivate() {
try {
server.getServer().getManagementService().unregisterHawtioSecurity();
} catch (Exception e) {
//ok to ignore
}
}
};

server = BrokerFactory.createServer(broker.server, security, activateCallback);

managementContext.start();
server.createComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.net.URI;

import org.apache.activemq.artemis.cli.ConfigurationException;
import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.dto.BrokerDTO;
import org.apache.activemq.artemis.dto.ServerDTO;
import org.apache.activemq.artemis.integration.Broker;
Expand Down Expand Up @@ -53,7 +54,7 @@ public static BrokerDTO createBrokerConfiguration(String configuration,
return createBrokerConfiguration(new URI(configuration), artemisHome, artemisInstance, artemisURIInstance);
}

public static Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security) throws Exception {
public static Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security, ActivateCallback activateCallback) throws Exception {
if (brokerDTO.configuration != null) {
BrokerHandler handler;
URI configURI = brokerDTO.getConfigurationURI();
Expand All @@ -65,7 +66,7 @@ public static Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager s
throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme());
}

return handler.createServer(brokerDTO, security);
return handler.createServer(brokerDTO, security, activateCallback);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/
package org.apache.activemq.artemis.cli.factory;

import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.dto.ServerDTO;
import org.apache.activemq.artemis.integration.Broker;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;

public interface BrokerHandler {

Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security);
Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security, ActivateCallback activateCallback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.activemq.artemis.cli.factory;

import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.dto.ServerDTO;
import org.apache.activemq.artemis.integration.Broker;
import org.apache.activemq.artemis.integration.FileBroker;
Expand All @@ -24,7 +25,7 @@
public class FileBrokerHandler implements BrokerHandler {

@Override
public Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security) {
return new FileBroker(brokerDTO, security);
public Broker createServer(ServerDTO brokerDTO, ActiveMQSecurityManager security, ActivateCallback activateCallback) {
return new FileBroker(brokerDTO, security, activateCallback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
import org.apache.activemq.artemis.core.config.impl.LegacyJMSConfiguration;
import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServiceComponent;
Expand All @@ -33,16 +34,18 @@
public class FileBroker implements Broker {

private final String configurationUrl;
private ActivateCallback activateCallback;

private boolean started;

private final ActiveMQSecurityManager securityManager;

private Map<String, ActiveMQComponent> components;

public FileBroker(ServerDTO broker, ActiveMQSecurityManager security) {
public FileBroker(ServerDTO broker, ActiveMQSecurityManager security, ActivateCallback activateCallback) {
this.securityManager = security;
this.configurationUrl = broker.configuration;
this.activateCallback = activateCallback;
}

@Override
Expand Down Expand Up @@ -116,7 +119,7 @@ public void createComponents() throws Exception {

createDirectories(configuration);

components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer());
components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer(), activateCallback);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void startWithoutJMS() throws Exception {
serverDTO.configuration = "broker-nojms.xml";
FileBroker broker = null;
try {
broker = new FileBroker(serverDTO, new ActiveMQJAASSecurityManager());
broker = new FileBroker(serverDTO, new ActiveMQJAASSecurityManager(), null);
broker.start();
JMSServerManagerImpl jmsServerManager = (JMSServerManagerImpl) broker.getComponents().get("jms");
Assert.assertNull(jmsServerManager);
Expand All @@ -70,8 +70,8 @@ public void startTwoBrokersWithSameDataDir() throws Exception {
ServerDTO serverDTO2 = new ServerDTO();
serverDTO1.configuration = "FileBrokerTest-broker1.xml";
serverDTO2.configuration = "FileBrokerTest-broker2.xml";
FileBroker broker1 = new FileBroker(serverDTO1, new ActiveMQJAASSecurityManager());
FileBroker broker2 = new FileBroker(serverDTO2, new ActiveMQJAASSecurityManager());
FileBroker broker1 = new FileBroker(serverDTO1, new ActiveMQJAASSecurityManager(), null);
FileBroker broker2 = new FileBroker(serverDTO2, new ActiveMQJAASSecurityManager(), null);
try {
broker1.start();
Assert.assertTrue(broker1.isStarted());
Expand Down Expand Up @@ -115,7 +115,7 @@ public void testConfigFileReload() throws Exception {
securityConfiguration.addUser("myUser", "myPass");
securityConfiguration.addRole("myUser", "guest");
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
broker = new FileBroker(serverDTO, securityManager);
broker = new FileBroker(serverDTO, securityManager, null);
broker.start();
ActiveMQServerImpl activeMQServer = (ActiveMQServerImpl) broker.getComponents().get("core");
Assert.assertNotNull(activeMQServer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ public interface ActiveMQServerControl {
@Attribute(desc = ADDRESS_MEMORY_USAGE_PERCENTAGE_DESCRIPTION)
int getAddressMemoryUsagePercentage();

@Attribute(desc = "Returns the HA Policy of this broker as a String")
String getHAPolicy();

/**
* Returns the runtime size of the authentication cache
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,8 @@ private String getBrokerProperties() {
return "";
}
}

public ObjectName getManagementContextObjectName() throws Exception {
return ObjectName.getInstance(String.format("hawtio:type=security,area=jmx,name=ArtemisJMXSecurity"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ int changeMessagesPriority(@Parameter(name = "filter", desc = "A message filter
CompositeData[] browse(@Parameter(name = "page", desc = "Current page") int page,
@Parameter(name = "pageSize", desc = "Page size") int pageSize) throws Exception;

@Operation(desc = "Browse Messages", impact = MBeanOperationInfo.ACTION)
CompositeData[] browse(@Parameter(name = "page", desc = "Current page") int page,
@Parameter(name = "pageSize", desc = "Page size") int pageSize,
@Parameter(name = "filter", desc = "filter") String filter) throws Exception;

/**
* Resets the MessagesAdded property
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
public final class ResourceNames {
public static final String BROKER = "broker";

public static final String MANAGEMENT_SECURITY = "managementsecurity";

public static final String QUEUE = "queue.";

public static final String ADDRESS = "address.";
Expand Down
13 changes: 13 additions & 0 deletions artemis-hawtio/activemq-branding/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@
<map from="${basedir}/src/main/webapp/" to="" />
</pathconvert>
<echo>Files: ${plugin-scripts}</echo>
<!--<replace file="${webapp-outdir}/plugin/js/brandingPlugin.js">
<replacefilter token="@artemis.version@" value="${project.version}"/>
</replace>-->

</target>
<!-- this exports plugin-scripts to the maven build, without
Expand Down Expand Up @@ -254,6 +257,16 @@
<exclude>log4j.properties</exclude>
</excludes>
</resource>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<exclude>log4j.properties</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
Expand Down
Loading