Search in sources :

Example 16 with JndiBindingRegistry

use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.

the class JMSClusteredTestBase method setupServer1.

/**
 * @throws Exception
 */
private void setupServer1() throws Exception {
    Configuration configuration = createConfigServer(1, 2);
    JMSConfigurationImpl jmsconfig = new JMSConfigurationImpl();
    mBeanServer1 = MBeanServerFactory.createMBeanServer();
    server1 = addServer(ActiveMQServers.newActiveMQServer(configuration, mBeanServer1, enablePersistence()));
    jmsServer1 = new JMSServerManagerImpl(server1, jmsconfig);
    context1 = new InVMNamingContext();
    jmsServer1.setRegistry(new JndiBindingRegistry(context1));
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)

Example 17 with JndiBindingRegistry

use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.

the class JMSBridgeImplTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    Configuration config = createBasicConfig().addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    InVMNamingContext context = new InVMNamingContext();
    jmsServer = new JMSServerManagerImpl(addServer(ActiveMQServers.newActiveMQServer(config, false)));
    jmsServer.setRegistry(new JndiBindingRegistry(context));
    jmsServer.start();
    jmsServer.createQueue(false, JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);
    jmsServer.createQueue(false, JMSBridgeImplTest.TARGET, null, true, "/queue/" + JMSBridgeImplTest.TARGET);
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Before(org.junit.Before)

Example 18 with JndiBindingRegistry

use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.

the class LocalTestServer method start.

@Override
public synchronized void start(final HashMap<String, Object> configuration, final boolean clearJournal) throws Exception {
    if (isStarted()) {
        return;
    }
    if (clearJournal) {
        // Delete the Journal environment
        File dir = new File("target/data");
        boolean deleted = LocalTestServer.deleteDirectory(dir);
        JmsTestLogger.LOGGER.info("Deleted dir: " + dir.getAbsolutePath() + " deleted: " + deleted);
    }
    javax.management.MBeanServer beanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer();
    FileConfiguration fileConfiguration = new FileConfiguration();
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    securityManager.getConfiguration().addUser("guest", "guest");
    securityManager.getConfiguration().setDefaultUser("guest");
    securityManager.getConfiguration().addRole("guest", "guest");
    ActiveMQServerImpl activeMQServer = new ActiveMQServerImpl(fileConfiguration, beanServer, securityManager);
    jmsServerManager = new JMSServerManagerImpl(activeMQServer);
    System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, "" + getServerID());
    jmsServerManager.setRegistry(new JndiBindingRegistry(getInitialContext()));
    FileDeploymentManager deploymentManager = new FileDeploymentManager();
    deploymentManager.addDeployable(fileConfiguration).readConfiguration();
    jmsServerManager.start();
    started = true;
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) File(java.io.File)

Example 19 with JndiBindingRegistry

use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.

the class EmbeddedJMS method start.

@Override
public EmbeddedJMS start() throws Exception {
    super.initStart();
    if (jmsConfiguration != null) {
        serverManager = new JMSServerManagerImpl(activeMQServer, jmsConfiguration);
    } else {
        FileJMSConfiguration fileConfiguration = new FileJMSConfiguration();
        FileDeploymentManager deploymentManager;
        if (configResourcePath != null) {
            deploymentManager = new FileDeploymentManager(configResourcePath);
        } else {
            deploymentManager = new FileDeploymentManager();
        }
        deploymentManager.addDeployable(fileConfiguration);
        deploymentManager.readConfiguration();
        serverManager = new JMSServerManagerImpl(activeMQServer, fileConfiguration);
    }
    if (registry == null) {
        if (context != null)
            registry = new JndiBindingRegistry(context);
        else
            registry = new MapBindingRegistry();
    }
    serverManager.setRegistry(registry);
    serverManager.start();
    return this;
}
Also used : MapBindingRegistry(org.apache.activemq.artemis.core.registry.MapBindingRegistry) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager)

Example 20 with JndiBindingRegistry

use of org.apache.activemq.artemis.core.registry.JndiBindingRegistry in project activemq-artemis by apache.

the class JMSConfigurationTest method testSetupJMSConfiguration.

@Test
public void testSetupJMSConfiguration() throws Exception {
    Context context = new InVMNamingContext();
    ActiveMQServer coreServer = new ActiveMQServerImpl(createDefaultInVMConfig());
    JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
    TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
    List<TransportConfiguration> transportConfigs = new ArrayList<>();
    transportConfigs.add(connectorConfig);
    ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName(RandomUtil.randomString()).setConnectorNames(registerConnectors(coreServer, transportConfigs)).setBindings("/cf/binding1", "/cf/binding2");
    jmsConfiguration.getConnectionFactoryConfigurations().add(cfConfig);
    JMSQueueConfigurationImpl queueConfig = new JMSQueueConfigurationImpl().setName(RandomUtil.randomString()).setDurable(false).setBindings("/queue/binding1", "/queue/binding2");
    jmsConfiguration.getQueueConfigurations().add(queueConfig);
    TopicConfiguration topicConfig = new TopicConfigurationImpl().setName(RandomUtil.randomString()).setBindings("/topic/binding1", "/topic/binding2");
    jmsConfiguration.getTopicConfigurations().add(topicConfig);
    JMSServerManager server = new JMSServerManagerImpl(coreServer, jmsConfiguration);
    server.setRegistry(new JndiBindingRegistry(context));
    server.start();
    for (String binding : cfConfig.getBindings()) {
        Object o = context.lookup(binding);
        Assert.assertNotNull(o);
        Assert.assertTrue(o instanceof ConnectionFactory);
        ConnectionFactory cf = (ConnectionFactory) o;
        Connection connection = cf.createConnection();
        connection.close();
    }
    for (String binding : queueConfig.getBindings()) {
        Object o = context.lookup(binding);
        Assert.assertNotNull(o);
        Assert.assertTrue(o instanceof Queue);
        Queue queue = (Queue) o;
        Assert.assertEquals(queueConfig.getName(), queue.getQueueName());
    }
    for (String binding : topicConfig.getBindings()) {
        Object o = context.lookup(binding);
        Assert.assertNotNull(o);
        Assert.assertTrue(o instanceof Topic);
        Topic topic = (Topic) o;
        Assert.assertEquals(topicConfig.getName(), topic.getTopicName());
    }
    server.stop();
}
Also used : InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Context(javax.naming.Context) JMSServerManager(org.apache.activemq.artemis.jms.server.JMSServerManager) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) ArrayList(java.util.ArrayList) Connection(javax.jms.Connection) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) TopicConfiguration(org.apache.activemq.artemis.jms.server.config.TopicConfiguration) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ConnectionFactory(javax.jms.ConnectionFactory) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) Topic(javax.jms.Topic) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) Queue(javax.jms.Queue) TopicConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.TopicConfigurationImpl) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Test(org.junit.Test)

Aggregations

JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)26 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)25 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)20 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)18 Configuration (org.apache.activemq.artemis.core.config.Configuration)13 Before (org.junit.Before)11 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)4 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)4 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)4 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)3 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)3 Role (org.apache.activemq.artemis.core.security.Role)3 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)3 ArrayList (java.util.ArrayList)2