Beispiel #1
0
 private ManagedObject findMOForOid(OID oid) {
   final List<ManagedObject> list = m_moList.get();
   for (ManagedObject mo : list) {
     if (mo.getScope().covers(oid)) {
       return mo;
     }
   }
   return null;
 }
Beispiel #2
0
  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;
  }