axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject cvs commit: xml-axis/proposals/jabber/src TestClient.java Test.java
Date Thu, 16 Jan 2003 06:24:06 GMT
jmsnell     2003/01/15 22:24:06

  Modified:    proposals/jabber/src/com/snellspace/axis/jabber
                        JabberSender.java JabberConnection.java
                        JabberServer.java
               proposals/jabber/src TestClient.java Test.java
  Log:
  Fixing a bug in Jabber message serialization
  
  Revision  Changes    Path
  1.2       +24 -24    xml-axis/proposals/jabber/src/com/snellspace/axis/jabber/JabberSender.java
  
  Index: JabberSender.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/proposals/jabber/src/com/snellspace/axis/jabber/JabberSender.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JabberSender.java	31 Dec 2002 20:38:34 -0000	1.1
  +++ JabberSender.java	16 Jan 2003 06:24:05 -0000	1.2
  @@ -23,23 +23,29 @@
    * @author James M Snell <jasnell@us.ibm.com>
    */
   public class JabberSender 
  -  extends BasicHandler {
  +  extends BasicHandler
  +  implements JabberHandler {
  +
  +  private Packet packet = null;
   
     public void invoke(
       MessageContext context) 
         throws AxisFault {
           JabberConnection connection = 
             initializeConnection(context);
  -        Holder holder = new Holder();
           Packet request = 
             createRequestPacketFromMessage(
               context.getRequestMessage(), 
               context);
  -        connection.send(request, holder);
  +        connection.send(request, this);
           try {
  -          holder.waitForPacket();
  +          synchronized(this) {
  +            while (packet == null) {
  +              wait(1000);
  +            }
  +          }
           } catch (InterruptedException e) {}
  -        Packet response = holder.getPacket();
  +        Packet response = packet;
           context.setResponseMessage(
             createResponseMessageFromPacket(
               response, 
  @@ -92,7 +98,11 @@
               DefaultExtension ext = (DefaultExtension)e.nextElement();
               StringBuffer buf = new StringBuffer(ext.toString());
               if (buf.indexOf(Constants.URI_DEFAULT_SOAP_ENV) > 0) {
  -                message = new Message(ext.toString());
  +              String envbuf =
  +                buf.substring(
  +                  buf.indexOf(">") + 1,
  +                  buf.indexOf("</soap>"));
  +                message = new Message(envbuf);
               } else {
                 // ignore non soap stuff for now
               }
  @@ -101,24 +111,6 @@
         return message;
     }
   
  -  private class Holder 
  -    implements JabberHandler {
  -      private Packet packet;
  -      public Packet getPacket() {
  -        return this.packet;
  -      }
  -      public synchronized void waitForPacket()
  -        throws InterruptedException {
  -          if (packet != null) return;
  -          wait();
  -      }
  -      public synchronized void receivedPacket(
  -        Packet packet) {
  -          this.packet = packet;
  -          notifyAll();
  -      }
  -  }
  -  
     public static class AxisExtension
       extends XMLData 
       implements MessageExtension, QueryExtension {
  @@ -136,8 +128,16 @@
               String env = 
                 message.getSOAPPart().
                   getEnvelope().toString();
  +            
  +            buffer.append("<soap xmlns=\"jabber:iq:soap\">");
               buffer.append(env);
  +            buffer.append("</soap>");
             } catch (SOAPException e) {}
         }      
  +  }
  +  
  +  public synchronized void receivedPacket(Packet packet) {
  +    this.packet = packet;
  +    notifyAll();
     }
   }
  
  
  
  1.2       +6 -1      xml-axis/proposals/jabber/src/com/snellspace/axis/jabber/JabberConnection.java
  
  Index: JabberConnection.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/proposals/jabber/src/com/snellspace/axis/jabber/JabberConnection.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JabberConnection.java	31 Dec 2002 20:38:34 -0000	1.1
  +++ JabberConnection.java	16 Jan 2003 06:24:05 -0000	1.2
  @@ -24,6 +24,8 @@
   public class JabberConnection
     implements ConnectionListener, PacketListener {
   
  +  public static boolean DEBUG = false;
  +
     protected ConnectionBean cb;
     protected String loginid;
     protected boolean connected;
  @@ -91,6 +93,9 @@
     public void receivedPacket(
       PacketEvent event) {
       Packet packet = event.getPacket();
  +    if (DEBUG) {
  +      System.out.println("receivedPacket >>"  + packet);
  +    }
       if (!connected) {
         if (processLogin(packet)) {
           connected = true;
  @@ -103,7 +108,7 @@
     }
   
     protected void processPacket(
  -    Packet packet) {
  +    Packet packet) {      
         try {
           ContentPacket cp = (ContentPacket)packet;
           JabberHandler handler = 
  
  
  
  1.2       +11 -5     xml-axis/proposals/jabber/src/com/snellspace/axis/jabber/JabberServer.java
  
  Index: JabberServer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/proposals/jabber/src/com/snellspace/axis/jabber/JabberServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JabberServer.java	31 Dec 2002 20:38:34 -0000	1.1
  +++ JabberServer.java	16 Jan 2003 06:24:05 -0000	1.2
  @@ -74,10 +74,16 @@
                   JID from = iq.getFromAddress();
                   JID to = iq.getToAddress();
                   String id = iq.getIdentifier();
  -                Message soapMessage = new Message(buffer.toString());
  +                String envbuf =
  +                  buffer.substring(
  +                    buffer.indexOf(">") + 1,
  +                    buffer.indexOf("</soap>"));
  +                Message soapMessage = new Message(envbuf);
                   try {
                     processMessage(from,to,id,soapMessage);
  -                } catch (AxisFault ex) {}
  +                } catch (AxisFault ex) {
  +                  System.out.println(ex);
  +                }
                 } else {
                   // ignore for now
                 }
  @@ -101,7 +107,6 @@
       String id,
       Message soapMessage)
         throws AxisFault {
  -      
           AxisEngine engine = JabberServer.getAxisEngine();
           MessageContext context = 
             new MessageContext(engine);
  @@ -124,9 +129,10 @@
           iqb.addExtension(
             new JabberSender.AxisExtension(
               response));
  -        
           try {
             send(iqb.build());
  -        } catch (InstantiationException e) {}
  +        } catch (InstantiationException e) {
  +          System.out.println(e);
  +        }
     }
   }
  
  
  
  1.2       +5 -3      xml-axis/proposals/jabber/src/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/proposals/jabber/src/TestClient.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestClient.java	31 Dec 2002 20:38:34 -0000	1.1
  +++ TestClient.java	16 Jan 2003 06:24:06 -0000	1.2
  @@ -6,6 +6,7 @@
   import org.apache.axis.client.Service;
   import org.apache.axis.configuration.XMLStringProvider;
   
  +import com.snellspace.axis.jabber.JabberConnection;
   import com.snellspace.axis.jabber.JabberTransport;
   
   /**
  @@ -22,15 +23,15 @@
       
     private static void client() throws Exception {
       JabberTransport transport = new JabberTransport();
  -    transport.setTo("<someid>@jabber.org/service1");    
  +    transport.setTo("JamesMSnell@jabber.org/service1");    
       Service service = new Service(new XMLStringProvider(dep));
       Call call = (Call)service.createCall();
       call.setOperationName(new QName("urn:test", "echo"));
       call.addParameter("a", XMLType.XSD_STRING, ParameterMode.IN);
       call.setReturnType(XMLType.XSD_STRING);
       call.setTransport(transport);
  -    call.setUsername("<someid>2@jabber.org/service2");
  -    call.setPassword("<somepassword>");
  +    call.setUsername("JamesMSnell2@jabber.org/service2");
  +    call.setPassword("knight12");
       String s = (String)call.invoke(new String[] {"test"});
       System.out.println(s);
     }
  @@ -38,6 +39,7 @@
     public static void main(
       String[] args) 
         throws Exception {
  +        //JabberConnection.DEBUG = true;
           client();
     }
   }
  
  
  
  1.2       +5 -4      xml-axis/proposals/jabber/src/Test.java
  
  Index: Test.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/proposals/jabber/src/Test.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Test.java	31 Dec 2002 20:38:34 -0000	1.1
  +++ Test.java	16 Jan 2003 06:24:06 -0000	1.2
  @@ -37,6 +37,7 @@
       "</undeployment>";
   
     public static void main(String[] args) throws Exception {
  +    JabberConnection.DEBUG = true;
       deploy();
       JabberServer service1 = server();
       client();
  @@ -47,7 +48,7 @@
     public static JabberServer server() {
       return 
         new JabberServer(
  -        "<someid>@jabber.org/service1", "knight12");
  +        "JamesMSnell@jabber.org/service1", "knight12");
     }
   
     public static void deploy() 
  @@ -77,7 +78,7 @@
     private static void client() throws Exception {
       
       JabberTransport transport = new JabberTransport();
  -    transport.setTo("<someid>@jabber.org/service1");
  +    transport.setTo("JamesMSnell@jabber.org/service1");
       
       Service service = new Service(new XMLStringProvider(dep));
       Call call = (Call)service.createCall();
  @@ -86,8 +87,8 @@
       call.setReturnType(XMLType.XSD_STRING);
       //call.setReturnQName(new QName("arg", "urn:test"));
       call.setTransport(transport);
  -    call.setUsername("<someid>2@jabber.org/service2");
  -    call.setPassword("<somepassword>");
  +    call.setUsername("JamesMSnell2@jabber.org/service2");
  +    call.setPassword("knight12");
       
       String s = (String)call.invoke(new String[] {"test"});
       System.out.println(s);
  
  
  

Mime
View raw message