Search in sources :

Example 1 with FileJMSConfiguration

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;
}
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 2 with FileJMSConfiguration

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();
}
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 3 with FileJMSConfiguration

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

Example 4 with FileJMSConfiguration

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);
}
Also used : FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) 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) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) Before(org.junit.Before)

Example 5 with FileJMSConfiguration

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());
}
Also used : JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) TopicConfiguration(org.apache.activemq.artemis.jms.server.config.TopicConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) TopicConfiguration(org.apache.activemq.artemis.jms.server.config.TopicConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) Test(org.junit.Test)

Aggregations

FileDeploymentManager (org.apache.activemq.artemis.core.config.FileDeploymentManager)8 FileJMSConfiguration (org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration)8 FileConfiguration (org.apache.activemq.artemis.core.config.impl.FileConfiguration)6 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)3 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)3 File (java.io.File)2 SecurityConfiguration (org.apache.activemq.artemis.core.config.impl.SecurityConfiguration)2 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)2 JMSQueueConfiguration (org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration)2 TopicConfiguration (org.apache.activemq.artemis.jms.server.config.TopicConfiguration)2 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)2 InVMLoginModule (org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)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 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)1