4141 */
4242public final class PluginRegistry {
4343
44- private static final Map <String , Class <Input >> INPUTS = new HashMap <>();
45- private static final Map <String , Class <Filter >> FILTERS = new HashMap <>();
46- private static final Map <String , Class <Output >> OUTPUTS = new HashMap <>();
47- private static final Map <String , Class <Codec >> CODECS = new HashMap <>();
44+ private final Map <String , Class <Input >> inputs = new HashMap <>();
45+ private final Map <String , Class <Filter >> filters = new HashMap <>();
46+ private final Map <String , Class <Output >> outputs = new HashMap <>();
47+ private final Map <String , Class <Codec >> codecs = new HashMap <>();
4848
49- static {
49+ public PluginRegistry () {
5050 discoverPlugins ();
5151 }
52-
53- private PluginRegistry () {} // utility class
54-
52+
5553 @ SuppressWarnings ("unchecked" )
56- private static void discoverPlugins () {
54+ private void discoverPlugins () {
5755 Reflections reflections = new Reflections ("org.logstash.plugins" );
5856 Set <Class <?>> annotated = reflections .getTypesAnnotatedWith (LogstashPlugin .class );
5957 for (final Class <?> cls : annotated ) {
6058 for (final Annotation annotation : cls .getAnnotations ()) {
6159 if (annotation instanceof LogstashPlugin ) {
6260 String name = ((LogstashPlugin ) annotation ).name ();
6361 if (Filter .class .isAssignableFrom (cls )) {
64- FILTERS .put (name , (Class <Filter >) cls );
62+ filters .put (name , (Class <Filter >) cls );
6563 }
6664 if (Output .class .isAssignableFrom (cls )) {
67- OUTPUTS .put (name , (Class <Output >) cls );
65+ outputs .put (name , (Class <Output >) cls );
6866 }
6967 if (Input .class .isAssignableFrom (cls )) {
70- INPUTS .put (name , (Class <Input >) cls );
68+ inputs .put (name , (Class <Input >) cls );
7169 }
7270 if (Codec .class .isAssignableFrom (cls )) {
73- CODECS .put (name , (Class <Codec >) cls );
71+ codecs .put (name , (Class <Codec >) cls );
7472 }
7573
7674 break ;
@@ -79,7 +77,7 @@ private static void discoverPlugins() {
7977 }
8078 }
8179
82- public static Class <?> getPluginClass (PluginLookup .PluginType pluginType , String pluginName ) {
80+ public Class <?> getPluginClass (PluginLookup .PluginType pluginType , String pluginName ) {
8381 if (pluginType == PluginLookup .PluginType .FILTER ) {
8482 return getFilterClass (pluginName );
8583 }
@@ -97,31 +95,31 @@ public static Class<?> getPluginClass(PluginLookup.PluginType pluginType, String
9795
9896 }
9997
100- public static Class <Input > getInputClass (String name ) {
101- return INPUTS .get (name );
98+ public Class <Input > getInputClass (String name ) {
99+ return inputs .get (name );
102100 }
103101
104- public static Class <Filter > getFilterClass (String name ) {
105- return FILTERS .get (name );
102+ public Class <Filter > getFilterClass (String name ) {
103+ return filters .get (name );
106104 }
107105
108- public static Class <Codec > getCodecClass (String name ) {
109- return CODECS .get (name );
106+ public Class <Codec > getCodecClass (String name ) {
107+ return codecs .get (name );
110108 }
111109
112- public static Class <Output > getOutputClass (String name ) {
113- return OUTPUTS .get (name );
110+ public Class <Output > getOutputClass (String name ) {
111+ return outputs .get (name );
114112 }
115113
116- public static Codec getCodec (String name , Configuration configuration , Context context ) {
117- if (name != null && CODECS .containsKey (name )) {
118- return instantiateCodec (CODECS .get (name ), configuration , context );
114+ public Codec getCodec (String name , Configuration configuration , Context context ) {
115+ if (name != null && codecs .containsKey (name )) {
116+ return instantiateCodec (codecs .get (name ), configuration , context );
119117 }
120118 return null ;
121119 }
122120
123121 @ SuppressWarnings ({"unchecked" ,"rawtypes" })
124- private static Codec instantiateCodec (Class clazz , Configuration configuration , Context context ) {
122+ private Codec instantiateCodec (Class clazz , Configuration configuration , Context context ) {
125123 try {
126124 Constructor <Codec > constructor = clazz .getConstructor (Configuration .class , Context .class );
127125 return constructor .newInstance (configuration , context );
0 commit comments