Package org.jboss.remoting

Examples of org.jboss.remoting.InvocationRequest


   {
     if (oneway)
     {      
       OnewayInvocation oi = new OnewayInvocation(this);
 
       InvocationRequest request =
         new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
             oi, ONE_WAY_METADATA, null, null);
 
       return request;    
     }
     else
View Full Code Here


      {
         PacketSupport packet = null;
        
         if (obj instanceof InvocationRequest)
         {                       
            InvocationRequest req = (InvocationRequest)obj;
           
            Object param = req.getParameter();
           
            if (param instanceof PacketSupport)
            {
               // A JBM invocation
               packet = (PacketSupport)param;   
View Full Code Here

  
   public Object getPayload()
   {
      //Wrap this in an InvocationRequest
        
      InvocationRequest req = new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
                                                    this, null, null, null);
     
      return req;
   }
View Full Code Here

      InternalInvocation ii = new InternalInvocation(InternalInvocation.HANDLECALLBACK,
                                                     new Object[]{callback});

      OnewayInvocation oi = new OnewayInvocation(ii);

      return new InvocationRequest(null, CallbackManager.JMS_CALLBACK_SUBSYSTEM, oi,
                                   ONE_WAY_METADATA, null, null);
   }
View Full Code Here

      {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
        
         OutputStream oos = new DataOutputStream(bos);
        
         InvocationRequest ir = new InvocationRequest("session123", null, req, null, null, null);  
        
         wf.write(ir, oos);
                 
         byte[] bytes = bos.toByteArray();
        
View Full Code Here

public class HttpMarshaller extends HTTPMarshaller {

    public void write(Object object, OutputStream outputStream, int version) throws IOException {
        if(object instanceof InvocationResponse) {
            Object result = ((InvocationResponse)object).getResult();
            InvocationRequest currentRequest = JBossRemotingGatewayListener.getCurrentRequest();
            boolean sendJavaResponse = false;

            if(result != null && currentRequest != null) {
                Map requestMetadata = currentRequest.getRequestPayload();
                Map responseMetadata = currentRequest.getReturnPayload();
                String userAgent = (String) requestMetadata.get(HTTPMetadataConstants.REMOTING_USER_AGENT);

                sendJavaResponse = JBossRemotingUtil.sendJavaObjectPayload(responseMetadata, userAgent);
            }
           
View Full Code Here

      Object obj = versionedRead(inputStream, invoker, getClass().getClassLoader(), version);

      // setting timestamp since about to start processing
      lastRequestHandledTimestamp = System.currentTimeMillis();

      InvocationRequest req = null;
      boolean createdInvocationRequest = false;
      boolean isError = false;

      if(obj instanceof InvocationRequest)
      {
         req = (InvocationRequest)obj;
      }
      else
      {
         req = createInvocationRequest(obj, socketWrapper);
         createdInvocationRequest = true;
         performVersioning = false;
      }

      Object resp = null;

      try
      {
         // Make absolutely sure thread interrupted is cleared.
         Thread.interrupted();

         if(trace) { log.trace("about to call " + invoker + ".invoke()"); }

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

      else
      {
         // need to wrap request with invocation request
         SocketAddress remoteAddress = socketWrapper.getSocket().getRemoteSocketAddress();

         return new InvocationRequest(remoteAddress.toString(),
                                      invoker.getSupportedSubsystems()[0],
                                      obj, null, null, null);
      }
   }
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

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

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

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

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.