[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/transport/web ...

Ron Sigal ron_sigal at yahoo.com
Wed Nov 21 02:01:58 EST 2007


  User: rsigal  
  Date: 07/11/21 02:01:58

  Modified:    src/tests/org/jboss/test/remoting/transport/web  Tag:
                        remoting_2_x WebInvocationHandler.java
  Log:
  JBREM-758, JBREM-792:  Added several new functions.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.4.4   +43 -1     JBossRemoting/src/tests/org/jboss/test/remoting/transport/web/WebInvocationHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WebInvocationHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/transport/web/WebInvocationHandler.java,v
  retrieving revision 1.6.4.3
  retrieving revision 1.6.4.4
  diff -u -b -r1.6.4.3 -r1.6.4.4
  --- WebInvocationHandler.java	2 Nov 2007 06:51:36 -0000	1.6.4.3
  +++ WebInvocationHandler.java	21 Nov 2007 07:01:58 -0000	1.6.4.4
  @@ -22,6 +22,9 @@
   
   package org.jboss.test.remoting.transport.web;
   
  +import java.io.OutputStream;
  +import java.net.InetAddress;
  +import java.net.Socket;
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -29,8 +32,10 @@
   
   import org.apache.log4j.Logger;
   import org.jboss.remoting.InvocationRequest;
  +import org.jboss.remoting.Remoting;
   import org.jboss.remoting.ServerInvocationHandler;
   import org.jboss.remoting.ServerInvoker;
  +import org.jboss.remoting.callback.Callback;
   import org.jboss.remoting.callback.InvokerCallbackHandler;
   
   /**
  @@ -54,8 +59,16 @@
      public static final String SET_CONTENT_TYPE = "setContentType";
      public static final String CONTENT_TYPE = "test/testContentType";
      
  +   public static final String GET_ADDRESS = "getAddress";
  +   public static final String OPEN_CONNECTION = "openConnection";
  +   public static final String SEND_CALLBACK = "sendCallback";
  +   public static final String COPY = "copy:";
  +   public static final int ANSWER = 17;
  +   
      private static Logger log = Logger.getLogger(WebInvocationHandler.class);
   
  +   private InvokerCallbackHandler callbackHandler;
  +
      /**
       * called to handle a specific invocation
       *
  @@ -109,6 +122,35 @@
            returnPayload.put("Content-Type", CONTENT_TYPE);
            return CONTENT_TYPE;
         }
  +      else if (GET_ADDRESS.equals(invocation.getParameter()))
  +      {
  +         InetAddress address = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS);
  +         log.info("returning address: " + address);
  +         return address;
  +      }
  +      else if (OPEN_CONNECTION.equals(invocation.getParameter()))
  +      {
  +         InetAddress addr = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS);
  +         log.info("creating socket connected to: " + addr);
  +         Integer callbackPortInt = (Integer) invocation.getRequestPayload().get("callbackPort");
  +         int callbackPort = callbackPortInt.intValue();
  +         Socket s = new Socket(addr, callbackPort);
  +         log.info("created socket connected to: " + addr);
  +         OutputStream os = s.getOutputStream();
  +         os.write(ANSWER);
  +         log.info("wrote answer");
  +         s.close();
  +         return null;
  +      }
  +      else if (SEND_CALLBACK.equals(invocation.getParameter()))
  +      {
  +         callbackHandler.handleCallback(new Callback("callback"));
  +         return null;
  +      }
  +      else if (((String)invocation.getParameter()).startsWith(COPY))
  +      {
  +         return ((String) invocation.getParameter()).substring(5);
  +      }
         else
         {
            return HTML_PAGE_RESPONSE;
  @@ -123,7 +165,7 @@
       */
      public void addListener(InvokerCallbackHandler callbackHandler)
      {
  -      // NO OP as do not handling callback listeners in this example
  +      this.callbackHandler = callbackHandler;
      }
   
      /**
  
  
  



More information about the jboss-cvs-commits mailing list