Author: ffang
Date: Fri Jul 25 08:18:09 2008
New Revision: 679831

URL: http://svn.apache.org/viewvc?rev=679831&view=rev
Log:
sync the fix for SM-1458, SM-1478, SM-1482 to 3.2.2 release branch preparing 
for next round of vote

Added:
    
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
   (with props)
Modified:
    
servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
    
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
    
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
    
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
    
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
    
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java

Modified: 
servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java?rev=679831&r1=679830&r2=679831&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
 Fri Jul 25 08:18:09 2008
@@ -20,7 +20,6 @@
 
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -110,17 +109,6 @@
     }
     
     /**
-     * Set the <code>ObjectName</code> used to register the 
<code>JMXConnectorServer</code>
-     * itself with the <code>MBeanServer</code>.
-     * @param objectName
-     * @throws MalformedObjectNameException if the <code>ObjectName</code> is 
malformed
-     * @see 
org.springframework.jmx.support.ConnectorServerFactoryBean#setObjectName(java.lang.String)
-     */
-    public void setObjectName(ObjectName objectName) throws 
MalformedObjectNameException {
-        this.objectName = objectName;
-    }
-
-    /**
      * Specify  what action should be taken when attempting to register an 
MBean
      * under an [EMAIL PROTECTED] javax.management.ObjectName} that already 
exists.
      * <p>Default is REGISTRATION_FAIL_ON_EXISTING.

Modified: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java?rev=679831&r1=679830&r2=679831&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
 Fri Jul 25 08:18:09 2008
@@ -57,6 +57,7 @@
     private FileFilter filter;  
     private boolean deleteFile = true;
     private boolean recursive = true;
+    private boolean changeWorkingDirectory;
     private FileMarshaler marshaler = new DefaultFileMarshaler();
     private LockManager lockManager;
     private QName targetOperation;
@@ -85,6 +86,9 @@
         if (uri != null && getClientPool() != null && 
getClientPool().getHost() != null) {
             throw new DeploymentException("Properties uri and clientPool.host 
can not be configured at the same time");
         }
+        if (changeWorkingDirectory && recursive) {
+            throw new DeploymentException("changeWorkingDirectory='true' can 
not be set when recursive='true'");
+        }
     }
     
     public void start() throws Exception {
@@ -195,6 +199,9 @@
 
     public void setTargetOperation(QName targetOperation) { 
this.targetOperation = targetOperation; }
 
+    public void setChangeWorkingDirectory(boolean changeWorkingDirectory) {
+        this.changeWorkingDirectory = changeWorkingDirectory;
+    }
     // Implementation methods
     //-------------------------------------------------------------------------
 
@@ -210,7 +217,7 @@
     }
 
     protected void pollFileOrDirectory(FTPClient ftp, String fileOrDirectory, 
boolean processDir) throws Exception {
-        FTPFile[] files = ftp.listFiles(fileOrDirectory);
+        FTPFile[] files = listFiles(ftp, fileOrDirectory);
         for (int i = 0; i < files.length; i++) {
             String name = files[i].getName();
             if (".".equals(name) || "..".equals(name)) {
@@ -236,6 +243,15 @@
         }
     }
 
+    private FTPFile[] listFiles(FTPClient ftp, String directory) throws 
IOException {
+        if (changeWorkingDirectory) {
+            ftp.changeWorkingDirectory(directory);
+            return ftp.listFiles("");
+        } else {
+            return ftp.listFiles(directory);
+        }
+    }
+
     protected void pollFile(final String file) {
         if (logger.isDebugEnabled()) {
             logger.debug("Scheduling file " + file + " for processing");
@@ -341,5 +357,6 @@
             }
         }
     }
+
     
 }

Added: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java?rev=679831&view=auto
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
 (added)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
 Fri Jul 25 08:18:09 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.ftp;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.jbi.management.DeploymentException;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for [EMAIL PROTECTED] FtpPollerEndpoint} 
+ */
+public class FtpPollerEndpointTest extends TestCase {
+
+    public void testValidateNoCwdWhenRecursive() throws URISyntaxException {
+        FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
+        endpoint.setUri(new URI("ftp://[EMAIL PROTECTED]/test"));
+        endpoint.setTargetService(new QName("test", "service"));
+        endpoint.setChangeWorkingDirectory(true);
+        try {
+            endpoint.validate();
+            fail("validate() should throw exception when 
changeWorkingDirectory='true' and recursive='true'");
+        } catch (DeploymentException e) {
+            //this is what we expect
+            System.out.println(e);
+        }
+    }
+}
\ No newline at end of file

Propchange: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-ftp/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java?rev=679831&r1=679830&r2=679831&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpComponent.java
 Fri Jul 25 08:18:09 2008
@@ -163,6 +163,15 @@
         return connectionPool;
     }
     
+    public org.mortbay.jetty.client.HttpClient getNewJettyClient(HttpComponent 
comp) throws Exception {
+        org.mortbay.jetty.client.HttpClient tempClient = new 
org.mortbay.jetty.client.HttpClient();
+        BoundedThreadPool btp = new BoundedThreadPool();
+        
btp.setMaxThreads(comp.getConfiguration().getJettyClientThreadPoolSize());
+        tempClient.setThreadPool(btp);
+        tempClient.start();
+        return tempClient;
+    }
+    
     public void setConnectionPool(org.mortbay.jetty.client.HttpClient 
connectionPool) {
         this.connectionPool = connectionPool;
     }
@@ -224,12 +233,9 @@
         }
         // Create connectionPool
         if (connectionPool == null) {
-            connectionPool = new org.mortbay.jetty.client.HttpClient();
-            BoundedThreadPool btp = new BoundedThreadPool();
-            
btp.setMaxThreads(this.configuration.getJettyClientThreadPoolSize());
-            connectionPool.setThreadPool(btp);
-            connectionPool.start();
+            connectionPool = getNewJettyClient(this);
         }
+        
         // Create serverManager
         if (configuration.isManaged()) {
             server = new ManagedContextManager();
@@ -241,6 +247,7 @@
         server.setConfiguration(configuration);
         server.init();
     }
+    
 
     protected void doShutDown() throws Exception {
         super.doShutDown();

Modified: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java?rev=679831&r1=679830&r2=679831&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
 Fri Jul 25 08:18:09 2008
@@ -68,6 +68,13 @@
      */
     private int jettyClientThreadPoolSize = 16;
     
+    /** 
+     * Configuration to switch from shared jetty client for all 
HttpProviderEndpoints to
+     * jetty client per HttpProviderEndpoint. It's default value is false.
+     */
+    
+    private boolean jettyClientPerProvider;
+    
     /**
      * Maximum number of concurrent requests to the same host.
      */
@@ -302,6 +309,15 @@
         this.jettyClientThreadPoolSize = jettyClientThreadPoolSize;
         save();
     }
+    
+    public boolean isJettyClientPerProvider() {
+        return jettyClientPerProvider;
+    }
+
+    public void setJettyClientPerProvider(boolean jettyClientPerProvider) {
+        this.jettyClientPerProvider = jettyClientPerProvider;
+        save();
+    }
 
     
     public int getMaxConnectionsPerHost() {
@@ -404,6 +420,7 @@
     public void save() {
         setProperty(componentName + ".jettyThreadPoolSize", 
Integer.toString(jettyThreadPoolSize));
         setProperty(componentName + ".jettyClientThreadPoolSize", 
Integer.toString(jettyClientThreadPoolSize));
+        setProperty(componentName + ".jettyClientPerProvider", 
Boolean.toString(jettyClientPerProvider));        
         setProperty(componentName + ".jettyConnectorClassName", 
jettyConnectorClassName);
         setProperty(componentName + ".streamingEnabled", 
Boolean.toString(streamingEnabled));
         setProperty(componentName + ".maxConnectionsPerHost", 
Integer.toString(maxConnectionsPerHost));
@@ -468,6 +485,9 @@
         if (properties.getProperty(componentName + 
".jettyClientThreadPoolSize") != null) {
             jettyClientThreadPoolSize = 
Integer.parseInt(properties.getProperty(componentName + 
".jettyClientThreadPoolSize"));
         }
+        if (properties.getProperty(componentName + ".jettyClientPerProvider") 
!= null) {
+            jettyClientPerProvider = 
Boolean.valueOf(properties.getProperty(componentName + 
".jettyClientPerProvider")).booleanValue();
+        }
         if (properties.getProperty(componentName + ".jettyConnectorClassName") 
!= null) {
             jettyConnectorClassName = properties.getProperty(componentName + 
".jettyConnectorClassName");
         }

Modified: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java?rev=679831&r1=679830&r2=679831&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
 Fri Jul 25 08:18:09 2008
@@ -33,6 +33,10 @@
     int getJettyClientThreadPoolSize();
 
     void setJettyClientThreadPoolSize(int jettyClientThreadPoolSize);
+    
+    boolean isJettyClientPerProvider();
+    
+    void setJettyClientPerProvider(boolean jettyClientPerProvider);
 
     int getMaxConnectionsPerHost();
 

Modified: 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java?rev=679831&r1=679830&r2=679831&view=diff
==============================================================================
--- 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
 (original)
+++ 
servicemix/smx3/branches/servicemix-3.2.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
 Fri Jul 25 08:18:09 2008
@@ -32,6 +32,7 @@
 import org.apache.servicemix.http.HttpComponent;
 import org.apache.servicemix.http.HttpEndpointType;
 import org.apache.servicemix.http.jetty.SmxHttpExchange;
+import org.mortbay.jetty.client.HttpClient;
 
 /**
  * 
@@ -45,7 +46,9 @@
     //private BasicAuthCredentials basicAuthentication;
     private HttpProviderMarshaler marshaler;
     private String locationURI;
-    
+    private int clientSoTimeout = 10000;
+    private HttpClient jettyClient;
+
     public HttpProviderEndpoint() {
         super();
     }
@@ -126,9 +129,18 @@
         }
     }
 
-    protected org.mortbay.jetty.client.HttpClient getConnectionPool() {
-        HttpComponent comp =  (HttpComponent) getServiceUnit().getComponent();
-        return comp.getConnectionPool();
+    protected org.mortbay.jetty.client.HttpClient getConnectionPool() throws 
Exception {
+        if (jettyClient == null) {
+            HttpComponent comp = (HttpComponent) 
getServiceUnit().getComponent();
+            if (comp.getConfiguration().isJettyClientPerProvider()) {
+                jettyClient = comp.getNewJettyClient(comp);
+            } else {
+                //return shared client
+                jettyClient = comp.getConnectionPool();
+            }
+            jettyClient.setSoTimeout(getClientSoTimeout());
+        }
+        return jettyClient;
     }
     
     protected class Exchange extends SmxHttpExchange {
@@ -144,6 +156,13 @@
         }
     }
 
+    public int getClientSoTimeout() {
+        return clientSoTimeout;
+    }
+
+    public void setClientSoTimeout(int clientTimeout) {
+        this.clientSoTimeout = clientTimeout;
+    }
     public void validate() throws DeploymentException {
         super.validate();
         if (marshaler == null) {


Reply via email to