Developers guide

32
These requirements were translated into the Java interfaces shown below:
// Java interface to the APC AP9212 Masterswitch
public interface Masterswitch {
// Outlet States
public static final String OUTLET_ON = "On";
public static final String OUTLET_OFF = "Off";
public static final String OUTLET_REBOOT = "Reboot";
public static final String OUTLET_UNKNOWN = "Unknown";
public static final String OUTLET_ON_WITH_DELAY = "On with delay";
public static final String OUTLET_OFF_WITH_DELAY = "Off with delay";
public static final String OUTLET_REBOOT_WITH_DELAY = "Reboot with delay";
public String setOutletState(int outlet,String outletState)
throws MasterswitchException;
public String getOutletState(int outlet)
throws MasterswitchException;
...
// Event Notification
public void addMasterswitchListener( MasterswitchListener listener);
public void removeMasterswitchListener( MasterswitchListener listener );
}
Figure 4-1 Masterswitch interface
// Event Notification
public interface MasterswitchListener {
public void outletStateChanged(int outlet, String newState);
public void outletNameChanged (int outlet, String newName );
// Something has changed, but we are not sure what
public void stateChanged();
}
Figure 4-2 Masterswitch interface
4.3 Code
4.3.1 SNMP libraries
In an effort to reduce development time and increase reliability, the decision was made to use a
3
rd
party SNMP package. Several Java SNMP implementations exist:
Open Source
JSNMP
i
Westhawk SNMP Stack [ 20 ]
AgentAPI [ 22 ]
JawaOpenEyes (Network Monitoring Tool) [ 23 ]
Commercial
Advent Net [ 24 ]
i
A sub-project of OpenNMS [ 21 ]