We have switched to SchemaNodeIdentifier across the board, this patch
makes the finishing touches.
JIRA: MDSAL-570
Change-Id: I8b54143e71ebbd4aef03cb00704e2b4f5311174f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type,
final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type,
final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
- final Map<QName, Method> rpcs = currentSerializer().getRpcMethodToSchemaPath(type).inverse();
+ final Map<QName, Method> rpcs = currentSerializer().getRpcMethodToQName(type).inverse();
final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(adapterContext(),
type, rpcs, implementation);
final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(adapterContext(),
type, rpcs, implementation);
}
// FIXME: This should be probably part of Binding Runtime context
}
// FIXME: This should be probably part of Binding Runtime context
- ImmutableBiMap<Method, QName> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
+ ImmutableBiMap<Method, QName> getRpcMethodToQName(final Class<? extends RpcService> key) {
final Module module = getModule(key);
final ImmutableBiMap.Builder<Method, QName> ret = ImmutableBiMap.builder();
try {
final Module module = getModule(key);
final ImmutableBiMap.Builder<Method, QName> ret = ImmutableBiMap.builder();
try {
.build(new CacheLoader<Class<?>, Absolute>() {
@Override
public Absolute load(final Class<?> key) {
.build(new CacheLoader<Class<?>, Absolute>() {
@Override
public Absolute load(final Class<?> key) {
- // TODO: for nested (YANG 1.1) notifications we will need the SchemaPath where the notification is
- // being invoked and use that instead of ROOT. How Binding users will refer to it is TBD (but
- // probably InstanceIdentifier, which means we will need to do some lifting to find the
- // SchemaPath)
+ // TODO: for nested (YANG 1.1) notifications we will need the SchemaNodeIdentifier where the
+ // notification is being invoked and use that instead of ROOT. How Binding users will refer to
+ // it is TBD (but probably InstanceIdentifier, which means we will need to do some lifting to
+ // find the SchemaNodeIdentifier)
return Absolute.of(BindingReflections.findQName(key)).intern();
}
});
return Absolute.of(BindingReflections.findQName(key)).intern();
}
});
public class ActionLookupTest {
@Test
public class ActionLookupTest {
@Test
- public void testActionSchemaPath() {
+ public void testActionPath() {
CurrentAdapterSerializer codec = new CurrentAdapterSerializer(new BindingCodecContext(
BindingRuntimeHelpers.createRuntimeContext()));
CurrentAdapterSerializer codec = new CurrentAdapterSerializer(new BindingCodecContext(
BindingRuntimeHelpers.createRuntimeContext()));
- public void testGetRpcMethodToSchemaPath() {
+ public void testGetRpcMethodToQName() {
codec.onModelContextUpdated(context);
final List<String> retMap = codec.currentSerializer()
codec.onModelContextUpdated(context);
final List<String> retMap = codec.currentSerializer()
- .getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class).keySet().stream()
+ .getRpcMethodToQName(OpendaylightTestRpcServiceService.class).keySet().stream()
.map(Method::getName)
.collect(Collectors.toList());
assertTrue(retMap.contains("rockTheHouse"));
.map(Method::getName)
.collect(Collectors.toList());
assertTrue(retMap.contains("rockTheHouse"));
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
checkArgument(Notification.class.isAssignableFrom(notificationType));
checkArgument(notificationType.isInterface(), "Supplied class must be interface.");
final QName qname = BindingReflections.findQName(notificationType);
checkArgument(Notification.class.isAssignableFrom(notificationType));
checkArgument(notificationType.isInterface(), "Supplied class must be interface.");
final QName qname = BindingReflections.findQName(notificationType);
- /**
- * FIXME: After Lithium cleanup of yang-model-api, use direct call on schema context
- * to retrieve notification via index.
- */
- final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(getSchema(),
- SchemaPath.create(true, qname));
- checkArgument(schema != null, "Supplied %s is not valid notification", notificationType);
-
+ final NotificationDefinition schema = getSchema().findNotification(qname).orElseThrow(
+ () -> new IllegalArgumentException("Supplied " + notificationType + " is not valid notification"));
return new NotificationCodecContext<>(notificationType, schema, factory());
}
return new NotificationCodecContext<>(notificationType, schema, factory());
}