This closes #24 Service Registry Interface

This commit is contained in:
Clebert Suconic 2015-06-11 09:04:58 -04:00
commit 7a432afffe
9 changed files with 82 additions and 15 deletions

View File

@ -52,10 +52,10 @@ import org.apache.activemq.artemis.core.server.ActiveMQComponent;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
import org.apache.activemq.artemis.core.server.impl.ServerSessionImpl;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistry;
import org.apache.activemq.artemis.core.server.management.ManagementService;
import org.apache.activemq.artemis.spi.core.protocol.ConnectionEntry;
import org.apache.activemq.artemis.spi.core.protocol.ProtocolManager;

View File

@ -78,6 +78,8 @@ public interface ActiveMQServer extends ActiveMQComponent
Configuration getConfiguration();
ServiceRegistry getServiceRegistry();
RemotingService getRemotingService();
StorageManager getStorageManager();

View File

@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.core.server;
import org.apache.activemq.artemis.api.core.Interceptor;
import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
/**
* A holder for common services leveraged by the broker.
*/
public interface ServiceRegistry
{
ExecutorService getExecutorService();
void setExecutorService(ExecutorService executorService);
ScheduledExecutorService getScheduledExecutorService();
void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService);
void addConnectorService(ConnectorServiceFactory connectorServiceFactory, ConnectorServiceConfiguration configuration);
void removeConnectorService(ConnectorServiceConfiguration configuration);
Collection<Pair<ConnectorServiceFactory, ConnectorServiceConfiguration>> getConnectorServices();
void addIncomingInterceptor(String name, Interceptor interceptor);
void removeIncomingInterceptor(String name);
Collection<Interceptor> getIncomingInterceptors();
Interceptor getIncomingInterceptor(String name);
void addOutgoingInterceptor(String name, Interceptor interceptor);
Interceptor getOutgoingInterceptor(String name);
void removeOutgoingInterceptor(String name);
Collection<Interceptor> getOutgoingInterceptors();
}

View File

@ -102,6 +102,7 @@ import org.apache.activemq.artemis.core.server.QueueCreator;
import org.apache.activemq.artemis.core.server.QueueFactory;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.ServerSessionFactory;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
import org.apache.activemq.artemis.core.server.cluster.BackupManager;
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
import org.apache.activemq.artemis.core.server.cluster.Transformer;
@ -343,7 +344,7 @@ public class ActiveMQServerImpl implements ActiveMQServer
this.parentServer = parentServer;
this.serviceRegistry = serviceRegistry == null ? new ServiceRegistry() : serviceRegistry;
this.serviceRegistry = serviceRegistry == null ? new ServiceRegistryImpl() : serviceRegistry;
}
// life-cycle methods

View File

@ -31,6 +31,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.ConnectorService;
import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
import org.apache.activemq.artemis.utils.ClassloadingUtil;
import org.apache.activemq.artemis.utils.ConfigurationHelper;

View File

@ -27,8 +27,9 @@ import org.apache.activemq.artemis.api.core.Interceptor;
import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
public class ServiceRegistry
public class ServiceRegistryImpl implements ServiceRegistry
{
private ExecutorService executorService;
@ -43,11 +44,11 @@ public class ServiceRegistry
private Map<String, Pair<ConnectorServiceFactory, ConnectorServiceConfiguration>> connectorServices;
public ServiceRegistry()
public ServiceRegistryImpl()
{
this.incomingInterceptors = new ConcurrentHashMap<String, Interceptor>();
this.outgoingInterceptors = new ConcurrentHashMap<String, Interceptor>();
this.connectorServices = new ConcurrentHashMap<String, Pair<ConnectorServiceFactory, ConnectorServiceConfiguration>>();
this.incomingInterceptors = new ConcurrentHashMap<>();
this.outgoingInterceptors = new ConcurrentHashMap<>();
this.connectorServices = new ConcurrentHashMap<>();
}
public ExecutorService getExecutorService()

View File

@ -24,10 +24,11 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistry;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -36,13 +37,11 @@ public class SuppliedThreadPoolTest extends ActiveMQTestBase
{
private ActiveMQServer server;
private Thread serverThread;
private ServiceRegistry serviceRegistry;
@Before
public void setup() throws Exception
{
serviceRegistry = new ServiceRegistry();
serviceRegistry = new ServiceRegistryImpl();
serviceRegistry.setExecutorService(Executors.newFixedThreadPool(1));
serviceRegistry.setScheduledExecutorService(Executors.newScheduledThreadPool(1));
server = new ActiveMQServerImpl(null, null, null, null, serviceRegistry);

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorServiceFactory;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.core.config.Configuration;
@ -27,7 +28,7 @@ import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.server.ConnectorService;
import org.apache.activemq.artemis.core.server.impl.ConnectorsService;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistry;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl;
import org.apache.activemq.artemis.tests.unit.core.config.impl.fakes.FakeConnectorService;
import org.junit.Before;
import org.junit.Test;
@ -43,7 +44,7 @@ public class ConnectorsServiceTest extends ActiveMQTestBase
{
// Setup Configuration
configuration = new ConfigurationImpl();
serviceRegistry = new ServiceRegistry();
serviceRegistry = new ServiceRegistryImpl();
}
/**

View File

@ -24,11 +24,12 @@ import java.util.List;
import org.apache.activemq.artemis.api.core.Interceptor;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.server.ServiceRegistry;
import org.apache.activemq.artemis.tests.unit.core.remoting.server.impl.fake.FakeInterceptor;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.remoting.server.impl.RemotingServiceImpl;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistry;
import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl;
import org.junit.Before;
import org.junit.Test;
@ -45,7 +46,7 @@ public class RemotingServiceImplTest
@Before
public void setUp() throws Exception
{
serviceRegistry = new ServiceRegistry();
serviceRegistry = new ServiceRegistryImpl();
configuration = new ConfigurationImpl();
configuration.setAcceptorConfigurations(new HashSet<TransportConfiguration>());
remotingService = new RemotingServiceImpl(null, configuration, null, null, null, null, null, serviceRegistry);