public static SchemaPath toPath(final QName rpc) { return SchemaPath.create(true, rpc); }
/** * Constructs new instance of this class with the concrete path. * * @param absolute * boolean value which specifies if the path is absolute or * relative * @param path * one or more QName instances which specifies exact path to the * module node * * @return A SchemaPath instance. */ public static SchemaPath create(final boolean absolute, final QName... path) { return create(Arrays.asList(path), absolute); }
/** * Constructs new instance of this class with the concrete path. * * @param absolute * boolean value which specifies if the path is absolute or * relative * @param path * one or more QName instances which specifies exact path to the * module node * * @return A SchemaPath instance. */ public static SchemaPath create(final boolean absolute, final QName... path) { return create(Arrays.asList(path), absolute); }
private static SchemaPath getSchemaPath(final YangInstanceIdentifier topLevelIdentifier, final Map.Entry<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> entry) { return SchemaPath.create(extractSchemaPathQNames(topLevelIdentifier, entry), true); }
private void registerListener(DOMNotificationService notifyService){ this.listenerReg = notifyService.registerNotificationListener(this,SchemaPath.create(true, TopicNotification.QNAME)); }
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; } }
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; } }
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; } }
@Override public SchemaPath readSchemaPath() throws IOException { readSignatureMarkerAndVersionIfNeeded(); final boolean absolute = input.readBoolean(); final int size = input.readInt(); final Builder<QName> qnames = ImmutableList.builderWithExpectedSize(size); for (int i = 0; i < size; ++i) { qnames.add(readQName()); } return SchemaPath.create(qnames.build(), absolute); }
/** * Create serializer of Binding notification data to DOM notification with specific codec. * * @param codec * - specific codec * @param data * - binding notification data * @return DOM notification serializer */ public static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification<?> data) { final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.getClass())); return new LazySerializedDOMNotification(codec, data, type); }
private SchemaPath getSchemaPath(final YangInstanceIdentifier dataRoot) { return SchemaPath.create(Iterables.transform(dataRoot.getPathArguments(), PATH_ARG_TO_QNAME), dataRoot.equals(ROOT)); }
private SchemaPath getSchemaPath(final YangInstanceIdentifier dataRoot) { return SchemaPath.create(Iterables.transform(dataRoot.getPathArguments(), PATH_ARG_TO_QNAME), dataRoot.equals(ROOT)); }
private YangpushDOMNotificationListener registerNotificationListnerPushUpdateForaNewDevice(Optional<DOMMountPoint> mountPoint, String node_name) { // register notification listener for PUSH-UPDATE //BUG: NotificationListner should be one instance or multiple?? YangpushDOMNotificationListener listener = new YangpushDOMNotificationListener(this.globalDomDataBroker); final Optional<DOMNotificationService> service = mountPoint.get().getService(DOMNotificationService.class); QName qname = PushUpdate.QNAME; SchemaPath schemaPath = SchemaPath.create(true, qname); @SuppressWarnings("unused") final ListenerRegistration<YangpushDOMNotificationListener> accessTopologyListenerListenerRegistration = service .get().registerNotificationListener(listener, schemaPath); this.notifyListnerRegister.put(node_name, listener); return listener; }
NotificationCodecContext<?> createNotificationDataContext(final Class<?> 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); return new NotificationCodecContext<>(notificationType, schema, factory()); }
private NotificationCodecContext<?> createNotificationDataContext(final Class<?> notificationType) { Preconditions.checkArgument(Notification.class.isAssignableFrom(notificationType)); Preconditions.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)); Preconditions.checkArgument(schema != null, "Supplied %s is not valid notification", notificationType); return new NotificationCodecContext<>(notificationType, schema, factory()); }
static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) { final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.getImplementedInterface())); return new LazySerializedDOMNotification(codec, data, type); }
@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(); } }; }
static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) { final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.getImplementedInterface())); return new LazySerializedDOMNotification(codec, data, type); }
@Override public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) { final String moduleName = sourceIdentifier.getName(); // If formatted revision is SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION, we have to omit it from request final String formattedRevision = sourceIdentifier.getRevision().equals(SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION) ? null : sourceIdentifier.getRevision(); final Optional<String> revision = Optional.fromNullable(formattedRevision); final NormalizedNode<?, ?> getSchemaRequest = createGetSchemaRequest(moduleName, revision); logger.trace("{}: Loading YANG schema source for {}:{}", id, moduleName, revision); final ListenableFuture<YangTextSchemaSource> transformed = Futures.transform( rpc.invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME), getSchemaRequest), new ResultToYangSourceTransformer(id, sourceIdentifier, moduleName, revision)); final CheckedFuture<YangTextSchemaSource, SchemaSourceException> checked = Futures.makeChecked(transformed, MAPPER); // / FIXME remove this get, it is only present to wait until source is retrieved // (goal is to limit concurrent schema download, since NetconfDevice listener does not handle concurrent messages properly) // TODO retest this try { logger.trace("{}: Blocking for {}", id, sourceIdentifier); checked.checkedGet(); } catch (final SchemaSourceException e) { return Futures.immediateFailedCheckedFuture(e); } return checked; }
@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); }