Package org.jboss.remoting

Examples of org.jboss.remoting.InvocationRequest


         Home home = null;
         try
         {
            home = (Home) it.next();
            locator = new InvokerLocator(protocol, home.host, home.port, path, params);
            invoke(new InvocationRequest(null, null, ServerInvoker.ECHO, null, null, null));
            if (log.isTraceEnabled()) log.trace(this + " able to contact server at: " + home);
            return home;
         }
         catch (Throwable e)
         {
View Full Code Here


         try
         {
            home = (Home) it.next();
            addr = getAddressByName(home.host);
            address = createServerAddress(addr, home.port);
            invoke(new InvocationRequest(null, null, ServerInvoker.ECHO, null, null, null));
            if (trace) log.trace(this + " able to contact server at: " + home);
            return home;
         }
         catch (Throwable e)
         {
View Full Code Here

      }

      boolean serverSideOneway = false;
      if (oneway && invocation instanceof InvocationRequest)
      {
         InvocationRequest ir = (InvocationRequest) invocation;
         if (ir.getParameter() instanceof OnewayInvocation)
            serverSideOneway = true;
      }
     
      int retryCount = 0;
      Exception sockEx = null;
View Full Code Here

         }
      }

      if (payload instanceof InvocationRequest)
      {
         InvocationRequest ir = (InvocationRequest) payload;
         Map metadata = ir.getRequestPayload();
         if (metadata == null)
         {
            metadata = new HashMap();
            ir.setRequestPayload(metadata);
         }
         try
         {
            String clientHost = RemoteServer.getClientHost();
            InetAddress clientAddress = getAddressByName(clientHost);
View Full Code Here

            {
               String userAgent = (String) userAgentObj;
               isRemotingUserAgent = userAgent.startsWith("JBossRemoting");
            }

            InvocationRequest invocationRequest = versionedRead(req, request, response, version);

            if (invocationRequest.getRequestPayload() == null)
               invocationRequest.setRequestPayload(new HashMap());
           
            MessageBytes remoteAddressMB = req.remoteAddr();
            if (remoteAddressMB != null)
            {
               String remoteAddressString = remoteAddressMB.toString();
               InetAddress remoteAddress = getAddressByName(remoteAddressString);
               invocationRequest.getRequestPayload().put(Remoting.CLIENT_ADDRESS, remoteAddress)
            }
            else
            {
               log.debug("unable to retrieve client address from coyote transport layer");
            }
           
           
            // FIXME: OPTIONS method handling ?
            try
            {
               // call transport on the subclass, get the result to handback
               responseObject = invoke(invocationRequest);
            }
            catch(Throwable ex)
            {
               log.debug("Error thrown calling invoke on server invoker.", ex);
               responseObject = ex;
               isError = true;
            }

            //Start with response code of 204 (no content), then if is a return from handler, change to 200 (ok)
            int status;
            String message = "";

            if(responseObject != null)
            {
               if(isError)
               {
                  status = 500;
                  message = "JBoss Remoting: Error occurred within target application.";
               }
               else
               {
                  status = 200;
                  message = "OK";
               }
            }
            else
            {
               if (isRemotingUserAgent && !req.method().equals("HEAD"))
               {
                  status = 200;
                  message = "OK";
               }
               else
               {
                  status = 204;
                  message = "No Content";
               }
            }

            // extract response code/message if exists
            Map responseMap = invocationRequest.getReturnPayload();
            if(responseMap != null)
            {
               Integer handlerStatus = (Integer) responseMap.get(HTTPMetadataConstants.RESPONSE_CODE);
               if(handlerStatus != null)
               {
                  status = handlerStatus.intValue();
               }
               String handlerMessage = (String) responseMap.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
               if(handlerMessage != null)
               {
                  message = handlerMessage;
               }
            }
            res.setStatus(status);
            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

            {
               request.put(HTTPUnMarshaller.PRESERVE_LINES, o);
            }

            receivedInvocationRequest.set(FALSE);
            InvocationRequest invocationRequest = null;
            MessageBytes method = req.method();
            if (method.equals("GET") || method.equals("HEAD")
                  || (method.equals("OPTIONS") && req.getContentLength() <= 0))
            {
               invocationRequest = createNewInvocationRequest(request, response, null);
            } else
            {
               // must be POST or PUT
               UnMarshaller unmarshaller = getUnMarshaller();
               Object obj = null;
               if (unmarshaller instanceof VersionedUnMarshaller)
                  obj = ((VersionedUnMarshaller)unmarshaller).read(request.getInputStream(), request, version);
               else
                  obj = unmarshaller.read(request.getInputStream(), request);
               if (obj instanceof InvocationRequest)
               {
                  receivedInvocationRequest.set(TRUE);
                  invocationRequest = (InvocationRequest) obj;
                  if (invocationRequest.getReturnPayload() == null)
                  {
                     // need to create a return payload map, so can be populated with metadata
                     invocationRequest.setReturnPayload(response);
                  }
                  Map requestPayloadMap = invocationRequest.getRequestPayload();
                  if (requestPayloadMap != null)
                  {
                     request.putAll(requestPayloadMap);
                  }
                  invocationRequest.setRequestPayload(request);
               } else
               {
                  invocationRequest = createNewInvocationRequest(request, response, obj);
               }
            }
View Full Code Here

   {
      // will try to use the same session id if possible to track
      String sessionId = getSessionId(requestMap);
      String subSystem = (String) requestMap.get(HEADER_SUBSYSTEM);

      InvocationRequest request = null;

      boolean isLeaseQueury = checkForLeaseQuery(requestMap);
      if(isLeaseQueury)
      {
         addLeaseInfo(responseMap);
         request = new InvocationRequest(sessionId, subSystem, "$PING$", null, responseMap, null);
      }
      else
      {
         request = new InvocationRequest(sessionId, subSystem, payload,
                                                        requestMap, responseMap, null);
      }
      return request;
   }
View Full Code Here

      return HTTPMarshaller.DATATYPE;
   }

   protected InvocationRequest getInvocationRequest(Map metadata, Object obj)
   {
      InvocationRequest request = null;

      if(obj instanceof InvocationRequest)
      {
         request = (InvocationRequest) obj;
         if(request.getRequestPayload() == null)
         {
            request.setRequestPayload(metadata);
         }
         else
         {
            request.getRequestPayload().putAll(metadata);
         }
      }
      else
      {
         request = createNewInvocationRequest(metadata, obj);
View Full Code Here

   {
      // will try to use the same session id if possible to track
      String sessionId = getSessionId(metadata);
      String subSystem = (String) metadata.get(HEADER_SUBSYSTEM);

      InvocationRequest request = null;
      Map responseMap = new HashMap();
      boolean isLeasQuery = checkForLeaseQuery(metadata);
      if(isLeasQuery)
      {
         addLeaseInfo(responseMap);
         request = new CreatedInvocationRequest(sessionId, subSystem, "$PING$", null, responseMap, null);
      }
      else
      {
         request = new CreatedInvocationRequest(sessionId, subSystem, payload, metadata, null, null);
      }
      request.setReturnPayload(responseMap);
      return request;
   }
View Full Code Here

      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();
View Full Code Here

TOP

Related Classes of org.jboss.remoting.InvocationRequest

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.