use of org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration in project activemq-artemis by apache.
the class Configurable method readConfiguration.
protected FileConfiguration readConfiguration() throws Exception {
FileConfiguration fileConfiguration = new FileConfiguration();
if (getBrokerInstance() == null) {
final String defaultLocation = "./data";
fileConfiguration = new FileConfiguration();
// These will be the default places in case the file can't be loaded
fileConfiguration.setBindingsDirectory(defaultLocation + "/bindings");
fileConfiguration.setJournalDirectory(defaultLocation + "/journal");
fileConfiguration.setLargeMessagesDirectory(defaultLocation + "/largemessages");
fileConfiguration.setPagingDirectory(defaultLocation + "/paging");
fileConfiguration.setBrokerInstance(new File("."));
} else {
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
String serverConfiguration = getBrokerDTO().server.getConfigurationURI().toASCIIString();
FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(serverConfiguration);
fileDeploymentManager.addDeployable(fileConfiguration).addDeployable(jmsConfiguration);
fileDeploymentManager.readConfiguration();
fileConfiguration.setBrokerInstance(new File(getBrokerInstance()));
}
return fileConfiguration;
}
use of org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration in project activemq-artemis by apache.
the class OsgiBroker method activate.
@Activate
public void activate(ComponentContext cctx) throws Exception {
final BundleContext context = cctx.getBundleContext();
final Dictionary<String, Object> properties = cctx.getProperties();
configurationUrl = getMandatory(properties, "config");
name = getMandatory(properties, "name");
rolePrincipalClass = (String) properties.get("rolePrincipalClass");
String domain = getMandatory(properties, "domain");
ActiveMQJAASSecurityManager security = new ActiveMQJAASSecurityManager(domain);
if (rolePrincipalClass != null) {
security.setRolePrincipalClass(rolePrincipalClass);
}
String brokerInstance = null;
String karafDataDir = System.getProperty("karaf.data");
if (karafDataDir != null) {
brokerInstance = karafDataDir + "/artemis/" + name;
}
// todo if we start to pullout more configs from the main config then we
// should pull out the configuration objects from factories if available
FileConfiguration configuration = new FileConfiguration();
if (brokerInstance != null) {
configuration.setBrokerInstance(new File(brokerInstance));
}
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl);
fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration).readConfiguration();
components = fileDeploymentManager.buildService(security, ManagementFactory.getPlatformMBeanServer());
final ActiveMQServer server = (ActiveMQServer) components.get("core");
String[] requiredProtocols = getRequiredProtocols(server.getConfiguration().getAcceptorConfigurations());
ServerTrackerCallBack callback = new ServerTrackerCallBackImpl(server, context, properties);
StoreConfiguration storeConfiguration = server.getConfiguration().getStoreConfiguration();
String dataSourceName = String.class.cast(properties.get("dataSourceName"));
if (storeConfiguration != null && storeConfiguration.getStoreType() == StoreType.DATABASE && dataSourceName != null && !dataSourceName.isEmpty()) {
callback.setDataSourceDependency(true);
String filter = "(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=" + dataSourceName + "))";
DataSourceTracker trackerCust = new DataSourceTracker(name, context, DatabaseStorageConfiguration.class.cast(storeConfiguration), (ServerTrackerCallBack) callback);
dataSourceTracker = new ServiceTracker(context, context.createFilter(filter), trackerCust);
dataSourceTracker.open();
}
ProtocolTracker trackerCust = new ProtocolTracker(name, context, requiredProtocols, callback);
tracker = new ServiceTracker(context, ProtocolManagerFactory.class, trackerCust);
tracker.open();
}
use of org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration in project activemq-artemis by apache.
the class FileBroker method start.
@Override
public synchronized void start() throws Exception {
if (started) {
return;
}
// todo if we start to pullout more configs from the main config then we should pull out the configuration objects from factories if available
FileConfiguration configuration = new FileConfiguration();
// Keep this as we still want to parse destinations in the <jms> element
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl);
fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration);
fileDeploymentManager.readConfiguration();
createDirectories(configuration);
/**
* This is a bit of a hack for backwards config compatibility since we no longer want to start the broker
* using the JMSServerManager which would normally deploy JMS destinations. Here we take the JMS destination
* configurations from the parsed JMS configuration and add them to the core configuration.
*
* It's also important here that we are adding them to the core ADDRESS configurations as those will be
* deployed first and therefore their configuration will take precedence over other legacy queue configurations
* which are deployed later. This is so we can maintain support for configurations like those found in the
* bridge and divert examples where there are JMS and core queues with the same name (which was itself a bit
* of a hack).
*
* This should be removed when support for the old "jms" configuation element is also removed.
*/
{
for (JMSQueueConfiguration jmsQueueConfig : jmsConfiguration.getQueueConfigurations()) {
List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations();
coreAddressConfigurations.add(new CoreAddressConfiguration().setName(jmsQueueConfig.getName()).addRoutingType(RoutingType.ANYCAST).addQueueConfiguration(new CoreQueueConfiguration().setAddress(jmsQueueConfig.getName()).setName(jmsQueueConfig.getName()).setFilterString(jmsQueueConfig.getSelector()).setRoutingType(RoutingType.ANYCAST)));
}
for (TopicConfiguration topicConfig : jmsConfiguration.getTopicConfigurations()) {
List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations();
coreAddressConfigurations.add(new CoreAddressConfiguration().setName(topicConfig.getName()).addRoutingType(RoutingType.MULTICAST));
}
}
components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer());
ArrayList<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components);
ActiveMQBootstrapLogger.LOGGER.serverStarting();
for (ActiveMQComponent component : componentsByStartOrder) {
component.start();
}
started = true;
}
use of org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration in project activemq-artemis by apache.
the class JMSServerStartStopTest method setUp.
@Override
@Before
public void setUp() throws Exception {
FileConfiguration fc = new FileConfiguration();
FileJMSConfiguration fileConfiguration = new FileJMSConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager("server-start-stop-config1.xml");
deploymentManager.addDeployable(fc);
deploymentManager.addDeployable(fileConfiguration);
deploymentManager.readConfiguration();
ActiveMQJAASSecurityManager sm = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
ActiveMQServer server = addServer(new ActiveMQServerImpl(fc, sm));
jmsServer = new JMSServerManagerImpl(server, fileConfiguration);
jmsServer.setRegistry(null);
}
use of org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration in project activemq-artemis by apache.
the class JMSServerConfigParserTest method testParsing.
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testParsing() throws Exception {
Configuration config = createDefaultInVMConfig().addConnectorConfiguration("netty", new TransportConfiguration());
String conf = "activemq-jms-for-JMSServerDeployerTest.xml";
FileJMSConfiguration jmsconfig = new FileJMSConfiguration();
FileDeploymentManager deploymentManager = new FileDeploymentManager(conf);
deploymentManager.addDeployable(jmsconfig);
deploymentManager.readConfiguration();
assertEquals(1, jmsconfig.getQueueConfigurations().size());
JMSQueueConfiguration queueConfig = jmsconfig.getQueueConfigurations().get(0);
assertEquals("fullConfigurationQueue", queueConfig.getName());
assertEquals(1, jmsconfig.getTopicConfigurations().size());
TopicConfiguration topicConfig = jmsconfig.getTopicConfigurations().get(0);
assertEquals("fullConfigurationTopic", topicConfig.getName());
}
Aggregations