Search in sources :

Example 6 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project wildfly by wildfly.

the class ConnectorServiceDefinition method createConnectorServiceConfiguration.

static ConnectorServiceConfiguration createConnectorServiceConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    final String factoryClass = CommonAttributes.FACTORY_CLASS.resolveModelAttribute(context, model).asString();
    Map<String, String> unwrappedParameters = CommonAttributes.PARAMS.unwrap(context, model);
    Map<String, Object> parameters = new HashMap<String, Object>(unwrappedParameters);
    return new ConnectorServiceConfiguration().setFactoryClassName(factoryClass).setParams(parameters).setName(name);
}
Also used : HashMap(java.util.HashMap) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)

Example 7 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class ConnectorsServiceTest method testConnectorServiceUsedDirectly.

/**
 * Test that connectors can be created and destroyed directly.
 *
 * @throws Exception
 */
@Test
public void testConnectorServiceUsedDirectly() throws Exception {
    // Initial setup with existing connector service
    ConnectorServiceConfiguration connectorServiceConfiguration = new ConnectorServiceConfiguration().setFactoryClassName(FakeConnectorServiceFactory.class.getCanonicalName()).setParams(new HashMap<String, Object>()).setName("myfact");
    configuration.setConnectorServiceConfigurations(Arrays.asList(connectorServiceConfiguration));
    ConnectorsService connectorsService = new ConnectorsService(configuration, null, null, null, serviceRegistry);
    connectorsService.start();
    assertEquals(1, connectorsService.getConnectors().size());
    // Add with same name
    FakeConnectorServiceFactory connectorServiceFactory = new FakeConnectorServiceFactory();
    try {
        connectorsService.createService(connectorServiceConfiguration, connectorServiceFactory);
        assertTrue("Expected exception when creating service with same name", false);
    } catch (Exception e) {
    }
    // Add unique with same factory
    ConnectorServiceConfiguration additionalServiceConfiguration = new ConnectorServiceConfiguration().setFactoryClassName(FakeConnectorServiceFactory.class.getCanonicalName()).setParams(new HashMap<String, Object>()).setName("myfact2");
    connectorsService.createService(additionalServiceConfiguration, connectorServiceFactory);
    assertEquals(2, connectorsService.getConnectors().size());
    // Destroy existing connector services
    connectorsService.destroyService("myfact");
    assertEquals(1, connectorsService.getConnectors().size());
    connectorsService.destroyService("myfact2");
    assertEquals(0, connectorsService.getConnectors().size());
    // Destroy non-existing connector service
    try {
        connectorsService.destroyService("myfact");
        assertTrue("Expected exception when destroying non-existing service", false);
    } catch (Exception e) {
    }
}
Also used : FakeConnectorServiceFactory(org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory) HashMap(java.util.HashMap) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration) ConnectorsService(org.apache.activemq.artemis.core.server.impl.ConnectorsService) Test(org.junit.Test)

Example 8 with ConnectorServiceConfiguration

use of org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration in project activemq-artemis by apache.

the class ServiceRegistryImpl method getConnectorServices.

@Override
public Collection<Pair<ConnectorServiceFactory, ConnectorServiceConfiguration>> getConnectorServices(List<ConnectorServiceConfiguration> configs) {
    if (configs != null) {
        for (final ConnectorServiceConfiguration config : configs) {
            if (connectorServices.get(config.getConnectorName()) == null) {
                ConnectorServiceFactory factory = loadClass(config.getFactoryClassName());
                addConnectorService(factory, config);
            }
        }
    }
    return connectorServices.values();
}
Also used : ConnectorServiceFactory(org.apache.activemq.artemis.core.server.ConnectorServiceFactory) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)

Aggregations

ConnectorServiceConfiguration (org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration)8 HashMap (java.util.HashMap)5 ConnectorsService (org.apache.activemq.artemis.core.server.impl.ConnectorsService)3 FakeConnectorServiceFactory (org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 ConnectorServiceFactory (org.apache.activemq.artemis.core.server.ConnectorServiceFactory)2 NodeList (org.w3c.dom.NodeList)2 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)1 ConnectorService (org.apache.activemq.artemis.core.server.ConnectorService)1 FakeConnectorService (org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1