use of org.opendaylight.yangtools.yang.model.api.SchemaPath in project controller by opendaylight.
the class NormalizedNodeStreamReaderWriterTest method testSchemaPathSerialization.
@Test
public void testSchemaPathSerialization() throws Exception {
final SchemaPath expected = SchemaPath.create(true, TestModel.ANY_XML_QNAME);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(ByteStreams.newDataOutput(bos));
nnout.writeSchemaPath(expected);
NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(ByteStreams.newDataInput(bos.toByteArray()));
SchemaPath actual = nnin.readSchemaPath();
assertEquals(expected, actual);
}
use of org.opendaylight.yangtools.yang.model.api.SchemaPath in project controller by opendaylight.
the class RpcUtil method decomposeRpcService.
static Collection<SchemaPath> decomposeRpcService(final Class<RpcService> service, final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
final QNameModule moduleName = BindingReflections.getQNameModule(service);
final Module module = schemaContext.findModule(moduleName).get();
LOG.debug("Resolved service {} to module {}", service, module);
final Collection<RpcDefinition> rpcs = module.getRpcs();
final Collection<SchemaPath> ret = new ArrayList<>(rpcs.size());
for (RpcDefinition rpc : rpcs) {
final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(rpc);
if (filter.test(strategy)) {
ret.add(rpc.getPath());
}
}
return ret;
}
use of org.opendaylight.yangtools.yang.model.api.SchemaPath in project controller by opendaylight.
the class HeliumNotificationProviderServiceWithInterestListeners method registerNotificationListener.
@Override
public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(final Class<T> type, final NotificationListener<T> listener) {
final FunctionalNotificationListenerAdapter<T> adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener);
final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
@Override
protected void removeRegistration() {
domReg.close();
}
};
}
use of org.opendaylight.yangtools.yang.model.api.SchemaPath in project controller by opendaylight.
the class BindingDOMNotificationListenerAdapter method createInvokerMapFor.
public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
Class<?> iface = ifaceToken.getRawType();
if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked") final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
for (final SchemaPath path : getNotificationTypes(listenerType)) {
builder.put(path, invoker);
}
}
}
return ImmutableMap.copyOf(builder);
}
use of org.opendaylight.yangtools.yang.model.api.SchemaPath in project controller by opendaylight.
the class BindingDOMNotificationListenerAdapter method getNotificationTypes.
private static Set<SchemaPath> getNotificationTypes(final Class<? extends NotificationListener> type) {
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<SchemaPath> ret = new HashSet<>();
for (final Method method : type.getMethods()) {
if (BindingReflections.isNotificationCallback(method)) {
final Class<?> notification = method.getParameterTypes()[0];
final QName name = BindingReflections.findQName(notification);
ret.add(SchemaPath.create(true, name));
}
}
return ret;
}
Aggregations