servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1374169 [2/3] - in /servicemix/components/trunk: ./ bindings/servicemix-cxf-bc/ bindings/servicemix-http/ bindings/servicemix-http/src/main/java/org/apache/servicemix/http/ bindings/servicemix-http/src/main/java/org/apache/servicemix/http/...
Date Fri, 17 Aug 2012 07:56:24 GMT
Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java Fri Aug 17 07:56:22 2012
@@ -16,32 +16,35 @@
  */
 package org.apache.servicemix.http.jetty;
 
-import java.security.GeneralSecurityException;
-import java.security.Principal;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.security.auth.Subject;
-
 import org.apache.servicemix.common.security.AuthenticationService;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.security.UserRealm;
+import org.eclipse.jetty.security.DefaultIdentityService;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.MappedLoginService;
+import org.eclipse.jetty.server.UserIdentity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.security.auth.Subject;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.Principal;
+
 /**
- * A JAAS based implementation of a realm for jetty 6.
- * 
+ * A JAAS based implementation of a identity service for jetty 8.
+ *
  * @author gnodet
  */
-public class JaasUserRealm implements UserRealm {
+public class JaasUserRealm extends MappedLoginService {
 
     private final Logger logger = LoggerFactory.getLogger(JaasUserRealm.class);
 
-    private String name = getClass().getName();
     private String domain = "servicemix-domain";
     private AuthenticationService authenticationService;
-    private final Map<String, JaasJettyPrincipal> userMap = new ConcurrentHashMap<String, JaasJettyPrincipal>();
+
+
+    public JaasUserRealm() {
+        this._identityService = new JaasJettyIdentityService();
+    }
 
     /**
      * @return the authenticationService
@@ -51,8 +54,7 @@ public class JaasUserRealm implements Us
     }
 
     /**
-     * @param authenticationService
-     *            the authenticationService to set
+     * @param authenticationService the authenticationService to set
      */
     public void setAuthenticationService(AuthenticationService authenticationService) {
         this.authenticationService = authenticationService;
@@ -66,91 +68,54 @@ public class JaasUserRealm implements Us
     }
 
     /**
-     * @param domain
-     *            the domain to set
+     * @param domain the domain to set
      */
     public void setDomain(String domain) {
         this.domain = domain;
     }
 
-    /**
-     * @return the name
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * @param name
-     *            the name to set
-     */
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Principal authenticate(final String username, final Object credentials, Request request) {
-        try {
-            if ((username != null) && (!username.equals(""))) {
-
-                JaasJettyPrincipal userPrincipal = userMap.get(username);
-
-                // user has been previously authenticated, but
-                // re-authentication has been requested, so remove them
-                if (userPrincipal != null) {
-                    userMap.remove(username);
+    @Override
+    public UserIdentity login(String username, Object credentials) {
+        if ((username != null) && (!username.equals(""))) {
+            // user has been previously authenticated, but
+            // re-authentication has been requested, so remove them if exists
+            _users.remove(username);
+
+            // set up the login context
+            Subject subject = new Subject();
+            try {
+                if (authenticationService != null){
+                    authenticationService.authenticate(subject, domain, username, credentials);
                 }
-
-                // set up the login context
-                Subject subject = new Subject();
-                authenticationService.authenticate(subject, domain, username, credentials);
-                // login success
-                userPrincipal = new JaasJettyPrincipal(username);
-                userPrincipal.setSubject(subject);
-
-                userMap.put(username, userPrincipal);
-
-                return userPrincipal;
-            } else {
-                logger.debug("Login Failed - null userID");
+            } catch (GeneralSecurityException e) {
+                logger.debug("Login Failed", e);
                 return null;
             }
 
-        } catch (GeneralSecurityException e) {
-            logger.debug("Login Failed", e);
+            // login success
+            return new JaasJettyPrincipal(subject, username, IdentityService.NO_ROLES);
+        } else {
+            logger.debug("Login Failed - null userID");
             return null;
         }
     }
 
-    public void disassociate(Principal user) {
+    @Override
+    protected UserIdentity loadUser(String username) {
+        return _users.get(username);
     }
 
-    public Principal getPrincipal(String username) {
-        return userMap.get(username);
+    @Override
+    protected void loadUsers() throws IOException {
     }
 
-    public boolean isUserInRole(Principal user, String role) {
-        // TODO: ?
-        return false;
-    }
-
-    public void logout(Principal user) {
-        JaasJettyPrincipal principal = (JaasJettyPrincipal) user;
-        userMap.remove(principal.getName());
-    }
 
-    public Principal popRole(Principal user) {
-        // TODO: ?
-        return null;
-    }
-
-    public Principal pushRole(Principal user, String role) {
-        // TODO: ?
-        return null;
+    public static class JaasJettyIdentityService extends DefaultIdentityService {
+        @Override
+        public UserIdentity newUserIdentity(Subject subject, Principal userPrincipal, String[] roles) {
+            return new JaasJettyPrincipal(subject, userPrincipal.getName(), roles);
+        }
     }
 
-    public boolean reauthenticate(Principal user) {
-        // get the user out of the cache
-        return userMap.get(user.getName()) != null;
-    }
 
 }

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java Fri Aug 17 07:56:22 2012
@@ -16,6 +16,40 @@
  */
 package org.apache.servicemix.http.jetty;
 
+import org.apache.servicemix.common.security.AuthenticationService;
+import org.apache.servicemix.common.security.KeystoreManager;
+import org.apache.servicemix.http.*;
+import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.http.MimeTypes;
+import org.eclipse.jetty.http.security.Constraint;
+import org.eclipse.jetty.jmx.MBeanContainer;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.servlet.ServletMapping;
+import org.eclipse.jetty.util.ByteArrayISO8859Writer;
+import org.eclipse.jetty.util.LazyList;
+import org.eclipse.jetty.util.StringUtil;
+import org.eclipse.jetty.util.component.AbstractLifeCycle;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.util.thread.ThreadPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import javax.jbi.JBIException;
+import javax.management.MBeanServer;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.InetAddress;
@@ -25,50 +59,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import javax.jbi.JBIException;
-import javax.management.MBeanServer;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.servicemix.http.ContextManager;
-import org.apache.servicemix.http.HttpBridgeServlet;
-import org.apache.servicemix.http.HttpConfiguration;
-import org.apache.servicemix.http.HttpProcessor;
-import org.apache.servicemix.http.SslParameters;
-import org.apache.servicemix.common.security.KeystoreManager;
-import org.apache.servicemix.common.security.AuthenticationService;
-import org.mortbay.component.AbstractLifeCycle;
-import org.mortbay.jetty.AbstractConnector;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.HttpConnection;
-import org.mortbay.jetty.HttpMethods;
-import org.mortbay.jetty.MimeTypes;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.handler.ContextHandlerCollection;
-import org.mortbay.jetty.handler.HandlerCollection;
-import org.mortbay.jetty.security.Constraint;
-import org.mortbay.jetty.security.ConstraintMapping;
-import org.mortbay.jetty.security.SecurityHandler;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.ServletHandler;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.jetty.servlet.ServletMapping;
-import org.mortbay.management.MBeanContainer;
-
-import org.mortbay.thread.QueuedThreadPool;
-
-import org.mortbay.thread.ThreadPool;
-import org.mortbay.util.ByteArrayISO8859Writer;
-import org.mortbay.util.LazyList;
-import org.mortbay.util.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.io.ClassPathResource;
-
 public class JettyContextManager implements ContextManager {
 
     private final Logger logger = LoggerFactory.getLogger(JettyContextManager.class);
@@ -88,8 +78,7 @@ public class JettyContextManager impleme
     }
 
     /**
-     * @param mBeanServer
-     *            the mbeanServer to set
+     * @param mBeanServer the mbeanServer to set
      */
     public void setMBeanServer(MBeanServer mBeanServer) {
         this.mBeanServer = mBeanServer;
@@ -115,18 +104,18 @@ public class JettyContextManager impleme
 
     public void start() throws Exception {
         threadPool.start();
-        for (Iterator<Server> it = servers.values().iterator(); it.hasNext();) {
+        for (Iterator<Server> it = servers.values().iterator(); it.hasNext(); ) {
             Server server = it.next();
             server.start();
         }
     }
 
     public void stop() throws Exception {
-        for (Iterator<Server> it = servers.values().iterator(); it.hasNext();) {
+        for (Iterator<Server> it = servers.values().iterator(); it.hasNext(); ) {
             Server server = it.next();
             server.stop();
         }
-        for (Iterator<Server> it = servers.values().iterator(); it.hasNext();) {
+        for (Iterator<Server> it = servers.values().iterator(); it.hasNext(); ) {
             Server server = it.next();
             server.join();
             Connector[] connectors = server.getConnectors();
@@ -149,7 +138,7 @@ public class JettyContextManager impleme
             SslParameters ssl = sslParams.get(getKey(url));
             if (ssl != null && !ssl.equals(processor.getSsl())) {
                 throw new Exception("An https server is already created on port " + url.getPort()
-                                + " but SSL parameters do not match");
+                        + " but SSL parameters do not match");
             }
         }
         String path = url.getPath();
@@ -171,54 +160,53 @@ public class JettyContextManager impleme
                     String handlerPath = h.getContextPath() + "/";
                     if (handlerPath.startsWith(pathSlash) || pathSlash.startsWith(handlerPath)) {
                         throw new Exception("The requested context for path '" + path
-                                        + "' overlaps with an existing context for path: '" + h.getContextPath() + "'");
+                                + "' overlaps with an existing context for path: '" + h.getContextPath() + "'");
                     }
                 }
             }
         }
         // Create context
-        ContextHandler context = new ContextHandler();
+        ServletContextHandler context = new ServletContextHandler();
         context.setContextPath(path);
         ServletHolder holder = new ServletHolder();
         holder.setName("jbiServlet");
         holder.setClassName(HttpBridgeServlet.class.getName());
-        ServletHandler handler = new ServletHandler();
-        handler.setServlets(new ServletHolder[] {holder});
+        ServletHandler servletHandler = new ServletHandler();
+        servletHandler.setServlets(new ServletHolder[]{holder});
         ServletMapping mapping = new ServletMapping();
         mapping.setServletName("jbiServlet");
         mapping.setPathSpec("/*");
-        handler.setServletMappings(new ServletMapping[] {mapping});
+        servletHandler.setServletMappings(new ServletMapping[]{mapping});
         if (processor.getAuthMethod() != null) {
-            SecurityHandler secHandler = new SecurityHandler();
+            ConstraintSecurityHandler secHandler = new ConstraintSecurityHandler();
             ConstraintMapping constraintMapping = new ConstraintMapping();
             Constraint constraint = new Constraint();
             constraint.setAuthenticate(true);
-            constraint.setRoles(new String[] {"*"});
+            constraint.setRoles(new String[]{"*"});
             constraintMapping.setConstraint(constraint);
             constraintMapping.setPathSpec("/");
-            secHandler.setConstraintMappings(new ConstraintMapping[] {constraintMapping});
-            secHandler.setHandler(handler);
+            secHandler.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
+            secHandler.setHandler(servletHandler);
             secHandler.setAuthMethod(processor.getAuthMethod());
             JaasUserRealm realm = new JaasUserRealm();
             if (configuration.getAuthenticationService() != null) {
                 realm.setAuthenticationService(AuthenticationService.Proxy.create(configuration.getAuthenticationService()));
             }
-            secHandler.setUserRealm(realm);
-            context.setHandler(secHandler);
-        } else {
-            context.setHandler(handler);
+            secHandler.setLoginService(realm);
+            context.setSecurityHandler(secHandler);
         }
+        context.setServletHandler(servletHandler);
         context.setAttribute("processor", processor);
         // add context
         contexts.addHandler(context);
-        handler.initialize();
+        servletHandler.initialize();
         context.start();
         return context;
     }
 
     public synchronized void remove(Object context) throws Exception {
         ((ContextHandler) context).stop();
-        for (Iterator<Server> it = servers.values().iterator(); it.hasNext();) {
+        for (Iterator<Server> it = servers.values().iterator(); it.hasNext(); ) {
             Server server = it.next();
             HandlerCollection handlerCollection = (HandlerCollection) server.getHandler();
             ContextHandlerCollection contexts = (ContextHandlerCollection) handlerCollection.getHandlers()[0];
@@ -271,26 +259,31 @@ public class JettyContextManager impleme
                 logger.warn("Could not create a jetty connector of class '{}'. Defaulting to {}", connectorClassName, HttpConfiguration.DEFAULT_JETTY_CONNECTOR_CLASS_NAME);
                 logger.debug("Reason: {}", e.getMessage(), e);
                 connector = (Connector) Class.forName(HttpConfiguration.DEFAULT_JETTY_CONNECTOR_CLASS_NAME)
-                                .newInstance();
+                        .newInstance();
             }
         }
         connector.setHost(url.getHost());
         connector.setPort(url.getPort());
         connector.setMaxIdleTime(this.configuration.getConnectorMaxIdleTime());
-        ((AbstractConnector)connector).setSoLingerTime(this.configuration.getSoLingerTime());
+        ((AbstractConnector) connector).setSoLingerTime(this.configuration.getSoLingerTime());
         Server server = new Server();
         server.setThreadPool(new ThreadPoolWrapper());
-        server.setConnectors(new Connector[] {connector});
+        server.setConnectors(new Connector[]{connector});
         ContextHandlerCollection contexts = new ContextHandlerCollection();
         HandlerCollection handlers = new HandlerCollection();
-        handlers.setHandlers(new Handler[] {contexts, new DisplayServiceHandler()});
+        handlers.setHandlers(new Handler[]{contexts, new DisplayServiceHandler()});
         server.setHandler(handlers);
-        server.start();
         servers.put(getKey(url), server);
         sslParams.put(getKey(url), isSsl ? ssl : null);
         if (mbeanContainer != null) {
             server.getContainer().addEventListener(mbeanContainer);
         }
+        int serverGracefulTimeout = this.configuration.getServerGracefulTimeout();
+        if (serverGracefulTimeout > 0){
+            server.setGracefulShutdown(serverGracefulTimeout);
+            server.setStopAtShutdown(true);
+        }
+        server.start();
         return server;
     }
 
@@ -301,7 +294,7 @@ public class JettyContextManager impleme
             keyStore = System.getProperty("javax.net.ssl.keyStore", "");
             if (keyStore == null) {
                 throw new IllegalArgumentException(
-                               "keyStore or system property javax.net.ssl.keyStore must be set");
+                        "keyStore or system property javax.net.ssl.keyStore must be set");
             }
         }
         if (keyStore.startsWith("classpath:")) {
@@ -318,7 +311,7 @@ public class JettyContextManager impleme
             keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
             if (keyStorePassword == null) {
                 throw new IllegalArgumentException(
-                    "keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
+                        "keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
             }
         }
         SslSocketConnector sslConnector = new SslSocketConnector();
@@ -388,12 +381,11 @@ public class JettyContextManager impleme
 
     protected class DisplayServiceHandler extends AbstractHandler {
 
-        public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
-            throws IOException, ServletException {
+        public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
             if (response.isCommitted() || HttpConnection.getCurrentConnection().getRequest().isHandled()) {
                 return;
             }
-                
+
             String method = request.getMethod();
 
             if (!method.equals(HttpMethods.GET) || !request.getRequestURI().equals("/")) {

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java Fri Aug 17 07:56:22 2012
@@ -16,10 +16,10 @@
  */
 package org.apache.servicemix.http.jetty;
 
-import javax.net.ssl.SSLServerSocketFactory;
-
-import org.mortbay.jetty.security.SslSocketConnector;
 import org.apache.servicemix.common.security.KeystoreManager;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+
+import javax.net.ssl.SSLServerSocketFactory;
 
 public class ServiceMixSslSocketConnector extends SslSocketConnector {
 

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/SmxHttpExchange.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/SmxHttpExchange.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/SmxHttpExchange.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/SmxHttpExchange.java Fri Aug 17 07:56:22 2012
@@ -16,20 +16,14 @@
  */
 package org.apache.servicemix.http.jetty;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.io.InputStream;
-
-import org.mortbay.io.Buffer;
-import org.mortbay.io.BufferUtil;
-import org.mortbay.jetty.HttpFields;
-import org.mortbay.jetty.HttpHeaders;
-import org.mortbay.jetty.client.HttpExchange;
-import org.mortbay.util.StringUtil;
+import org.eclipse.jetty.client.HttpExchange;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpHeaders;
+import org.eclipse.jetty.io.Buffer;
+import org.eclipse.jetty.io.BufferUtil;
+import org.eclipse.jetty.util.StringUtil;
+
+import java.io.*;
 
 public class SmxHttpExchange extends HttpExchange {
 

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java Fri Aug 17 07:56:22 2012
@@ -16,29 +16,23 @@
  */
 package org.apache.servicemix.http.processors;
 
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.security.KeyStore;
-
-import javax.jbi.JBIException;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManagerFactory;
-
 import org.apache.commons.httpclient.ConnectTimeoutException;
 import org.apache.commons.httpclient.params.HttpConnectionParams;
 import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
 import org.apache.servicemix.common.security.KeystoreManager;
 import org.apache.servicemix.http.SslParameters;
-import org.mortbay.resource.Resource;
+import org.eclipse.jetty.util.resource.Resource;
 import org.springframework.core.io.ClassPathResource;
 
+import javax.jbi.JBIException;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManagerFactory;
+import java.io.IOException;
+import java.net.*;
+import java.security.KeyStore;
+
 public class CommonsHttpSSLSocketFactory implements SecureProtocolSocketFactory {
 
     private SSLSocketFactory factory;

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Fri Aug 17 07:56:22 2012
@@ -16,72 +16,70 @@
  */
 package org.apache.servicemix.http.processors;
 
-import java.net.URI;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jbi.component.ComponentContext;
-import javax.jbi.messaging.DeliveryChannel;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.jbi.messaging.Fault;
-import javax.security.auth.Subject;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.namespace.QName;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Node;
-
-import org.apache.servicemix.common.JbiConstants;
 import org.apache.servicemix.common.EndpointComponentContext;
-import org.apache.servicemix.http.ContextManager;
-import org.apache.servicemix.http.HttpComponent;
-import org.apache.servicemix.http.HttpEndpoint;
-import org.apache.servicemix.http.HttpProcessor;
-import org.apache.servicemix.http.SslParameters;
+import org.apache.servicemix.common.JbiConstants;
+import org.apache.servicemix.http.*;
+import org.apache.servicemix.http.exception.HttpTimeoutException;
+import org.apache.servicemix.http.exception.LateResponseException;
 import org.apache.servicemix.http.jetty.JaasJettyPrincipal;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.soap.Context;
+import org.apache.servicemix.soap.SoapExchangeProcessor;
 import org.apache.servicemix.soap.SoapFault;
 import org.apache.servicemix.soap.SoapHelper;
-import org.apache.servicemix.soap.SoapExchangeProcessor;
 import org.apache.servicemix.soap.marshalers.JBIMarshaler;
 import org.apache.servicemix.soap.marshalers.SoapMessage;
 import org.apache.servicemix.soap.marshalers.SoapWriter;
-import org.mortbay.jetty.RetryRequest;
-import org.mortbay.util.ajax.Continuation;
-import org.mortbay.util.ajax.ContinuationSupport;
+import org.eclipse.jetty.continuation.Continuation;
+import org.eclipse.jetty.continuation.ContinuationSupport;
+import org.eclipse.jetty.http.HttpMethods;
+import org.eclipse.jetty.server.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
 
-public class ConsumerProcessor extends AbstractProcessor implements SoapExchangeProcessor, HttpProcessor {
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.*;
+import javax.security.auth.Subject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
+public class ConsumerProcessor extends AbstractProcessor implements SoapExchangeProcessor, HttpProcessor {
+    private static final String HTTP_METHOD  = "HTTP_METHOD";
+    private static final String EXCHANGE = MessageExchange.class.getName();
+    private static final String MUTEX = MessageExchange.class.getName() + "Mutex";
+    private static final String EXCHANGEID = MessageExchange.class.getName() + "Mutex";
     private final Logger logger = LoggerFactory.getLogger(ConsumerProcessor.class);
 
     protected Object httpContext;
     protected ComponentContext context;
     protected DeliveryChannel channel;
     protected SoapHelper soapHelper;
-    protected Map<String, Continuation> locks;
-    protected Map<String, MessageExchange> exchanges;
+    protected Map<String, Continuation> continuations = new ConcurrentHashMap<String, Continuation>();
+    protected Map<String, Object> mutexes = new ConcurrentHashMap<String, Object>();
+    private Map<String, MessageExchange> sentExchanges = new ConcurrentHashMap<String, MessageExchange>();
     protected int suspentionTime = 60000;
     protected boolean started = false;
-    private boolean isSTFlow;
+    protected boolean supportAllHttpMethods;
+    protected LateResponseStrategy lateResponseStrategy = LateResponseStrategy.error;
+
         
     public ConsumerProcessor(HttpEndpoint endpoint) {
         super(endpoint);
         this.soapHelper = new SoapHelper(endpoint);
-        this.locks = new ConcurrentHashMap<String, Continuation>();
-        this.exchanges = new ConcurrentHashMap<String, MessageExchange>();
         this.suspentionTime = endpoint.getTimeout();
         if (suspentionTime <= 0) {
             this.suspentionTime = getConfiguration().getConsumerProcessorSuspendTime();
         }
+        this.supportAllHttpMethods = endpoint.isSupportAllHttpMethods();
     }
     
     public SslParameters getSsl() {
@@ -93,28 +91,40 @@ public class ConsumerProcessor extends A
     }
     
     public void process(MessageExchange exchange) throws Exception {
-        Continuation cont = locks.get(exchange.getExchangeId());
-        if (cont == null) {
-            throw new Exception("HTTP request has timed out");
-        }
+        final String id = exchange.getExchangeId();
 
-        if (!cont.isPending()) {
-            isSTFlow = true;
-        } else {
-            isSTFlow = false;
-            synchronized (cont) {
-                if (locks.remove(exchange.getExchangeId()) == null) {
-                    throw new Exception("HTTP request has timed out");
-                }
-                logger.debug("Resuming continuation for exchange: {}", exchange.getExchangeId());
-                exchanges.put(exchange.getExchangeId(), exchange);
-                cont.resume();
-                if (!cont.isResumed()) {
-                    logger.debug("Could not resume continuation for exchange: {}", exchange.getExchangeId());
-                    exchanges.remove(exchange.getExchangeId());
-                    throw new Exception("HTTP request has timed out for exchange: " + exchange.getExchangeId());
+        // Synchronize on the mutex object while we're tinkering with the continuation object,
+        // this is still jetty, so do not trust jetty locks anymore
+        final Continuation continuation = continuations.get(id);
+        if (continuation != null){
+            final Object mutex = continuation.getAttribute(MUTEX);
+            if (mutex == null) {
+                handleLateResponse(exchange);
+                return;
+            }
+            synchronized (mutex) {
+                if (!continuation.isExpired() && !continuation.isResumed()) {
+                    logger.debug("Resuming continuation for exchange: {}", id);
+
+                    // in case of the JMS/JCA flow, you might have a different instance of the message exchange here
+                    continuation.setAttribute(EXCHANGE, exchange);
+
+                    continuation.resume();
+
+
+                    // if the continuation could no longer be resumed, the HTTP request might have timed out before the message
+                    // exchange got handled by the ESB
+                    if (!continuation.isResumed()) {
+                        handleLateResponse(exchange);
+                    }
+                } else {
+                    // it the continuation is no longer available or no longer pending, the HTTP request has time out before
+                    // the message exchange got handled by the ESB
+                    handleLateResponse(exchange);
                 }
             }
+        } else {
+            handleLateResponse(exchange);
         }
     }
 
@@ -126,6 +136,9 @@ public class ConsumerProcessor extends A
     }
 
     public void shutdown() throws Exception {
+        if (httpContext instanceof Server.Graceful){
+            ((Server.Graceful)httpContext).setShutdown(true);
+        }
         getServerManager().remove(httpContext);
     }
 
@@ -138,83 +151,145 @@ public class ConsumerProcessor extends A
     }
 
     public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
-        logger.debug("Receiving HTTP request: {}", request);
-        if ("GET".equals(request.getMethod())) {
-            processGetRequest(request, response);
-            return;
-        }
-        if (!"POST".equals(request.getMethod())) {
-            response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, request.getMethod() + " not supported");
-            return;
-        }
-        // Not giving a specific mutex will synchronize on the contination itself
-        Continuation cont = ContinuationSupport.getContinuation(request, null);
         MessageExchange exchange;
-        // If the continuation is not a retry
-        if (!cont.isPending()) {
-            try {
-		        if (!started) {
-		            response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Endpoint is stopped");
-		            return;
-		        }
-                Context ctx = createContext(request);
-                request.setAttribute(Context.class.getName(), ctx);
-                exchange = soapHelper.onReceive(ctx);
-                exchanges.put(exchange.getExchangeId(), exchange);
-                NormalizedMessage inMessage = exchange.getMessage("in");
-                if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
-                    inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(request));
-                }
-                locks.put(exchange.getExchangeId(), cont);
-                request.setAttribute(MessageExchange.class.getName(), exchange.getExchangeId());
-                synchronized (cont) {
-                    channel.send(exchange);
-                    if (!isSTFlow) {
-                        logger.debug("Suspending continuation for exchange: {}", exchange.getExchangeId());
-                        boolean result = cont.suspend(suspentionTime);
-                        exchange = exchanges.remove(exchange.getExchangeId());
-                        request.removeAttribute(MessageExchange.class.getName());
-                        if (!result) {
-                            locks.remove(exchange.getExchangeId());
-                            throw new Exception("Exchange timed out");
-                        }
-                    } else {
-                        String id = (String) request.getAttribute(MessageExchange.class.getName());
-                        locks.remove(id);
-                        exchange = exchanges.remove(id);
-                        request.removeAttribute(MessageExchange.class.getName());
+        Continuation continuation = null;
+        Object mutex = null;
+        String id = null;
+
+        try {
+            // Handle WSDLs, XSDs
+            if (handleStaticResource(request, response)) {
+                return;
+            }
+            continuation = ContinuationSupport.getContinuation(request);
+            mutex = getOrCreateMutex(continuation);
+
+            boolean sendExchange = false;
+            synchronized (mutex) {
+                exchange = (MessageExchange) continuation.getAttribute(EXCHANGE);
+                id = (String)continuation.getAttribute(EXCHANGEID);
+
+                if (exchange == null) {
+                    // Synchronize on the mutex object while we're (s)tinkering with the continuation object
+                    // if this is  a timeout
+                    if (continuation.isExpired()) {
+                        throw new HttpTimeoutException(id);
                     }
+
+                    logger.debug("Receiving HTTP request: {}", request);
+
+                    // send back HTTP status 503 (Not Available) to reject any new requests if the endpoint is not started
+                    if (!started) {
+                        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Endpoint is stopped");
+                        return;
+                    }
+
+                    continuation.setTimeout(suspentionTime);
+
+                    // Create the exchange
+                    exchange = createExchange(request);
+                    id = exchange.getExchangeId();
+
+                    continuation.setAttribute(MUTEX, mutex);
+                    continuation.setAttribute(EXCHANGEID, id);
+                    mutexes.put(id, mutex);
+                    continuations.put(id, continuation);
+                    sentExchanges.put(id, exchange);
+
+                    logger.debug("Suspending continuation for exchange: {}", id);
+                    continuation.suspend(response);
+                    sendExchange = true;
                 }
-            } catch (RetryRequest retry) {
-                throw retry;
-            } catch (SoapFault fault) {
-                sendFault(fault, request, response);
-                return;
-            } catch (Exception e) {
-                sendFault(new SoapFault(e), request, response);
+            }
+
+            if (sendExchange) {
+                send(exchange);
                 return;
             }
-        } else {
-            synchronized (cont) {
-                String id = (String) request.getAttribute(MessageExchange.class.getName());
-                locks.remove(id);
-                exchange = exchanges.remove(id);
-                request.removeAttribute(MessageExchange.class.getName());
-                // Check if this is a timeout
-                if (exchange == null) {
-                    throw new IllegalStateException("Exchange not found");
+
+
+            // message exchange has been completed, so we're ready to send back an HTTP response now
+            logger.debug("Resuming HTTP request: {}", request);
+            doClean(mutex, continuation, id);
+            handleResponse(exchange, request, response);
+        } catch (Exception e) {
+            doClean(mutex, continuation, id);
+            sendFault(e instanceof  SoapFault ? (SoapFault)e : new SoapFault(e), request, response);
+        }
+    }
+
+    private void send(MessageExchange exchange) throws MessagingException {
+        channel.send(exchange);
+    }
+
+    protected MessageExchange createExchange(HttpServletRequest request) throws Exception {
+        Context ctx = createContext(request);
+        request.setAttribute(Context.class.getName(), ctx);
+        MessageExchange exchange = soapHelper.onReceive(ctx);
+
+        NormalizedMessage inMessage = exchange.getMessage("in");
+        if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
+            Map<String, String> requestMessageHeaders = getHeaders(request);
+            if (supportAllHttpMethods){
+                requestMessageHeaders.put(HTTP_METHOD, request.getMethod());
+            }
+            inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, requestMessageHeaders);
+        }
+        return exchange;
+    }
+
+
+    /*
+     * Get or create an object that can be used for synchronizing code blocks for a given exchange
+     */
+    private Object getOrCreateMutex(Continuation continuation) {
+        Object result = null;
+
+        // let's try to find the object that corresponds to the exchange first
+        if (continuation != null) {
+            result = continuation.getAttribute(MUTEX);
+        }
+
+        // no luck finding an existing object, let's create a new one
+        if (result == null) {
+            result = new Object();
+        }
+
+        return result;
+    }
+
+    private MessageExchange doClean(Object mutex, Continuation continuation, String exchangeId) {
+        if (mutex != null) {
+            synchronized (mutex) {
+                if (exchangeId == null && continuation != null) {
+                    exchangeId = (String) continuation.getAttribute(EXCHANGEID);
                 }
-                if (!cont.isResumed()) {
-                    Exception e = new Exception("Exchange timed out: " + exchange.getExchangeId());
-                    sendFault(new SoapFault(e), request, response);
-                    return;
+                if (exchangeId != null && continuation == null) {
+                    continuation = continuations.remove(exchangeId);
+                }
+                if (continuation != null) {
+                    continuation.removeAttribute(EXCHANGEID);
+                    continuation.removeAttribute(EXCHANGE);
+                    continuation.removeAttribute(MUTEX);
+                }
+                if (exchangeId != null) {
+                    mutexes.remove(exchangeId);
+                    continuations.remove(exchangeId);
+                    return sentExchanges.remove(exchangeId);
                 }
             }
         }
+        return null;
+    }
+
+    /*
+     * Handle the HTTP response based on the information in the message exchange we received
+     */
+    private void handleResponse(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) throws Exception {
         if (exchange.getStatus() == ExchangeStatus.ERROR) {
             Exception e = exchange.getError();
             if (e == null) {
-                e = new Exception("Unkown error (exchange aborted ?)");
+                e = new Exception("Unknown error (exchange aborted ?)");
             }
             throw e;
         } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
@@ -225,11 +300,9 @@ public class ConsumerProcessor extends A
                 } else {
                     processResponse(exchange, request, response);
                 }
-                exchange.setStatus(ExchangeStatus.DONE);
-                channel.send(exchange);
+                done(exchange);
             } catch (Exception e) {
-                exchange.setError(e);
-                channel.send(exchange);
+                fail(exchange, e);
                 throw e;
             }
         } else if (exchange.getStatus() == ExchangeStatus.DONE) {
@@ -238,6 +311,30 @@ public class ConsumerProcessor extends A
         }
     }
 
+    private void done(MessageExchange exchange) throws MessagingException {
+        exchange.setStatus(ExchangeStatus.DONE);
+        channel.send(exchange);
+    }
+
+    private void fail(MessageExchange exchange, Exception e) throws MessagingException {
+        exchange.setError(e);
+        channel.send(exchange);
+    }
+
+    protected boolean handleStaticResource(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        logger.debug("Receiving HTTP request: {}", request);
+        String httpMethod = request.getMethod();
+        if (HttpMethods.GET.equals(httpMethod)) {
+            processGetRequest(request, response);
+            return true;
+        }
+        if (!HttpMethods.POST.equals(httpMethod) && !supportAllHttpMethods) {
+            response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, httpMethod + " not supported");
+            return true;
+        }
+        return false;
+    }
+
     private Context createContext(HttpServletRequest request) throws Exception {
         SoapMessage message = soapHelper.getSoapMarshaler().createReader().read(
                                     request.getInputStream(),
@@ -348,4 +445,48 @@ public class ConsumerProcessor extends A
         new SourceTransformer().toResult(new DOMSource(node), new StreamResult(response.getOutputStream()));
     }
 
+
+        /*
+     * Handle a message exchange that is being received after the corresponding HTTP request has timed out
+     */
+    protected void handleLateResponse(MessageExchange exchange) throws Exception {
+        // if the exchange is no longer active by now, something else probably went wrong in the meanwhile
+        if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+            if (lateResponseStrategy == LateResponseStrategy.error) {
+                // ends the exchange in ERROR
+                fail(exchange, new LateResponseException(exchange));
+            } else {
+                // let's log the exception message text, but end the exchange with DONE
+                logger.warn(LateResponseException.createMessage(exchange));
+                done(exchange);
+            }
+        }
+    }
+
+    /**
+     * Set the strategy to be used for handling a late response from the ESB (i.e. a response that arrives after the HTTP request has timed out).
+     * Defaults to <code>error</code>
+     * <p/>
+     * <ul>
+     * <li><code>error</code> will terminate the exchange with an ERROR status and log an exception for the late response</li>
+     * <li><code>warning</code> will end the exchange with a DONE status and log a warning for the late response instead</li>
+     * </ul>
+     *
+     * @param value
+     */
+    public void setLateResponseStrategy(String value) {
+        this.lateResponseStrategy = LateResponseStrategy.valueOf(value);
+    }
+
+    public String getLateResponseStrategy() {
+        return lateResponseStrategy.name();
+    }
+
+    public boolean isSupportAllHttpMethods() {
+        return supportAllHttpMethods;
+    }
+
+    public void setSupportAllHttpMethods(boolean supportAllHttpMethods) {
+        this.supportAllHttpMethods = supportAllHttpMethods;
+    }
 }

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java Fri Aug 17 07:56:22 2012
@@ -16,32 +16,7 @@
  */
 package org.apache.servicemix.http.processors;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jbi.messaging.DeliveryChannel;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.Fault;
-import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.InOptionalOut;
-import javax.jbi.messaging.InOut;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpHost;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.*;
 import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
@@ -53,14 +28,24 @@ import org.apache.servicemix.common.secu
 import org.apache.servicemix.http.HttpComponent;
 import org.apache.servicemix.http.HttpEndpoint;
 import org.apache.servicemix.soap.Context;
-import org.apache.servicemix.soap.SoapHelper;
 import org.apache.servicemix.soap.SoapExchangeProcessor;
+import org.apache.servicemix.soap.SoapHelper;
 import org.apache.servicemix.soap.marshalers.SoapMessage;
 import org.apache.servicemix.soap.marshalers.SoapReader;
 import org.apache.servicemix.soap.marshalers.SoapWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jbi.messaging.*;
+import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 /**
  * 
  * @author Guillaume Nodet
@@ -347,6 +332,8 @@ public class ProviderProcessor extends A
 
     protected HttpClient getClient() {
         HttpComponent comp =  (HttpComponent) endpoint.getServiceUnit().getComponent();
+        //TODO apply the same changes what was applied to HttpProviderEndpoint during last 5 years
+        // it can work only when there is only one http:endpoint with role provider in the whole jvm
         HttpClient client = comp.getClient();
         client.getParams().setSoTimeout(endpoint.getTimeout());
         return client;

Modified: servicemix/components/trunk/bindings/servicemix-http/src/main/resources/OSGI-INF/blueprint/servicemix-http.xml
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/main/resources/OSGI-INF/blueprint/servicemix-http.xml?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/main/resources/OSGI-INF/blueprint/servicemix-http.xml (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/main/resources/OSGI-INF/blueprint/servicemix-http.xml Fri Aug 17 07:56:22 2012
@@ -32,14 +32,17 @@
     </bean>
 
     <bean id="servicemix-http-configuration" class="org.apache.servicemix.http.HttpConfiguration">
+		<property name="clientConnectTimeout" value="${clientConnectTimeout}" />
         <property name="connectorMaxIdleTime" value="${connectorMaxIdleTime}" />
         <property name="soLingerTime" value="${soLingerTime}" />
         <property name="consumerProcessorSuspendTime" value="${consumerProcessorSuspendTime}" />
         <property name="providerExpirationTime" value="${providerExpirationTime}" />
+		<property name="jettyClientPerProvider" value="${jettyClientPerProvider}" />		
         <property name="jettyClientThreadPoolSize" value="${jettyClientThreadPoolSize}" />
         <property name="jettyConnectorClassName" value="${jettyConnectorClassName}" />
         <property name="jettyThreadPoolSize" value="${jettyThreadPoolSize}" />
         <property name="jettyManagement" value="${jettyManagement}" />
+		<property name="maxConnectionsPerAddress" value="${maxConnectionsPerAddress}" />
         <property name="maxConnectionsPerHost" value="${maxConnectionsPerHost}" />
         <property name="maxTotalConnections" value="${maxTotalConnections}" />
         <property name="proxyHost" value="${proxyHost}" />
@@ -95,12 +98,14 @@
 
     <cm:property-placeholder persistent-id="org.apache.servicemix.components.http">
         <cm:default-properties>
+			<cm:property name="clientConnectTimeout" value="75000"/>
 			<cm:property name="connectorMaxIdleTime" value="30000"/>
-                        <cm:property name="soLingerTime" value="-1"/>
+            <cm:property name="soLingerTime" value="-1"/>
 			<cm:property name="consumerProcessorSuspendTime" value="60000"/>
-                        <cm:property name="providerExpirationTime" value="300000"/>
+            <cm:property name="providerExpirationTime" value="300000"/>
 			<cm:property name="jettyClientThreadPoolSize" value="16"/>
-			<cm:property name="jettyConnectorClassName" value="org.mortbay.jetty.nio.SelectChannelConnector"/>
+			<cm:property name="jettyClientPerProvider" value="false"/>
+			<cm:property name="jettyConnectorClassName" value="org.eclipse.jetty.server.nio.SelectChannelConnector"/>
 			<cm:property name="jettyThreadPoolSize" value="255"/>
 			<cm:property name="jettyManagement" value="false"/>
 			<cm:property name="maxConnectionsPerHost" value="65536"/>

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java Fri Aug 17 07:56:22 2012
@@ -16,41 +16,12 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.jbi.servicedesc.ServiceEndpoint;
-import javax.wsdl.Binding;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.wsdl.extensions.soap12.SOAP12Address;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.stream.StreamSource;
-
 import junit.framework.TestCase;
-
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.log4j.Level;
 import org.apache.servicemix.components.http.InvalidStatusResponseException;
 import org.apache.servicemix.components.util.EchoComponent;
 import org.apache.servicemix.components.util.MockServiceComponent;
@@ -71,7 +42,7 @@ import org.apache.servicemix.soap.util.D
 import org.apache.servicemix.tck.ExchangeCompletedListener;
 import org.apache.servicemix.tck.ReceiverComponent;
 import org.apache.xpath.CachedXPathAPI;
-import org.mortbay.jetty.HttpHeaders;
+import org.eclipse.jetty.http.HttpHeaders;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.ClassPathResource;
@@ -80,18 +51,43 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.traversal.NodeIterator;
 
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.wsdl.*;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
 public class ConsumerEndpointTest extends TestCase {
 
     private final Logger logger = LoggerFactory.getLogger(ConsumerEndpointTest.class);
 
-    String port1 = System.getProperty("http.port1");
-    String port2 = System.getProperty("http.port2");
+    String port1 = System.getProperty("http.port1", "61101");
+    String port2 = System.getProperty("http.port2", "61102");
     
     protected JBIContainer container;
     protected SourceTransformer transformer = new SourceTransformer();
 
     static {
         System.setProperty("org.apache.servicemix.preserveContent", "true");
+
     }
 
     protected void setUp() throws Exception {
@@ -103,6 +99,7 @@ public class ConsumerEndpointTest extend
         factory.getDefaultConfig().setQueueSize(0);
         container.setExecutorFactory(factory);
         container.init();
+        org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO);
     }
 
     protected void tearDown() throws Exception {
@@ -134,7 +131,7 @@ public class ConsumerEndpointTest extend
         ep.setService(new QName("urn:test", "svc"));
         ep.setEndpoint("ep");
         ep.setTargetService(new QName("urn:test", "recv"));
-        ep.setLocationURI("http://localhost:"+port1+"/ep1/");
+        ep.setLocationURI("http://localhost:"+port1+"/ep1");
         ep.setDefaultMep(MessageExchangeSupport.IN_ONLY);
         http.setEndpoints(new HttpEndpointType[] {ep});
         container.activateComponent(http, "http");
@@ -145,7 +142,7 @@ public class ConsumerEndpointTest extend
 
         container.start();
 
-        PostMethod post = new PostMethod("http://localhost:"+port1+"/ep1/");
+        PostMethod post = new PostMethod("http://localhost:"+port1+"/ep1/23");
         post.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
         new HttpClient().executeMethod(post);
         String res = post.getResponseBodyAsString();
@@ -198,7 +195,7 @@ public class ConsumerEndpointTest extend
         String res = post.getResponseBodyAsString();
         logger.info(res);
         
-        if (post.getStatusCode() != 500 || !res.contains("HTTP request has timed out for exchange")) {
+        if (post.getStatusCode() != 500 || !res.contains("HTTP request has timed out")) {
             throw new InvalidStatusResponseException(post.getStatusCode());
         }
         Thread.sleep(1000);
@@ -615,9 +612,9 @@ public class ConsumerEndpointTest extend
         final int nbThreads = 16;
         final int nbRequests = 8;
         final int endpointTimeout = 100;
-        final int echoSleepTime = 90;
+        final int echoSleepTime = 120;
         final int soTimeout = 60 * 1000 * 1000;
-        final int listenerTimeout = 5000;
+        final int listenerTimeout = 15000;
 
         ExchangeCompletedListener listener = new ExchangeCompletedListener(listenerTimeout);
         container.addListener(listener);
@@ -681,7 +678,7 @@ public class ConsumerEndpointTest extend
                             if (post != null) {
                             	post.releaseConnection();
                             }
-                            //System.out.println("[" + System.currentTimeMillis() + "] Request " + latch.getCount() + " processed");
+//                            System.out.println("[" + System.currentTimeMillis() + "] Request " + latchSent.getCount() + " processed");
                         }
                     }
                 }

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpAddressingTest.java Fri Aug 17 07:56:22 2012
@@ -16,33 +16,31 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOut;
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Node;
-
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.util.FileUtil;
 import org.apache.servicemix.tck.SpringTestSupport;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.w3c.dom.Node;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLConnection;
 
 public class HttpAddressingTest extends SpringTestSupport {
 
     private final Logger logger = LoggerFactory.getLogger(HttpAddressingTest.class);
     
-    String port1 = System.getProperty("http.port1");
+    String port1 = System.getProperty("http.port1", "61101");
 
     public void testOk() throws Exception {
         DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java Fri Aug 17 07:56:22 2012
@@ -31,8 +31,8 @@ import javax.servlet.http.HttpServletRes
 
 import junit.framework.TestCase;
 
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Response;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
 
 public class HttpBridgeServletTest extends TestCase {
 

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConsumerTest.java Fri Aug 17 07:56:22 2012
@@ -16,21 +16,7 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOut;
-import javax.jbi.messaging.RobustInOnly;
-import javax.wsdl.Definition;
-import javax.wsdl.factory.WSDLFactory;
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
-
 import junit.framework.TestCase;
-
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.components.http.HttpInvoker;
 import org.apache.servicemix.components.http.HttpSoapClientMarshaler;
@@ -43,13 +29,25 @@ import org.apache.servicemix.tck.Receive
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.RobustInOnly;
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
 public class HttpConsumerTest extends TestCase {
 
     private final Logger logger = LoggerFactory.getLogger(HttpConsumerTest.class);
 
     protected JBIContainer container;
     
-    String port1 = System.getProperty("http.port1");
+    String port1 = System.getProperty("http.port1","61101");
     
     protected void setUp() throws Exception {
         container = new JBIContainer();

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpProviderTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpProviderTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpProviderTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpProviderTest.java Fri Aug 17 07:56:22 2012
@@ -16,37 +16,46 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOut;
-import javax.jbi.messaging.RobustInOnly;
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
-
 import junit.framework.TestCase;
-
 import org.apache.servicemix.JbiConstants;
 import org.apache.servicemix.client.DefaultServiceMixClient;
-import org.apache.servicemix.components.http.HttpConnector;
+import org.apache.servicemix.components.http.BindingServlet;
+import org.apache.servicemix.components.http.HttpInOutBinding;
 import org.apache.servicemix.components.util.EchoComponent;
 import org.apache.servicemix.jbi.container.ActivationSpec;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.tck.Receiver;
 import org.apache.servicemix.tck.ReceiverComponent;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.bio.SocketConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.servlet.ServletMapping;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jbi.JBIException;
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.RobustInOnly;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
 public class HttpProviderTest extends TestCase {
 
     private final Logger logger = LoggerFactory.getLogger(HttpProviderTest.class);
 
     protected JBIContainer container;
-    Integer port1 = Integer.parseInt(System.getProperty("http.port1"));
+    Integer port1 = Integer.parseInt(System.getProperty("http.port1", "61101"));
 
     protected void setUp() throws Exception {
         container = new JBIContainer();
@@ -75,7 +84,7 @@ public class HttpProviderTest extends Te
         container.activateComponent(asReceiver);
 
         // Add the http receiver
-        HttpConnector connector = new HttpConnector("localhost", port1);
+        JettyHttpConnector connector = new JettyHttpConnector("localhost", port1);
         connector.setDefaultInOut(false);
         ActivationSpec asConnector = new ActivationSpec("connector", connector);
         asConnector.setDestinationService(new QName("test", "receiver"));
@@ -135,7 +144,7 @@ public class HttpProviderTest extends Te
         container.activateComponent(asReceiver);
 
         // Add the http receiver
-        HttpConnector connector = new HttpConnector("localhost", 9192);
+        JettyHttpConnector connector = new JettyHttpConnector("localhost", 9192);
         connector.setDefaultInOut(false);
         ActivationSpec asConnector = new ActivationSpec("connector", connector);
         asConnector.setDestinationService(new QName("test", "receiver"));
@@ -187,7 +196,7 @@ public class HttpProviderTest extends Te
         container.activateComponent(asReceiver);
 
         // Add the http receiver
-        HttpConnector connector = new HttpConnector("localhost", port1);
+        JettyHttpConnector connector = new JettyHttpConnector("localhost", port1);
         connector.setDefaultInOut(true);
         ActivationSpec asConnector = new ActivationSpec("connector", connector);
         asConnector.setDestinationService(new QName("test", "echo"));
@@ -299,4 +308,148 @@ public class HttpProviderTest extends Te
 
         testInOut(str, true);
     }
+
+
+
+
+public class JettyHttpConnector extends HttpInOutBinding {
+    private Connector listener = new SocketConnector();
+
+	/**
+	 * The maximum number of threads for the Jetty SocketListener. It's set
+	 * to 256 by default to match the default value in Jetty.
+	 */
+	private int maxThreads = 256;
+
+    private Server server;
+    private String host;
+    private int port;
+
+    /**
+     * Constructor
+     *
+     * @param host
+     * @param port
+     */
+    public JettyHttpConnector(String host, int port) {
+        this.host = host;
+        this.port = port;
+    }
+
+
+    /**
+     * Constructor
+     *
+     * @param listener
+     */
+    public JettyHttpConnector(Connector listener) {
+        this.listener = listener;
+    }
+
+    /**
+     * Called when the Component is initialized
+     *
+     * @param cc
+     * @throws javax.jbi.JBIException
+     */
+    public void init(ComponentContext cc) throws JBIException {
+        super.init(cc);
+        //should set all ports etc here - from the naming context I guess ?
+        if (listener == null) {
+            listener = new SocketConnector();
+        }
+        listener.setHost(host);
+        listener.setPort(port);
+        server = new Server();
+        QueuedThreadPool btp = new QueuedThreadPool();
+        btp.setMaxThreads(getMaxThreads());
+        server.setThreadPool(btp);
+    }
+
+    /**
+     * start the Component
+     *
+     * @throws JBIException
+     */
+    public void start() throws JBIException {
+        server.setConnectors(new Connector[] { listener });
+        ServletContextHandler context = new ServletContextHandler();
+        context.setContextPath("/");
+        ServletHolder holder = new ServletHolder();
+        holder.setName("jbiServlet");
+        holder.setClassName(BindingServlet.class.getName());
+        ServletHandler servletHandler = new ServletHandler();
+        servletHandler.setServlets(new ServletHolder[]{holder});
+        ServletMapping mapping = new ServletMapping();
+        mapping.setServletName("jbiServlet");
+        mapping.setPathSpec("/*");
+        servletHandler.setServletMappings(new ServletMapping[]{mapping});
+        context.setServletHandler(servletHandler);
+        server.setHandler(context);
+        context.setAttribute("binding", this);
+        try {
+            server.start();
+        }
+        catch (Exception e) {
+            throw new JBIException("Start failed: " + e, e);
+        }
+    }
+
+    /**
+     * stop
+     */
+    public void stop() throws JBIException {
+        try {
+            if (server != null) {
+                server.stop();
+            }
+        }
+        catch (Exception e) {
+            throw new JBIException("Stop failed: " + e, e);
+        }
+    }
+
+    /**
+     * shutdown
+     */
+    public void shutDown() throws JBIException {
+        super.shutDown();
+        server = null;
+    }
+
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public Server getServer() {
+        return server;
+    }
+
+    public void setServer(Server server) {
+        this.server = server;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+	public int getMaxThreads() {
+		return maxThreads;
+	}
+
+	public void setMaxThreads(int maxThreads) {
+		this.maxThreads = maxThreads;
+	}
+}
 }

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSoapTest.java Fri Aug 17 07:56:22 2012
@@ -16,34 +16,8 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.util.List;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.Fault;
-import javax.jbi.messaging.InOut;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.MessagingException;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import junit.framework.TestCase;
-
 import com.ibm.wsdl.util.xml.DOMUtils;
+import junit.framework.TestCase;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpMethodRetryHandler;
@@ -55,8 +29,8 @@ import org.apache.servicemix.client.Defa
 import org.apache.servicemix.client.ServiceMixClient;
 import org.apache.servicemix.components.util.EchoComponent;
 import org.apache.servicemix.components.util.TransformComponentSupport;
-import org.apache.servicemix.jbi.api.Destination;
 import org.apache.servicemix.jbi.FaultException;
+import org.apache.servicemix.jbi.api.Destination;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
@@ -67,16 +41,34 @@ import org.apache.servicemix.jbi.util.Fi
 import org.apache.servicemix.soap.marshalers.JBIMarshaler;
 import org.apache.servicemix.soap.marshalers.SoapMarshaler;
 import org.apache.servicemix.tck.ReceiverComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.jbi.messaging.*;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.List;
 
 public class HttpSoapTest extends TestCase {
 
     private final Logger logger = LoggerFactory.getLogger(HttpSoapTest.class);
 
     protected JBIContainer container;
-    
-    String port1 = System.getProperty("http.port1");
-    String port2 = System.getProperty("http.port2");
-    String port3 = System.getProperty("http.port3");
+
+    String port1 = System.getProperty("http.port1","61101");
+    String port2 = System.getProperty("http.port2", "61102");
+    String port3 = System.getProperty("http.port3", "61103");
 
     protected void setUp() throws Exception {
         container = new JBIContainer();

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSpringTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSpringTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSpringTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpSpringTest.java Fri Aug 17 07:56:22 2012
@@ -16,13 +16,6 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOut;
-import javax.xml.namespace.QName;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.PostMethod;
@@ -41,11 +34,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
 public class HttpSpringTest extends SpringTestSupport {
 
     private final Logger logger = LoggerFactory.getLogger(HttpSpringTest.class);
     
-    String port9 = System.getProperty("http.port9");
+    String port9 = System.getProperty("http.port9", "61109");
 
     protected void setUp() throws Exception {
         String str = "Basic " + EncodingUtil.getAsciiString(

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpURITest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpURITest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpURITest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpURITest.java Fri Aug 17 07:56:22 2012
@@ -16,21 +16,7 @@
  */
 package org.apache.servicemix.http;
 
-import java.util.List;
-
-import javax.jbi.messaging.ExchangeStatus;
-import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.MessageExchange;
-import javax.jbi.messaging.NormalizedMessage;
-import javax.jbi.servicedesc.ServiceEndpoint;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-
 import junit.framework.TestCase;
-
 import org.apache.servicemix.client.DefaultServiceMixClient;
 import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
@@ -38,12 +24,23 @@ import org.apache.servicemix.jbi.jaxp.St
 import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
 import org.apache.servicemix.jbi.resolver.URIResolver;
 import org.apache.servicemix.tck.ReceiverComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import java.util.List;
 
 public class HttpURITest extends TestCase {
 
     private final Logger logger = LoggerFactory.getLogger(HttpURITest.class);
 
-    String port1 = System.getProperty("http.port1");
+    String port1 = System.getProperty("http.port1", "61101");
     
     private JBIContainer jbi;
 

Modified: servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpWsdlTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpWsdlTest.java?rev=1374169&r1=1374168&r2=1374169&view=diff
==============================================================================
--- servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpWsdlTest.java (original)
+++ servicemix/components/trunk/bindings/servicemix-http/src/test/java/org/apache/servicemix/http/HttpWsdlTest.java Fri Aug 17 07:56:22 2012
@@ -16,34 +16,7 @@
  */
 package org.apache.servicemix.http;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-
-import javax.jbi.servicedesc.ServiceEndpoint;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.wsdl.Definition;
-import javax.wsdl.Input;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Output;
-import javax.wsdl.Part;
-import javax.wsdl.PortType;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-
 import junit.framework.TestCase;
-
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.servicemix.components.util.EchoComponent;
@@ -52,20 +25,34 @@ import org.apache.servicemix.jbi.contain
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
 import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.core.io.UrlResource;
+import org.w3c.dom.Document;
+
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.wsdl.*;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import java.io.*;
 
 public class HttpWsdlTest extends TestCase {
 
     private final Logger logger = LoggerFactory.getLogger(HttpWsdlTest.class);
       
-    private Integer port4 = Integer.parseInt(System.getProperty("http.port4"));
-    private Integer port5 = Integer.parseInt(System.getProperty("http.port5"));
-    private Integer port6 = Integer.parseInt(System.getProperty("http.port6"));
-    private Integer port7 = Integer.parseInt(System.getProperty("http.port7"));
-    private Integer port8 = Integer.parseInt(System.getProperty("http.port8"));
+    private Integer port4 = Integer.parseInt(System.getProperty("http.port4", "61104"));
+    private Integer port5 = Integer.parseInt(System.getProperty("http.port5", "61105"));
+    private Integer port6 = Integer.parseInt(System.getProperty("http.port6", "61106"));
+    private Integer port7 = Integer.parseInt(System.getProperty("http.port7", "61107"));
+    private Integer port8 = Integer.parseInt(System.getProperty("http.port8", "61108"));
     
 
     protected JBIContainer container;
@@ -206,11 +193,7 @@ public class HttpWsdlTest extends TestCa
         int remoteHttpServerPort = port7;
         Server remoteServer = new Server(remoteHttpServerPort);
         Handler handler = new AbstractHandler() {
-
-            public void handle(String arg0, HttpServletRequest req,
-                    HttpServletResponse res, int arg3) throws IOException,
-                    ServletException {
-
+            public void handle(String target, Request baseRequest, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
                 res.setContentType("text/xml");
                 PrintWriter writer = res.getWriter();
                 BufferedReader br = new BufferedReader(new InputStreamReader(
@@ -223,10 +206,9 @@ public class HttpWsdlTest extends TestCa
                 br.close();
                 writer.close();
             }
-
         };
         
-        remoteServer.addHandler(handler);
+        remoteServer.setHandler(handler);
         remoteServer.start();
         
         try {



Mime
View raw message