import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collection;
-import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
- * An asynchronous factory for building {@link SchemaContext} instances based on
- * a specification of what {@link SourceIdentifier}s are required and dynamic
- * recursive resolution.
+ * An asynchronous factory for building {@link SchemaContext} instances based on a specification of what
+ * {@link SourceIdentifier}s are required and dynamic recursive resolution.
*/
@Beta
public interface SchemaContextFactory {
* of the schema context failed.
*/
@NonNull ListenableFuture<SchemaContext> createSchemaContext(@NonNull Collection<SourceIdentifier> requiredSources);
-
- /**
- * Create a new schema context containing specified sources, pulling in any dependencies they may have.
- *
- * @param requiredSources a collection of sources which are required to be present
- * @param statementParserMode mode of statement parser
- * @return A future which will produce a schema context, or fail with an explanation why the creation
- * of the schema context failed.
- * @deprecated Use SchemaContextFactoryConfiguration instead.
- */
- @Deprecated
- default @NonNull ListenableFuture<SchemaContext> createSchemaContext(
- final Collection<SourceIdentifier> requiredSources, final StatementParserMode statementParserMode) {
- return createSchemaContext(requiredSources, statementParserMode, null);
- }
-
- /**
- * Create a new schema context containing specified sources, pulling in any dependencies they may have.
- *
- * @param requiredSources a collection of sources which are required to be present
- * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
- * models are resolved
- * @return A future which will produce a schema context, or fail with an explanation why the creation of the schema
- * context failed.
- * @deprecated Use SchemaContextFactoryConfiguration instead.
- */
- @Deprecated
- default @NonNull ListenableFuture<SchemaContext> createSchemaContext(
- final @NonNull Collection<SourceIdentifier> requiredSources, final Set<QName> supportedFeatures) {
- return createSchemaContext(requiredSources, StatementParserMode.DEFAULT_MODE, supportedFeatures);
- }
-
- /**
- * Create a new schema context containing specified sources, pulling in any dependencies they may have.
- *
- * @param requiredSources a collection of sources which are required to be present
- * @param statementParserMode mode of statement parser
- * @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
- * models are resolved
- * @return A future which will produce a schema context, or fail with an explanation why the creation of the schema
- * context failed.
- * @deprecated Use SchemaContextFactoryConfiguration instead.
- */
- @Deprecated
- @NonNull ListenableFuture<SchemaContext> createSchemaContext(Collection<SourceIdentifier> requiredSources,
- StatementParserMode statementParserMode, Set<QName> supportedFeatures);
}
import org.antlr.v4.runtime.ParserRuleContext;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
this.config = requireNonNull(config);
}
- @Override
- @Deprecated
- public @NonNull ListenableFuture<SchemaContext> createSchemaContext(
- final Collection<SourceIdentifier> requiredSources,
- final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
- return createSchemaContext(requiredSources,
- statementParserMode == StatementParserMode.SEMVER_MODE ? semVerCache : revisionCache,
- new AssembleSources(SchemaContextFactoryConfiguration.builder()
- .setFilter(config.getSchemaSourceFilter()).setStatementParserMode(statementParserMode)
- .setSupportedFeatures(supportedFeatures).build()));
- }
-
@Override
public @NonNull ListenableFuture<SchemaContext> createSchemaContext(
final @NonNull Collection<SourceIdentifier> requiredSources) {
} while (ver != version);
while (true) {
- final ListenableFuture<SchemaContext> f = factory.createSchemaContext(sources, statementParserMode);
+ final ListenableFuture<SchemaContext> f = factory.createSchemaContext(sources);
try {
sc = Optional.of(f.get());
break;
throws SchemaResolutionException {
final ListenableFuture<SchemaContext> future = repository
.createSchemaContextFactory(config(statementParserMode))
- .createSchemaContext(ImmutableSet.copyOf(requiredSources), statementParserMode);
+ .createSchemaContext(ImmutableSet.copyOf(requiredSources));
try {
return future.get();
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
semVer.register(sharedSchemaRepository);
semVer.setResult();
- final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory();
+ final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory(
+ SchemaContextFactoryConfiguration.builder().setStatementParserMode(StatementParserMode.SEMVER_MODE)
+ .build());
- final ListenableFuture<SchemaContext> inetAndTopologySchemaContextFuture =
- fact.createSchemaContext(ImmutableList.of(bar.getId(), foo.getId(), semVer.getId()),
- StatementParserMode.SEMVER_MODE);
+ final ListenableFuture<SchemaContext> inetAndTopologySchemaContextFuture = fact.createSchemaContext(
+ ImmutableList.of(bar.getId(), foo.getId(), semVer.getId()));
assertTrue(inetAndTopologySchemaContextFuture.isDone());
assertSchemaContext(inetAndTopologySchemaContextFuture.get(), 3);
- final ListenableFuture<SchemaContext> barSchemaContextFuture = fact
- .createSchemaContext(ImmutableList.of(bar.getId(), semVer.getId()), StatementParserMode.SEMVER_MODE);
+ final ListenableFuture<SchemaContext> barSchemaContextFuture = fact.createSchemaContext(
+ ImmutableList.of(bar.getId(), semVer.getId()));
assertTrue(barSchemaContextFuture.isDone());
assertSchemaContext(barSchemaContextFuture.get(), 2);
}
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToASTTransformer;
foobar.register(sharedSchemaRepository);
foobar.setResult();
- final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory();
final ListenableFuture<SchemaContext> testSchemaContextFuture =
- fact.createSchemaContext(ImmutableList.of(foobar.getId()), supportedFeatures);
+ sharedSchemaRepository.createSchemaContextFactory(
+ SchemaContextFactoryConfiguration.builder().setSupportedFeatures(supportedFeatures).build())
+ .createSchemaContext(ImmutableList.of(foobar.getId()));
assertTrue(testSchemaContextFuture.isDone());
assertSchemaContext(testSchemaContextFuture.get(), 1);
@Test
public void testSharedSchemaRepositoryWithNoFeaturesSupported() throws Exception {
- final Set<QName> supportedFeatures = ImmutableSet.of();
-
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
foobar.register(sharedSchemaRepository);
foobar.setResult();
- final SchemaContextFactory fact = sharedSchemaRepository.createSchemaContextFactory();
final ListenableFuture<SchemaContext> testSchemaContextFuture =
- fact.createSchemaContext(ImmutableList.of(foobar.getId()), supportedFeatures);
+ sharedSchemaRepository.createSchemaContextFactory(
+ SchemaContextFactoryConfiguration.builder().setSupportedFeatures(ImmutableSet.of()).build())
+ .createSchemaContext(ImmutableList.of(foobar.getId()));
assertTrue(testSchemaContextFuture.isDone());
assertSchemaContext(testSchemaContextFuture.get(), 1);