diff options
9 files changed, 63 insertions, 96 deletions
diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/META-INF/MANIFEST.MF b/sca-java-2.x/contrib/modules/implementation-ejb/META-INF/MANIFEST.MF index 17dc48478c..178fd5af3d 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/META-INF/MANIFEST.MF +++ b/sca-java-2.x/contrib/modules/implementation-ejb/META-INF/MANIFEST.MF @@ -1,29 +1,26 @@ Manifest-Version: 1.0
Export-Package: org.apache.tuscany.sca.implementation.ejb;uses:="org.a
pache.tuscany.sca.assembly";version="2.0.0"
-Private-Package: org.apache.tuscany.sca.implementation.ejb.impl;versio
- n="1.4",org.apache.tuscany.sca.implementation.ejb.xml;version="2.0.0"
-Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany SCA EJB Session Bean Implementation Model
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Bundle-Vendor: The Apache Software Foundation
Bundle-Version: 2.0.0
-Bnd-LastModified: 1225397451671
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA EJB Session Bean Implementation
Model
-Import-Package: javax.xml.namespace,javax.xml.stream,org.apache.tuscan
- y.sca.assembly;version="2.0.0",org.apache.tuscany.sca.contribution.proc
- essor;version="2.0.0",org.apache.tuscany.sca.contribution.resolver;vers
- ion="1.4",org.apache.tuscany.sca.core;version="2.0.0",org.apache.tuscan
- y.sca.implementation.ejb;version="2.0.0",org.apache.tuscany.sca.monitor
- ;version="2.0.0",org.apache.tuscany.sca.assembly.builder.impl;resolutio
- n:=optional,org.apache.tuscany.sca.definitions;version="2.0.0";resoluti
- on:=optional,org.apache.tuscany.sca.policy;version="2.0.0";resolution:=
- optional,org.apache.tuscany.sca.interfacedef;version="2.0.0";resolution
- :=optional,org.apache.tuscany.sc
- a.assembly.builder;version="2.0.0";resolution:=optional
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="1.4",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.implementation.ejb;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0";resolution:=optional
Bundle-SymbolicName: org.apache.tuscany.sca.implementation.ejb
Bundle-DocURL: http://www.apache.org/
diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/pom.xml b/sca-java-2.x/contrib/modules/implementation-ejb/pom.xml index 472f8f81ed..ff5f356d99 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/pom.xml +++ b/sca-java-2.x/contrib/modules/implementation-ejb/pom.xml @@ -53,7 +53,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.5</version> + <version>4.8.1</version> <scope>test</scope> </dependency> diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java index 0d3b05f0c9..b04a696c61 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java @@ -18,6 +18,9 @@ */ package org.apache.tuscany.sca.implementation.ejb; +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.assembly.Implementation; @@ -28,7 +31,7 @@ import org.apache.tuscany.sca.assembly.Implementation; * @version $Rev$ $Date$ */ public interface EJBImplementation extends Implementation { - + QName TYPE = new QName(Base.SCA11_NS, "implementation.ejb"); /** * Returns the EJB link URI. * @return the EJB link URI diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java index bf2e6354d5..1eb1d575ea 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java @@ -18,13 +18,7 @@ */ package org.apache.tuscany.sca.implementation.ejb.impl; -import java.util.ArrayList; -import java.util.List; - -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.ejb.EJBImplementation; @@ -33,11 +27,7 @@ import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; * * @version $Rev$ $Date$ */ -class EJBImplementationImpl implements EJBImplementation { - - private List<Property> properties = new ArrayList<Property>(); - private List<Service> services = new ArrayList<Service>(); - private List<Reference> references = new ArrayList<Reference>(); +public class EJBImplementationImpl extends ImplementationImpl implements EJBImplementation { private String ejbLink; private String uri; private boolean unresolved; @@ -45,34 +35,14 @@ class EJBImplementationImpl implements EJBImplementation { /** * Constructs a new EJB implementation. */ - EJBImplementationImpl() { - } - - public ConstrainingType getConstrainingType() { - // The EJB implementation does not support constrainingTypes - return null; - } - - public List<Property> getProperties() { - return properties; - } - - public List<Service> getServices() { - return services; - } - - public List<Reference> getReferences() { - return references; + public EJBImplementationImpl() { + super(TYPE); } public String getEJBLink() { return ejbLink; } - public void setConstrainingType(ConstrainingType constrainingType) { - // The EJB implementation does not support constrainingTypes - } - public void setEJBLink(String ejbLink) { this.ejbLink = ejbLink; } @@ -84,12 +54,4 @@ class EJBImplementationImpl implements EJBImplementation { public void setURI(String uri) { this.uri = uri; } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean unresolved) { - this.unresolved = unresolved; - } } diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java index 573bd7ef17..e963be1e69 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java @@ -31,12 +31,13 @@ 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.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; import org.apache.tuscany.sca.implementation.ejb.EJBImplementationFactory; -import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; @@ -47,17 +48,14 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; * @version $Rev$ $Date$ */ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<EJBImplementation> { - private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0"; - private static final QName IMPLEMENTATION_EJB = new QName(SCA10_NS, "implementation.ejb"); - + private static final QName IMPLEMENTATION_EJB = EJBImplementation.TYPE; private AssemblyFactory assemblyFactory; private EJBImplementationFactory implementationFactory; - private Monitor monitor; - public EJBImplementationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) { - this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - this.implementationFactory = modelFactories.getFactory(EJBImplementationFactory.class); - this.monitor = monitor; + public EJBImplementationProcessor(ExtensionPointRegistry registry) { + FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + this.assemblyFactory = factories.getFactory(AssemblyFactory.class); + this.implementationFactory = factories.getFactory(EJBImplementationFactory.class); } /** @@ -67,7 +65,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem * @param message * @param model */ - private void error(String message, Object model, Object... messageParameters) { + private void error(org.apache.tuscany.sca.monitor.Monitor monitor, String message, Object model, Object... messageParameters) { if (monitor != null) { Problem problem = monitor.createProblem(this.getClass().getName(), "impl-ejb-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); monitor.problem(problem); @@ -84,7 +82,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem return EJBImplementation.class; } - public EJBImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + public EJBImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { // Read an <implementation.ejb> element EJBImplementation implementation = implementationFactory.createEJBImplementation(); @@ -104,7 +102,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem implementation.setURI(ejbLink); } } else { - error("EJBLinkAttributeMissing", reader); + error(context.getMonitor(), "EJBLinkAttributeMissing", reader); } // Skip to end element @@ -117,14 +115,14 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem return implementation; } - public void resolve(EJBImplementation implementation, ModelResolver resolver) throws ContributionResolveException { + public void resolve(EJBImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { // Resolve the component type String uri = implementation.getURI(); if (uri != null) { ComponentType componentType = assemblyFactory.createComponentType(); componentType.setURI(uri + ".componentType"); - componentType = resolver.resolveModel(ComponentType.class, componentType); + componentType = resolver.resolveModel(ComponentType.class, componentType, context); if (!componentType.isUnresolved()) { // Initialize the implementation's services, references and properties @@ -136,7 +134,7 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem implementation.setUnresolved(false); } - public void write(EJBImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + public void write(EJBImplementation implementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { // Write <implementation.ejb> writeStart(writer, IMPLEMENTATION_EJB.getNamespaceURI(), IMPLEMENTATION_EJB.getLocalPart(), diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index ae6db609a2..a3d1f64b56 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -16,4 +16,4 @@ # under the License. # Implementation class for the artifact processor extension -org.apache.tuscany.sca.implementation.ejb.xml.EJBImplementationProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#implementation.ejb,model=org.apache.tuscany.sca.implementation.ejb.EJBImplementation,factory=org.apache.tuscany.sca.implementation.ejb.EJBImplementationFactory +org.apache.tuscany.sca.implementation.ejb.xml.EJBImplementationProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200912#implementation.ejb,model=org.apache.tuscany.sca.implementation.ejb.EJBImplementation,factory=org.apache.tuscany.sca.implementation.ejb.EJBImplementationFactory diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/ReadTestCase.java b/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/ReadTestCase.java index ffbdf1d54c..bc72dd1459 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/ReadTestCase.java +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/ReadTestCase.java @@ -27,13 +27,15 @@ import javax.xml.stream.XMLStreamReader; import junit.framework.TestCase; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.builder.BuilderContext; +import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; /** @@ -43,27 +45,30 @@ import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; */ public class ReadTestCase extends TestCase { + private ExtensionPointRegistry registry; private XMLInputFactory inputFactory; private StAXArtifactProcessor<Object> staxProcessor; private CompositeBuilder compositeBuilder; @Override public void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); + registry = new DefaultExtensionPointRegistry(); + inputFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(XMLInputFactory.class); + // StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(registry); - compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder"); + compositeBuilder = registry.getExtensionPoint(BuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder"); } public void testReadComposite() throws Exception { + ProcessorContext context = new ProcessorContext(registry); InputStream is = getClass().getResourceAsStream("TestEJB.composite"); XMLStreamReader reader = inputFactory.createXMLStreamReader(is); - Composite composite = (Composite) staxProcessor.read(reader); + Composite composite = (Composite) staxProcessor.read(reader, context); assertNotNull(composite); - compositeBuilder.build(composite, null, null); + BuilderContext builderContext = new BuilderContext(registry); + compositeBuilder.build(composite, builderContext); assertTrue(((EJBImplementation) composite.getComponents().get(0).getImplementation()).getEJBLink().equals("module.jar#TestEJB")); } diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/WriteTestCase.java b/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/WriteTestCase.java index 8ba43dd635..d3b7300e4c 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/WriteTestCase.java +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/test/java/org/apache/tuscany/sca/implementation/ejb/xml/WriteTestCase.java @@ -28,11 +28,12 @@ import javax.xml.stream.XMLOutputFactory; import junit.framework.TestCase; import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; /** * Test reading/write WSDL interfaces. @@ -40,26 +41,27 @@ import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; * @version $Rev$ $Date$ */ public class WriteTestCase extends TestCase { - + private ExtensionPointRegistry registry; private XMLInputFactory inputFactory; private XMLOutputFactory outputFactory; private StAXArtifactProcessor<Object> staxProcessor; @Override public void setUp() throws Exception { - DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - inputFactory = XMLInputFactory.newInstance(); - outputFactory = XMLOutputFactory.newInstance(); - StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); - staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null); + registry = new DefaultExtensionPointRegistry(); + FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); + inputFactory = factories.getFactory(XMLInputFactory.class); + outputFactory = factories.getFactory(XMLOutputFactory.class); + staxProcessor = new ExtensibleStAXArtifactProcessor(registry); } public void testReadWriteComposite() throws Exception { + ProcessorContext context = new ProcessorContext(registry); InputStream is = getClass().getResourceAsStream("TestEJB.composite"); - Composite composite = (Composite) staxProcessor.read(inputFactory.createXMLStreamReader(is)); + Composite composite = (Composite) staxProcessor.read(inputFactory.createXMLStreamReader(is), context); assertNotNull(composite); ByteArrayOutputStream bos = new ByteArrayOutputStream(); - staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), context); assertTrue(bos.toString().contains("module.jar#TestEJB")); diff --git a/sca-java-2.x/contrib/modules/implementation-ejb/src/test/resources/org/apache/tuscany/sca/implementation/ejb/xml/TestEJB.composite b/sca-java-2.x/contrib/modules/implementation-ejb/src/test/resources/org/apache/tuscany/sca/implementation/ejb/xml/TestEJB.composite index 0c1368c4dd..a231ab5e17 100644 --- a/sca-java-2.x/contrib/modules/implementation-ejb/src/test/resources/org/apache/tuscany/sca/implementation/ejb/xml/TestEJB.composite +++ b/sca-java-2.x/contrib/modules/implementation-ejb/src/test/resources/org/apache/tuscany/sca/implementation/ejb/xml/TestEJB.composite @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. --> -<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" targetNamespace="http://sample/ejb" xmlns:sc="http://sample/composite" name="TestEJB"> |