Skip to content
Snippets Groups Projects
Commit 21f6a55b authored by Ryan Izard's avatar Ryan Izard
Browse files

Commented my edits to the NotificationManagerFactory's init() function.

parent f7d14cd5
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import net.floodlightcontroller.notification.syslog.SyslogNotificationFactory;
* instance.
*
* @author kevinwang
* @edited Ryan Izard, rizard@g.clemson.edu, ryan.izard@bigswich.com
*
*/
public class NotificationManagerFactory {
......@@ -14,7 +15,17 @@ public class NotificationManagerFactory {
public static final String NOTIFICATION_FACTORY_NAME =
"floodlight.notification.factoryName";
// default to SyslogNotificationFactory
/**
* Do not set the default here. Delay until init(), which will be
* called by the JVM at class load. This will allow the unit tests
* to test dynamic binding to a factory, then reset to the default
* factory by clearing the System property and then calling init()
* again for subsequent unit tests that actually need a non-mocked
* NotificationManagerFactory.
*
* If a dynamic binding is not specified, init() will fall through
* to else and the default of SyslogNotifcationFactory will be used.
*/
private static INotificationManagerFactory factory;
/**
......@@ -28,7 +39,13 @@ public class NotificationManagerFactory {
}
/**
* A simple mechanism to initialize factory with dynamic binding
* A simple mechanism to initialize factory with dynamic binding.
*
* Extended to default to SyslogNotifcationFactory in the event
* a dynamic binding is not specified via System properties.
* This allows init() to be called multiple times for the unit tests
* and select the default or a another factory if the System property
* is cleared or is set, respectively.
*/
protected static void init() {
String notificationfactoryClassName = null;
......@@ -47,7 +64,7 @@ public class NotificationManagerFactory {
throw new RuntimeException(e);
}
} else {
factory = new SyslogNotificationFactory();
factory = new SyslogNotificationFactory(); // use as the default
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment