*/
package org.opendaylight.mdsal.dom.api;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
*
* @param listener Listener which should be registered
* @return Listener registration handle
+ * @throws NullPointerException if {@code listener} is {@code null}
*/
- ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
- EffectiveModelContextListener listener);
+ @NonNull Registration registerSchemaContextListener(EffectiveModelContextListener listener);
}
import org.opendaylight.yangtools.concepts.AbstractRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
private final @NonNull DOMRpcService rpcService = new RpcServiceFacade();
@GuardedBy("this")
- private ImmutableList<Registration<?>> listeners = ImmutableList.of();
+ private ImmutableList<RegImpl<?>> listeners = ImmutableList.of();
@GuardedBy("this")
private ImmutableList<ActionRegistration<?>> actionListeners = ImmutableList.of();
private volatile DOMActionRoutingTable actionRoutingTable = DOMActionRoutingTable.EMPTY;
- private ListenerRegistration<?> listenerRegistration;
+ private Registration listenerRegistration;
@Deprecated
@VisibleForTesting
}
private synchronized void notifyAdded(final DOMRpcRoutingTable newTable, final DOMRpcImplementation impl) {
- for (Registration<?> l : listeners) {
+ for (RegImpl<?> l : listeners) {
l.addRpc(newTable, impl);
}
}
private synchronized void notifyAdded(final DOMRpcRoutingTable newTable,
final Collection<? extends DOMRpcImplementation> impls) {
- for (Registration<?> l : listeners) {
+ for (RegImpl<?> l : listeners) {
for (DOMRpcImplementation impl : impls) {
l.addRpc(newTable, impl);
}
}
private synchronized void notifyRemoved(final DOMRpcRoutingTable newTable, final DOMRpcImplementation impl) {
- for (Registration<?> l : listeners) {
+ for (RegImpl<?> l : listeners) {
l.removeRpc(newTable, impl);
}
}
private synchronized void notifyRemoved(final DOMRpcRoutingTable newTable,
final Collection<? extends DOMRpcImplementation> impls) {
- for (Registration<?> l : listeners) {
+ for (RegImpl<?> l : listeners) {
for (DOMRpcImplementation impl : impls) {
l.removeRpc(newTable, impl);
}
return routingTable;
}
- private static final class Registration<T extends DOMRpcAvailabilityListener>
- extends AbstractListenerRegistration<T> {
-
+ private static final class RegImpl<T extends DOMRpcAvailabilityListener> extends AbstractListenerRegistration<T> {
private Map<QName, Set<YangInstanceIdentifier>> prevRpcs;
private DOMRpcRouter router;
- Registration(final DOMRpcRouter router, final T listener, final Map<QName, Set<YangInstanceIdentifier>> rpcs) {
+ RegImpl(final DOMRpcRouter router, final T listener, final Map<QName, Set<YangInstanceIdentifier>> rpcs) {
super(listener);
this.router = requireNonNull(router);
this.prevRpcs = requireNonNull(rpcs);
@Override
public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T listener) {
synchronized (DOMRpcRouter.this) {
- final Registration<T> ret = new Registration<>(DOMRpcRouter.this, listener,
- routingTable.getOperations(listener));
- listeners = ImmutableList.<Registration<?>>builder().addAll(listeners).add(ret).build();
+ final RegImpl<T> ret = new RegImpl<>(DOMRpcRouter.this, listener, routingTable.getOperations(listener));
+ listeners = ImmutableList.<RegImpl<?>>builder().addAll(listeners).add(ret).build();
listenerNotifier.execute(ret::initialTable);
return ret;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.schema.osgi.OSGiModuleInfoSnapshot;
import org.opendaylight.mdsal.dom.spi.AbstractDOMSchemaService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.osgi.service.component.ComponentFactory;
-import org.osgi.service.component.ComponentInstance;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
}
@Override
- public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
- final EffectiveModelContextListener listener) {
+ public Registration registerSchemaContextListener(final EffectiveModelContextListener listener) {
return registerListener(requireNonNull(listener));
}
deactivated = true;
}
- private @NonNull ListenerRegistration<EffectiveModelContextListener> registerListener(
- final @NonNull EffectiveModelContextListener listener) {
- final ComponentInstance<EffectiveModelContextImpl> reg =
- listenerFactory.newInstance(EffectiveModelContextImpl.props(listener));
- return new ListenerRegistration<>() {
- @Override
- public EffectiveModelContextListener getInstance() {
- return listener;
- }
-
+ private @NonNull Registration registerListener(final @NonNull EffectiveModelContextListener listener) {
+ final var reg = listenerFactory.newInstance(EffectiveModelContextImpl.props(listener));
+ return new AbstractRegistration() {
@Override
- public void close() {
+ protected void removeRegistration() {
reg.dispose();
}
};
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.NoOpListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
}
@Override
- public final @NonNull ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
- final EffectiveModelContextListener listener) {
+ public final Registration registerSchemaContextListener(final EffectiveModelContextListener listener) {
listener.onModelContextUpdated(getGlobalContext());
return NoOpListenerRegistration.of(listener);
}