Пример #1
0
  /** Retrieve previous object from the remote scrollable cursor */
  public Object scrollableCursorPreviousObject(
      ObjID remoteScrollableCursorOid, ReadQuery query, DistributedSession session) {
    Transporter transporter = null;
    try {
      transporter =
          getRemoteSessionController()
              .scrollableCursorPreviousObject(new Transporter(remoteScrollableCursorOid));
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }

    if (transporter == null) {
      return null;
    }

    if (!transporter.wasOperationSuccessful()) {
      throw transporter.getException();
    }

    Object object = transporter.getObject();
    if (object == null) {
      // For bug 2797683 do not close if at end of stream.
      return null;
    }

    if (query.isReadAllQuery() && (!query.isReportQuery())) { // could be DataReadQuery
      object =
          session.getObjectCorrespondingTo(
              object,
              transporter.getObjectDescriptors(),
              new IdentityHashMap(),
              (ObjectLevelReadQuery) query);
    }
    return object;
  }
Пример #2
0
  /** Retrieve next page size of objects from the remote cursored stream */
  public Vector cursoredStreamNextPage(
      RemoteCursoredStream remoteCursoredStream,
      ReadQuery query,
      DistributedSession session,
      int pageSize) {
    Transporter transporter = null;
    try {
      transporter =
          getRemoteSessionController()
              .cursoredStreamNextPage(new Transporter(remoteCursoredStream.getID()), pageSize);
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }

    if (transporter == null) {
      return null;
    }

    if (!transporter.wasOperationSuccessful()) {
      throw transporter.getException();
    }

    Vector serverNextPageObjects = (Vector) transporter.getObject();
    if (serverNextPageObjects == null) {
      cursoredStreamClose(remoteCursoredStream.getID());
      return null;
    }
    Vector clientNextPageObjects = serverNextPageObjects;
    if (query.isReadAllQuery() && (!query.isReportQuery())) { // could be DataReadQuery
      clientNextPageObjects = new Vector(serverNextPageObjects.size());
      for (Enumeration objEnum = serverNextPageObjects.elements(); objEnum.hasMoreElements(); ) {
        // 2612538 - the default size of Map (32) is appropriate
        Object clientObject =
            session.getObjectCorrespondingTo(
                objEnum.nextElement(),
                transporter.getObjectDescriptors(),
                new IdentityHashMap(),
                (ObjectLevelReadQuery) query);
        clientNextPageObjects.addElement(clientObject);
      }
    }

    return clientNextPageObjects;
  }