コード例 #1
0
 protected void registerScalar(String oid, String value) {
   try {
     server.register(
         new MOScalar<Variable>(
             new OID(oid), MOAccessImpl.ACCESS_READ_CREATE, new OctetString(value)),
         null);
   } catch (DuplicateRegistrationException drex) {
     logger.error(
         "Duplicate registration: "
             + drex.getMessage()
             + "."
             + " MIB object registration may be incomplete!",
         drex);
   }
 }
コード例 #2
0
ファイル: SampleAgent.java プロジェクト: codefans/test-utf8
  public Variable getVariable(String name) {
    OID oid;
    OctetString context = null;
    int pos = name.indexOf(':');
    if (pos >= 0) {
      context = new OctetString(name.substring(0, pos));
      oid = new OID(name.substring(pos + 1, name.length()));
    } else {
      oid = new OID(name);
    }
    final DefaultMOContextScope scope = new DefaultMOContextScope(context, oid, true, oid, true);
    MOQuery query = new DefaultMOQuery(scope, false, this);
    ManagedObject mo = server.lookup(query);
    if (mo != null) {
      final VariableBinding vb = new VariableBinding(oid);
      final RequestStatus status = new RequestStatus();
      SubRequest req =
          new SubRequest() {
            private boolean completed;
            private MOQuery query;

            public boolean hasError() {
              return false;
            }

            public void setErrorStatus(int errorStatus) {
              status.setErrorStatus(errorStatus);
            }

            public int getErrorStatus() {
              return status.getErrorStatus();
            }

            public RequestStatus getStatus() {
              return status;
            }

            public MOScope getScope() {
              return scope;
            }

            public VariableBinding getVariableBinding() {
              return vb;
            }

            public Request getRequest() {
              return null;
            }

            public Object getUndoValue() {
              return null;
            }

            public void setUndoValue(Object undoInformation) {}

            public void completed() {
              completed = true;
            }

            public boolean isComplete() {
              return completed;
            }

            public void setTargetMO(ManagedObject managedObject) {}

            public ManagedObject getTargetMO() {
              return null;
            }

            public int getIndex() {
              return 0;
            }

            public void setQuery(MOQuery query) {
              this.query = query;
            }

            public MOQuery getQuery() {
              return query;
            }

            public SubRequestIterator repetitions() {
              return null;
            }

            public void updateNextRepetition() {}

            public Object getUserObject() {
              return null;
            }

            public void setUserObject(Object userObject) {}
          };
      mo.get(req);
      return vb.getVariable();
    }
    return null;
  }
コード例 #3
0
ファイル: StaticMOGroup.java プロジェクト: GEBIT/snmp4j
 public void unregisterMOs(MOServer server, OctetString context) {
   server.unregister(this, context);
 }
コード例 #4
0
ファイル: StaticMOGroup.java プロジェクト: GEBIT/snmp4j
 public void registerMOs(MOServer server, OctetString context)
     throws DuplicateRegistrationException {
   server.register(this, context);
 }