diff options
Diffstat (limited to '')
18 files changed, 676 insertions, 81 deletions
diff --git a/java/sca/modules/deployment/LICENSE b/java/sca/modules/deployment/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/java/sca/modules/deployment/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/java/sca/modules/deployment/META-INF/MANIFEST.MF b/java/sca/modules/deployment/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..c0c86e615c --- /dev/null +++ b/java/sca/modules/deployment/META-INF/MANIFEST.MF @@ -0,0 +1,49 @@ +Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.deployment;version="2.0.0";
+ uses:="javax.xml.stream,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.assembly.builder",
+ org.apache.tuscany.sca.deployment.impl;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.definitions,
+ org.apache.tuscany.sca.common.xml.stax,
+ org.apache.tuscany.sca.contribution,
+ org.apache.tuscany.sca.core,
+ org.apache.tuscany.sca.deployment,
+ org.apache.tuscany.sca.monitor,
+ javax.xml.stream,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.contribution.processor,
+ org.apache.tuscany.sca.assembly.builder"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Deployment
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397240796
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Node Implementation
+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",
+ org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.stax;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.core;version="2.0.0",
+ org.apache.tuscany.sca.definitions;version="2.0.0",
+ org.apache.tuscany.sca.definitions.util;version="2.0.0",
+ org.apache.tuscany.sca.definitions.xml;version="2.0.0",
+ org.apache.tuscany.sca.deployment;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.deployment
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/java/sca/modules/deployment/NOTICE b/java/sca/modules/deployment/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/java/sca/modules/deployment/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2009 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/java/sca/modules/deployment/pom.xml b/java/sca/modules/deployment/pom.xml new file mode 100644 index 0000000000..20475d5bbd --- /dev/null +++ b/java/sca/modules/deployment/pom.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-deployment</artifactId> + <name>Apache Tuscany SCA Deployment</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <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-assembly-xml</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-builder</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xsd</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java b/java/sca/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java index 3d7b99612e..c510d10e47 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java +++ b/java/sca/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java @@ -68,6 +68,8 @@ public interface Deployer extends LifeCycleListener { Composite build(List<Contribution> contributions, Map<QName, List<String>> bindingBaseURIs, Monitor monitor) throws ContributionResolveException, CompositeBuilderException; + Monitor createMonitor(); + /** * Create an instance of {@link BuilderContext} * @return diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java b/java/sca/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java index 8180ac6465..8180ac6465 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java +++ b/java/sca/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/java/sca/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java index f3462ad1da..3b06aa4d93 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java +++ b/java/sca/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.deployment.impl; -import static java.lang.System.currentTimeMillis; - import java.io.Reader; import java.io.Writer; import java.net.URI; @@ -31,7 +29,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.namespace.QName; @@ -102,8 +99,8 @@ public class DeployerImpl implements Deployer { protected MonitorFactory monitorFactory; - protected static final String NODE_IMPL_VALIDATION_MESSAGES = - "org.apache.tuscany.sca.node.impl.node-impl-validation-messages"; + protected static final String DEPLOYER_IMPL_VALIDATION_MESSAGES = + "org.apache.tuscany.sca.deployment.impl.deployer-impl-validation-messages"; /** * @param registry @@ -112,7 +109,12 @@ public class DeployerImpl implements Deployer { super(); this.registry = registry; } - + + public Monitor createMonitor() { + init(); + return monitorFactory.createMonitor(); + } + public synchronized void stop() { if (inited) { staxHelper = null; @@ -135,10 +137,10 @@ public class DeployerImpl implements Deployer { * Analyze a contribution and add its dependencies to the given dependency set. */ protected void addContributionDependencies(Contribution contribution, - List<Contribution> contributions, - List<Contribution> dependencies, - Set<Contribution> set, - Monitor monitor) { + List<Contribution> contributions, + List<Contribution> dependencies, + Set<Contribution> set, + Monitor monitor) { // Go through the contribution imports for (Import import_ : contribution.getImports()) { @@ -180,7 +182,7 @@ public class DeployerImpl implements Deployer { if (!(import_ instanceof DefaultImport)) { // Add the (empty) matchingExports List and report a warning import_.setModelResolver(new DefaultImportModelResolver(matchingExports)); - Monitor.error(monitor, this, NODE_IMPL_VALIDATION_MESSAGES, "UnresolvedImport", import_); + Monitor.error(monitor, this, DEPLOYER_IMPL_VALIDATION_MESSAGES, "UnresolvedImport", import_); } } // end if } @@ -208,8 +210,8 @@ public class DeployerImpl implements Deployer { * @throws ContributionResolveException */ protected void contributionsPreresolve(List<Contribution> contributions, - ModelResolver resolver, - ProcessorContext context) throws ContributionResolveException { + ModelResolver resolver, + ProcessorContext context) throws ContributionResolveException { for (Contribution contribution : contributions) { contributionProcessor.preResolve(contribution, resolver, context); @@ -219,17 +221,19 @@ public class DeployerImpl implements Deployer { public ExtensionPointRegistry getExtensionPointRegistry() { return registry; } + + public void start() { + // Defer to the init() method + } - public synchronized void start() { + public synchronized void init() { if (inited) { return; } - long start = currentTimeMillis(); // Enable schema validation only of the logger level is FINE or higher if (isSchemaValidationEnabled()) { - ValidationSchemaExtensionPoint schemas = - registry.getExtensionPoint(ValidationSchemaExtensionPoint.class); + ValidationSchemaExtensionPoint schemas = registry.getExtensionPoint(ValidationSchemaExtensionPoint.class); if (schemas != null) { schemas.setEnabled(true); } @@ -259,7 +263,7 @@ public class DeployerImpl implements Deployer { URLArtifactProcessorExtensionPoint docProcessorExtensions = registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); artifactProcessor = new ExtensibleURLArtifactProcessor(docProcessorExtensions); - + contributionProcessor = (ExtendedURLArtifactProcessor<Contribution>)docProcessorExtensions.getProcessor(Contribution.class); @@ -275,10 +279,6 @@ public class DeployerImpl implements Deployer { inited = true; - if (logger.isLoggable(Level.FINE)) { - long end = currentTimeMillis(); - logger.fine("The tuscany runtime started in " + (end - start) + " ms."); - } } protected void loadSystemContribution(Monitor monitor) { @@ -314,9 +314,9 @@ public class DeployerImpl implements Deployer { artifact.setModel(systemDefinitions); artifacts.add(artifact); } - + protected Contribution cloneSystemContribution(Monitor monitor) { - start(); + init(); Contribution contribution = contributionFactory.createContribution(); contribution.setURI(systemContribution.getURI()); contribution.setLocation(systemContribution.getLocation()); @@ -339,7 +339,7 @@ public class DeployerImpl implements Deployer { } public void attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending) { - start(); + init(); // Create an artifact for the deployment composite Artifact artifact = contributionFactory.createArtifact(); String uri = composite.getName().getLocalPart() + ".composite"; @@ -359,8 +359,11 @@ public class DeployerImpl implements Deployer { contribution.getDeployables().add(composite); } - public Composite build(List<Contribution> contributions, Map<QName, List<String>> bindingMap, Monitor monitor) throws ContributionResolveException, CompositeBuilderException { - start(); + public Composite build(List<Contribution> contributions, Map<QName, List<String>> bindingMap, Monitor monitor) + throws ContributionResolveException, CompositeBuilderException { + init(); + List<Contribution> contributionList = new ArrayList<Contribution>(contributions); + Contribution systemContribution = cloneSystemContribution(monitor); Definitions systemDefinitions = systemContribution.getArtifacts().get(0).getModel(); // Build an aggregated SCA definitions model. Must be done before we try and @@ -372,7 +375,7 @@ public class DeployerImpl implements Deployer { // each contribution so that for unresolved items the resolution // processing will look in the system contribution ProcessorContext context = new ProcessorContext(monitor); - for (Contribution contribution : contributions) { + for (Contribution contribution : contributionList) { monitor.pushContext("Contribution: " + contribution.getURI()); try { // aggregate definitions @@ -401,19 +404,19 @@ public class DeployerImpl implements Deployer { } ExtensibleModelResolver modelResolver = - new ExtensibleModelResolver(new Contributions(contributions), modelResolvers, modelFactories); + new ExtensibleModelResolver(new Contributions(contributionList), modelResolvers, modelFactories); // now resolve and add the system contribution contributionProcessor.resolve(systemContribution, modelResolver, context); - contributions.add(systemContribution); + contributionList.add(systemContribution); // pre-resolve the contributions - contributionsPreresolve(contributions, modelResolver, context); + contributionsPreresolve(contributionList, modelResolver, context); // Build the contribution dependencies Set<Contribution> resolved = new HashSet<Contribution>(); - for (Contribution contribution : contributions) { - buildDependencies(contribution, contributions, monitor); + for (Contribution contribution : contributionList) { + buildDependencies(contribution, contributionList, monitor); // Resolve contributions for (Contribution dependency : contribution.getDependencies()) { @@ -430,7 +433,7 @@ public class DeployerImpl implements Deployer { domainComposite.setName(Composite.DOMAIN_COMPOSITE); domainComposite.setURI(Base.SCA11_NS); - for (Contribution contribution : contributions) { + for (Contribution contribution : contributionList) { for (Composite composite : contribution.getDeployables()) { // Include the node composite in the top-level composite domainComposite.getIncludes().add(composite); @@ -446,7 +449,7 @@ public class DeployerImpl implements Deployer { } public Artifact loadArtifact(URI uri, URL location, Monitor monitor) throws ContributionReadException { - start(); + init(); Artifact artifact = contributionFactory.createArtifact(); artifact.setLocation(location.toString()); artifact.setURI(uri.toString()); @@ -457,16 +460,16 @@ public class DeployerImpl implements Deployer { artifact.setModel(model); return artifact; } - + @SuppressWarnings("unchecked") public <T> T loadDocument(URI uri, URL location, Monitor monitor) throws ContributionReadException { - start(); + init(); Object model = artifactProcessor.read(null, uri, location, new ProcessorContext(monitor)); - return (T) model; + return (T)model; } public <T> T loadXMLDocument(URL document, Monitor monitor) throws XMLStreamException, ContributionReadException { - start(); + init(); XMLStreamReader reader = staxHelper.createXMLStreamReader(document); reader.nextTag(); ValidatingXMLInputFactory.setMonitor(reader, monitor); @@ -476,29 +479,29 @@ public class DeployerImpl implements Deployer { reader.close(); } } - + public void saveXMLDocument(Object model, Writer writer, Monitor monitor) throws XMLStreamException, ContributionWriteException { - start(); + init(); XMLStreamWriter streamWriter = staxHelper.createXMLStreamWriter(writer); staxProcessor.write(model, streamWriter, new ProcessorContext(monitor)); } - public void saveXMLElement(Object model, XMLStreamWriter writer, Monitor monitor) - throws XMLStreamException, ContributionWriteException { - start(); + public void saveXMLElement(Object model, XMLStreamWriter writer, Monitor monitor) throws XMLStreamException, + ContributionWriteException { + init(); staxProcessor.write(model, writer, new ProcessorContext(monitor)); } @SuppressWarnings("unchecked") public <T> T loadXMLElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException, XMLStreamException { - start(); + init(); return (T)staxProcessor.read(reader, new ProcessorContext(monitor)); } - + public <T> T loadXMLDocument(Reader document, Monitor monitor) throws XMLStreamException, ContributionReadException { - start(); + init(); XMLStreamReader reader = staxHelper.createXMLStreamReader(document); ValidatingXMLInputFactory.setMonitor(reader, monitor); reader.nextTag(); @@ -510,20 +513,20 @@ public class DeployerImpl implements Deployer { } public Contribution loadContribution(URI uri, URL location, Monitor monitor) throws ContributionReadException { - start(); + init(); ProcessorContext context = new ProcessorContext(monitor); // Load the contribution Contribution contribution = contributionProcessor.read(null, uri, location, context); return contribution; } - + public ProcessorContext createProcessorContext() { - start(); + init(); return new ProcessorContext(monitorFactory.createMonitor()); } - + public BuilderContext createBuilderContext() { - start(); + init(); return new BuilderContext(monitorFactory.createMonitor()); } diff --git a/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer b/java/sca/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer index 9ba95bc94b..9ba95bc94b 100644 --- a/java/sca/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer +++ b/java/sca/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer diff --git a/java/sca/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties b/java/sca/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties new file mode 100644 index 0000000000..0c07a3a30f --- /dev/null +++ b/java/sca/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties @@ -0,0 +1,22 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# + +UnresolvedImport = Unresolved import: Import = {0} diff --git a/java/sca/modules/deployment/src/test/java/hello/deployer/HelloWorld.java b/java/sca/modules/deployment/src/test/java/hello/deployer/HelloWorld.java new file mode 100644 index 0000000000..2480a5e4d9 --- /dev/null +++ b/java/sca/modules/deployment/src/test/java/hello/deployer/HelloWorld.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package hello.deployer; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * HelloWorld interface + */ +@Remotable +public interface HelloWorld { + String hello(String name); +} diff --git a/java/sca/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java b/java/sca/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java new file mode 100644 index 0000000000..fc81dc2167 --- /dev/null +++ b/java/sca/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package hello.deployer; + +/** + * HelloWorldImpl + */ +public class HelloWorldImpl implements HelloWorld { + public String hello(String name) { + System.out.println("Hello: " + name); + return "Hello, " + name; + } +} diff --git a/java/sca/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java b/java/sca/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java new file mode 100644 index 0000000000..cc2bf92dcf --- /dev/null +++ b/java/sca/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.deployment.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.StringWriter; +import java.io.Writer; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Arrays; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Artifact; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.deployment.Deployer; +import org.apache.tuscany.sca.monitor.Monitor; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + */ +public class DeployerImplTestCase { + private static ExtensionPointRegistry registry; + private static Deployer deployer; + + private static URL contributionURL; + private static URL compositeURL; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + compositeURL = DeployerImplTestCase.class.getResource("HelloWorld.composite"); + contributionURL = new URL(compositeURL, "../"); + registry = new DefaultExtensionPointRegistry(); + deployer = new DeployerImpl(registry); + deployer.start(); + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + deployer.stop(); + } + + /** + * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#build(java.util.List, java.util.Map, org.apache.tuscany.sca.monitor.Monitor)}. + */ + @Test + public void testBuild() throws Exception { + Monitor monitor = deployer.createMonitor(); + Contribution contribution = deployer.loadContribution(contributionURL.toURI(), contributionURL, monitor); + Composite composite = deployer.build(Arrays.asList(contribution), null, monitor); + assertTrue(composite != null); + } + + /** + * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadArtifact(java.net.URI, java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}. + */ + @Test + public void testLoadArtifact() throws Exception { + Monitor monitor = deployer.createMonitor(); + Artifact artifact = deployer.loadArtifact(compositeURL.toURI(), compositeURL, monitor); + assertTrue(artifact.getModel() instanceof Composite); + Composite composite = artifact.getModel(); + assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1")); + } + + /** + * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadDocument(java.net.URI, java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}. + */ + @Test + public void testLoadDocument() throws Exception { + Monitor monitor = deployer.createMonitor(); + Composite composite = deployer.loadDocument(compositeURL.toURI(), compositeURL, monitor); + assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1")); + } + + /** + * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadXMLDocument(java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}. + */ + @Test + public void testLoadXMLDocumentURLMonitor() throws Exception { + Monitor monitor = deployer.createMonitor(); + Composite composite = deployer.loadXMLDocument(compositeURL, monitor); + assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1")); + Writer sw = new StringWriter(); + deployer.saveXMLDocument(composite, sw, monitor); + assertTrue(sw.toString() != null); + } + + /** + * Test method for {@link org.apache.tuscany.sca.deployment.impl.DeployerImpl#loadContribution(java.net.URI, java.net.URL, org.apache.tuscany.sca.monitor.Monitor)}. + * @throws URISyntaxException + * @throws ContributionReadException + */ + @Test + public void testLoadContribution() throws Exception { + Monitor monitor = deployer.createMonitor(); + Contribution contribution = deployer.loadContribution(contributionURL.toURI(), contributionURL, monitor); + Composite composite = contribution.getDeployables().get(0); + assertEquals(composite.getName(), new QName("http://sample/composite", "HelloWorld1")); + assertTrue(contribution.getArtifacts().size() >= 2); + } + +} diff --git a/java/sca/modules/deployment/src/test/resources/META-INF/sca-contribution.xml b/java/sca/modules/deployment/src/test/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f00e00a373 --- /dev/null +++ b/java/sca/modules/deployment/src/test/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +--> + +<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + xmlns:sc="http://sample/composite"> + <deployable composite="sc:HelloWorld1" /> +</contribution> diff --git a/java/sca/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite b/java/sca/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite new file mode 100644 index 0000000000..b4fee2c7a6 --- /dev/null +++ b/java/sca/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://sample/composite" + name="HelloWorld1"> + + <component name="HelloWorld1"> + <implementation.java class="hello.deployer.HelloWorldImpl"/> + </component> + +</composite> diff --git a/java/sca/modules/node-impl/META-INF/MANIFEST.MF b/java/sca/modules/node-impl/META-INF/MANIFEST.MF index f352334527..cd4afe6871 100644 --- a/java/sca/modules/node-impl/META-INF/MANIFEST.MF +++ b/java/sca/modules/node-impl/META-INF/MANIFEST.MF @@ -1,25 +1,5 @@ Manifest-Version: 1.0
-Export-Package: org.apache.tuscany.sca.deployment;version="2.0.0";
- uses:="javax.xml.stream,
- org.apache.tuscany.sca.assembly,
- org.apache.tuscany.sca.contribution.processor,
- org.apache.tuscany.sca.core,
- org.apache.tuscany.sca.contribution,
- org.apache.tuscany.sca.monitor,
- org.apache.tuscany.sca.assembly.builder",
- org.apache.tuscany.sca.deployment.impl;version="2.0.0";
- uses:="org.apache.tuscany.sca.assembly,
- org.apache.tuscany.sca.definitions,
- org.apache.tuscany.sca.common.xml.stax,
- org.apache.tuscany.sca.contribution,
- org.apache.tuscany.sca.core,
- org.apache.tuscany.sca.deployment,
- org.apache.tuscany.sca.monitor,
- javax.xml.stream,
- org.apache.tuscany.sca.contribution.resolver,
- org.apache.tuscany.sca.contribution.processor,
- org.apache.tuscany.sca.assembly.builder",
- org.apache.tuscany.sca.node.impl;version="2.0.0"
+Export-Package: org.apache.tuscany.sca.node.impl;version="2.0.0"
Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany SCA Node Implementation
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
diff --git a/java/sca/modules/node-impl/pom.xml b/java/sca/modules/node-impl/pom.xml index 513fb8ebf5..ca708af859 100644 --- a/java/sca/modules/node-impl/pom.xml +++ b/java/sca/modules/node-impl/pom.xml @@ -61,6 +61,12 @@ <artifactId>tuscany-assembly-xml</artifactId> <version>2.0-SNAPSHOT</version> </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-deployment</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.tuscany.sca</groupId> diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 1c2ea6b921..91eb7592d0 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -61,7 +61,6 @@ import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; import org.apache.tuscany.sca.deployment.Deployer; -import org.apache.tuscany.sca.deployment.impl.DeployerImpl; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; @@ -215,16 +214,14 @@ public class NodeFactoryImpl extends NodeFactory { AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(registry); modelFactories.addFactory(assemblyFactory); - deployer = new DeployerImpl(registry); + UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); + monitorFactory = utilities.getUtility(MonitorFactory.class); + + // Load the Deployer + deployer = utilities.getUtility(Deployer.class); // Enable schema validation only of the logger level is FINE or higher deployer.setSchemaValidationEnabled(isSchemaValidationEnabled()); - deployer.start(); - - // Create a monitor - UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); - - monitorFactory = utilities.getUtility(MonitorFactory.class); // Initialize the Tuscany module activators // The module activators will be started diff --git a/java/sca/modules/pom.xml b/java/sca/modules/pom.xml index 9e1a7d5c78..d277137991 100644 --- a/java/sca/modules/pom.xml +++ b/java/sca/modules/pom.xml @@ -66,6 +66,7 @@ <module>databinding-jaxb</module> <module>databinding-jaxb-axiom</module> <module>databinding-json</module> + <module>deployment</module> <module>domain-node</module> <module>endpoint-tribes</module> <module>extensibility</module> |