use of org.apache.activemq.artemis.core.server.ConnectorService in project activemq-artemis by apache.
the class ConnectorsServiceTest method testConnectorsServiceUsesInjectedConnectorServiceFactory.
/**
* Test that the connectors added via the service registry are added to the connectorsService,
*
* @throws Exception
*/
@Test
public void testConnectorsServiceUsesInjectedConnectorServiceFactory() throws Exception {
ConnectorServiceConfiguration connectorServiceConfiguration = new ConnectorServiceConfiguration().setFactoryClassName(null).setParams(new HashMap<String, Object>()).setName("myfact");
// Creates a fake connector service factory that returns the fake connector service object
ConnectorService connectorService = new FakeConnectorService();
FakeConnectorServiceFactory connectorServiceFactory = new FakeConnectorServiceFactory();
serviceRegistry.addConnectorService(connectorServiceFactory, connectorServiceConfiguration);
ConnectorsService connectorsService = new ConnectorsService(configuration, null, null, null, serviceRegistry);
connectorsService.start();
assertTrue(connectorsService.getConnectors().size() == 1);
assertTrue(connectorsService.getConnectors().values().contains(connectorServiceFactory.getConnectorService()));
}
use of org.apache.activemq.artemis.core.server.ConnectorService in project activemq-artemis by apache.
the class ConnectorsService method destroyService.
public synchronized void destroyService(String name) throws Exception {
if (!connectors.containsKey(name)) {
throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Connector service " + name + " does not exist");
}
ConnectorService connectorService = connectors.get(name);
connectorService.stop();
connectors.remove(name);
}
use of org.apache.activemq.artemis.core.server.ConnectorService in project activemq-artemis by apache.
the class ConnectorsService method createService.
public synchronized void createService(ConnectorServiceConfiguration info, ConnectorServiceFactory factory) throws Exception {
if (connectors.containsKey(info.getConnectorName())) {
throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Connector service " + info.getConnectorName() + " already created");
}
if (info.getParams() != null) {
Set<String> invalid = ConfigurationHelper.checkKeys(factory.getAllowableProperties(), info.getParams().keySet());
if (!invalid.isEmpty()) {
throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Invalid connector keys for connector service " + info.getConnectorName() + ": " + ConfigurationHelper.stringSetToCommaListString(invalid));
}
}
Set<String> invalid = ConfigurationHelper.checkKeysExist(factory.getRequiredProperties(), info.getParams().keySet());
if (!invalid.isEmpty()) {
throw ActiveMQExceptionType.GENERIC_EXCEPTION.createException("Missing connector keys for connector service " + info.getConnectorName() + ": " + ConfigurationHelper.stringSetToCommaListString(invalid));
}
ConnectorService connectorService = factory.createConnectorService(info.getConnectorName(), info.getParams(), storageManager, postOffice, scheduledPool);
connectorService.start();
connectors.put(info.getConnectorName(), connectorService);
}
Aggregations