summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-widget/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/Widget.java3
-rw-r--r--java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationIntrospector.java7
-rw-r--r--java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/WidgetImplementationProcessor.java94
-rw-r--r--java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationFactoryImpl.java14
-rw-r--r--java/sca/modules/implementation-widget/src/main/java/org/apache/tuscany/sca/implementation/widget/impl/WidgetImplementationImpl.java12
5 files changed, 79 insertions, 51 deletions
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 ff181d35c0..f1c1c36934 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
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.implementation.widget;
import java.io.InputStream;
import org.apache.tuscany.sca.data.collection.Collection;
+import org.oasisopen.sca.annotation.Remotable;
/**
* The service interface of widget implementations. This is not an API for application
@@ -30,6 +31,8 @@ import org.apache.tuscany.sca.data.collection.Collection;
*
* @version $Rev$ $Date$
*/
+
+@Remotable
public interface Widget extends Collection<String, InputStream> {
}
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 dfffcfd5b5..9bf8c05d73 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
@@ -26,6 +26,8 @@ import java.util.Scanner;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
/**
* A HTML Widget Introspector used to introspect references and property
@@ -40,9 +42,10 @@ class WidgetImplementationIntrospector {
private AssemblyFactory assemblyFactory;
private WidgetImplementation widgetImplementation;
- WidgetImplementationIntrospector(AssemblyFactory assemblyFactory, WidgetImplementation widgetImplementation) {
+ WidgetImplementationIntrospector(ExtensionPointRegistry registry, WidgetImplementation widgetImplementation ) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
this.widgetImplementation = widgetImplementation;
- this.assemblyFactory = assemblyFactory;
}
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 f15a060216..d4896b8d0a 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
@@ -28,7 +28,6 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.ContributionFactory;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
@@ -38,6 +37,7 @@ 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.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
@@ -50,45 +50,17 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
* @version $Rev$ $Date$
*/
public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WidgetImplementation> {
- private AssemblyFactory assemblyFactory;
+ private ExtensionPointRegistry registry;
private ContributionFactory contributionFactory;
private WidgetImplementationFactory implementationFactory;
- private Monitor monitor;
- public WidgetImplementationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ public WidgetImplementationProcessor(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
contributionFactory = modelFactories.getFactory(ContributionFactory.class);
implementationFactory = modelFactories.getFactory(WidgetImplementationFactory.class);
- this.monitor = monitor;
- }
-
- /**
- * Report a exception.
- *
- * @param problems
- * @param message
- * @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);
- }
- }
-
- /**
- * Report a error.
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "impl-widget-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
}
+
public QName getArtifactType() {
// Returns the QName of the XML element processed by this processor
@@ -114,7 +86,7 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp
implementation.setLocation(location);
implementation.setUnresolved(true);
} else {
- error("LocationAttributeMissing", reader);
+ error(context.getMonitor(), "LocationAttributeMissing", reader);
//throw new ContributionReadException(MSG_LOCATION_MISSING);
}
@@ -141,17 +113,17 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp
//introspect implementation
WidgetImplementationIntrospector widgetIntrospector =
- new WidgetImplementationIntrospector(assemblyFactory, implementation);
+ new WidgetImplementationIntrospector(registry, implementation);
widgetIntrospector.introspectImplementation();
implementation.setUnresolved(false);
} catch (IOException e) {
ContributionResolveException ce = new ContributionResolveException(e);
- error("ContributionResolveException", resolver, ce);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
//throw ce;
}
} else {
- error("CouldNotResolveLocation", resolver, implementation.getLocation());
+ error(context.getMonitor(), "CouldNotResolveLocation", resolver, implementation.getLocation());
//throw new ContributionResolveException("Could not resolve implementation.widget location: " + implementation.getLocation());
}
}
@@ -167,4 +139,50 @@ public class WidgetImplementationProcessor extends BaseStAXArtifactProcessor imp
writeEnd(writer);
}
+
+ /**
+ * Utility methods
+ */
+
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-widget-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(Monitor monitor, 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);
+ }
+ }
+
}
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 626e8f1bc0..960a01d07e 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
@@ -19,11 +19,9 @@
package org.apache.tuscany.sca.implementation.widget.impl;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
import org.apache.tuscany.sca.implementation.widget.WidgetImplementationFactory;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
/**
* Factory for the widget implementation model.
@@ -32,16 +30,14 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
*/
public class WidgetImplementationFactoryImpl implements WidgetImplementationFactory {
- private AssemblyFactory assemblyFactory;
- private JavaInterfaceFactory javaFactory;
+ private ExtensionPointRegistry registry;
- public WidgetImplementationFactoryImpl(FactoryExtensionPoint modelFactories) {
- assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+ public WidgetImplementationFactoryImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
}
public WidgetImplementation createWidgetImplementation() {
- return new WidgetImplementationImpl(assemblyFactory, javaFactory);
+ return new WidgetImplementationImpl(registry);
}
}
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 de86aa9196..7bdecc2c3a 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
@@ -25,6 +25,8 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.widget.Widget;
import org.apache.tuscany.sca.implementation.widget.WidgetImplementation;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
@@ -47,11 +49,14 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg
/**
* Constructs a new resource implementation.
*/
- WidgetImplementationImpl(AssemblyFactory assemblyFactory,
- JavaInterfaceFactory javaFactory) {
+ WidgetImplementationImpl(ExtensionPointRegistry registry) {
super(TYPE);
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
+
// Resource implementation always provide a single service exposing
// the Resource interface, and have no references and properties
widgetService = assemblyFactory.createService();
@@ -67,6 +72,8 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg
JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
interfaceContract.setInterface(javaInterface);
widgetService.setInterfaceContract(interfaceContract);
+
+ this.getServices().add(widgetService);
}
public QName getType() {
@@ -99,6 +106,7 @@ public class WidgetImplementationImpl extends ImplementationImpl implements Widg
this.locationUrl = url;
}
+
@Override
public String toString() {
return "Widget : " + getLocation();