Package org.persvr.remote.Client

Examples of org.persvr.remote.Client.IndividualRequest


    public int sendNotification(Notification notification, Client connection,boolean first) throws IOException {
      String pathInfo = notification.getPathInfo();
      InnerResponse innerResponse = new InnerResponse(prefix + pathInfo);
        ObservedCall call = notification.getCall();
        innerResponse.setHeader("Event", call.getMethod());
        IndividualRequest request = connection.getIndividualRequest(null, response);
        request.setRequestedPath(pathInfo, Identification.idForString(pathInfo));
        Object target = call.getContent();
        String output;
      if (target == Scriptable.NOT_FOUND || target == Undefined.instance){
        innerResponse.setStatus(204);
        output ="";
      }
      else
        output = request.serialize(target);
      innerResponse.setHeader("Last-Modified", "" + new Date()); // TODO: This should come from the transaction
      innerResponse.getOutputStream().print(output);
      String message = innerResponse.asString();
      response.getOutputStream().print(message);
      response.getOutputStream().flush();
View Full Code Here


    public int sendNotification(Notification notification, Client connection,boolean first) throws IOException {
      String pathInfo = notification.getPathInfo();
        ObservedCall call = notification.getCall();
        response.setHeader("Event", call.getMethod());
        response.setHeader("Content-Location", prefix + pathInfo);
        IndividualRequest request = connection.getIndividualRequest(null, response);
        request.setRequestedPath(pathInfo, Identification.idForString(pathInfo));
//      target = PersevereServlet.handleRange(range, target, since,response);
      String output = request.serialize(call.getContent());
      response.setHeader("Last-Modified", "" + new Date()); // TODO: This should come from the transaction
        response.getOutputStream().print(output);
        response.getOutputStream().flush();
        return 0;
    }
View Full Code Here

      String pathInfo = notification.getPathInfo();
        ObservedCall call = notification.getCall();
        ServletOutputStream outStream = response.getOutputStream();
        outStream.print(first ? "[" : ",");
        outStream.print("{\"event\":"+JSON.quote(call.getMethod()) + ",\"source\":" + JSON.quote(prefix + pathInfo));
        IndividualRequest request = connection.getIndividualRequest(null, response);
        Client.registerThisConnection(request);
        request.setRequestedPath(pathInfo, Identification.idForString(pathInfo));
//      target = PersevereServlet.handleRange(range, target, since,response);
        Object content = call.getContent();
        if (content != Undefined.instance) {
          outStream.print(",\"result\":");
          try{
View Full Code Here

      @Override
      public Object call(Context cx, Scriptable scope,
          Scriptable thisObj, Object[] args) {
        final StringWriter writer = new StringWriter();
       
        IndividualRequest request = Client.getCurrentObjectResponse();
        HttpServletResponse currentResponse = request.getHttpResponse();
        request.setHttpResponse(new HttpServletResponse(){

          public void addCookie(Cookie arg0) {
          }

          public void addDateHeader(String arg0, long arg1) {
          }

          public void addHeader(String arg0, String arg1) {
          }

          public void addIntHeader(String arg0, int arg1) {
          }

          public boolean containsHeader(String arg0) {
            return false;
          }

          public String encodeRedirectUrl(String arg0) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public String encodeRedirectURL(String arg0) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public String encodeUrl(String arg0) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public String encodeURL(String arg0) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void sendError(int arg0, String arg1) throws IOException {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void sendError(int arg0) throws IOException {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void sendRedirect(String arg0) throws IOException {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void setDateHeader(String arg0, long arg1) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void setHeader(String arg0, String arg1) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void setIntHeader(String arg0, int arg1) {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void setStatus(int arg0, String arg1) {
          }

          public void setStatus(int arg0) {
          }

          public void flushBuffer() throws IOException {
          }

          public int getBufferSize() {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public String getCharacterEncoding() {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public String getContentType() {
            return "application/json";
          }

          public Locale getLocale() {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public ServletOutputStream getOutputStream() throws IOException {
            return new ServletOutputStream(){

              @Override
              public void write(byte[] b) throws IOException {
                writer.write(new String(b));
              }

              @Override
              public void write(int b) throws IOException {
                writer.write(new String(new byte[]{(byte) b}));
               
              }
             
            };
           
          }

          public PrintWriter getWriter() throws IOException {
            return new PrintWriter(writer);
          }

          public boolean isCommitted() {
            throw new UnsupportedOperationException("Not implemented yet");
          }

          public void reset() {
          }

          public void resetBuffer() {
          }

          public void setBufferSize(int arg0) {
          }

          public void setCharacterEncoding(String arg0) {
          }

          public void setContentLength(int arg0) {
          }

          public void setContentType(String arg0) {
          }

          public void setLocale(Locale arg0) {
          }
         
        });
        try{
          DataSerializer.serialize(args[0], args.length > 1 ? (String) args[1] : null);
        }finally{
          request.setHttpResponse(currentResponse);
        }
        return writer.toString();
      }
    },true,false);
    set("_setIdSequence", new PersevereNativeFunction() {
View Full Code Here

    public void propertyChange(List<ObservedCall> evt) {
      for(ObservedCall call : evt){
        if ("MESSAGE".equalsIgnoreCase(call.getMethod())){
          try {
              IndividualRequest request = new Client(null).getIndividualRequest(null, null);
            ((RestChannelsBayeux)bayeux).internalPublish("/" + call.getSourceId(), new JSON.Literal(request.serialize(call.getContent())));
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
        }
      }
View Full Code Here

      return convertIdIfNeeded(idFromJSPONObject((Map) value,id instanceof ObjectId ? (ObjectId) id : null, true));
   
     return convertJsonStringToObject(jsponString);
  }
  public String outputWaitingResponse() throws IOException {
        IndividualRequest requestHandler = Client.getCurrentObjectResponse();
        return requestHandler.outputWaitingData();

  }
View Full Code Here

   * This takes an object and returns a JSPON string representation
   * @param returnValue The object to output
   * @return JSPON string representation
   */
  public String outputReturnObject(Object returnValue)  {
        IndividualRequest requestHandler = Client.getCurrentObjectResponse();
      return requestHandler.serialize(returnValue);
        //requestHandler.outputWaitingData();
       
  }
View Full Code Here

      return requestHandler.serialize(returnValue);
        //requestHandler.outputWaitingData();
       
  }
  public String outputWaitingResponse() throws IOException {
        IndividualRequest requestHandler = Client.getCurrentObjectResponse();
        return requestHandler.outputWaitingData();

  }
View Full Code Here

   */
  public void propertyChange(List<ObservedCall> evts) {
    if (finished) // if it is finished it should be gc'ed soon, but until then, we don't want it doing anything
      return;
    UserSecurity.registerThisThread(authorizedUser);
    IndividualRequest request = Client.getCurrentObjectResponse();
    ((Client)this).adoptThread(Thread.currentThread());
    boolean channelFound = false;
    // we map the resource changes here, so each resource only fires once
    List<Notification> updatedResources = new ArrayList<Notification>();
    for (ObservedCall evt : evts) {
View Full Code Here

          Transaction.currentTransaction().commit();
        }
      }
      //TODO: Release the read set monitoring to free those memory references
      //TODO: Release the IndividualRequest object to free those memory references
      IndividualRequest individualRequest = Client.getCurrentObjectResponse();
      if (individualRequest != null)
        individualRequest.finish(); // indicate we are finished

    }
  }
View Full Code Here

TOP

Related Classes of org.persvr.remote.Client.IndividualRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.