diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2012-06-16 18:13:30 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2012-06-16 18:13:30 +0000 |
commit | ed88c41f044ca9c0a2fdc4d07f0e2a06edae4501 (patch) | |
tree | d58a4aa6f269989bd299703e437da60f81b26eb3 | |
parent | 4d4099c369ade4eedc0244eeddb5b58d19b3de39 (diff) |
Adding suppot for parsing uri as new attribute for implementation widget
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1350969 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
4 files changed, 50 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java index d032d3ca8d..3f0480ab78 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java +++ b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java @@ -56,4 +56,16 @@ public interface WidgetImplementation extends Implementation { * @param url the location */ void setLocationURL(URL url); + + /** + * Get the widget URI + * @return the uri + */ + String getUri(); + + /** + * Set the widget URI, used to automatically add a binding to the widget + * @param uri the uri + */ + void setUri(String uri); } diff --git a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java index b5b374baad..ab278c4923 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java +++ b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java @@ -20,11 +20,8 @@ package org.apache.tuscany.sca.implementation.widget; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import java.io.File; -import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; -import java.net.URISyntaxException; import java.net.URL; import javax.xml.namespace.QName; @@ -80,18 +77,24 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp // Read an <implementation.widget> element // Create and initialize the resource implementation model - WidgetImplementation implementation = null; - + WidgetImplementation implementation = implementationFactory.createWidgetImplementation(); + implementation.setUnresolved(true); + // Read the location attribute specifying the location of the resources String location = getURIString(reader, "location"); - if (location != null) { - implementation = implementationFactory.createWidgetImplementation(); + if (location != null && location.isEmpty() == false) { implementation.setLocation(location); - implementation.setUnresolved(true); } else { error(context.getMonitor(), "LocationAttributeMissing", reader); //throw new ContributionReadException(MSG_LOCATION_MISSING); } + + String uri = getURIString(reader, "uri"); + if(uri != null && uri.isEmpty() == false) { + implementation.setUri(uri); + } else { + warning(context.getMonitor(), "UocationAttributeMissing", reader); + } // Skip to end element while (reader.hasNext()) { @@ -168,10 +171,14 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp // Write <implementation.widget> writeStart(writer, WidgetImplementation.TYPE.getNamespaceURI(), WidgetImplementation.TYPE.getLocalPart()); - if (implementation.getLocation() != null) { + if (implementation.getLocation() != null && implementation.getLocation().isEmpty() == false) { writer.writeAttribute("location", implementation.getLocation()); } + if (implementation.getUri() != null && implementation.getUri().isEmpty() == false) { + writer.writeAttribute("uri", implementation.getUri()); + } + writeEnd(writer); } @@ -179,6 +186,18 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp * Utility methods */ + private void warning(Monitor monitor, String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = + monitor.createProblem(this.getClass().getName(), + "impl-widget-validation-messages", + Severity.WARNING, + model, + message, + (Object[])messageParameters); + monitor.problem(problem); + } + } /** * Report a error. diff --git a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java index 58edfdd3ba..e2ecbb8fcb 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java +++ b/sca-java-2.x/trunk/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java @@ -45,6 +45,8 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg private String location; private URL locationUrl; + + private String uri; /** * Constructs a new resource implementation. @@ -96,6 +98,13 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg this.locationUrl = url; } + public String getUri() { + return this.uri; + } + + public void setUri(String uri) { + this.uri = uri; + } @Override public String toString() { diff --git a/sca-java-2.x/trunk/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties b/sca-java-2.x/trunk/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties index 3778bd4c50..0b3796de56 100644 --- a/sca-java-2.x/trunk/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/implementation-widget/src/main/resources/impl-widget-validation-messages.properties @@ -20,4 +20,5 @@ # ContributionResolveException = ContributionResolveException occured due to: LocationAttributeMissing = Reading implementation.widget - location attribute missing +UriAttributeMissing = Reading implementation.widget - uri attribute missing CouldNotResolveLocation = Could not resolve implementation.widget location: {0} |