Title: [863] trunk/components/base/src/main/java/org/servicemix/components/vfs: SM-192 : VSF not working
Revision
863
Author
gnt
Date
2005-11-18 06:35:15 -0500 (Fri, 18 Nov 2005)

Log Message

SM-192 : VSF not working

Modified Paths


Diff

Modified: trunk/components/base/src/main/java/org/servicemix/components/vfs/FilePoller.java (862 => 863)

--- trunk/components/base/src/main/java/org/servicemix/components/vfs/FilePoller.java	2005-11-18 11:33:50 UTC (rev 862)
+++ trunk/components/base/src/main/java/org/servicemix/components/vfs/FilePoller.java	2005-11-18 11:35:15 UTC (rev 863)
@@ -19,6 +19,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.vfs.FileContent;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSelector;
 import org.apache.commons.vfs.FileSystemManager;
@@ -29,7 +30,7 @@
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet;
 
 import javax.jbi.JBIException;
-import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.RobustInOnly;
 import javax.jbi.messaging.NormalizedMessage;
 import javax.resource.spi.work.Work;
 
@@ -56,6 +57,8 @@
 
     public void poll() throws Exception {
         FileObject[] files = null;
+        // SM-192: Force close the file, so that the cached informations are cleared
+        directory.close();
         if (selector != null) {
             files = directory.findFiles(selector);
         }
@@ -168,16 +171,24 @@
     }
 
     protected void processFile(FileObject file) throws Exception {
+        // SM-192: Force close the file, so that the cached informations are cleared
+        file.close();
         String name = file.getName().getURI();
-        InputStream in = file.getContent().getInputStream();
+        FileContent content = file.getContent();
+        content.close();
+        InputStream in = content.getInputStream();
         if (in == null) {
             throw new JBIException("No input available for file!");
         }
-        InOnly exchange = getExchangeFactory().createInOnlyExchange();
+        RobustInOnly exchange = getExchangeFactory().createRobustInOnlyExchange();
         NormalizedMessage message = exchange.createMessage();
         exchange.setInMessage(message);
         marshaler.readMessage(exchange, message, in, name);
         getDeliveryChannel().sendSync(exchange);
         in.close();
+        content.close();
+        if (exchange.getError() != null) {
+            throw exchange.getError();
+        }
     }
 }

Modified: trunk/components/base/src/main/java/org/servicemix/components/vfs/FileWriter.java (862 => 863)

--- trunk/components/base/src/main/java/org/servicemix/components/vfs/FileWriter.java	2005-11-18 11:33:50 UTC (rev 862)
+++ trunk/components/base/src/main/java/org/servicemix/components/vfs/FileWriter.java	2005-11-18 11:35:15 UTC (rev 863)
@@ -115,16 +115,17 @@
             if (name == null) {
                 throw new MessagingException("No output name available. Cannot output message!");
             }
-            else {
-                FileObject newFile = directory.resolveFile(name);
-                FileContent content = newFile.getContent();
-                if (content != null) {
-                    out = content.getOutputStream();
-                }
-                if (out == null) {
-                    throw new MessagingException("No output stream available for output name: " + name);
-                }
+            directory.close(); // remove any cached informations
+            FileObject newFile = directory.resolveFile(name);
+            newFile.close(); // remove any cached informations
+            FileContent content = newFile.getContent();
+            content.close();
+            if (content != null) {
+                out = content.getOutputStream();
             }
+            if (out == null) {
+                throw new MessagingException("No output stream available for output name: " + name);
+            }
             marshaler.writeMessage(exchange, message, out, name);
             done(exchange);
         }

Reply via email to