activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r359551 - in /incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http: HttpClientTransport.java HttpTransportFactory.java HttpTunnelServlet.java
Date Wed, 28 Dec 2005 15:38:14 GMT
Author: jstrachan
Date: Wed Dec 28 07:38:10 2005
New Revision: 359551

URL: http://svn.apache.org/viewcvs?rev=359551&view=rev
Log:
use commons-httpclient by default

Modified:
    incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpClientTransport.java
    incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTransportFactory.java
    incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTunnelServlet.java

Modified: incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpClientTransport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpClientTransport.java?rev=359551&r1=359550&r2=359551&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpClientTransport.java
(original)
+++ incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpClientTransport.java
Wed Dec 28 07:38:10 2005
@@ -24,6 +24,7 @@
 import org.activemq.transport.util.TextWireFormat;
 import org.activemq.util.IOExceptionSupport;
 import org.activemq.util.ServiceStopper;
+import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpStatus;
@@ -52,7 +53,6 @@
     private String clientID;
     private String sessionID;
 
-
     public HttpClientTransport(TextWireFormat wireFormat, URI remoteUrl) {
         super(wireFormat, remoteUrl);
     }
@@ -62,9 +62,9 @@
     }
 
     public void oneway(Command command) throws IOException {
-        if (command.getDataStructureType()==ConnectionInfo.DATA_STRUCTURE_TYPE)
-            clientID=((ConnectionInfo)command).getClientId();
-        
+        if (command.getDataStructureType() == ConnectionInfo.DATA_STRUCTURE_TYPE)
+            clientID = ((ConnectionInfo) command).getClientId();
+
         PostMethod httpMethod = new PostMethod(getRemoteUrl().toString());
         configureMethod(httpMethod);
         httpMethod.setRequestBody(getTextWireFormat().toString(command));
@@ -90,10 +90,10 @@
         HttpClient httpClient = getReceiveHttpClient();
         URI remoteUrl = getRemoteUrl();
         while (!isClosed()) {
-            
+
             GetMethod httpMethod = new GetMethod(remoteUrl.toString());
             configureMethod(httpMethod);
-     
+
             try {
                 int answer = httpClient.executeMethod(httpMethod);
                 if (answer != HttpStatus.SC_OK) {
@@ -121,7 +121,6 @@
         }
     }
 
-
     // Properties
     // -------------------------------------------------------------------------
     public HttpClient getSendHttpClient() {
@@ -157,8 +156,8 @@
     }
 
     protected void configureMethod(HttpMethod method) {
-        if (sessionID!=null) {
-            method.addRequestHeader("Cookie", "JSESSIONID="+sessionID);
+        if (sessionID != null) {
+            method.addRequestHeader("Cookie", "JSESSIONID=" + sessionID);
         }
         else if (clientID != null) {
             method.setRequestHeader("clientID", clientID);
@@ -166,12 +165,15 @@
     }
 
     protected void checkSession(HttpMethod client) {
-        String set_cookie=client.getRequestHeader("Set-Cookie").getValue();
-        
-        if (set_cookie!=null && set_cookie.startsWith("JSESSIONID=")) {
-            String[] bits=set_cookie.split("[=;]");
-            sessionID=bits[1];
+        Header header = client.getRequestHeader("Set-Cookie");
+        if (header != null) {
+            String set_cookie = header.getValue();
+
+            if (set_cookie != null && set_cookie.startsWith("JSESSIONID=")) {
+                String[] bits = set_cookie.split("[=;]");
+                sessionID = bits[1];
+            }
         }
     }
-    
+
 }

Modified: incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTransportFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTransportFactory.java?rev=359551&r1=359550&r2=359551&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTransportFactory.java
(original)
+++ incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTransportFactory.java
Wed Dec 28 07:38:10 2005
@@ -55,7 +55,9 @@
     }
 
     protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException
{
-        Transport transport = new HttpTransport(asTextWireFormat(wf), location);
+        TextWireFormat textWireFormat = asTextWireFormat(wf);
+        Transport transport = new HttpClientTransport(textWireFormat, location);
+        //Transport transport = new HttpTransport(textWireFormat, location);
         transport = new MutexTransport(transport);
         transport = new ResponseCorrelator(transport);
         return transport;

Modified: incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTunnelServlet.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTunnelServlet.java?rev=359551&r1=359550&r2=359551&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTunnelServlet.java
(original)
+++ incubator/activemq/trunk/activemq-optional/src/main/java/org/activemq/transport/http/HttpTunnelServlet.java
Wed Dec 28 07:38:10 2005
@@ -109,7 +109,7 @@
             ConnectionInfo info = (ConnectionInfo) command;
             request.getSession(true).setAttribute("clientID", info.getClientId());
         }
-        if (command instanceof WireFormatInfo) {
+        else if (command instanceof WireFormatInfo) {
             WireFormatInfo info = (WireFormatInfo) command;
             if (!canProcessWireFormatVersion(info.getVersion())) {
                 response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire
format of version: " + info.getVersion());
@@ -173,12 +173,14 @@
                 listener.onAccept(answer);
             }
             else {
+                /*
                 try {
-                    answer.asyncRequest(ping);
+                    answer.oneway(ping);
                 }
                 catch (IOException e) {
                     log.warn("Failed to ping transport: " + e, e);
                 }
+                */
             }
             return answer;
         }



Mime
View raw message