FLUME-978: Context interface is too basic requiring boilerplate user code
Review Request #3968 - Created Feb. 20, 2012 and submitted
1) Changing backing structure of Context from object to String 2) Add getBoolean, getInteger, getLong to Context 3) Remove get(key, clazz) 4) Add javadoc to public methods of Context 5) Change backing map of Context to synchronized map since it seems this class could be accessed by multiple threads.
Unit tests added for all new methods and some exiting methods. All unit tests pass.
Posted (Feb. 29, 2012, 2:45 a.m.)
Thanks for the patch Brock. Changes look good. A couple of suggestions:
Another thing to consider while you are at it is to provide a constructor that takes in a Map<String, String>. That way the two step call: Context c = new Context(); c.putAll(config); Can be collapsed into one: Context c = new Context(config); If you decide to do this, I suggest making a copy of the map that is passed in to insulate it from accidental external modification.
Since the parameters member variable is used for synchronization, you cannot replace it's reference. Replacing it's reference will break the thread safety of this class. Alternatively, you can instantiate parameters at the point of declaration or in constructor, and the clear() could then be applied to it directly.
Posted (Feb. 29, 2012, 2:49 a.m.)