public IRegisterDMData readRegister(Object element) {
    /*
     * Get the DMC and the session. If element is not an register DMC, or
     * session is stale, then bail out.
     */
    IRegisterDMContext dmc = getRegisterDMC(element);
    if (dmc == null) return null;
    DsfSession session = DsfSession.getSession(dmc.getSessionId());
    if (session == null) return null;

    /*
     * Create the query to request the value from service. Note: no need to
     * guard agains RejectedExecutionException, because
     * DsfSession.getSession() above would only return an active session.
     */
    GetRegisterValueQuery query = new GetRegisterValueQuery(dmc);
    session.getExecutor().execute(query);

    /*
     * Now we have the data, go and get it. Since the call is completed now
     * the ".get()" will not suspend it will immediately return with the
     * data.
     */
    try {
      return query.get();
    } catch (InterruptedException e) {
      assert false;
      return null;
    } catch (ExecutionException e) {
      return null;
    }
  }
  public void writeRegister(Object element, String value, String formatId) {

    /*
     * Get the DMC and the session. If element is not an register DMC, or
     * session is stale, then bail out.
     */
    IRegisterDMContext dmc = getRegisterDMC(element);
    if (dmc == null) return;
    DsfSession session = DsfSession.getSession(dmc.getSessionId());
    if (session == null) return;

    /*
     * Create the query to write the value to the service. Note: no need to
     * guard agains RejectedExecutionException, because
     * DsfSession.getSession() above would only return an active session.
     */
    SetRegisterValueQuery query = new SetRegisterValueQuery(dmc, value, formatId);
    session.getExecutor().execute(query);

    /*
     * Now we have the data, go and get it. Since the call is completed now
     * the ".get()" will not suspend it will immediately return with the
     * data.
     */
    try {
      /*
       * Return value is irrelevant, any error would come through with an
       * exception.
       */
      query.get();
    } catch (InterruptedException e) {
      assert false;
    } catch (ExecutionException e) {
      /*
       * View must be shutting down, no need to show erro dialog.
       */
    }
  }
  public IRegisterDMData getRegisterDMData(Object element) {
    IRegisterDMContext dmc = null;
    if (element instanceof IDMVMContext) {
      dmc =
          DMContexts.getAncestorOfType(
              ((IDMVMContext) element).getDMContext(), IRegisterDMContext.class);
    }

    if (dmc != null) {
      DsfSession session = DsfSession.getSession(dmc.getSessionId());

      if (session != null) {
        GetRegisterDataQuery query = new GetRegisterDataQuery(dmc);
        session.getExecutor().execute(query);

        try {
          return query.get();
        } catch (InterruptedException e) {
        } catch (ExecutionException e) {
        }
      }
    }
    return null;
  }