Exemplo n.º 1
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;
  }
Exemplo n.º 2
0
  /** INTERNAL: Returns remote cursor stream */
  public RemoteCursoredStream cursorSelectObjects(
      CursoredStreamPolicy policy, DistributedSession session) {
    try {
      Transporter transporter =
          getRemoteSessionController().cursorSelectObjects(new Transporter(policy));
      if (!transporter.wasOperationSuccessful()) {
        throw transporter.getException();
      }

      RemoteCursoredStream remoteCursoredStream = (RemoteCursoredStream) transporter.getObject();
      remoteCursoredStream.setSession(session);
      remoteCursoredStream.setPolicy(policy);

      if (policy.getQuery().isReadAllQuery()
          && (!policy.getQuery().isReportQuery())) { // could be DataReadQuery
        fixObjectReferences(transporter, (ObjectLevelReadQuery) policy.getQuery(), session);
      }
      return remoteCursoredStream;
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }
  }