+++ /dev/null
-/*
- * Copyright (c) 2015 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.mdsal.dom.api;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * A registration of a {@link DOMRpcImplementation}. Used to track and revoke a registration
- * with a {@link DOMRpcProviderService}.
- *
- * @param <T> RPC implementation type
- */
-// FIXME: reconsider usefulness of this capture
-public interface DOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends ObjectRegistration<T> {
-
-}
* @param implementation RPC implementation, must not be null
* @param rpcs Array of supported RPC identifiers. Must not be null, empty, or contain a null element.
* Each identifier is added exactly once, no matter how many times it occurs.
- * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
+ * @return A {@link Registration} object, guaranteed to be non-null.
* @throws NullPointerException if implementation or types is null
* @throws IllegalArgumentException if types is empty or contains a null element.
*/
- // FIXME: just Registration and forward to set
- // FIXME: single-instance specialization
- @NonNull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
- registerRpcImplementation(@NonNull T implementation, @NonNull DOMRpcIdentifier... rpcs);
+ default @NonNull Registration registerRpcImplementation(final @NonNull DOMRpcImplementation implementation,
+ final @NonNull DOMRpcIdentifier... rpcs) {
+ return registerRpcImplementation(implementation, Set.of(rpcs));
+ }
/**
* Register an {@link DOMRpcImplementation} object with this service.
*
* @param implementation RPC implementation, must not be null
* @param rpcs Set of supported RPC identifiers. Must not be null, empty, or contain a null element.
- * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
+ * @return A {@link Registration} object, guaranteed to be non-null.
* @throws NullPointerException if implementation or types is null
* @throws IllegalArgumentException if types is empty or contains a null element.
*/
- // FIXME: just Registration and forward to set
- @NonNull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
- registerRpcImplementation(@NonNull T implementation, @NonNull Set<DOMRpcIdentifier> rpcs);
+ // FIXME: just Registration and forward to Map
+ @NonNull Registration registerRpcImplementation(@NonNull DOMRpcImplementation implementation,
+ @NonNull Set<DOMRpcIdentifier> rpcs);
/**
* Register a set of {@link DOMRpcImplementation}s with this service. The registration is performed atomically.
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.spi.AbstractDOMRpcImplementationRegistration;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.concepts.AbstractRegistration;
private final class RpcProviderServiceFacade implements DOMRpcProviderService {
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final DOMRpcIdentifier... rpcs) {
- return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs));
- }
-
- @Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final Set<DOMRpcIdentifier> rpcs) {
+ public Registration registerRpcImplementation(final DOMRpcImplementation implementation,
+ final Set<DOMRpcIdentifier> rpcs) {
synchronized (DOMRpcRouter.this) {
final DOMRpcRoutingTable oldTable = routingTable;
listenerNotifier.execute(() -> notifyAdded(newTable, implementation));
}
- return new AbstractDOMRpcImplementationRegistration<>(implementation) {
+ return new AbstractRegistration() {
@Override
protected void removeRegistration() {
- removeRpcImplementation(getInstance(), rpcs);
+ removeRpcImplementation(implementation, rpcs);
}
};
}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.mdsal.dom.spi;
-
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-
-/**
- * Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
- */
-public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends
- AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
- protected AbstractDOMRpcImplementationRegistration(final T instance) {
- super(instance);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 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.mdsal.dom.spi;
-
-import com.google.common.collect.ImmutableSet;
-import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-
-/**
- * Convenience abstract base class for {@link DOMRpcProviderService} implementations.
- */
-public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
- @Override
- public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
- registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
- return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
- }
-}
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.yangtools.concepts.Registration;
protected abstract @NonNull DOMRpcProviderService delegate();
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final DOMRpcIdentifier... types) {
+ public Registration registerRpcImplementation(final DOMRpcImplementation implementation,
+ final DOMRpcIdentifier... types) {
return delegate().registerRpcImplementation(implementation, types);
}
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final Set<DOMRpcIdentifier> types) {
+ public Registration registerRpcImplementation(final DOMRpcImplementation implementation,
+ final Set<DOMRpcIdentifier> types) {
return delegate().registerRpcImplementation(implementation, types);
}
+++ /dev/null
-/*
- * Copyright (c) 2016 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.mdsal.dom.spi;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Test;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-
-public class AbstractDOMRpcImplementationRegistrationTest
- extends AbstractDOMRpcImplementationRegistration<DOMRpcImplementation> {
-
- private static final DOMRpcImplementation DOM_RPC_IMPLEMENTATION = mock(DOMRpcImplementation.class);
-
- public AbstractDOMRpcImplementationRegistrationTest() {
- super(DOM_RPC_IMPLEMENTATION);
- }
-
- @Test
- public void basicTest() throws Exception {
- AbstractDOMRpcImplementationRegistration<?> abstractDOMRpcImplementationRegistration =
- new AbstractDOMRpcImplementationRegistrationTest();
- assertEquals(DOM_RPC_IMPLEMENTATION, abstractDOMRpcImplementationRegistration.getInstance());
- abstractDOMRpcImplementationRegistration.close();
- }
-
- @Override
- protected void removeRegistration() {
- // NOOP
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2016 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.mdsal.dom.spi;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import java.util.Map;
-import java.util.Set;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
-import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
-
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class AbstractDOMRpcProviderServiceTest extends AbstractDOMRpcProviderService {
- @Mock(name = "domRpcImplementationRegistration")
- public DOMRpcImplementationRegistration<?> domRpcImplementationRegistration;
-
- @Test
- public void registerRpcImplementation() throws Exception {
- assertEquals(domRpcImplementationRegistration, this.registerRpcImplementation(
- mock(DOMRpcImplementation.class)));
- }
-
- @Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
- final T implementation, final Set<DOMRpcIdentifier> rpcs) {
- return (DOMRpcImplementationRegistration<T>) domRpcImplementationRegistration;
- }
-
- @Override
- public Registration registerRpcImplementations(final Map<DOMRpcIdentifier, DOMRpcImplementation> map) {
- throw new UnsupportedOperationException();
- }
-}
\ No newline at end of file