Package org.jboss.remoting

Examples of org.jboss.remoting.InvocationResponse


/* 416 */     return result;
/*     */   }
/*     */
/*     */   private Object checkForLeasePing(HttpURLConnection conn, Object invocation, Map metadata) throws IOException
/*     */   {
/* 421 */     InvocationResponse response = null;
/* 422 */     boolean shouldLease = false;
/* 423 */     long leasePeriod = -1L;
/*     */
/* 425 */     if ((invocation != null) && ((invocation instanceof InvocationRequest)))
/*     */     {
/* 427 */       InvocationRequest request = (InvocationRequest)invocation;
/*     */
/* 429 */       Object payload = request.getParameter();
/*     */
/* 431 */       if ((payload != null) && ((payload instanceof String)) && ("$PING$".equalsIgnoreCase((String)payload)) && (request.getReturnPayload() != null))
/*     */       {
/*     */         try
/*     */         {
/* 436 */           conn.setDoOutput(false);
/* 437 */           conn.setDoInput(true);
/* 438 */           conn.setRequestMethod("HEAD");
/*     */
/* 440 */           conn.setRequestProperty("JBoss-Remoting-Version", new Integer(Version.getDefaultVersion()).toString());
/*     */
/* 442 */           conn.setRequestProperty("User-Agent", "JBossRemoting - 2.2.2.SP3 (Bluto)");
/* 443 */           conn.setRequestProperty("JBoss-Remoting-Lease-Query", "true");
/* 444 */           conn.setRequestProperty("sessionId", request.getSessionId());
/* 445 */           conn.connect();
/*     */
/* 448 */           Map headers = conn.getHeaderFields();
/*     */
/* 450 */           if (headers != null)
/*     */           {
/* 452 */             Object leasingEnabled = headers.get("LEASING_ENABLED");
/* 453 */             if ((leasingEnabled != null) && ((leasingEnabled instanceof List)))
/*     */             {
/* 455 */               shouldLease = new Boolean((String)((List)leasingEnabled).get(0)).booleanValue();
/*     */             }
/* 457 */             Object leasingPeriod = headers.get("LEASE_PERIOD");
/* 458 */             if ((leasingPeriod != null) && ((leasingPeriod instanceof List)))
/*     */             {
/* 460 */               leasePeriod = new Long((String)((List)leasingPeriod).get(0)).longValue();
/*     */             }
/*     */           }
/*     */         }
/*     */         catch (IOException e)
/*     */         {
/* 466 */           log.error("Error checking server for lease information.", e);
/*     */         }
/*     */
/* 469 */         Map p = new HashMap();
/* 470 */         p.put("clientLeasePeriod", new Long(leasePeriod));
/* 471 */         InvocationResponse innterResponse = new InvocationResponse(null, new Boolean(shouldLease), false, p);
/* 472 */         response = new InvocationResponse(null, innterResponse, false, null);
/*     */       }
/*     */
/*     */     }
/*     */
/* 477 */     return response;
View Full Code Here


/* 117 */     os.flush();
/*     */   }
/*     */
/*     */   public Object getPayload()
/*     */   {
/* 122 */     return new InvocationResponse(this.sessionID, this.callbacks, false, null);
/*     */   }
View Full Code Here

/*    */
/*    */   public abstract Object getResponse();
/*    */
/*    */   public Object getPayload()
/*    */   {
/* 53 */     InvocationResponse resp = new InvocationResponse(null, this, false, null);
/*    */
/* 55 */     return resp;
/*    */   }
View Full Code Here

/* 192 */           packet = new SerializedPacket(req);
/*     */         }
/*     */       }
/* 195 */       else if ((obj instanceof InvocationResponse))
/*     */       {
/* 197 */         InvocationResponse resp = (InvocationResponse)obj;
/*     */
/* 199 */         Object param = resp.getResult();
/*     */
/* 201 */         if ((param instanceof ResponseSupport))
/*     */         {
/* 205 */           packet = (ResponseSupport)param;
/*     */
/* 207 */           if (this.trace) log.trace("JBM Response");
/*     */         }
/* 209 */         else if ((param instanceof List))
/*     */         {
/* 214 */           packet = new PolledCallbacksDelivery((List)param, resp.getSessionId());
/*     */         }
/* 216 */         else if (param == null)
/*     */         {
/* 219 */           packet = new NullResponse();
/*     */
View Full Code Here

/*    */     throws IOException, ClassNotFoundException
/*    */   {
/* 47 */     Object object = super.receiveObject(inputStream, customClassLoader);
/* 48 */     if ((object instanceof InvocationResponse))
/*    */     {
/* 50 */       InvocationResponse ir = (InvocationResponse)object;
/* 51 */       Object obj = ir.getResult();
/* 52 */       if ((obj instanceof SealedObject))
/*    */       {
/*    */         try
/*    */         {
/* 56 */           object = new InvocationResponse(ir.getSessionId(), EncryptionUtil.unsealObject((SealedObject)obj), ir.isException(), ir.getPayload());
/*    */         }
/*    */         catch (Exception e)
/*    */         {
/* 62 */           e.printStackTrace();
/*    */         }
View Full Code Here

/*     */
/* 564 */       if ("$GET_CLIENT_LOCAL_ADDRESS$".equals(req.getParameter()))
/*     */       {
/* 566 */         Socket s = socketWrapper.getSocket();
/* 567 */         InetAddress a = s.getInetAddress();
/* 568 */         resp = new InvocationResponse(req.getSessionId(), a, false, null);
/*     */       }
/*     */       else
/*     */       {
/* 573 */         resp = this.invoker.invoke(req);
/*     */       }
/*     */
/* 576 */       if (trace) log.trace(this.invoker + ".invoke() returned " + resp);
/*     */     }
/*     */     catch (Throwable ex)
/*     */     {
/* 580 */       resp = ex;
/* 581 */       isError = true;
/* 582 */       if (trace) log.trace(this.invoker + ".invoke() call failed", ex);
/*     */     }
/*     */
/* 585 */     Thread.interrupted();
/*     */
/* 587 */     if (isOneway(req.getRequestPayload()))
/*     */     {
/* 589 */       if (trace) log.trace("oneway request, writing no reply on the wire");
/*     */     }
/*     */     else
/*     */     {
/* 593 */       if (!createdInvocationRequest)
/*     */       {
/* 596 */         if (trace) log.trace("creating response instance");
/* 597 */         resp = new InvocationResponse(req.getSessionId(), resp, isError, req.getReturnPayload());
/*     */       }
/*     */
/* 600 */       OutputStream outputStream = socketWrapper.getOutputStream();
/* 601 */       if (performVersioning)
/*     */       {
View Full Code Here

/*  366 */         res.setMessage(message);
/*      */
/*  368 */         if ((this.isRemotingUserAgent) && (((Boolean)receivedInvocationRequest.get()).booleanValue()))
/*      */         {
/*  370 */           responseMap = ((ResponseMap)responseMap).getMap();
/*  371 */           responseObject = new InvocationResponse(invocationRequest.getSessionId(), responseObject, isError, responseMap);
/*      */         }
/*      */
/*  375 */         if (responseObject != null)
/*      */         {
/*  377 */           versionedWrite(version, responseObject, req, res, response);
View Full Code Here

/*     */
/* 239 */         if (checkForExceptionReturn(metadata))
/*     */         {
/* 241 */           String sessionId = invocationRequest.getSessionId();
/* 242 */           ServletThrowable st = new ServletThrowable(ex);
/* 243 */           invocationResponse = new InvocationResponse(sessionId, st, true, null);
/*     */         }
/*     */         else
/*     */         {
/* 247 */           isError = true;
/*     */         }
View Full Code Here

         // handle socket-specific invocations
         if ("$GET_CLIENT_LOCAL_ADDRESS$".equals(req.getParameter()))
         {
            Socket s = socketWrapper.getSocket();
            InetAddress a = s.getInetAddress();
            resp = new InvocationResponse(req.getSessionId(), a, false, null);
         }
         else
         {
             // call transport on the subclass, get the result to handback
             resp = invoker.invoke(req);
         }

         if(trace) { log.trace(invoker + ".invoke() returned " + resp); }
      }
      catch (Throwable ex)
      {
         resp = ex;
         isError = true;
         if (trace) log.trace(invoker + ".invoke() call failed", ex);
      }

      Thread.interrupted(); // clear interrupted state so we don't fail on socket writes

      if(isOneway(req.getRequestPayload()))
      {
         if(trace) { log.trace("oneway request, writing no reply on the wire"); }
      }
      else
      {
         if(!createdInvocationRequest)
         {
            // need to return invocation response
            if(trace) { log.trace("creating response instance"); }
            resp = new InvocationResponse(req.getSessionId(), resp, isError, req.getReturnPayload());
         }

         OutputStream outputStream = socketWrapper.getOutputStream();
         if (performVersioning)
         {
View Full Code Here

      return result;
   }

   private Object checkForLeasePing(HttpURLConnection conn, Object invocation, Map metadata) throws IOException
   {
      InvocationResponse response = null;
      boolean shouldLease = false;
      long leasePeriod = -1;

      if(invocation != null && invocation instanceof InvocationRequest)
      {
         InvocationRequest request = (InvocationRequest)invocation;

         Object payload = request.getParameter();
         // although a bit of a hack, this will determin if first time ping called by client.
         if(payload != null && payload instanceof String && "$PING$".equalsIgnoreCase((String)payload) && request.getReturnPayload() != null)
         {
            try
            {
               // now know is a ping request, so convert to be a HEAD method call
               conn.setDoOutput(false);
               conn.setDoInput(true);
               conn.setRequestMethod("HEAD");

               conn.connect();

               //InputStream is = (conn.getResponseCode() < 400) ? conn.getInputStream() : conn.getErrorStream();
               Map headers = conn.getHeaderFields();

               if(headers != null)
               {
                  Object leasingEnabled = headers.get("LEASING_ENABLED");
                  if(leasingEnabled != null && leasingEnabled instanceof List)
                  {
                     shouldLease = new Boolean((String)((List)leasingEnabled).get(0)).booleanValue();
                  }
                  Object leasingPeriod = headers.get("LEASE_PERIOD");
                  if(leasingPeriod != null && leasingPeriod instanceof List)
                  {
                     leasePeriod = new Long((String)((List)leasingPeriod).get(0)).longValue();
                  }
               }
            }
            catch (IOException e)
            {
               log.error("Error checking server for lease information.", e);
            }

            Map p = new HashMap();
            p.put("clientLeasePeriod", new Long(leasePeriod));
            InvocationResponse innterResponse = new InvocationResponse(null, new Boolean(shouldLease), false, p);
            response = new InvocationResponse(null, innterResponse, false, null);

         }
      }

      return response;
View Full Code Here

TOP

Related Classes of org.jboss.remoting.InvocationResponse

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.