You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/10/28 00:31:48 UTC
svn commit: r589230 -
/incubator/tuscany/java/sca/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPResourceServiceBindingProvider.java
Author: lresende
Date: Sat Oct 27 15:31:47 2007
New Revision: 589230
URL: http://svn.apache.org/viewvc?rev=589230&view=rev
Log:
Registering support for passing files as resources, and using the parent folder location for servlet registration
Modified:
incubator/tuscany/java/sca/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPResourceServiceBindingProvider.java
Modified: incubator/tuscany/java/sca/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPResourceServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPResourceServiceBindingProvider.java?rev=589230&r1=589229&r2=589230&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPResourceServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPResourceServiceBindingProvider.java Sat Oct 27 15:31:47 2007
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.binding.http.provider;
+import java.io.File;
import java.net.URL;
import org.apache.tuscany.sca.binding.http.HTTPResourceBinding;
@@ -96,10 +97,22 @@
message = getLocationInvoker.invoke(message);
URL locationURL = message.getBody();
+ // If resource is a file, register the parent dir
+ try {
+ if( locationURL.getProtocol().equals("file")) {
+ File fileLocation = new File(locationURL.toURI());
+ if (fileLocation.isFile()) {
+ File parent = new File(fileLocation.getParent());
+ locationURL = parent.toURL();
+ }
+ }
+ }catch(Exception e) {
+ throw new IllegalStateException("Invalid getLocationURL, could not retrieve parent folder");
+ }
+
// Register the default resource servlet with the servlet host
DefaultResourceServlet resourceServlet = new DefaultResourceServlet(locationURL.toString());
- servletHost.addServletMapping(uri, resourceServlet);
-
+ servletHost.addServletMapping(uri, resourceServlet);
}
public void stop() {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org