/* * This method is synchronized to guard against user attempting to install * multiple contexts. Otherwise it runs in a lock-free manner. */ @Override public synchronized void setSchemaContext(final SchemaContext newSchemaContext) { Preconditions.checkNotNull(newSchemaContext); LOG.debug("Following schema contexts will be attempted {}", newSchemaContext); final DataSchemaContextTree contextTree = DataSchemaContextTree.from(newSchemaContext); final DataSchemaContextNode<?> rootContextNode = contextTree.getChild(rootPath); if (rootContextNode == null) { LOG.debug("Could not find root {} in new schema context, not upgrading", rootPath); return; } final DataSchemaNode rootSchemaNode = rootContextNode.getDataSchemaNode(); if (!(rootSchemaNode instanceof DataNodeContainer)) { LOG.warn( "Root {} resolves to non-container type {}, not upgrading", rootPath, rootSchemaNode); return; } final ModificationApplyOperation rootNode; if (rootSchemaNode instanceof ContainerSchemaNode) { // FIXME: real root needs to enfore presence, but that require pre-population rootNode = new ContainerModificationStrategy((ContainerSchemaNode) rootSchemaNode, treeType); } else { rootNode = SchemaAwareApplyOperation.from(rootSchemaNode, treeType); } DataTreeState currentState, newState; do { currentState = state; newState = currentState.withSchemaContext(newSchemaContext, rootNode); } while (!STATE_UPDATER.compareAndSet(this, currentState, newState)); }
JSONStringInstanceIdentifierCodec( final SchemaContext context, final JSONCodecFactory jsonCodecFactory) { this.context = Preconditions.checkNotNull(context); this.dataContextTree = DataSchemaContextTree.from(context); this.codecFactory = Preconditions.checkNotNull(jsonCodecFactory); }
ElementInstanceIdentifierParser(final SchemaContext schema, final Element element) { this.element = Preconditions.checkNotNull(element); this.schema = Preconditions.checkNotNull(schema); this.dataContextTree = DataSchemaContextTree.from(schema); }