diff options
Diffstat (limited to '')
9 files changed, 107 insertions, 102 deletions
diff --git a/java/sca/modules/implementation-widget/META-INF/MANIFEST.MF b/java/sca/modules/implementation-widget/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..ede05162e7 --- /dev/null +++ b/java/sca/modules/implementation-widget/META-INF/MANIFEST.MF @@ -0,0 +1,25 @@ +Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.implementation.widget
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA Widget Implementation Model
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1258090277695
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Widget Implementation Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream;version="1.0",
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.contribution;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.data.collection;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef,
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.widget
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/java/sca/modules/implementation-widget/pom.xml b/java/sca/modules/implementation-widget/pom.xml index d73b78c987..9a167eeed6 100644 --- a/java/sca/modules/implementation-widget/pom.xml +++ b/java/sca/modules/implementation-widget/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-modules</artifactId> - <version>1.6-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> @@ -33,19 +33,25 @@ <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-assembly-xml</artifactId> - <version>1.6-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-interface-java</artifactId> - <version>1.6-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> <artifactId>tuscany-data-api</artifactId> - <version>1.6-SNAPSHOT</version> + <version>2.0-SNAPSHOT</version> </dependency> <dependency> @@ -54,26 +60,5 @@ <version>4.5</version> <scope>test</scope> </dependency> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.implementation.widget</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.implementation.widget*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - </project> diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java index f47850a05c..ff181d35c0 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java @@ -31,4 +31,5 @@ import org.apache.tuscany.sca.data.collection.Collection; * @version $Rev$ $Date$ */ public interface Widget extends Collection<String, InputStream> { + } diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java index 2a092884be..d032d3ca8d 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementation.java @@ -20,6 +20,8 @@ package org.apache.tuscany.sca.implementation.widget; import java.net.URL; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.Implementation; @@ -29,12 +31,29 @@ import org.apache.tuscany.sca.assembly.Implementation; * @version $Rev$ $Date$ */ public interface WidgetImplementation extends Implementation { + QName TYPE = new QName(SCA11_TUSCANY_NS, "implementation.widget"); + /** + * Returns the location of the HTML file representing the Widget + * @return the location + */ String getLocation(); + /** + * Set the location of the HTML file representing the Widget + * @param location + */ void setLocation(String location); + /** + * Returns the Location URL for the HTML file representing the Widget + * @return the location + */ URL getLocationURL(); + /** + * Set the Location URL for the HTML file representing the Widget + * @param url the location + */ void setLocationURL(URL url); } diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java index 3a3754f67d..74addf1e39 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationFactory.java @@ -26,6 +26,10 @@ package org.apache.tuscany.sca.implementation.widget; */ public interface WidgetImplementationFactory { + /** + * Create a Widget Implementation model object + * @return + */ WidgetImplementation createWidgetImplementation(); }
\ No newline at end of file diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java index abe00bac5b..dfffcfd5b5 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java @@ -28,7 +28,9 @@ import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.Reference; /** - * + * A HTML Widget Introspector used to introspect references and property + * annotations in JavaScript code + * * @version $Rev$ $Date$ */ class WidgetImplementationIntrospector { diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java index c0087e97fe..f15a060216 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java @@ -29,16 +29,16 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; @@ -50,14 +50,12 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; * @version $Rev$ $Date$ */ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WidgetImplementation> { - private static final QName IMPLEMENTATION_WIDGET = new QName(Constants.SCA10_TUSCANY_NS, "implementation.widget"); - private AssemblyFactory assemblyFactory; private ContributionFactory contributionFactory; private WidgetImplementationFactory implementationFactory; private Monitor monitor; - public WidgetImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + public WidgetImplementationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); contributionFactory = modelFactories.getFactory(ContributionFactory.class); implementationFactory = modelFactories.getFactory(WidgetImplementationFactory.class); @@ -72,10 +70,10 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp * @param model */ private void error(String message, Object model, Exception ex) { - if (monitor != null) { - Problem problem = monitor.createProblem(this.getClass().getName(), "impl-widget-validation-messages", Severity.ERROR, model, message, ex); - monitor.problem(problem); - } + if (monitor != null) { + Problem problem = monitor.createProblem(this.getClass().getName(), "impl-widget-validation-messages", Severity.ERROR, model, message, ex); + monitor.problem(problem); + } } /** @@ -94,7 +92,7 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp public QName getArtifactType() { // Returns the QName of the XML element processed by this processor - return IMPLEMENTATION_WIDGET; + return WidgetImplementation.TYPE; } public Class<WidgetImplementation> getModelType() { @@ -102,7 +100,7 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp return WidgetImplementation.class; } - public WidgetImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public WidgetImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { // Read an <implementation.widget> element @@ -122,7 +120,7 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp // Skip to end element while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && IMPLEMENTATION_WIDGET.equals(reader.getName())) { + if (reader.next() == END_ELEMENT && WidgetImplementation.TYPE.equals(reader.getName())) { break; } } @@ -130,13 +128,13 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp return implementation; } - public void resolve(WidgetImplementation implementation, ModelResolver resolver) throws ContributionResolveException { + public void resolve(WidgetImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { if (implementation != null) { // Resolve the resource directory location Artifact artifact = contributionFactory.createArtifact(); artifact.setURI(implementation.getLocation()); - Artifact resolved = resolver.resolveModel(Artifact.class, artifact); + Artifact resolved = resolver.resolveModel(Artifact.class, artifact, context); if (resolved.getLocation() != null) { try { implementation.setLocationURL(new URL(resolved.getLocation())); @@ -159,9 +157,9 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp } } - public void write(WidgetImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + public void write(WidgetImplementation implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { // Write <implementation.widget> - writeStart(writer, IMPLEMENTATION_WIDGET.getNamespaceURI(), IMPLEMENTATION_WIDGET.getLocalPart()); + writeStart(writer, WidgetImplementation.TYPE.getNamespaceURI(), WidgetImplementation.TYPE.getLocalPart()); if (implementation.getLocation() != null) { writer.writeAttribute("location", implementation.getLocation()); diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java index c24c9e7eab..626e8f1bc0 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java @@ -20,7 +20,7 @@ package org.apache.tuscany.sca.implementation.widget.impl; import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.widget.WidgetImplementation; import org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory; import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; @@ -35,7 +35,7 @@ public class WidgetImplementationFactoryImpl implements WidgetImplementationFact private AssemblyFactory assemblyFactory; private JavaInterfaceFactory javaFactory; - public WidgetImplementationFactoryImpl(ModelFactoryExtensionPoint modelFactories) { + public WidgetImplementationFactoryImpl(FactoryExtensionPoint modelFactories) { assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); } diff --git a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java index f50fd73b5c..de86aa9196 100644 --- a/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java +++ b/java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java @@ -19,15 +19,12 @@ package org.apache.tuscany.sca.implementation.widget.impl; import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; + +import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; import org.apache.tuscany.sca.implementation.widget.Widget; import org.apache.tuscany.sca.implementation.widget.WidgetImplementation; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; @@ -41,21 +38,20 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; * * @version $Rev$ $Date$ */ -public class WidgetImplementationImpl implements WidgetImplementation { +public class WidgetImplementationImpl extends ImplementationImpl implements WidgetImplementation { private Service widgetService; - private List<Reference> references = new ArrayList<Reference>(); - private List<Property> properties = new ArrayList<Property>(); - + private String location; - private URL url; - private boolean unresolved; + private URL locationUrl; /** * Constructs a new resource implementation. */ WidgetImplementationImpl(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory) { - + JavaInterfaceFactory javaFactory) { + + super(TYPE); + // Resource implementation always provide a single service exposing // the Resource interface, and have no references and properties widgetService = assemblyFactory.createService(); @@ -73,61 +69,36 @@ public class WidgetImplementationImpl implements WidgetImplementation { widgetService.setInterfaceContract(interfaceContract); } - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public URL getLocationURL() { - return url; + public QName getType() { + return TYPE; } - public void setLocationURL(URL url) { - this.url = url; - } - - public ConstrainingType getConstrainingType() { - // The resource implementation does not support constrainingTypes - return null; - } - - public List<Property> getProperties() { - return properties; + @Override + public String getURI() { + return location; } - public List<Service> getServices() { - // The resource implementation does not support services - return Collections.singletonList(widgetService); + @Override + public void setURI(String uri) { + this.location = uri; } - public List<Reference> getReferences() { - return references; - } - - public String getURI() { + public String getLocation() { return location; } - public void setConstrainingType(ConstrainingType constrainingType) { - // The resource implementation does not support constrainingTypes + public void setLocation(String location) { + this.location = location; } - public void setURI(String uri) { - this.location = uri; + public URL getLocationURL() { + return locationUrl; } - - - public boolean isUnresolved() { - return unresolved; + + public void setLocationURL(URL url) { + this.locationUrl = url; } - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } - @Override public String toString() { return "Widget : " + getLocation(); |