Search in sources :

Example 1 with ActiveMQServerPlugin

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);
}
Also used : ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) Test(org.junit.Test)

Example 2 with ActiveMQServerPlugin

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;
}
Also used : OperationContext(org.apache.activemq.artemis.core.persistence.OperationContext) JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) ServerSession(org.apache.activemq.artemis.core.server.ServerSession) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SessionCallback(org.apache.activemq.artemis.spi.core.protocol.SessionCallback) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) StompConnection(org.apache.activemq.artemis.core.protocol.stomp.StompConnection) RoutingType(org.apache.activemq.artemis.api.core.RoutingType)

Example 3 with ActiveMQServerPlugin

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;
}
Also used : ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 4 with ActiveMQServerPlugin

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);
        }
    }
}
Also used : ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 5 with ActiveMQServerPlugin

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;
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQServerPlugin(org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin) RemotingConnection(org.apache.activemq.artemis.spi.core.protocol.RemotingConnection) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) JMSException(javax.jms.JMSException)

Aggregations

ActiveMQServerPlugin (org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin)7 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 ServerSession (org.apache.activemq.artemis.core.server.ServerSession)2 RemotingConnection (org.apache.activemq.artemis.spi.core.protocol.RemotingConnection)2 Test (org.junit.Test)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 JMSException (javax.jms.JMSException)1 RoutingType (org.apache.activemq.artemis.api.core.RoutingType)1 FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)1 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)1 StompConnection (org.apache.activemq.artemis.core.protocol.stomp.StompConnection)1 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)1 JMSServerManager (org.apache.activemq.artemis.jms.server.JMSServerManager)1 SessionCallback (org.apache.activemq.artemis.spi.core.protocol.SessionCallback)1 CriticalComponent (org.apache.activemq.artemis.utils.critical.CriticalComponent)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1