*/
package org.opendaylight.netconf.nettyutil.handler;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufUtil;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.shaded.exificient.core.exceptions.EXIException;
import org.opendaylight.yangtools.util.xml.UntrustedXML;
-import org.openexi.proc.common.EXIOptionsException;
-import org.openexi.sax.EXIReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
private static final Logger LOG = LoggerFactory.getLogger(NetconfEXIToMessageDecoder.class);
private static final SAXTransformerFactory FACTORY;
+
static {
final TransformerFactory f = SAXTransformerFactory.newInstance();
if (!f.getFeature(SAXTransformerFactory.FEATURE)) {
- throw new TransformerFactoryConfigurationError(String.format("Factory %s is not a SAXTransformerFactory", f));
+ throw new TransformerFactoryConfigurationError(
+ String.format("Factory %s is not a SAXTransformerFactory", f));
}
FACTORY = (SAXTransformerFactory)f;
* which means that {@link #decode(ChannelHandlerContext, ByteBuf, List)}
* cannot be invoked concurrently. Hence we can reuse the reader.
*/
- private final EXIReader reader;
+ private final ThreadLocalSAXDecoder reader;
private final DocumentBuilder documentBuilder;
- private NetconfEXIToMessageDecoder(final EXIReader reader) {
- this.reader = Preconditions.checkNotNull(reader);
+ private NetconfEXIToMessageDecoder(final ThreadLocalSAXDecoder reader) {
+ this.reader = requireNonNull(reader);
this.documentBuilder = UntrustedXML.newDocumentBuilder();
}
- public static NetconfEXIToMessageDecoder create(final NetconfEXICodec codec) throws EXIOptionsException {
+ public static NetconfEXIToMessageDecoder create(final NetconfEXICodec codec) throws EXIException {
return new NetconfEXIToMessageDecoder(codec.getReader());
}
@Override
- protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws EXIOptionsException, IOException, SAXException, TransformerConfigurationException {
+ protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out)
+ throws IOException, SAXException, TransformerConfigurationException {
/*
* Note that we could loop here and process all the messages, but we can't do that.
* The reason is <stop-exi> operation, which has the contract of immediately stopping
final DOMResult domResult = new DOMResult(documentBuilder.newDocument());
handler.setResult(domResult);
- try (final InputStream is = new ByteBufInputStream(in)) {
+ try (InputStream is = new ByteBufInputStream(in)) {
// Performs internal reset before doing anything
reader.parse(new InputSource(is));
}