com.netflix.logging.messaging
Class BatcherFactory

java.lang.Object
  extended by com.netflix.logging.messaging.BatcherFactory

public class BatcherFactory
extends java.lang.Object

A simple singleton factory class that finds the batchers by name. Batchers are also created by the factory if needed. The users of the batcher have to simply override the MessageProcessor to specify what to do with the batched messages. It is the user's responsibility to make sure the name is unique (ie) a FQCN would be ideal for a name. The user should also remove the batcher from the cache during shutdown or when they do not need it. The methods are not synchronized for performance reasons and there is very little downside of not synchronizing it as the last put wins and the already existing objects are garbage collected.


Constructor Summary
BatcherFactory()
           
 
Method Summary
static MessageBatcher createBatcher(java.lang.String name, MessageProcessor processor)
          Creates the batcher.
static MessageBatcher getBatcher(java.lang.String name)
          Get a batcher by name
static void removeBatcher(java.lang.String name)
          Removes the batcher from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatcherFactory

public BatcherFactory()
Method Detail

getBatcher

public static MessageBatcher getBatcher(java.lang.String name)
Get a batcher by name

Parameters:
name - - The name of the batcher
Returns:
- the batcher associated with the name

createBatcher

public static MessageBatcher createBatcher(java.lang.String name,
                                           MessageProcessor processor)
Creates the batcher. The user needs to make sure another batcher already exists before they create one.

Parameters:
name - - The name of the batcher to be created
processor - - The user override for actions to be performed on the batched messages.
Returns:

removeBatcher

public static void removeBatcher(java.lang.String name)
Removes the batcher from the cache.

Parameters:
name - - The name of the batcher to be removed