tom

Changed nomenclature from Broker to Registry.

Showing 23 changed files with 102 additions and 102 deletions
package org.onlab.onos.event;
/**
* Base abstraction of an event.
* Base event implementation.
*/
public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, S> {
......
......@@ -10,10 +10,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Base implementation of a manager capable of tracking listeners and
* dispatching events to them.
* Base implementation of an event sink and a registry capable of tracking
* listeners and dispatching events to them as part of event sink processing.
*/
public class AbstractListenerManager<E extends Event, L extends EventListener<E>>
public class AbstractListenerRegistry<E extends Event, L extends EventListener<E>>
implements EventSink<E> {
private final Logger log = getLogger(getClass());
......
......@@ -10,12 +10,12 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Base implementation of event sink broker.
* Base implementation of event sink registry.
*/
public class DefaultEventSinkBroker implements EventSinkBroker {
public class DefaultEventSinkRegistry implements EventSinkRegistry {
private final Map<Class<? extends Event>, EventSink<? extends Event>> sinks =
new ConcurrentHashMap<>();
private final Map<Class<? extends Event>, EventSink<? extends Event>>
sinks = new ConcurrentHashMap<>();
@Override
public <E extends Event> void addSink(Class<E> eventClass, EventSink<E> sink) {
......
package org.onlab.onos.event;
/**
* Abstraction of an event.
* Abstraction of an of a time-stamped event pertaining to an arbitrary subject.
*/
public interface Event<T extends Enum, S extends Object> {
......
......@@ -4,5 +4,5 @@ package org.onlab.onos.event;
* Abstraction of an entity capable of accepting events to be posted and
* then dispatching them to the appropriate event sink.
*/
public interface EventDispatchService extends EventDispatcher, EventSinkBroker {
public interface EventDeliveryService extends EventDispatcher, EventSinkRegistry {
}
......
......@@ -3,10 +3,10 @@ package org.onlab.onos.event;
import java.util.Set;
/**
* Abstraction of an event sink broker capable of tracking sinks based on
* Abstraction of an event sink registry capable of tracking sinks based on
* their event class.
*/
public interface EventSinkBroker {
public interface EventSinkRegistry {
/**
* Adds the specified sink for the given event class.
......
package org.onlab.onos.net.device;
import org.onlab.onos.net.provider.ProviderBroker;
import org.onlab.onos.net.provider.ProviderRegistry;
/**
* Abstraction of a device provider brokerage.
* Abstraction of a device provider registry.
*/
public interface DeviceProviderBroker
extends ProviderBroker<DeviceProvider, DeviceProviderService> {
public interface DeviceProviderRegistry
extends ProviderRegistry<DeviceProvider, DeviceProviderService> {
}
......
package org.onlab.onos.net.flow;
import org.onlab.onos.net.provider.ProviderBroker;
import org.onlab.onos.net.provider.ProviderRegistry;
/**
* Abstraction for a flow rule provider brokerage.
* Abstraction for a flow rule provider registry.
*/
public interface FlowRuleProviderBroker
extends ProviderBroker<FlowRuleProvider, FlowRuleProviderService> {
public interface FlowRuleProviderRegistry
extends ProviderRegistry<FlowRuleProvider, FlowRuleProviderService> {
}
......
package org.onlab.onos.net.host;
import org.onlab.onos.net.provider.ProviderBroker;
import org.onlab.onos.net.provider.ProviderRegistry;
/**
* Abstraction of a host provider brokerage.
* Abstraction of a host provider registry.
*/
public interface HostProviderBroker
extends ProviderBroker<HostProvider, HostProviderService> {
public interface HostProviderRegistry
extends ProviderRegistry<HostProvider, HostProviderService> {
}
......
package org.onlab.onos.net.link;
import org.onlab.onos.net.provider.ProviderBroker;
import org.onlab.onos.net.provider.ProviderRegistry;
/**
* Abstraction of an infrastructure link provider brokerage.
* Abstraction of an infrastructure link provider registry.
*/
public interface LinkProviderBroker
extends ProviderBroker<LinkProvider, LinkProviderService> {
public interface LinkProviderRegistry
extends ProviderRegistry<LinkProvider, LinkProviderService> {
}
......
......@@ -7,13 +7,13 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Base implementation of provider broker.
* Base implementation of provider registry.
*
* @param <P> type of the information provider
* @param <S> type of the provider service
*/
public abstract class AbstractProviderBroker<P extends Provider, S extends ProviderService<P>>
implements ProviderBroker<P, S> {
public abstract class AbstractProviderRegistry<P extends Provider, S extends ProviderService<P>>
implements ProviderRegistry<P, S> {
private final Map<ProviderId, S> services = new HashMap<>();
......
package org.onlab.onos.net.provider;
/**
* Broker used for registering/unregistering information providers with the core.
* Registry for tracking information providers with the core.
*
* @param <P> type of the information provider
* @param <S> type of the provider service
*/
public interface ProviderBroker<P extends Provider, S extends ProviderService<P>> {
public interface ProviderRegistry<P extends Provider, S extends ProviderService<P>> {
/**
* Registers the supplied provider with the core.
......
package org.onlab.onos.net.topology;
import org.onlab.onos.net.provider.ProviderBroker;
import org.onlab.onos.net.provider.ProviderRegistry;
/**
* Abstraction of a network topology provider brokerage.
* Abstraction of a network topology provider registry.
*/
public interface TopologyProviderBroker extends
ProviderBroker<TopologyProvider, TopologyProviderService> {
public interface TopologyProviderRegistry extends
ProviderRegistry<TopologyProvider, TopologyProviderService> {
}
......
......@@ -8,13 +8,13 @@ import static org.junit.Assert.assertTrue;
/**
* Tests of the base listener manager.
*/
public class AbstractListenerManagerTest {
public class AbstractListenerRegistryTest {
@Test
public void basics() {
TestListener listener = new TestListener();
TestListener secondListener = new TestListener();
TestListenerManager manager = new TestListenerManager();
TestListenerRegistry manager = new TestListenerRegistry();
manager.addListener(listener);
manager.addListener(secondListener);
......@@ -35,7 +35,7 @@ public class AbstractListenerManagerTest {
public void badListener() {
TestListener listener = new BrokenListener();
TestListener secondListener = new TestListener();
TestListenerManager manager = new TestListenerManager();
TestListenerRegistry manager = new TestListenerRegistry();
manager.addListener(listener);
manager.addListener(secondListener);
......
......@@ -6,11 +6,11 @@ import org.junit.Test;
import static org.junit.Assert.*;
/**
* Tests of the default event sink broker.
* Tests of the default event sink registry.
*/
public class DefaultEventSinkBrokerTest {
public class DefaultEventSinkRegistryTest {
private DefaultEventSinkBroker broker;
private DefaultEventSinkRegistry registry;
private static class FooEvent extends TestEvent {
public FooEvent(String subject) { super(Type.FOO, subject); }
......@@ -30,23 +30,23 @@ public class DefaultEventSinkBrokerTest {
@Before
public void setUp() {
broker = new DefaultEventSinkBroker();
registry = new DefaultEventSinkRegistry();
}
@Test
public void basics() {
FooSink fooSink = new FooSink();
BarSink barSink = new BarSink();
broker.addSink(FooEvent.class, fooSink);
broker.addSink(BarEvent.class, barSink);
registry.addSink(FooEvent.class, fooSink);
registry.addSink(BarEvent.class, barSink);
assertEquals("incorrect sink count", 2, broker.getSinks().size());
assertEquals("incorrect sink", fooSink, broker.getSink(FooEvent.class));
assertEquals("incorrect sink", barSink, broker.getSink(BarEvent.class));
assertEquals("incorrect sink count", 2, registry.getSinks().size());
assertEquals("incorrect sink", fooSink, registry.getSink(FooEvent.class));
assertEquals("incorrect sink", barSink, registry.getSink(BarEvent.class));
broker.removeSink(FooEvent.class);
assertNull("incorrect sink", broker.getSink(FooEvent.class));
assertEquals("incorrect sink", barSink, broker.getSink(BarEvent.class));
registry.removeSink(FooEvent.class);
assertNull("incorrect sink", registry.getSink(FooEvent.class));
assertEquals("incorrect sink", barSink, registry.getSink(BarEvent.class));
}
}
......
......@@ -6,8 +6,8 @@ import java.util.List;
/**
* Test event listener manager fixture.
*/
public class TestListenerManager
extends AbstractListenerManager<TestEvent, TestListener> {
public class TestListenerRegistry
extends AbstractListenerRegistry<TestEvent, TestListener> {
public final List<Throwable> errors = new ArrayList<>();
......
......@@ -5,9 +5,9 @@ import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.event.AbstractEvent;
import org.onlab.onos.event.DefaultEventSinkBroker;
import org.onlab.onos.event.DefaultEventSinkRegistry;
import org.onlab.onos.event.Event;
import org.onlab.onos.event.EventDispatchService;
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.event.EventSink;
import org.slf4j.Logger;
......@@ -24,8 +24,8 @@ import static org.slf4j.LoggerFactory.getLogger;
*/
@Component(immediate = true)
@Service
public class SimpleEventDispatcher extends DefaultEventSinkBroker
implements EventDispatchService {
public class SimpleEventDispatcher extends DefaultEventSinkRegistry
implements EventDeliveryService {
private final Logger log = getLogger(getClass());
......
......@@ -6,8 +6,8 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.event.AbstractListenerManager;
import org.onlab.onos.event.EventDispatchService;
import org.onlab.onos.event.AbstractListenerRegistry;
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
......@@ -17,11 +17,11 @@ import org.onlab.onos.net.device.DeviceDescription;
import org.onlab.onos.net.device.DeviceEvent;
import org.onlab.onos.net.device.DeviceListener;
import org.onlab.onos.net.device.DeviceProvider;
import org.onlab.onos.net.device.DeviceProviderBroker;
import org.onlab.onos.net.device.DeviceProviderRegistry;
import org.onlab.onos.net.device.DeviceProviderService;
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.AbstractProviderBroker;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
import org.slf4j.Logger;
......@@ -36,8 +36,8 @@ import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true)
@Service
public class SimpleDeviceManager
extends AbstractProviderBroker<DeviceProvider, DeviceProviderService>
implements DeviceService, DeviceProviderBroker {
extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService>
implements DeviceService, DeviceProviderRegistry {
public static final String DEVICE_ID_NULL = "Device ID cannot be null";
public static final String PORT_NUMBER_NULL = "Port number cannot be null";
......@@ -46,17 +46,17 @@ public class SimpleDeviceManager
private final Logger log = getLogger(getClass());
private final AbstractListenerManager<DeviceEvent, DeviceListener>
listenerManager = new AbstractListenerManager<>();
private final AbstractListenerRegistry<DeviceEvent, DeviceListener>
listenerRegistry = new AbstractListenerRegistry<>();
private final DeviceStore store = new DeviceStore();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private EventDispatchService eventDispatcher;
private EventDeliveryService eventDispatcher;
@Activate
public void activate() {
eventDispatcher.addSink(DeviceEvent.class, listenerManager);
eventDispatcher.addSink(DeviceEvent.class, listenerRegistry);
log.info("Started");
}
......@@ -98,12 +98,12 @@ public class SimpleDeviceManager
@Override
public void addListener(DeviceListener listener) {
listenerManager.addListener(listener);
listenerRegistry.addListener(listener);
}
@Override
public void removeListener(DeviceListener listener) {
listenerManager.removeListener(listener);
listenerRegistry.removeListener(listener);
}
@Override
......
......@@ -6,15 +6,15 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.event.AbstractListenerManager;
import org.onlab.onos.event.EventDispatchService;
import org.onlab.onos.event.AbstractListenerRegistry;
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.net.host.HostDescription;
import org.onlab.onos.net.host.HostEvent;
import org.onlab.onos.net.host.HostListener;
import org.onlab.onos.net.host.HostProvider;
import org.onlab.onos.net.host.HostProviderBroker;
import org.onlab.onos.net.host.HostProviderRegistry;
import org.onlab.onos.net.host.HostProviderService;
import org.onlab.onos.net.provider.AbstractProviderBroker;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
import org.slf4j.Logger;
......@@ -26,21 +26,21 @@ import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true)
@Service
public class SimpleHostManager
extends AbstractProviderBroker<HostProvider, HostProviderService>
implements HostProviderBroker {
extends AbstractProviderRegistry<HostProvider, HostProviderService>
implements HostProviderRegistry {
private final Logger log = getLogger(getClass());
private final AbstractListenerManager<HostEvent, HostListener>
listenerManager = new AbstractListenerManager<>();
private final AbstractListenerRegistry<HostEvent, HostListener>
listenerRegistry = new AbstractListenerRegistry<>();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private EventDispatchService eventDispatcher;
private EventDeliveryService eventDispatcher;
@Activate
public void activate() {
eventDispatcher.addSink(HostEvent.class, listenerManager);
eventDispatcher.addSink(HostEvent.class, listenerRegistry);
log.info("Started");
}
......
......@@ -6,15 +6,15 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.event.AbstractListenerManager;
import org.onlab.onos.event.EventDispatchService;
import org.onlab.onos.event.AbstractListenerRegistry;
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.net.link.LinkDescription;
import org.onlab.onos.net.link.LinkEvent;
import org.onlab.onos.net.link.LinkListener;
import org.onlab.onos.net.link.LinkProvider;
import org.onlab.onos.net.link.LinkProviderBroker;
import org.onlab.onos.net.link.LinkProviderRegistry;
import org.onlab.onos.net.link.LinkProviderService;
import org.onlab.onos.net.provider.AbstractProviderBroker;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
import org.slf4j.Logger;
......@@ -26,20 +26,20 @@ import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true)
@Service
public class SimpleLinkManager
extends AbstractProviderBroker<LinkProvider, LinkProviderService>
implements LinkProviderBroker {
extends AbstractProviderRegistry<LinkProvider, LinkProviderService>
implements LinkProviderRegistry {
private final Logger log = getLogger(getClass());
private final AbstractListenerManager<LinkEvent, LinkListener>
listenerManager = new AbstractListenerManager<>();
private final AbstractListenerRegistry<LinkEvent, LinkListener>
listenerRegistry = new AbstractListenerRegistry<>();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private EventDispatchService eventDispatcher;
private EventDeliveryService eventDispatcher;
@Activate
public void activate() {
eventDispatcher.addSink(LinkEvent.class, listenerManager);
eventDispatcher.addSink(LinkEvent.class, listenerRegistry);
log.info("Started");
}
......
......@@ -8,7 +8,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.device.DeviceProvider;
import org.onlab.onos.net.device.DeviceProviderBroker;
import org.onlab.onos.net.device.DeviceProviderRegistry;
import org.onlab.onos.net.device.DeviceProviderService;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
......@@ -27,7 +27,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceProviderBroker providerBroker;
protected DeviceProviderRegistry providerRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OpenFlowController controller;
......@@ -43,13 +43,13 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
@Activate
public void activate() {
providerService = providerBroker.register(this);
providerService = providerRegistry.register(this);
log.info("Started");
}
@Deactivate
public void deactivate() {
providerBroker.unregister(this);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
}
......
......@@ -7,7 +7,7 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.host.HostProvider;
import org.onlab.onos.net.host.HostProviderBroker;
import org.onlab.onos.net.host.HostProviderRegistry;
import org.onlab.onos.net.host.HostProviderService;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
......@@ -26,7 +26,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostProviderBroker providerBroker;
protected HostProviderRegistry providerRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OpenFlowController controller;
......@@ -42,13 +42,13 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
@Activate
public void activate() {
providerService = providerBroker.register(this);
providerService = providerRegistry.register(this);
log.info("Started");
}
@Deactivate
public void deactivate() {
providerBroker.unregister(this);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
}
......
......@@ -6,7 +6,7 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.onos.net.link.LinkProvider;
import org.onlab.onos.net.link.LinkProviderBroker;
import org.onlab.onos.net.link.LinkProviderRegistry;
import org.onlab.onos.net.link.LinkProviderService;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
......@@ -25,7 +25,7 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LinkProviderBroker providerBroker;
protected LinkProviderRegistry providerRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OpenFlowController controller;
......@@ -41,13 +41,13 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
@Activate
public void activate() {
providerService = providerBroker.register(this);
providerService = providerRegistry.register(this);
log.info("Started");
}
@Deactivate
public void deactivate() {
providerBroker.unregister(this);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
}
......