You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/01/25 02:06:01 UTC
svn commit: r615091 - in
/incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider:
WidgetImplementationInvoker.java WidgetImplementationProvider.java
Author: jsdelfino
Date: Thu Jan 24 17:05:58 2008
New Revision: 615091
URL: http://svn.apache.org/viewvc?rev=615091&view=rev
Log:
Allow a widget to serve resources in its containing folder.
Modified:
incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
Modified: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java?rev=615091&r1=615090&r2=615091&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationInvoker.java Thu Jan 24 17:05:58 2008
@@ -41,11 +41,15 @@
*/
class WidgetImplementationInvoker implements Invoker {
private RuntimeComponent component;
- private String locationURL;
+ private String widgetName;
+ private String widgetFolderURL;
+ private String widgetLocationURL;
- WidgetImplementationInvoker(RuntimeComponent component, String locationURL) {
+ WidgetImplementationInvoker(RuntimeComponent component, String widgetName, String widgetFolderURL, String widgetLocationURL) {
this.component = component;
- this.locationURL = locationURL;
+ this.widgetName = widgetName + ".js";
+ this.widgetFolderURL = widgetFolderURL;
+ this.widgetLocationURL = widgetLocationURL;
}
public Message invoke(Message msg) {
@@ -54,7 +58,14 @@
String id = (String)((Object[])msg.getBody())[0];
try {
- if (id.endsWith(".js")) {
+ if (id.length() == 0) {
+
+ // Return an input stream for the widget resource
+ URL url = new URL(widgetLocationURL);
+ InputStream is = url.openStream();
+ msg.setBody(is);
+
+ } else if (id.equals(widgetName)) {
// Generate Javascript header for use in the Widget
InputStream is = generateWidgetCode();
@@ -62,8 +73,9 @@
} else {
- // Return an input stream for a resource
- URL url = new URL(locationURL +'/' + id);
+ // Return an input stream for a resource inside the
+ // widget folder
+ URL url = new URL(widgetFolderURL +'/' + id);
InputStream is = url.openStream();
msg.setBody(is);
}
Modified: incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java?rev=615091&r1=615090&r2=615091&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/provider/WidgetImplementationProvider.java Thu Jan 24 17:05:58 2008
@@ -31,18 +31,24 @@
*/
class WidgetImplementationProvider implements ImplementationProvider {
private RuntimeComponent component;
- private WidgetImplementation implementation;
+ private String widgetLocationURL;
+ private String widgetFolderURL;
+ private String widgetName;
/**
* Constructs a new resource implementation provider.
*/
WidgetImplementationProvider(RuntimeComponent component, WidgetImplementation implementation) {
this.component = component;
- this.implementation = implementation;
+ widgetLocationURL = implementation.getLocationURL().toString();
+ int s = widgetLocationURL.lastIndexOf('/');
+ widgetFolderURL = widgetLocationURL.substring(0, s);
+ widgetName = widgetLocationURL.substring(s +1);
+ widgetName = widgetName.substring(0, widgetName.lastIndexOf('.'));
}
public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
- WidgetImplementationInvoker invoker = new WidgetImplementationInvoker(component, implementation.getLocationURL().toString());
+ WidgetImplementationInvoker invoker = new WidgetImplementationInvoker(component, widgetName, widgetFolderURL, widgetLocationURL);
return invoker;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org