From 387d3284582249172aa42fa41c2c20db0498099c Mon Sep 17 00:00:00 2001 From: dev-mlb <19797865+dev-mlb@users.noreply.github.com> Date: Sat, 9 Sep 2023 10:09:32 -0400 Subject: [PATCH] remove deprecated parserfactory methods --- .../java/emissary/parser/ParserFactory.java | 69 +------------------ .../java/emissary/pickup/PickUpPlace.java | 12 +++- .../emissary/parser/ParserFactory.cfg | 2 - 3 files changed, 13 insertions(+), 70 deletions(-) diff --git a/src/main/java/emissary/parser/ParserFactory.java b/src/main/java/emissary/parser/ParserFactory.java index 59059d7a01..b5db8233ba 100755 --- a/src/main/java/emissary/parser/ParserFactory.java +++ b/src/main/java/emissary/parser/ParserFactory.java @@ -3,16 +3,12 @@ import emissary.config.ConfigUtil; import emissary.config.Configurator; import emissary.core.Factory; -import emissary.util.WindowedSeekableByteChannel; import emissary.util.shell.Executrix; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.channels.Channels; import java.nio.channels.SeekableByteChannel; import java.util.HashMap; import java.util.Map; @@ -20,8 +16,8 @@ /** * Provide a factory for getting the proper type of input parser Provide the implementing classes for that match the - * configured Data Identifier Engine in both PARSER_IMPL_[type] and PARSER_NIO_IMPL_[type] variants if available. All - * configured parsers must implement emissary.parser.SessionParser. + * configured Data Identifier Engine in PARSER_NIO_IMPL_[type] variants if available. All configured parsers must + * implement emissary.parser.SessionParser. * * When no proper mappings are found or the specified parser cannot be instantiated, the SimpleParser and * SimpleNioParser are used instead. If these cannot be instantiated, then something is likely seriously wrong. @@ -110,53 +106,6 @@ public void reconfigure(@Nullable Configurator config) { } } - /** - * Make a session parser with the data - * - * @param data the bytes to parse - * @return SessionParser implementation - */ - @Deprecated - public SessionParser makeSessionParser(byte[] data) { - try { - WindowedSeekableByteChannel channel = new WindowedSeekableByteChannel(Channels.newChannel(new ByteArrayInputStream(data)), 1024 * 1024); - return makeSessionParser(channel); - } catch (IOException ex) { - logger.warn("Unable to instantiate channel"); - throw new RuntimeException("Failed to instantiate WindowedSeekableByteChannel from byte[]", ex); - } - } - - /** - * Make a session parser with the data of the specified data type - * - * @param type the data type - * @param data the bytes to parse - * @return SessionParser implementation - */ - @Deprecated - public SessionParser makeSessionParser(String type, byte[] data) { - try { - WindowedSeekableByteChannel channel = new WindowedSeekableByteChannel(Channels.newChannel(new ByteArrayInputStream(data)), 1024 * 1024); - return makeSessionParser(type, channel); - } catch (IOException ex) { - logger.warn("Unable to instantiate channel"); - throw new RuntimeException("Failed to instantiate WindowedSeekableByteChannel from byte[]", ex); - } - } - - /** - * Make a session parser with the data in the file. If no RAF parser is configured for the type of this data, a byte[] - * parser will be produced if there is one available. - * - * @param raf the data to be parsed - * @return SessionParser implementation - */ - @Deprecated - public SessionParser makeSessionParser(RandomAccessFile raf) { - return makeSessionParser(raf.getChannel()); - } - /** * Make a session parser with the data in channel. If no NIO parser is configured for the type of this data, a standard * byte[] parser will be produced if there is one available and the size of the data in the channel is less than the @@ -190,20 +139,6 @@ public SessionParser makeSessionParser(String type, SeekableByteChannel channel) return sp; } - /** - * Make a session parser with the data in the file. If no RAF parser is configured for the type of this data, a standard - * byte[] parser will be produced if there is one available. - * - * @param type the type of data - * @param raf the data to be parsed - * @return SessionParser implementation - */ - @Deprecated - public SessionParser makeSessionParser(String type, RandomAccessFile raf) { - return makeSessionParser(type, raf.getChannel()); - } - - /** * Make a session parser for the specified data type with the args * diff --git a/src/main/java/emissary/pickup/PickUpPlace.java b/src/main/java/emissary/pickup/PickUpPlace.java index b016737ba9..07e5f3b272 100755 --- a/src/main/java/emissary/pickup/PickUpPlace.java +++ b/src/main/java/emissary/pickup/PickUpPlace.java @@ -18,14 +18,17 @@ import emissary.pool.AgentPool; import emissary.util.ClassComparator; import emissary.util.TimeUtil; +import emissary.util.WindowedSeekableByteChannel; import emissary.util.shell.Executrix; import org.slf4j.MDC; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.RandomAccessFile; +import java.nio.channels.Channels; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -625,7 +628,14 @@ public int processSessions(byte[] data, String fixedName, File theFile) { int sessionNum = 0; // Get the right type of session parser - SessionParser sp = parserFactory.makeSessionParser(data); + SessionParser sp; + try { + WindowedSeekableByteChannel channel = new WindowedSeekableByteChannel(Channels.newChannel(new ByteArrayInputStream(data)), 1024 * 1024); + sp = parserFactory.makeSessionParser(channel); + } catch (IOException e) { + logger.warn("Unable to instantiate channel"); + throw new RuntimeException("Failed to instantiate WindowedSeekableByteChannel from byte[]", e); + } logger.debug("Using session parser from byte ident {}", sp.getClass().getName()); // .. and a session producer to crank out the data objects... diff --git a/src/main/resources/emissary/parser/ParserFactory.cfg b/src/main/resources/emissary/parser/ParserFactory.cfg index 20284eb021..a6e7b7b486 100644 --- a/src/main/resources/emissary/parser/ParserFactory.cfg +++ b/src/main/resources/emissary/parser/ParserFactory.cfg @@ -1,7 +1,6 @@ # # Set up some defaults # -DEFAULT_PARSER = "emissary.parser.SimpleParser" DEFAULT_NIO_PARSER = "emissary.parser.SimpleNioParser" # @@ -14,7 +13,6 @@ MAX_NIO_FALLBACK_SIZE = "100M" # Any classes specified here must implement # the interfact emissary.parser.SessionParser # -PARSER_IMPL_simple = "emissary.parser.SimpleParser" PARSER_NIO_IMPL_simple = "emissary.parser.SimpleNioParser" #