title: How to register a listener on a OID / Managed Object using SNMP4J to act on set or get requests the agent receives?
body: <p>I need to implement a basic <code>snmp</code> agent into my application. This agent should be able to answer get and set requests from <code>snmp</code> browsers on my own <code>OID's</code>. Since most examples for <code>snmp4j</code> are quite old and use the "extend the <code>org.snmp4j.agent.BaseAgent.classapproach"</code> there are of little use. </p>
  
  <p>Therefore tried to understand and strip down the <code>org.snmp4j.agent.example.SampleAgentincluded</code> inside the <code>snmp4j-agent-3.2.1.jar</code>. I managed to get an example working with just the mandatory MIB's ( i at least think they are required because the source of the <code>AgentConfigManager</code> states in a comment they are mandatory <strong>snmpv2MIB, snmpMpdMib, targetMIB, communityMIB, notificationMIB, frameworkMIB, usmMIB, vacmMIB, tlsTmMib</strong> ) provided by the sample config file.</p>
  
  <p>I than added a custom <code>OID</code> to query to the agend using the following code</p>
  
  <pre class="lang-java prettyprint-override"><code>
      MOServer server = new DefaultMOServer();
      MOServer[] moServers = new MOServer[]{server};
      ...
      AgentConfigManager agent = new AgentConfigManager(new OctetString(MPv3.createLocalEngineID()),
                      messageDispatcher,
                      null,
                      moServers,
                      ThreadPool.create("SampleAgent", 3),
                      configurationFactory, 
                      new DefaultMOPersistenceProvider(moServers, configFile),
                      new EngineBootsCounterFile(bootCounterFile), null, dhKickstartParameters);
      ...
      agent.initialize();
      ...
  
      server.register(new MOScalar(new OID("1.someIODshere.0"), MOAccessImpl.ACCESS_READ_ONLY, new OctetString("object 1")), null);
  
  </code></pre>
  
  <p>Now i'm missing a way to intercept get or set requests from <code>snmp</code> managers / browsers to return a dynamic value or change the program behavior according to the request.</p>
  
  <p>I kind of expect to be able to bind a kind of event listener to this <code>OID</code> to get notified on requests / changes.</p>
  
  <p>How to watch an <code>OID</code>?</p>