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));
}
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);
}
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;
}
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;
}
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();
}
Aggregations