import org.opendaylight.protocol.bgp.rib.impl.BGPPeer;
import org.opendaylight.protocol.bgp.rib.impl.RIBImpl;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import com.google.common.base.Preconditions;
package org.opendaylight.protocol.bgp.rib.impl;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
/**
* BGP interface. At this time it only supports listening to changes seen by the backing device, typically a network
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import com.google.common.base.Preconditions;
@Override
public ListenerRegistration<BGPSessionListener> registerUpdateListener(final BGPSessionListener listener, final ReconnectStrategyFactory tcpStrategyFactory, final ReconnectStrategy sessionStrategy) {
final Future<Void> s = this.dispatcher.createReconnectingClient(address, this.proposal.getProposal(), listener, tcpStrategyFactory, sessionStrategy);
- return new ListenerRegistration<BGPSessionListener>(listener) {
+ return new AbstractListenerRegistration<BGPSessionListener>(listener) {
@Override
protected void removeRegistration() {
s.cancel(true);
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.BgpParameters;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
public class BGPImplTest {
return new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000);
}
}, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000));
- assertEquals(SimpleSessionListener.class, reg.getListener().getClass());
+ assertEquals(SimpleSessionListener.class, reg.getInstance().getClass());
}
@After
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
import org.opendaylight.protocol.bgp.rib.impl.BGP;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.NotifyBuilder;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Keepalive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.BgpParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.c.parameters.MultiprotocolCase;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* This class has @Subscribe annotated methods which receive events from {@link EventBus} . Events are produced by
* {@link BGPMock}, and each instance notifies exactly one {@link BGPSessionListener}.
*/
-final class EventBusRegistration extends ListenerRegistration<BGPSessionListener> {
+final class EventBusRegistration extends AbstractListenerRegistration<BGPSessionListener> {
private static final Logger LOG = LoggerFactory.getLogger(EventBusRegistration.class);
@Subscribe
public void onMessage(final Notification message) {
- sendMessage(this.getListener(), message);
+ sendMessage(this.getInstance(), message);
}
@Override
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.concepts;
-
-/**
- * Marker interface for objects which are immutable. This interface should be used directly on objects, preferably
- * final, which are eligible for the JSR-305 @Immutable annotation and objects implementing this interface are required
- * to abide to interface contract specified by @Immutable. The reason for the existence of this interface is twofold:
- * unlike @Immutable, it is visible at runtime and objects can be quickly checked for compliance using a quick
- * 'instanceof' check. This is useful for code which needs to capture a point-in-time snapshot of otherwise unknown
- * objects -- a typical example being logging/tracing systems. Such systems would normally have to rely on serializing
- * the object to get a stable checkpoint. Objects marked with this interface are guaranteed to remain stable, thus
- * already being a checkpoint for all intents and purposes, so aside from retaining a reference no further action on
- * them is necessary.
- *
- * @deprecated Use {@link org.opendaylight.yangtools.concepts.Immutable} instead
- */
-@Deprecated
-public interface Immutable {
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.concepts;
-
-import java.util.EventListener;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-import com.google.common.base.Preconditions;
-
-/**
- * An interface representing a listener registration. Objects offering the ability to register listener should return an
- * implementation of this interface upon successful registration. The users are required to call #close() before losing
- * the reference to that object.
- *
- * @param <T> template reference to associated EventListener implementation
- */
-@ThreadSafe
-public abstract class ListenerRegistration<T extends EventListener> extends AbstractRegistration {
-
- private final T listener;
-
- protected ListenerRegistration(final T listener) {
- this.listener = Preconditions.checkNotNull(listener);
- }
-
- /**
- * Access the listener object associated with this registration.
- *
- * @return Associated listener.
- */
- public final T getListener() {
- return this.listener;
- }
-}
package org.opendaylight.protocol.concepts;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.EventListener;
import org.junit.Test;
assertEquals(Integer.valueOf(5), registry.get('c'));
}
- @Test
- public void testRegistration() {
- EventListener list1 = new EventListener() {
- };
- SimpleListenerRegistration<EventListener> holder = new SimpleListenerRegistration<EventListener>(list1);
-
- assertEquals(list1, holder.getListener());
- assertEquals(1, holder.listeners.size());
-
- holder.removeRegistration();
-
- assertEquals(0, holder.listeners.size());
- assertNotNull(holder.getListener());
- }
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.concepts;
-
-import java.util.ArrayList;
-import java.util.EventListener;
-import java.util.List;
-
-public class SimpleListenerRegistration<K extends EventListener> extends ListenerRegistration<K> {
-
- public List<K> listeners = new ArrayList<>();
-
- protected SimpleListenerRegistration(K listener) {
- super(listener);
- this.listeners.add(listener);
- }
-
- @Override
- protected void removeRegistration() {
- this.listeners.clear();
- }
-}