Search in sources :

Example 1 with FileConfiguration

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;
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager)

Example 2 with FileConfiguration

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;
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) File(java.io.File)

Example 3 with 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();
}
Also used : ProtocolManagerFactory(org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory) ServiceTracker(org.osgi.util.tracker.ServiceTracker) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) File(java.io.File) BundleContext(org.osgi.framework.BundleContext) Activate(org.osgi.service.component.annotations.Activate)

Example 4 with FileConfiguration

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();
        }
    }
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)

Example 5 with FileConfiguration

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;
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) ActiveMQComponent(org.apache.activemq.artemis.core.server.ActiveMQComponent) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) TopicConfiguration(org.apache.activemq.artemis.jms.server.config.TopicConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager)

Aggregations

FileConfiguration (org.apache.activemq.artemis.core.config.impl.FileConfiguration)14 FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)12 FileJMSConfiguration (org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration)6 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)5 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)5 File (java.io.File)4 SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)3 InVMLoginModule (org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule)3 Test (org.junit.Test)3 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)2 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 CoreAddressConfiguration (org.apache.activemq.artemis.core.config.CoreAddressConfiguration)1 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)1 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)1 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)1