可以通过扩展CommandProcessor
并实现RequestHandler来完成
就像我做的那样
public class SNMPRequestProcessor extends CommandProcessor
{
SetHandler setHandler = new SetHandler ();
public SNMPRequestProcessor()
{
//Your code
}
@Override
protected void processRequest(CommandResponderEvent command, CoexistenceInfo cinfo, RequestHandler handler)
{
synchronized (command) {
if (command.getPDU().getType() == PDU.SET) {
super.processRequest(command, cinfo, setHandler);
}
super.processRequest(command, cinfo, handler);
}
}
/**
* Handler for process set request which update to the database
*
*/
class SetHandler implements RequestHandler
{
@Override
public boolean isSupported(int mode)
{
return mode == PDU.SET;
}
@Override
public void processPdu(Request request, MOServer server)
{
//your code
}
}
}