Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
 /** INTERNAL: Extract the correct query result from the transporter. */
 public Object extractRemoteResult(Transporter transporter) {
   return ((RemoteSession) getSession())
       .getObjectsCorrespondingToAll(
           transporter.getObject(),
           transporter.getObjectDescriptors(),
           new IdentityHashMap(),
           this,
           getContainerPolicy());
 }
Ejemplo n.º 3
0
 /** INTERNAL: Begin an early unit of work transaction. */
 public void beginEarlyTransaction() {
   try {
     Transporter transporter = getRemoteSessionController().beginEarlyTransaction();
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 4
0
 /** INTERNAL: Reset the cache on the server-side session. */
 public void initializeIdentityMapsOnServerSession() {
   try {
     Transporter transporter =
         getRemoteSessionController().initializeIdentityMapsOnServerSession();
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 5
0
 /** Return the scrollable cursor size */
 public int scrollableCursorSize(ObjID cursorId) {
   Transporter transporter = null;
   try {
     transporter = getRemoteSessionController().scrollableCursorSize(new Transporter(cursorId));
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
   if (!transporter.wasOperationSuccessful()) {
     throw transporter.getException();
   }
   return ((Integer) transporter.getObject()).intValue();
 }
Ejemplo n.º 6
0
 /** INTERNAL: Return the table descriptor specified for the class. */
 public Login getLogin() {
   try {
     Transporter transporter = getRemoteSessionController().getLogin();
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     } else {
       return (Login) transporter.getObject();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 7
0
 /** INTERNAL Return the read-only classes */
 public Vector getDefaultReadOnlyClasses() {
   try {
     Transporter transporter = getRemoteSessionController().getDefaultReadOnlyClasses();
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     } else {
       return (Vector) transporter.getObject();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 8
0
 /** Used for closing scrollable cursor across RMI. */
 public void scrollableCursorClose(ObjID remoteScrollableCursorOid) {
   Transporter transporter = null;
   try {
     transporter =
         getRemoteSessionController()
             .scrollableCursorClose(new Transporter(remoteScrollableCursorOid));
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
   if (!transporter.wasOperationSuccessful()) {
     throw transporter.getException();
   }
 }
Ejemplo n.º 9
0
 /** INTERNAL: Return the table descriptor specified for the alias. */
 public ClassDescriptor getDescriptorForAlias(String alias) {
   try {
     Transporter transporter =
         getRemoteSessionController().getDescriptorForAlias(new Transporter(alias));
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     } else {
       return (ClassDescriptor) transporter.getObject();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 10
0
 /**
  * ADVANCED: This method will send the command to the remote session for processing
  *
  * @param command RemoteCOmmand Contains a command that will be executed on the remote session
  * @see org.eclipse.persistence.internal.sessions.remote.RemoteCommand
  */
 public void processCommand(RemoteCommand command) {
   try {
     Transporter transporter = new Transporter();
     transporter.setObject(command);
     transporter.prepare(this.session);
     transporter = getRemoteSessionController().processCommand(transporter);
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 11
0
 /** INTERNAL: Instantiate remote value holder on the server */
 public Transporter instantiateRemoteValueHolderOnServer(RemoteValueHolder remoteValueHolder) {
   try {
     Transporter transporter =
         getRemoteSessionController()
             .instantiateRemoteValueHolderOnServer(new Transporter(remoteValueHolder));
     transporter.expand(this.session);
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     }
     return transporter;
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 12
0
  /** INTERNAL: Perform remote function call */
  public Object getSequenceNumberNamed(Object remoteFunctionCall) {
    try {
      Transporter transporter =
          getRemoteSessionController().getSequenceNumberNamed(new Transporter(remoteFunctionCall));
      Object returnValue = transporter.getObject();

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

      return returnValue;
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }
  }
Ejemplo n.º 13
0
 /** INTERNAL: Execute query remotely. */
 public Transporter remoteExecuteNamedQuery(String name, Class javaClass, Vector arguments) {
   try {
     Transporter transporter =
         getRemoteSessionController()
             .executeNamedQuery(
                 new Transporter(name), new Transporter(javaClass), new Transporter(arguments));
     transporter.expand(this.session);
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     }
     return transporter;
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 14
0
  /** Indicates whether the cursor is after the last row in the result set. */
  public boolean scrollableCursorIsAfterLast(ObjID remoteScrollableCursorOid) {
    Transporter transporter = null;
    try {
      transporter =
          getRemoteSessionController()
              .scrollableCursorIsAfterLast(new Transporter(remoteScrollableCursorOid));
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }
    if (transporter == null) {
      return false;
    }

    if (!transporter.wasOperationSuccessful()) {
      throw transporter.getException();
    }
    return ((Boolean) transporter.getObject()).booleanValue();
  }
Ejemplo n.º 15
0
  /** Retrieves the current row index number */
  public int scrollableCursorCurrentIndex(ObjID remoteScrollableCursorOid) {
    Transporter transporter = null;
    try {
      transporter =
          getRemoteSessionController()
              .scrollableCursorAfterLast(new Transporter(remoteScrollableCursorOid));
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }
    if (transporter == null) {
      return -1;
    }

    if (!transporter.wasOperationSuccessful()) {
      throw transporter.getException();
    }
    return ((Integer) transporter.getObject()).intValue();
  }
Ejemplo n.º 16
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;
  }
Ejemplo n.º 17
0
  /** INTERNAL: Returns remote cursor stream */
  public RemoteScrollableCursor cursorSelectObjects(
      ScrollableCursorPolicy policy, DistributedSession session) {
    try {
      Transporter transporter =
          getRemoteSessionController().cursorSelectObjects(new Transporter(policy));
      if (!transporter.wasOperationSuccessful()) {
        throw transporter.getException();
      }

      RemoteScrollableCursor remoteScrollableCursor =
          (RemoteScrollableCursor) transporter.getObject();
      remoteScrollableCursor.setSession(session);
      remoteScrollableCursor.setPolicy(policy);

      return remoteScrollableCursor;
    } catch (RemoteException exception) {
      throw CommunicationException.errorInInvocation(exception);
    }
  }
Ejemplo n.º 18
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);
    }
  }
Ejemplo n.º 19
0
 /** INTERNAL: Commit root unit of work from the client side to the server side. */
 public RemoteUnitOfWork commitRootUnitOfWork(RemoteUnitOfWork theRemoteUnitOfWork) {
   try {
     Transporter transporter = new Transporter();
     transporter.setObject(theRemoteUnitOfWork);
     transporter.prepare(this.session);
     transporter = getRemoteSessionController().commitRootUnitOfWork(transporter);
     transporter.expand(this.session);
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     } else {
       return (RemoteUnitOfWork) transporter.getObject();
     }
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }
Ejemplo n.º 20
0
 /** INTERNAL: Execute the query on the server. */
 public Transporter remoteExecute(DatabaseQuery query) {
   try {
     Transporter transporter = new Transporter();
     transporter.setObject(query);
     transporter.prepare(this.session);
     transporter = getRemoteSessionController().executeQuery(transporter);
     transporter.expand(session);
     if (!transporter.wasOperationSuccessful()) {
       throw transporter.getException();
     }
     return transporter;
   } catch (RemoteException exception) {
     throw CommunicationException.errorInInvocation(exception);
   }
 }