Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. For each context create a separate ManagedObject instance and register it with the target context using MOServer.register.

    Code Block
    languagejava
    MOScalar myScalarObjAContext1 = new MyScalarObjA(..);
    MOScalar myScalarObjAContext2 = new MyScalarObjA(..);
     
    MOServer server = ..;
    server.register(myScalarObjAContext1, new OctetString("context1"));
    server.register(myScalarObjAContext2, new OctetString("context2"));
  2. Use the same ManagedObject instance for all target contexts by calling MOServer.register repeatedly for each context with the same instance. The single instance is then responsible to deliver and update its content (MIB data) based on the context information given in the ManagedObject.get, .next, .prepare, .commit, .undo, and .cleanup SubRequest parameter in the MOScope (in fact it is then a MOContextScope) member.

    Code Block
    languagejava
    OctetString context1 = new OctetString("context1");
    OctetString context2 = new OctetString("context2");
     
    MOScalar myScalarObjA = new MyScalarObjA(..) {
    	public void get(SubRequest request) {
    		if (request.getScope() instanceof MOContextScope) {
    			MOContextScope scope = (MOContextScope)request.gewtScopegetScope();
    			if (context1.equals(scope.getContext()) {
    				// return value from context1
    				..
    			}
    			else if (context2.equals(scope.getContext()) {				
    				// return value from context2
    				..
    			}
    			else {
    				// cannot be reached
    			}
    		}
    	}
    }
    
    MOServer server = ..;
    server.register(myScalarObjA, context1);
    server.register(myScalarObjA, context2));
  3. Any combination of the above two approaches will work too.

...