Package org.jboss.remoting

Examples of org.jboss.remoting.InvocationResponse


               packet = new SerializedPacket(req);              
            }
         }        
         else if (obj instanceof InvocationResponse)
         {
            InvocationResponse resp = (InvocationResponse)obj;
           
            Object param = resp.getResult();
           
            if (param instanceof ResponseSupport)
            {
               // A JBM invocation response
              
               packet = (ResponseSupport)param;
            
               if (trace) { log.trace("JBM Response"); }
            }
            else if (param instanceof List)
            {
               // List of polled Callbacks, this is how messages are delivered when using
               // polled callbacks e.g. the HTTP transport
              
               packet = new PolledCallbacksDelivery((List)param, resp.getSessionId());            
            }
            else if (param == null)
            {
               // Null response
               packet = new NullResponse();
View Full Code Here


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

                     WebServerError ex = new WebServerError((String)result);
                     return ex;
                  }
                  else if (result instanceof InvocationResponse)
                  {
                     InvocationResponse response = (InvocationResponse) result;
                     Object innerResult = response.getResult();
                     if (innerResult instanceof ServletThrowable)
                     {
                        return ((ServletThrowable) innerResult).getCause();
                     }
                     else
                     {
                        return innerResult;
                     }
                  }
                  else
                  {
                     return result;
                  }
               }
            }
         }


         // if got here, wasn't configured to not throw exception, so will throw it.

         // In this case, MicroRemoteClientInvoker will throw the exception carried by
         // the InvocationResponse.
         if (result instanceof InvocationResponse)
         {
            if ((((InvocationResponse) result).getResult()) instanceof ServletThrowable)
            {
               InvocationResponse response = (InvocationResponse) result;
               ServletThrowable st = (ServletThrowable) response.getResult();
               Throwable t = st.getCause();
               InvocationResponse ir = new InvocationResponse(response.getSessionId(),
                                                              t,
                                                              response.isException(),
                                                              response.getPayload());
               return ir;
            }
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");
               // set the remoting version
               conn.setRequestProperty(HTTPMetadataConstants.REMOTING_VERSION_HEADER, new Integer(Version.getDefaultVersion()).toString());
               // set the user agent
               conn.setRequestProperty(HTTPMetadataConstants.REMOTING_USER_AGENT, "JBossRemoting - " + Version.VERSION);
               conn.setRequestProperty(HTTPMetadataConstants.REMOTING_LEASE_QUERY, "true");
               conn.setRequestProperty("sessionId", request.getSessionId());
               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

         // 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

            res.setMessage(message);

            if (isRemotingUserAgent && ((Boolean)receivedInvocationRequest.get()).booleanValue())
            {
               responseMap = ((ResponseMap) responseMap).getMap();
               responseObject = new InvocationResponse(invocationRequest.getSessionId(),
                                                       responseObject, isError, responseMap);
            }

            if(responseObject != null)
            {
View Full Code Here

      log.info("connection is good");
     
      // Get address of server.
      Object o = client.invoke("$GET_CLIENT_LOCAL_ADDRESS$");
      assertTrue(o instanceof InvocationResponse);
      InvocationResponse response = (InvocationResponse) o;
      assertTrue(response.getResult() instanceof InetAddress);
      InetAddress newAddress = (InetAddress) response.getResult();
      String newLocatorURI = getTransport() + "://" + newAddress.getHostAddress() + ":" + port;
      log.info("new locator: " + newLocatorURI);
     
      // Try to connect to locator constructed from returned address.
      Client newClient = new Client(new InvokerLocator(newLocatorURI));
View Full Code Here

      log.info("connection is good");
     
      // Get address of server.
      Object o = client.invoke("$GET_CLIENT_LOCAL_ADDRESS$");
      assertTrue(o instanceof InvocationResponse);
      InvocationResponse response = (InvocationResponse) o;
      assertTrue(response.getResult() instanceof InetAddress);
      InetAddress newAddress = (InetAddress) response.getResult();
      String newLocatorURI = getTransport() + "://" + newAddress.getHostAddress() + ":" + port;
      log.info("new locator: " + newLocatorURI);
     
      // Try to connect to locator constructed from returned address.
      Client newClient = new Client(new InvokerLocator(newLocatorURI));
View Full Code Here

            res.setMessage(message);

            if (isRemotingUserAgent && ((Boolean)receivedInvocationRequest.get()).booleanValue())
            {
               responseMap = ((ResponseMap) responseMap).getMap();
               responseObject = new InvocationResponse(invocationRequest.getSessionId(),
                                                       responseObject, isError, responseMap);
            }

            if(responseObject != null)
            {
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

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.