summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/META-INF/MANIFEST.MF9
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java28
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java64
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java11
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor4
-rw-r--r--sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java2
6 files changed, 53 insertions, 65 deletions
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/databinding-sdo/META-INF/MANIFEST.MF
index ef2273ea9c..742e737616 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/META-INF/MANIFEST.MF
@@ -8,7 +8,11 @@ Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Data Binding for SDO
Import-Package: javax.xml.namespace,
+ javax.xml.parsers,
javax.xml.stream,
+ javax.xml.transform.dom,
+ commonj.sdo,
+ commonj.sdo.helper,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.common.java.collection;version="2.0.0",
@@ -24,7 +28,8 @@ Import-Package: javax.xml.namespace,
org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
org.oasisopen.sca;version="2.0.0",
- org.oasisopen.sca.annotation;version="2.0.0"
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.w3c.dom
Bundle-SymbolicName: org.apache.tuscany.sca.databinding.sdo
Bundle-DocURL: http://www.apache.org/
-
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java
index df1587c625..117d61ff26 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessor.java
@@ -42,6 +42,7 @@ import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ClassReference;
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;
@@ -61,11 +62,10 @@ import commonj.sdo.helper.XSDHelper;
public class ImportSDOProcessor implements StAXArtifactProcessor<ImportSDO> {
private ContributionFactory contributionFactory;
- private Monitor monitor;
- public ImportSDOProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ public ImportSDOProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- this.monitor = monitor;
}
/**
@@ -75,11 +75,13 @@ public class ImportSDOProcessor implements StAXArtifactProcessor<ImportSDO> {
* @param message
* @param model
*/
- private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,message, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
+ message, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
/**
@@ -89,7 +91,7 @@ public class ImportSDOProcessor implements StAXArtifactProcessor<ImportSDO> {
* @param message
* @param model
*/
- private void error(String message, Object model, Exception ex) {
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
if (monitor != null) {
Problem problem = new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR, message,model, message, ex);
monitor.problem(problem);
@@ -136,11 +138,11 @@ public class ImportSDOProcessor implements StAXArtifactProcessor<ImportSDO> {
importSDO.setUnresolved(false);
} catch (Exception e) {
ContributionResolveException ce = new ContributionResolveException(e);
- error("ContributionResolveException", resolver, ce);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
//throw ce;
}
} else {
- error("FailToResolveClass", resolver, factoryName);
+ error(context.getMonitor(), "FailToResolveClass", resolver, factoryName);
//ContributionResolveException loaderException =
//new ContributionResolveException("Fail to resolve class: " + factoryName);
//throw loaderException;
@@ -178,13 +180,13 @@ public class ImportSDOProcessor implements StAXArtifactProcessor<ImportSDO> {
}
importSDO.setUnresolved(false);
} else {
- error("FailToResolveLocation", resolver, location);
+ error(context.getMonitor(), "FailToResolveLocation", resolver, location);
//ContributionResolveException loaderException = new ContributionResolveException("Fail to resolve location: " + location);
//throw loaderException;
}
} catch (IOException e) {
ContributionResolveException ce = new ContributionResolveException(e);
- error("ContributionResolveException", resolver, ce);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
//throw ce;
}
}
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
index 760d4b689b..f9d66bf04e 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesModelResolver.java
@@ -31,22 +31,20 @@ import java.util.List;
import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.ContributionFactory;
-import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.resolver.ClassReference;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.databinding.sdo.SDOTypes;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
import org.apache.tuscany.sca.xsd.XSDFactory;
import org.apache.tuscany.sca.xsd.XSDefinition;
import org.apache.tuscany.sdo.api.SDOUtil;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
import commonj.sdo.Type;
import commonj.sdo.helper.HelperContext;
import commonj.sdo.helper.XSDHelper;
@@ -60,34 +58,20 @@ public class SDOTypesModelResolver implements ModelResolver {
private List<SDOTypes> sdoTypes = new ArrayList<SDOTypes>();
private ContributionFactory contributionFactory;
private XSDFactory xsdFactory;
- private Monitor monitor;
- private ProcessorContext context;
+ private ProcessorContext context;
- public SDOTypesModelResolver(Contribution contribution, ExtensionPointRegistry registry) {
+ public SDOTypesModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
super();
- DefaultFactoryExtensionPoint modelFactories = registry.getExtensionPoint(DefaultFactoryExtensionPoint.class);
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
this.xsdFactory = modelFactories.getFactory(XSDFactory.class);
- this.monitor = createMonitor(registry);
this.contribution = contribution;
}
- private static Monitor createMonitor(ExtensionPointRegistry extensionPoints) {
- UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- if (utilities != null) {
- MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
- if (monitorFactory != null) {
- return monitorFactory.createMonitor();
- }
- }
- return null;
- }
-
- public void addModel(Object resolved,ProcessorContext context) {
+ public void addModel(Object resolved, ProcessorContext context) {
if (helperContext == null) {
helperContext = SDOUtil.createHelperContext();
}
- this.context=context;
+ this.context = context;
SDOTypes types = (SDOTypes)resolved;
try {
loadSDOTypes(types, contribution.getModelResolver());
@@ -98,16 +82,16 @@ public class SDOTypesModelResolver implements ModelResolver {
sdoTypes.add(types);
}
- public Object removeModel(Object resolved,ProcessorContext context) {
+ public Object removeModel(Object resolved, ProcessorContext context) {
SDOTypes types = (SDOTypes)resolved;
-
+
return sdoTypes.remove(types);
}
- public <T> T resolveModel(Class<T> modelClass, T unresolved,ProcessorContext context) {
+ public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
SDOTypes types = (SDOTypes)unresolved;
String ns = types.getNamespace();
- this.context=context;
+ this.context = context;
for (SDOTypes t : sdoTypes) {
if (t.getNamespace().equals(types.getNamespace())) {
try {
@@ -133,7 +117,7 @@ public class SDOTypesModelResolver implements ModelResolver {
String factoryName = importSDO.getFactory();
if (factoryName != null) {
ClassReference reference = new ClassReference(factoryName);
- ClassReference resolved = resolver.resolveModel(ClassReference.class, reference,context);
+ ClassReference resolved = resolver.resolveModel(ClassReference.class, reference, context);
if (resolved != null && !resolved.isUnresolved()) {
try {
Class<?> factoryClass = resolved.getJavaClass();
@@ -144,11 +128,11 @@ public class SDOTypesModelResolver implements ModelResolver {
importSDO.setUnresolved(false);
} catch (Exception e) {
ContributionResolveException ce = new ContributionResolveException(e);
- error("ContributionResolveException", resolver, ce);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
//throw ce;
}
} else {
- error("FailToResolveClass", resolver, factoryName);
+ error(context.getMonitor(), "FailToResolveClass", resolver, factoryName);
//ContributionResolveException loaderException =
//new ContributionResolveException("Fail to resolve class: " + factoryName);
//throw loaderException;
@@ -162,7 +146,7 @@ public class SDOTypesModelResolver implements ModelResolver {
try {
Artifact artifact = contributionFactory.createArtifact();
artifact.setURI(location);
- artifact = resolver.resolveModel(Artifact.class, artifact,context);
+ artifact = resolver.resolveModel(Artifact.class, artifact, context);
if (artifact.getLocation() != null) {
String wsdlURL = artifact.getLocation();
URLConnection connection = new URL(wsdlURL).openConnection();
@@ -181,13 +165,13 @@ public class SDOTypesModelResolver implements ModelResolver {
}
importSDO.setUnresolved(false);
} else {
- error("FailToResolveLocation", resolver, location);
+ error(context.getMonitor(), "FailToResolveLocation", resolver, location);
//ContributionResolveException loaderException = new ContributionResolveException("Fail to resolve location: " + location);
//throw loaderException;
}
} catch (IOException e) {
ContributionResolveException ce = new ContributionResolveException(e);
- error("ContributionResolveException", resolver, ce);
+ error(context.getMonitor(), "ContributionResolveException", resolver, ce);
//throw ce;
}
} else {
@@ -196,7 +180,7 @@ public class SDOTypesModelResolver implements ModelResolver {
XSDefinition xsd = xsdFactory.createXSDefinition();
xsd.setUnresolved(true);
xsd.setNamespace(ns);
- xsd = resolver.resolveModel(XSDefinition.class, xsd,context);
+ xsd = resolver.resolveModel(XSDefinition.class, xsd, context);
if (!xsd.isUnresolved()) {
XSDHelper xsdHelper = helperContext.getXSDHelper();
xsdHelper.define(xsd.getLocation().toString());
@@ -222,11 +206,11 @@ public class SDOTypesModelResolver implements ModelResolver {
* @param message
* @param model
*/
- private void error(String message, Object model, Exception ex) {
+ private void error(Monitor monitor, String message, Object model, Exception ex) {
if (monitor != null) {
Problem problem =
new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
- message, model, message, ex);
+ message, model, message, ex);
monitor.problem(problem);
}
}
@@ -238,15 +222,13 @@ public class SDOTypesModelResolver implements ModelResolver {
* @param message
* @param model
*/
- private void error(String message, Object model, Object... messageParameters) {
+ private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
if (monitor != null) {
Problem problem =
new ProblemImpl(this.getClass().getName(), "databinding-sdo-validation-messages", Severity.ERROR,
- message,model, message, (Object[])messageParameters);
+ message, model, message, (Object[])messageParameters);
monitor.problem(problem);
}
}
-
-
}
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
index d595b07b11..76e2955f06 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/xml/SDOTypesProcessor.java
@@ -25,15 +25,14 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
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.databinding.sdo.SDOTypes;
-import org.apache.tuscany.sca.monitor.Monitor;
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.databinding.sdo.SDOTypes;
/**
@@ -43,7 +42,7 @@ import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
*/
public class SDOTypesProcessor implements StAXArtifactProcessor<SDOTypes> {
- public SDOTypesProcessor(DefaultFactoryExtensionPoint modelFactories, Monitor monitor) {
+ public SDOTypesProcessor(ExtensionPointRegistry registry) {
}
public QName getXMLType() {
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index da9b7f5ed4..27fa6e85ad 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-org.apache.tuscany.sca.databinding.sdo.ImportSDOProcessor;qname=http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.1#import.sdo,model=org.apache.tuscany.sca.databinding.sdo.ImportSDO
-org.apache.tuscany.sca.databinding.sdo.xml.SDOTypesProcessor;qname=http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.1#sdo.types,model=org.apache.tuscany.sca.databinding.sdo.SDOTypes
+org.apache.tuscany.sca.databinding.sdo.ImportSDOProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#import.sdo,model=org.apache.tuscany.sca.databinding.sdo.ImportSDO
+org.apache.tuscany.sca.databinding.sdo.xml.SDOTypesProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#sdo.types,model=org.apache.tuscany.sca.databinding.sdo.SDOTypes
diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java
index ef7f425d7c..1fcae3cb73 100644
--- a/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java
+++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/ImportSDOProcessorTestCase.java
@@ -83,7 +83,7 @@ public class ImportSDOProcessorTestCase {
public static void setUp() throws Exception {
registry = new DefaultExtensionPointRegistry();
FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- loader = new ImportSDOProcessor(factories, null);
+ loader = new ImportSDOProcessor(registry);
xmlFactory = factories.getFactory(XMLInputFactory.class);
}