- private static final LoadingCache<Short, GrammarCache> GRAMMAR_CACHES = CacheBuilder.newBuilder().weakValues().build(new CacheLoader<Short, GrammarCache>() {
- @Override
- public GrammarCache load(final Short key) {
- return new GrammarCache(key);
- }
- });
-
- /**
- * Grammar cache acts as a template and is duplicated by the Transmogrifier and the Reader
- * before use. It is safe to reuse a single instance.
- */
- private final GrammarCache exiGrammarCache;
- private final EXIOptions exiOptions;
-
- public NetconfEXICodec(final EXIOptions exiOptions) {
- this.exiOptions = Preconditions.checkNotNull(exiOptions);
- this.exiGrammarCache = createGrammarCache(exiOptions);
+ private static final LoadingCache<EXIParameters, NetconfEXICodec> CODECS =
+ CacheBuilder.newBuilder().weakValues().build(new CacheLoader<EXIParameters, NetconfEXICodec>() {
+ @Override
+ public NetconfEXICodec load(final EXIParameters key) {
+ return new NetconfEXICodec(key.getFactory());
+ }
+ });
+
+ private final ThreadLocalSAXFactory exiFactory;
+
+ private NetconfEXICodec(final EXIFactory exiFactory) {
+ this.exiFactory = new ThreadLocalSAXFactory(requireNonNull(exiFactory));