use of org.apache.activemq.artemis.core.config.impl.FileConfiguration in project activemq-artemis by apache.
the class ActiveMQServers method newActiveMQServer.
public static ActiveMQServer newActiveMQServer(final String configURL, final MBeanServer mbeanServer, final ActiveMQSecurityManager securityManager) throws Exception {
FileConfiguration config = new FileConfiguration();
new FileDeploymentManager(configURL).addDeployable(config).readConfiguration();
ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, mbeanServer, securityManager);
return server;
}
use of org.apache.activemq.artemis.core.config.impl.FileConfiguration 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.core.config.impl.FileConfiguration 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.core.config.impl.FileConfiguration in project activemq-artemis by apache.
the class DBOption method parseDBConfig.
private void parseDBConfig() throws Exception {
if (jdbc == null) {
FileConfiguration fileConfiguration = getFileConfiguration();
jdbc = fileConfiguration.isJDBC();
if (jdbc) {
DatabaseStorageConfiguration storageConfiguration = (DatabaseStorageConfiguration) fileConfiguration.getStoreConfiguration();
jdbcBindings = storageConfiguration.getBindingsTableName();
jdbcMessages = storageConfiguration.getMessageTableName();
jdbcLargeMessages = storageConfiguration.getLargeMessageTableName();
jdbcPageStore = storageConfiguration.getPageStoreTableName();
jdbcNodeManager = storageConfiguration.getNodeManagerStoreTableName();
jdbcURL = storageConfiguration.getJdbcConnectionUrl();
jdbcClassName = storageConfiguration.getJdbcDriverClassName();
}
}
}
use of org.apache.activemq.artemis.core.config.impl.FileConfiguration 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;
}
Aggregations