Author: wire
Date: Tue Aug  9 13:02:49 2005
New Revision: 231094

URL: http://svn.apache.org/viewcvs?rev=231094&view=rev
Log:
Added better timeout support and ability to read the post request URI.

Modified:
    
webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java

Modified: 
webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java
URL: 
http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java?rev=231094&r1=231093&r2=231094&view=diff
==============================================================================
--- 
webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java
 (original)
+++ 
webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java
 Tue Aug  9 13:02:49 2005
@@ -33,6 +33,7 @@
     private static final String HTTP_STATUS = "202 Accepted";

     private boolean closeSocketAfterNotification=true;

     private ServerSocket server ;

+    private String request;

     int port;

     int timeout;

     final Object listenerStarted = new Object();

@@ -125,7 +126,8 @@
                        byte[] responseBytes=null;

             try {

                                server = new ServerSocket( port );

-                      //server.setSoTimeout( timeout );

+                   // U might want to comment this back out   

+                               server.setSoTimeout( timeout );

 

                        // let the outer method know that we have started and 
just about to block on the accept

                        synchronized ( listenerStarted )

@@ -143,7 +145,7 @@
                        

                                try

                    {   

-                                               System.out.println("Going into 
accepting state");

+                                               //System.out.println("Going 
into accepting state");

                                sock = server.accept();

                        

                        bufIn = new BufferedReader(

@@ -152,9 +154,10 @@
                        String header=readHeader(bufIn);

                        

                        HttpHeader headerObj=new HttpHeader(header);

+                       //headerObj.getHeader()

                                    String content_length = 
headerObj.getHeader(HttpHeader.CONTENT_LENGTH);

                                    int size = Integer.parseInt(content_length);

-                                   System.out.println("Waiting on "+size+" 
bytes");

+                                   //System.out.println("Waiting on "+size+" 
bytes");

                        responseBytes = buildResponse().toString().getBytes();

                        Thread.sleep(1000);

                        try

@@ -179,14 +182,14 @@
                      bufOut.close();

                      if(closeSocketAfterNotification){

                        sock.close();

-                       System.out.println("This notification socket has been 
closed.");

+                       //System.out.println("This notification socket has been 
closed.");

                      }

                                

                    }    

                    catch ( InterruptedIOException ignored )

                    {

                        ignored.printStackTrace();

-                       System.out.println("Notification Listener Has Exited.");

+                       //System.out.println("Notification Listener Has 
Exited.");

                        return;

                    }

                    catch ( Throwable t )

@@ -214,7 +217,7 @@
                                                        
retIncomingMessage.wait();

                                                } catch (InterruptedException 
e1) {

                                                        // TODO Auto-generated 
catch block

-                                                       
System.out.println("Notification Worker Exiting");

+                                                       
//System.out.println("Notification Worker Exiting");

                                                        return;

                                                //      e1.printStackTrace();

                                                }

@@ -238,7 +241,7 @@
                        {

                            listenerStarted.notify();

                        }

-                                       System.out.println("Notification 
Listening Thread has Died.");

+                                       //System.out.println("Notification 
Listening Thread has Died.");

 

                        

 

@@ -258,7 +261,8 @@
        int input = -1;

        StringBuffer header = new StringBuffer();

        

-        String str = streamIn.readLine(); 

+       request= streamIn.readLine();

+       String str = request; 

          while (!str.equals("")){

            str = streamIn.readLine();

            header.append(str);

@@ -304,6 +308,10 @@
 

             return responseBuf.toString();

         }

-

+        public String getRequestUri(){

+               if(request==null)

+                       return "";

+               return request.split(" ")[1];           

+        }

          

 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to