+++ /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.binding.dom.adapter.invoke;
-
-import com.google.common.base.Preconditions;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-
-@Deprecated(forRemoval = true, since = "9.0.3")
-final class ClassBasedRpcServiceInvoker extends AbstractMappedRpcInvoker<String> {
- private static final LoadingCache<Class<? extends RpcService>, RpcServiceInvoker> INVOKERS =
- CacheBuilder.newBuilder().weakKeys()
- .build(new CacheLoader<Class<? extends RpcService>, RpcServiceInvoker>() {
- @Override
- public RpcServiceInvoker load(final Class<? extends RpcService> key) {
- final Map<String, Method> ret = new HashMap<>();
- for (Method m : key.getMethods()) {
- ret.put(m.getName(), m);
- }
-
- return new ClassBasedRpcServiceInvoker(ret);
- }
- });
-
- ClassBasedRpcServiceInvoker(final Map<String, Method> ret) {
- super(ret);
- }
-
- @Override
- protected String qnameToKey(final QName qname) {
- return BindingMapping.getMethodName(qname);
- }
-
- static RpcServiceInvoker instanceFor(final Class<? extends RpcService> type) {
- Preconditions.checkArgument(type.isInterface());
- Preconditions.checkArgument(BindingReflections.isBindingClass(type));
- return INVOKERS.getUnchecked(type);
- }
-}
public abstract class RpcServiceInvoker {
private static final Logger LOG = LoggerFactory.getLogger(RpcServiceInvoker.class);
- /**
- * Creates RPCServiceInvoker for specified RpcService type.
- *
- * @param type RpcService interface, which was generated from model.
- * @return Cached instance of {@link RpcServiceInvoker} for supplied RPC type.
- * @deprecated This method is not used by the adapter and is scheduled for removal.
- */
- @Deprecated(forRemoval = true, since = "9.0.3")
- public static RpcServiceInvoker from(final Class<? extends RpcService> type) {
- return ClassBasedRpcServiceInvoker.instanceFor(type);
- }
-
/**
* Creates an RPCServiceInvoker for specified QName-<Method mapping.
*
+++ /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.binding.dom.adapter.invoke;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-
-@Deprecated(forRemoval = true, since = "9.0.3")
-public class ClassBasedRpcServiceInvokerTest {
- @Test
- public void qnameToKeyTest() throws Exception {
- final ClassBasedRpcServiceInvoker classBasedRpcServiceInvoker =
- new ClassBasedRpcServiceInvoker(ImmutableMap.of());
- assertNotNull(classBasedRpcServiceInvoker);
- assertNotNull(ClassBasedRpcServiceInvoker.instanceFor(TestInterface.class));
- assertEquals("localName", classBasedRpcServiceInvoker.qnameToKey(QName.create("testNamespace", "localName")));
- }
-
- interface TestInterface extends DataContainer, RpcService {}
-}
\ No newline at end of file
package org.opendaylight.mdsal.binding.dom.adapter.invoke;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import com.google.common.collect.ImmutableMap;
import java.lang.reflect.Method;
+import java.util.Map;
import org.junit.Test;
-import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.common.XMLNamespace;
public class RpcServiceInvokerTest {
-
@Test
public void fromTest() throws Exception {
final Method method = this.getClass().getDeclaredMethod("testMethod");
method.setAccessible(true);
- assertNotNull(RpcServiceInvoker.from(ImmutableMap.of(
+ assertNotNull(RpcServiceInvoker.from(Map.of(
QName.create(QNameModule.create(XMLNamespace.of("testURI"), Revision.of("2017-10-26")),"test"), method,
QName.create(QNameModule.create(XMLNamespace.of("testURI2"), Revision.of("2017-10-26")),"test"), method)));
- assertNotNull(RpcServiceInvoker.from(ImmutableMap.of(
+ assertNotNull(RpcServiceInvoker.from(Map.of(
QName.create(QNameModule.create(XMLNamespace.of("testURI"), Revision.of("2017-10-26")), "test"), method)));
}
- @Deprecated(forRemoval = true)
- @Test(expected = IllegalArgumentException.class)
- public void fromWithExceptionTest() {
- RpcServiceInvoker.from(RpcService.class);
- fail("Expected IllegalArgumentException");
- }
-
private void testMethod() {
// NOOP
}