+ final String moduleSchemaCacheDirectory = getSchemaCacheDirectory();
+ // If a custom schema cache directory is specified, then create the backing Repository,
+ // SchemaContextFactory and FilesystemSchemaSourceCache. If the default is specified,
+ // the the defaults are used from NetconfConnectorModuleFactory.
+ if (!Strings.isNullOrEmpty(moduleSchemaCacheDirectory) &&
+ !moduleSchemaCacheDirectory.equals(DEFAULT_CACHE_DIRECTORY)) {
+
+ final SharedSchemaRepository repository = new SharedSchemaRepository(instanceName);
+ final SchemaContextFactory schemaContextFactory
+ = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
+ setSchemaRegistry(repository);
+ setSchemaContextFactory(schemaContextFactory);
+
+ final FilesystemSchemaSourceCache<YangTextSchemaSource> deviceCache =
+ createDeviceFilesystemCache(moduleSchemaCacheDirectory);
+ repository.registerSchemaSourceListener(deviceCache);
+ logger.info("Netconf connector for device {} will use schema cache directory {} instead of {}",
+ instanceName, moduleSchemaCacheDirectory, DEFAULT_CACHE_DIRECTORY);
+ }
+
+ schemaRegistry.registerSchemaSourceListener(
+ TextToASTTransformer.create((SchemaRepository) schemaRegistry, schemaRegistry));
+