use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin in project activemq-artemis by apache.
the class FileConfigurationTest method testBrokerPlugin.
@Test
public void testBrokerPlugin() throws Exception {
FileConfiguration fc = new FileConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager("brokerPlugin.xml");
deploymentManager.addDeployable(fc);
deploymentManager.readConfiguration();
List<ActiveMQServerPlugin> brokerPlugins = fc.getBrokerPlugins();
assertEquals(2, brokerPlugins.size());
assertTrue(brokerPlugins.get(0) instanceof EmptyPlugin1);
assertTrue(brokerPlugins.get(1) instanceof EmptyPlugin2);
}
use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin in project activemq-artemis by apache.
the class StompPluginTest method createServer.
@Override
protected JMSServerManager createServer() throws Exception {
JMSServerManager server = super.createServer();
server.getActiveMQServer().registerBrokerPlugin(verifier);
server.getActiveMQServer().registerBrokerPlugin(new ActiveMQServerPlugin() {
@Override
public void beforeCreateSession(String name, String username, int minLargeMessageSize, RemotingConnection connection, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, boolean xa, String defaultAddress, SessionCallback callback, boolean autoCreateQueues, OperationContext context, Map<SimpleString, RoutingType> prefixes) throws ActiveMQException {
if (connection instanceof StompConnection) {
stompBeforeCreateSession.set(true);
}
}
@Override
public void beforeCloseSession(ServerSession session, boolean failed) throws ActiveMQException {
if (session.getRemotingConnection() instanceof StompConnection) {
stompBeforeRemoveSession.set(true);
}
}
});
return server;
}
use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin in project activemq-artemis by apache.
the class FileConfigurationParser method parseActiveMQServerPlugin.
private ActiveMQServerPlugin parseActiveMQServerPlugin(Node item) {
final String clazz = item.getAttributes().getNamedItem("class-name").getNodeValue();
Map<String, String> properties = getMapOfChildPropertyElements(item);
ActiveMQServerPlugin serverPlugin = AccessController.doPrivileged(new PrivilegedAction<ActiveMQServerPlugin>() {
@Override
public ActiveMQServerPlugin run() {
return (ActiveMQServerPlugin) ClassloadingUtil.newInstanceFromClassLoader(clazz);
}
});
serverPlugin.init(properties);
return serverPlugin;
}
use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin in project activemq-artemis by apache.
the class FileConfigurationParser method parseBrokerPlugins.
private void parseBrokerPlugins(final Element e, final Configuration config) {
NodeList brokerPlugins = e.getElementsByTagName(BROKER_PLUGINS_ELEMENT_NAME);
if (brokerPlugins.getLength() != 0) {
Element node = (Element) brokerPlugins.item(0);
NodeList list = node.getElementsByTagName(BROKER_PLUGIN_ELEMENT_NAME);
for (int i = 0; i < list.getLength(); i++) {
ActiveMQServerPlugin plugin = parseActiveMQServerPlugin(list.item(i));
config.registerBrokerPlugin(plugin);
}
}
}
use of org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin in project activemq-artemis by apache.
the class OpenwirePluginTest method createServer.
@Override
protected ActiveMQServer createServer(boolean realFiles, Configuration configuration, long pageSize, long maxAddressSize, Map<String, AddressSettings> settings) {
ActiveMQServer server = super.createServer(realFiles, configuration, pageSize, maxAddressSize, settings);
server.registerBrokerPlugin(verifier);
server.registerBrokerPlugin(new ActiveMQServerPlugin() {
@Override
public void afterCreateConnection(RemotingConnection connection) throws ActiveMQException {
try {
// Verify that calling getClientID() before initialized doesn't cause an error
// Test for ARTEMIS-1713
connection.getClientID();
} catch (Exception e) {
throw new ActiveMQException(e.getMessage());
}
}
});
configuration.getAddressesSettings().put("autoCreated", new AddressSettings().setAutoDeleteAddresses(true).setAutoDeleteQueues(true).setAutoCreateQueues(true).setAutoCreateAddresses(true));
return server;
}
Aggregations