diff options
Diffstat (limited to 'sca-java-1.x/contrib/modules')
237 files changed, 24369 insertions, 0 deletions
diff --git a/sca-java-1.x/contrib/modules/api/LICENSE b/sca-java-1.x/contrib/modules/api/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/api/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/sca-java-1.x/contrib/modules/api/NOTICE b/sca-java-1.x/contrib/modules/api/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sca-java-1.x/contrib/modules/api/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/contrib/modules/api/pom.xml b/sca-java-1.x/contrib/modules/api/pom.xml new file mode 100644 index 0000000000..62092ea610 --- /dev/null +++ b/sca-java-1.x/contrib/modules/api/pom.xml @@ -0,0 +1,304 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-api</artifactId>
+ <name>Apache Tuscany SCA API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-definitions-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <!-- artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:sca-api</include>
+ </includes>
+ <excludes>
+ <exclude>org.apache.tuscany.sca:extensibility</exclude>
+ </excludes>
+ </artifactSet -->
+
+ <filters>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-host-embedded</artifact>
+ <excludes>
+ <exclude>org/apache/tuscany/sca/host/embedded/impl/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>${project.groupId}:${project.artifactId}</artifact>
+
+ <excludes>
+ <exclude>org/**</exclude>
+ </excludes>
+ </filter>
+ </filters>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.definitions.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/LICENSE b/sca-java-1.x/contrib/modules/assembly-java-dsl/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/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/sca-java-1.x/contrib/modules/assembly-java-dsl/NOTICE b/sca-java-1.x/contrib/modules/assembly-java-dsl/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/pom.xml b/sca-java-1.x/contrib/modules/assembly-java-dsl/pom.xml new file mode 100644 index 0000000000..953615f596 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/pom.xml @@ -0,0 +1,56 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-assembly-java-dsl</artifactId> + <name>Apache Tuscany SCA Assembly Model Java DSL</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.assembly.java.dsl</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.assembly.java.dsl*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java new file mode 100644 index 0000000000..28a5ecdc24 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/AssemblyBuilder.java @@ -0,0 +1,37 @@ +/* + * 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.assembly.dsl; + + +public interface AssemblyBuilder { + + CompositeBuilder composite(String name); + + ComponentBuilder component(String name); + + ComponentReferenceBuilder reference(String name); + + ComponentServiceBuilder service(String name); + + ComponentPropertyBuilder property(String name); + + CompositeBuilder domain(String uri); + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java new file mode 100644 index 0000000000..3d97041907 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentBuilder.java @@ -0,0 +1,34 @@ +/* + * 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.assembly.dsl; + +public interface ComponentBuilder { + + ComponentBuilder implementedBy(Class clazz); + + ComponentBuilder implementedBy(CompositeBuilder composite); + + ComponentBuilder uses(ComponentReferenceBuilder... componentReferences); + + ComponentBuilder provides(ComponentServiceBuilder... componentServices); + + ComponentBuilder declares(ComponentPropertyBuilder...componentProperties); + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java new file mode 100644 index 0000000000..7f3c89fd2f --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentPropertyBuilder.java @@ -0,0 +1,28 @@ +/* + * 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.assembly.dsl; + +public interface ComponentPropertyBuilder { + + ComponentPropertyBuilder ofType(String type); + + ComponentPropertyBuilder configuredTo(Object value); + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java new file mode 100644 index 0000000000..8966a4be9d --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentReferenceBuilder.java @@ -0,0 +1,36 @@ +/* + * 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.assembly.dsl; + +public interface ComponentReferenceBuilder { + + ComponentReferenceBuilder wiredTo(String target); + + ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target); + + ComponentReferenceBuilder typedBy(Class interfaceClass); + + ComponentReferenceBuilder promotedAs(String promoted); + + ComponentReferenceBuilder promoted(); + + ComponentReferenceBuilder boundTo(String uri); + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java new file mode 100644 index 0000000000..f3e36e8c38 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/ComponentServiceBuilder.java @@ -0,0 +1,32 @@ +/* + * 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.assembly.dsl; + +public interface ComponentServiceBuilder { + + ComponentServiceBuilder typedBy(Class interfaceClass); + + ComponentServiceBuilder promotedAs(String promoted); + + ComponentServiceBuilder promoted(); + + ComponentServiceBuilder boundTo(String uri); + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java new file mode 100644 index 0000000000..e2108b5ef8 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/CompositeBuilder.java @@ -0,0 +1,29 @@ +/* + * 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.assembly.dsl; + + +public interface CompositeBuilder { + + CompositeBuilder contains(ComponentBuilder... components); + + CompositeBuilder includes(CompositeBuilder... includes); + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java new file mode 100644 index 0000000000..0968310548 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/AssemblyBuilderImpl.java @@ -0,0 +1,70 @@ +/* + * 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.assembly.dsl.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.dsl.AssemblyBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder; + +public class AssemblyBuilderImpl extends DefaultAssemblyFactory implements AssemblyBuilder { + + public ComponentBuilder component(String name) { + ComponentBuilderImpl component = new ComponentBuilderImpl(); + component.setName(name); + return component; + } + + public CompositeBuilder composite(String name) { + CompositeBuilderImpl composite = new CompositeBuilderImpl(); + //TODO handle namespace + composite.setName(new QName("", name)); + return composite; + } + + public CompositeBuilder domain(String uri) { + CompositeBuilderImpl composite = new CompositeBuilderImpl(); + composite.setName(new QName(uri, "")); + return composite; + } + + public ComponentPropertyBuilder property(String name) { + ComponentPropertyBuilderImpl property = new ComponentPropertyBuilderImpl(); + property.setName(name); + return property; + } + + public ComponentReferenceBuilder reference(String name) { + ComponentReferenceBuilderImpl reference = new ComponentReferenceBuilderImpl(this); + reference.setName(name); + return reference; + } + + public ComponentServiceBuilder service(String name) { + ComponentServiceBuilderImpl service = new ComponentServiceBuilderImpl(this); + service.setName(name); + return service; + } + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java new file mode 100644 index 0000000000..9022b9d9e6 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentBuilderImpl.java @@ -0,0 +1,74 @@ +/* + * 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.assembly.dsl.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.ComponentProperty; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentImpl; + +public class ComponentBuilderImpl extends ComponentImpl implements ComponentBuilder { + + public ComponentBuilderImpl() { + } + + public ComponentBuilder implementedBy(Class clazz) { + //FIXME support Java implementations + return this; + } + + public ComponentBuilder implementedBy(CompositeBuilder composite) { + setImplementation((Composite)composite); + return this; + } + + public ComponentBuilder uses(ComponentReferenceBuilder... componentReferences) { + List<ComponentReference> references = getReferences(); + for (ComponentReferenceBuilder componentReference: componentReferences) { + references.add((ComponentReference)componentReference); + } + return this; + } + + public ComponentBuilder provides(ComponentServiceBuilder... componentServices) { + List<ComponentService> services = getServices(); + for (ComponentServiceBuilder componentService: componentServices) { + services.add((ComponentService)componentService); + } + return this; + } + + public ComponentBuilder declares(ComponentPropertyBuilder...componentProperties) { + List<ComponentProperty> properties = getProperties(); + for (ComponentPropertyBuilder componentProperty: componentProperties) { + properties.add((ComponentProperty)componentProperty); + } + return this; + } + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java new file mode 100644 index 0000000000..49f7cd46b2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentPropertyBuilderImpl.java @@ -0,0 +1,40 @@ +/* + * 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.assembly.dsl.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.dsl.ComponentPropertyBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentPropertyImpl; + +public class ComponentPropertyBuilderImpl extends ComponentPropertyImpl implements ComponentPropertyBuilder { + + public ComponentPropertyBuilderImpl ofType(String type) { + //TODO handle namespace + this.setXSDType(new QName("", type)); + return this; + } + + public ComponentPropertyBuilderImpl configuredTo(Object value) { + this.setValue(value); + return this; + } + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java new file mode 100644 index 0000000000..d9aab9de22 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentReferenceBuilderImpl.java @@ -0,0 +1,77 @@ +/* + * 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.assembly.dsl.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.dsl.ComponentReferenceBuilder; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl; +import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl; + +public class ComponentReferenceBuilderImpl extends ComponentReferenceImpl implements ComponentReferenceBuilder { + + private CompositeReference compositeReference; + private AssemblyFactory assemblyFactory; + + protected ComponentReferenceBuilderImpl(AssemblyFactory assemblyFactory) { + this.assemblyFactory = assemblyFactory; + } + + public ComponentReferenceBuilder wiredTo(String target) { + ComponentService componentService = assemblyFactory.createComponentService(); + componentService.setUnresolved(true); + componentService.setName(target); + getTargets().add(componentService); + return this; + } + + public ComponentReferenceBuilder wiredTo(ComponentServiceBuilder target) { + getTargets().add((ComponentServiceImpl)target); + return this; + } + + public ComponentReferenceBuilderImpl typedBy(Class interfaceClass) { + //FIXME support for Java interfaces + return this; + } + + public ComponentReferenceBuilderImpl promotedAs(String promoted) { + compositeReference = assemblyFactory.createCompositeReference(); + compositeReference.setName(promoted); + return this; + } + + public ComponentReferenceBuilderImpl promoted() { + compositeReference = assemblyFactory.createCompositeReference(); + compositeReference.setName(getName()); + return this; + } + + public ComponentReferenceBuilder boundTo(String uri) { + //TODO support bindings + return this; + } + + CompositeReference getCompositeReference() { + return compositeReference; + } +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java new file mode 100644 index 0000000000..379429d17e --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/ComponentServiceBuilderImpl.java @@ -0,0 +1,62 @@ +/* + * 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.assembly.dsl.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.dsl.ComponentServiceBuilder; +import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl; + +public class ComponentServiceBuilderImpl extends ComponentServiceImpl implements ComponentServiceBuilder { + + private CompositeService compositeService; + private AssemblyFactory assemblyFactory; + + protected ComponentServiceBuilderImpl(AssemblyFactory assemblyFactory) { + this.assemblyFactory = assemblyFactory; + } + + public ComponentServiceBuilderImpl typedBy(Class interfaceClass) { + //FIXME support for Java interfaces + return this; + } + + public ComponentServiceBuilderImpl promotedAs(String promoted) { + compositeService = assemblyFactory.createCompositeService(); + compositeService.setName(promoted); + return this; + } + + public ComponentServiceBuilderImpl promoted() { + compositeService = assemblyFactory.createCompositeService(); + compositeService.setName(getName()); + return this; + } + + public ComponentServiceBuilder boundTo(String uri) { + // TODO support bindings + return this; + } + + CompositeService getCompositeService() { + return compositeService; + } + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java new file mode 100644 index 0000000000..709562cd72 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/main/java/org/apache/tuscany/sca/assembly/dsl/impl/CompositeBuilderImpl.java @@ -0,0 +1,62 @@ +/* + * 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.assembly.dsl.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.dsl.ComponentBuilder; +import org.apache.tuscany.sca.assembly.dsl.CompositeBuilder; +import org.apache.tuscany.sca.assembly.impl.CompositeImpl; + +public class CompositeBuilderImpl extends CompositeImpl implements CompositeBuilder { + + public CompositeBuilder contains(ComponentBuilder... componentBuilders) { + List<Component> components = getComponents(); + for (ComponentBuilder componentBuilder: componentBuilders) { + Component component = (Component)componentBuilder; + components.add(component); + + for (ComponentService componentService: component.getServices()) { + ComponentServiceBuilderImpl builder = (ComponentServiceBuilderImpl)componentService; + if (builder.getCompositeService() != null) + getServices().add(builder.getCompositeService()); + } + for (ComponentReference componentReference: component.getReferences()) { + ComponentReferenceBuilderImpl builder = (ComponentReferenceBuilderImpl)componentReference; + if (builder.getCompositeReference() != null) + getReferences().add(builder.getCompositeReference()); + } + } + return this; + } + + public CompositeBuilder includes(CompositeBuilder... compositeBuilders) { + List<Composite> list = getIncludes(); + for (CompositeBuilder composite: compositeBuilders) { + list.add((Composite)composite); + } + return this; + } + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java new file mode 100644 index 0000000000..ba91fd2168 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataService.java @@ -0,0 +1,24 @@ +/* + * 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.assembly.dsl; + +public interface AccountDataService { + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java new file mode 100644 index 0000000000..4e239d03d3 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountDataServiceImpl.java @@ -0,0 +1,24 @@ +/* + * 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.assembly.dsl; + +public class AccountDataServiceImpl { + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java new file mode 100644 index 0000000000..030c820ed2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountService.java @@ -0,0 +1,24 @@ +/* + * 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.assembly.dsl; + +public interface AccountService { + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java new file mode 100644 index 0000000000..92f448ec87 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/AccountServiceImpl.java @@ -0,0 +1,24 @@ +/* + * 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.assembly.dsl; + +public class AccountServiceImpl { + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java new file mode 100644 index 0000000000..b856201551 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilder.java @@ -0,0 +1,59 @@ +/* + * 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.assembly.dsl; + +import org.apache.tuscany.sca.assembly.dsl.impl.AssemblyBuilderImpl; + +public class BigBankBuilder extends AssemblyBuilderImpl { + + public CompositeBuilder build() { + + CompositeBuilder bigbankAccount = composite("bigbank.account").contains( + + component("AccountServiceComponent"). + implementedBy(AccountServiceImpl.class). + uses( + reference("accountDataService").typedBy(AccountDataService.class).wiredTo("AccountDataServiceComponent/AccountDataService"), + reference("stockQuoteService").promotedAs("StockQuoteService") + ). + provides( + service("AccountDataService").typedBy(AccountService.class).promoted() + ). + declares( + property("currency").ofType("string").configuredTo("USD") + ), + + component("AccountDataServiceComponent"). + implementedBy(AccountDataServiceImpl.class). + provides( + service("AccountDataService").typedBy(AccountDataService.class) + ) + ); + + CompositeBuilder bigbankApp = composite("bigbank.app"). + contains( + component("BigBankAccount").implementedBy(bigbankAccount) + ); + + CompositeBuilder domain = domain("http://bigbank.org").includes(bigbankApp); + + return domain; + } +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java new file mode 100644 index 0000000000..fb950b5c13 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/BigBankBuilderTestCase.java @@ -0,0 +1,33 @@ +/* + * 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.assembly.dsl; + +import junit.framework.TestCase; + +public class BigBankBuilderTestCase extends TestCase { + + public void testBuild() throws Exception { + + BigBankBuilder builder = new BigBankBuilder(); + CompositeBuilder domain = builder.build(); + assertNotNull(domain); + } + +} diff --git a/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java new file mode 100644 index 0000000000..a0580095a0 --- /dev/null +++ b/sca-java-1.x/contrib/modules/assembly-java-dsl/src/test/java/org/apache/tuscany/sca/assembly/dsl/StockQuoteService.java @@ -0,0 +1,24 @@ +/* + * 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.assembly.dsl; + +public interface StockQuoteService { + +} diff --git a/sca-java-1.x/contrib/modules/compact-base/pom.xml b/sca-java-1.x/contrib/modules/compact-base/pom.xml new file mode 100644 index 0000000000..a1357309db --- /dev/null +++ b/sca-java-1.x/contrib/modules/compact-base/pom.xml @@ -0,0 +1,604 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-base</artifactId>
+ <name>Apache Tuscany SCA Base Jar</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <tuscany.version>${pom.version}</tuscany.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-sca</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-sca-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-namespace</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-contribution-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-definitions-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-endpoint</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-java-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-node</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>${pom.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>bsf-all</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby-complete</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all-minimal</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-workspace</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-workspace-impl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-workspace-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- these remaining dependencies are not required when using JDK6, maybe make them optional -->
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.7</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <!-- resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources -->
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+ <filters>
+
+ <filter>
+ <artifact>org.apache.ws.commons.schema:XmlSchema</artifact>
+ <excludes>
+ <exclude>org/apache/ws/commons/schema/**</exclude>
+ </excludes>
+ </filter>
+ <!-- filter>
+ <artifact>org.apache.geronimo.specs:geronimo-commonj_1.1_spec</artifact>
+ <excludes>
+ <exclude>commonj/**</exclude>
+ <exclude>META-INF/**</exclude>
+ </excludes>
+ </filter -->
+ <filter>
+ <artifact>cglib:cglib-nodep</artifact>
+ <excludes>
+ <!-- exclude>net/sf/cglib/**</exclude -->
+ <exclude>asm-license.txt</exclude>
+ <exclude>LICENSE</exclude>
+ <exclude>NOTICE</exclude>
+ <exclude>META-INF/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>asm:asm-all</artifact>
+ <excludes>
+ <!-- exclude>org/objectweb/asm/**</exclude -->
+ <exclude>META-INF/**</exclude>
+ </excludes>
+ </filter>
+
+
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-interface-java-jaxws</artifact>
+ <excludes>
+ <exclude>com/example/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-databinding-jaxb</artifact>
+ <excludes>
+ <exclude>com/example/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-databinding-sdo</artifact>
+ <excludes>
+ <exclude>com/example/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>${project.groupId}:${project.artifactId}</artifact>
+
+ <excludes>
+ <exclude>org/**</exclude>
+ </excludes>
+ </filter>
+ </filters>
+
+
+ <relocations>
+ <relocation>
+ <pattern>org.objectweb.asm</pattern>
+ <shadedPattern>org.apache.tuscany.asm</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>net.sf.cglib</pattern>
+ <shadedPattern>org.apache.tuscany.cglib</shadedPattern>
+ </relocation>
+ </relocations>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+<!--
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.tuscany.sca.node.DynamicNodeMain</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Class-Path>activemq-all-5.1.0.jar geronimo-commonj_1.1_spec-1.0.jar jaxb-api-2.1.jar jaxb-impl-2.1.3.jar jaxws-api-2.1.jar jsr181-api-1.0-MR1.jar stax-api-1.0.1.jar stax-api-1.0-2.jar wstx-asl-3.2.1.jar</Class-Path>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.compact.base</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca*</Export-Package>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+-->
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/compact-bpel/pom.xml b/sca-java-1.x/contrib/modules/compact-bpel/pom.xml new file mode 100644 index 0000000000..ed28ae19c3 --- /dev/null +++ b/sca-java-1.x/contrib/modules/compact-bpel/pom.xml @@ -0,0 +1,554 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-bpel</artifactId>
+ <name>Apache Tuscany SCA BPEL Jar</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <tuscany.version>${pom.version}</tuscany.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-bpel-ode</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- these remaining dependencies are not required when using JDK6, maybe make them optional -->
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.7</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- dependencies to keep in the shaded pom.xml -->
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-webservices</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-webservices</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-epr</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-store</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-dao</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-dao</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-dao-jpa-ojpa-derby</artifactId>
+ <version>1.1.1</version>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-runtime</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-api</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-scheduler-simple</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-utils</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-compiler</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-schemas</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-bpel-obj</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-jacob</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ode</groupId>
+ <artifactId>ode-jacob-ap</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <!-- ODE Dependencies -->
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-kernel</artifactId>
+ <version>1.2-beta</version>
+ <exclusions>
+ <exclusion>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xstream</groupId>
+ <artifactId>xstream</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <version>1.2-beta</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_2.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ognl</groupId>
+ <artifactId>ognl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_3.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.modules</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ <version>1.2-beta</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>tranql</groupId>
+ <artifactId>tranql-connector</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-all</artifactId>
+ <version>0.9.7-incubating</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-lib</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-kernel</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-kernel-5</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-jdbc</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-jdbc-5</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-persistence-jdbc</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-xmlstore</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.serp</groupId>
+ <artifactId>serp</artifactId>
+ <version>1.12.0</version>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>2.3.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-dom</artifactId>
+ <version>8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-xpath</artifactId>
+ <version>8.7</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-implementation-bpel</include>
+ <include>org.apache.tuscany.sca:tuscany-implementation-bpel-ode</include>
+ </includes>
+ </artifactSet>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/compact-spring/pom.xml b/sca-java-1.x/contrib/modules/compact-spring/pom.xml new file mode 100644 index 0000000000..cf44588d40 --- /dev/null +++ b/sca-java-1.x/contrib/modules/compact-spring/pom.xml @@ -0,0 +1,293 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-spring</artifactId>
+ <name>Apache Tuscany SCA Spring Jar</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <tuscany.version>${pom.version}</tuscany.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- these remaining dependencies are not required when using JDK6, maybe make them optional -->
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.7</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- dependencies to keep in the shaded pom.xml -->
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-implementation-spring</include>
+ </includes>
+ </artifactSet>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/compact-standalone/pom.xml b/sca-java-1.x/contrib/modules/compact-standalone/pom.xml new file mode 100644 index 0000000000..99441c20c5 --- /dev/null +++ b/sca-java-1.x/contrib/modules/compact-standalone/pom.xml @@ -0,0 +1,299 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-standalone</artifactId>
+ <name>Apache Tuscany SCA Standalone Jar</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <tuscany.version>${pom.version}</tuscany.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- these remaining dependencies are not required when using JDK6, maybe make them optional -->
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.7</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- dependencies to keep in the shaded pom.xml -->
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api-2.5</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-host-jetty</include>
+ </includes>
+ </artifactSet>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/compact-webservices/pom.xml b/sca-java-1.x/contrib/modules/compact-webservices/pom.xml new file mode 100644 index 0000000000..e3b388de7d --- /dev/null +++ b/sca-java-1.x/contrib/modules/compact-webservices/pom.xml @@ -0,0 +1,592 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-webservices</artifactId>
+ <name>Apache Tuscany SCA Web Services Jar</name>
+
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <tuscany.version>${pom.version}</tuscany.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws-axis2-policy</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ws-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-wsdl-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-xsd-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+
+ <!-- these remaining dependencies are not required when using JDK6, maybe make them optional -->
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.4</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.7</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.jws</groupId>
+ <artifactId>jsr181-api</artifactId>
+ <version>1.0-MR1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- dependencies to keep in the shaded pom.xml -->
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-base</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2</artifactId>
+ <version>1.4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-dom</artifactId>
+ <version>1.2.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.woden</groupId>
+ <artifactId>woden-api</artifactId>
+ <version>1.0M8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>annogen</groupId>
+ <artifactId>annogen</artifactId>
+ <version>0.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-discovery</groupId>
+ <artifactId>commons-discovery</artifactId>
+ <version>0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.neethi</groupId>
+ <artifactId>neethi</artifactId>
+ <version>2.0.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.4.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.bcel</groupId>
+ <artifactId>bcel</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:tuscany-binding-ws</include>
+ <include>org.apache.tuscany.sca:tuscany-binding-ws-axis2</include>
+ <include>org.apache.tuscany.sca:tuscany-binding-ws-axis2-policy</include>
+ <include>org.apache.tuscany.sca:tuscany-binding-ws-wsdlgen</include>
+ <include>org.apache.tuscany.sca:tuscany-binding-ws-xml</include>
+ <include>org.apache.tuscany.sca:tuscany-ws-xml</include>
+ <include>org.apache.tuscany.sca:tuscany-databinding-axiom</include>
+ <include>org.apache.tuscany.sca:tuscany-databinding-jaxb-axiom</include>
+ <include>org.apache.tuscany.sca:tuscany-interface-wsdl</include>
+ <include>org.apache.tuscany.sca:tuscany-interface-wsdl-xml</include>
+ <include>org.apache.tuscany.sca:tuscany-xsd</include>
+ <include>org.apache.tuscany.sca:tuscany-xsd-xml</include>
+ </includes>
+ </artifactSet>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/LICENSE b/sca-java-1.x/contrib/modules/contribution-updater-impl/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/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/sca-java-1.x/contrib/modules/contribution-updater-impl/NOTICE b/sca-java-1.x/contrib/modules/contribution-updater-impl/NOTICE new file mode 100644 index 0000000000..94481d6cfa --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/pom.xml b/sca-java-1.x/contrib/modules/contribution-updater-impl/pom.xml new file mode 100644 index 0000000000..bece514f4a --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/pom.xml @@ -0,0 +1,124 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-contribution-updater-impl</artifactId> + <name>Apache Tuscany SCA Contribution Updater Implementation</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-namespace</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-updater</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + <version>3.2.1</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.contribution.updater.impl</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.contribution.updater.impl*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ArtifactsFinder.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ArtifactsFinder.java new file mode 100644 index 0000000000..a23bf6f8cd --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ArtifactsFinder.java @@ -0,0 +1,51 @@ +/* + * 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.contribution.updater.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.DeployedArtifact; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +public class ArtifactsFinder { + + public static Composite findComposite(String compositeURI, + List<Composite> artifacts) { + for (Composite composite : artifacts) { + if (composite.getURI().equals(compositeURI)) + return composite; + } + return null; + } + + public static Component findComponent(Composite composite, + String componentName) { + for (Component component : composite.getComponents()) { + if (component.getName().equals(componentName)) { + return component; + + } + + } + return null; + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ComponentUpdaterImpl.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ComponentUpdaterImpl.java new file mode 100644 index 0000000000..a6a6084f5f --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ComponentUpdaterImpl.java @@ -0,0 +1,381 @@ +/* + * 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.contribution.updater.impl; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Multiplicity; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.DeployedArtifact; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.contribution.updater.ComponentNotFoundException; +import org.apache.tuscany.sca.contribution.updater.ComponentUpdater; +import org.apache.tuscany.sca.contribution.updater.ComponentUpdaterException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.assembly.CompositeActivator; +import org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.contribution.updater.impl.ArtifactsFinder; +import org.apache.tuscany.sca.assembly.xml.MetaComponentProcessor; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.implementation.java.IntrospectionException; +import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper; + +public class ComponentUpdaterImpl implements ComponentUpdater { + + private String contribURI; + private String compositeURI; + private String componentName; + private JavaInterfaceFactory javaFactory; + private CompositeBuilder compositeBuilder; + private CompositeActivator compositeActivator; + private ContributionService contributionService; + private ExtensionPointRegistry registry; + private AssemblyFactory assemblyFactory; + private InterfaceContractMapper interfaceContractMapper; + private Contribution contrib; + + public ComponentUpdaterImpl(String contribURI, String compositeURI, + String componentName, AssemblyFactory assembly, + JavaInterfaceFactory javaFactory, + CompositeBuilder compositeBuilder, + CompositeActivator compositeActivator, + ContributionService contribService, + ExtensionPointRegistry registry, InterfaceContractMapper mapper) { + this.contribURI = contribURI; + this.compositeURI = compositeURI; + this.componentName = componentName; + this.javaFactory = javaFactory; + this.compositeBuilder = compositeBuilder; + this.compositeActivator = compositeActivator; + this.contributionService = contribService; + this.registry = registry; + this.assemblyFactory = assembly; + this.interfaceContractMapper = mapper; + this.contrib = this.contributionService.getContribution(contribURI); + } + + private void reconcileReference(Reference reference, + ComponentReference targetReference, String componentName) { + + targetReference.setReference(reference); + targetReference.setIsCallback(reference.isCallback()); + targetReference.setMultiplicity(reference.getMultiplicity()); + if (targetReference.getInterfaceContract() != null) { + if (!targetReference.getInterfaceContract().equals( + reference.getInterfaceContract())) { + if (!interfaceContractMapper.isCompatible(reference + .getInterfaceContract(), targetReference + .getInterfaceContract())) { + System.err + .println("Component reference interface incompatible with reference interface: " + + componentName + + "/" + + targetReference.getName()); + } + } + } else { + targetReference.setInterfaceContract(reference + .getInterfaceContract()); + } + if (targetReference.getBindings().isEmpty()) { + targetReference.getBindings().addAll(reference.getBindings()); + } + + // Reconcile callback bindings + if (targetReference.getCallback() == null) { + targetReference.setCallback(reference.getCallback()); + if (targetReference.getCallback() == null) { + targetReference.setCallback(assemblyFactory.createCallback()); + } + + } else if (targetReference.getCallback().getBindings().isEmpty() + && reference.getCallback() != null) { + targetReference.getCallback().getBindings().addAll( + reference.getCallback().getBindings()); + } + Contribution contrib = contributionService.getContribution(contribURI); + List<DeployedArtifact> artifacts = contrib.getArtifacts(); + // RuntimeComponent source = null; + Composite composite = ArtifactsFinder.findComposite(compositeURI, + artifacts); + Component c = ArtifactsFinder.findComponent(composite, componentName); + if (targetReference.getAutowire() == null) { + targetReference.setAutowire(c.getAutowire()); + } + + // Reconcile targets + if (targetReference.getTargets().isEmpty()) { + targetReference.getTargets().addAll(reference.getTargets()); + } + + } + + public org.apache.tuscany.sca.assembly.Reference buildReference( + String name, String className, Class<?> businessInterface, + boolean required) throws Exception { + + Class<?> rawType = contrib.getClassLoader().loadClass(className); + + if (rawType == null) + return null; + + org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory + .createReference(); + JavaInterfaceContract interfaceContract = javaFactory + .createJavaInterfaceContract(); + reference.setInterfaceContract(interfaceContract); + reference.setName(name); + + if (required) { + reference.setMultiplicity(Multiplicity.ONE_ONE); + } else { + reference.setMultiplicity(Multiplicity.ZERO_ONE); + } + Type[] interfaces = rawType.getGenericInterfaces(); + Type genericType = null; + + for (int i = 0; i < interfaces.length; ++i) { + Type tmp = interfaces[i]; + if (interfaces[i] instanceof ParameterizedType) { + ParameterizedType type = (ParameterizedType) tmp; + tmp = type.getRawType(); + } + if (tmp.getClass().getName().equals( + businessInterface.getClass().getName())) { + genericType = tmp; + } + } + if (genericType == null) + throw new ComponentUpdaterException( + "User has specified a wrong businessInterface:" + + businessInterface); + // baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, + // genericType); + /* + * Class<?> baseType = getBaseType(rawType, genericType); if + * (CallableReference.class.isAssignableFrom(baseType)) { if + * (Collection.class.isAssignableFrom(rawType)) { genericType = + * JavaIntrospectionHelper.getParameterType(genericType); } baseType = + * JavaIntrospectionHelper.getBusinessInterface(baseType, genericType); } + */ + try { + + JavaInterface callInterface = javaFactory + .createJavaInterface(JavaIntrospectionHelper + .getErasure(genericType)); + reference.getInterfaceContract().setInterface(callInterface); + if (callInterface.getCallbackClass() != null) { + JavaInterface callbackInterface = javaFactory + .createJavaInterface(callInterface.getCallbackClass()); + reference.getInterfaceContract().setCallbackInterface( + callbackInterface); + } + } catch (InvalidInterfaceException e) { + throw new IntrospectionException(e); + } + return reference; + } + + /* + * private org.apache.tuscany.sca.assembly.Reference + * createReference(JavaElementImpl element, String name) throws + * IntrospectionException { org.apache.tuscany.sca.assembly.Reference + * reference = assemblyFactory.createReference(); JavaInterfaceContract + * interfaceContract = javaFactory.createJavaInterfaceContract(); + * reference.setInterfaceContract(interfaceContract); + * // reference.setMember((Member)element.getAnchor()); boolean required = + * true; Reference ref = element.getAnnotation(Reference.class); if (ref != + * null) { required = ref.required(); } // reference.setRequired(required); + * reference.setName(name); Class<?> rawType = element.getType(); if + * (rawType.isArray() || Collection.class.isAssignableFrom(rawType)) { if + * (required) { reference.setMultiplicity(Multiplicity.ONE_N); } else { + * reference.setMultiplicity(Multiplicity.ZERO_N); } } else { if (required) { + * reference.setMultiplicity(Multiplicity.ONE_ONE); } else { + * reference.setMultiplicity(Multiplicity.ZERO_ONE); } } Type genericType = + * element.getGenericType(); Class<?> baseType = getBaseType(rawType, + * genericType); if (CallableReference.class.isAssignableFrom(baseType)) { + * if (Collection.class.isAssignableFrom(rawType)) { genericType = + * JavaIntrospectionHelper.getParameterType(genericType); } baseType = + * JavaIntrospectionHelper.getBusinessInterface(baseType, genericType); } + * try { JavaInterface callInterface = + * javaFactory.createJavaInterface(baseType); + * reference.getInterfaceContract().setInterface(callInterface); if + * (callInterface.getCallbackClass() != null) { JavaInterface + * callbackInterface = + * javaFactory.createJavaInterface(callInterface.getCallbackClass()); + * reference.getInterfaceContract().setCallbackInterface(callbackInterface); } } + * catch (InvalidInterfaceException e) { throw new + * IntrospectionException(e); } return reference; } + */ + public ComponentReference addReferenceWire(String referenceName, + String className, Class<?> interfaceName, String targetComponent) + throws ComponentUpdaterException, ComponentNotFoundException { + + StAXArtifactProcessorExtensionPoint staxProcessors = registry + .getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + MetaComponentProcessor processor = (MetaComponentProcessor) staxProcessors + .getProcessor(Component.class); + + Contribution contrib = contributionService.getContribution(contribURI); + + List<DeployedArtifact> artifacts = contrib.getArtifacts(); + RuntimeComponent source = null; + Composite composite = ArtifactsFinder.findComposite(compositeURI, + artifacts); + // TODO error handling + if (composite != null) + source = (RuntimeComponent) ArtifactsFinder.findComponent( + composite, componentName); + else { + throw new ComponentNotFoundException("Not found component " + + componentName + " for update"); + } + if (source != null) { + // Debig this + RuntimeComponentReference targetReference = (RuntimeComponentReference) assemblyFactory + .createComponentReference(); + targetReference.setName(referenceName); + targetReference.setUnresolved(true); + Reference reference = null; + try { + reference = buildReference(referenceName, className, + interfaceName, true); + } catch (Exception e) { + throw new ComponentUpdaterException(e.getMessage()); + } + source.getImplementation().getReferences().add(reference); + + // targetService. + ComponentService targetService = assemblyFactory + .createComponentService(); + targetService.setUnresolved(true); + targetService.setName(targetComponent); + targetReference.getTargets().add(targetService); + + // reconciliate + reconcileReference(reference, targetReference, componentName); + // create component reference for the reference + source.getReferences().add(targetReference); + try { + processor.resolveReference(targetReference, contrib + .getModelResolver()); + } catch (ContributionResolveException e) { + throw new ComponentUpdaterException( + "Contribution Resolving Exception while updating.."); + } + + CompositeActivatorImpl activator = (CompositeActivatorImpl) compositeActivator; + compositeBuilder.attachWire(source, composite, targetReference); + activator.activate(source, targetReference); + synchronized (source) { + activator.configureComponentContext(source); + } + // RuntimeComponentReference runtimeRef = + // ((RuntimeComponentReference)ref); + // runtimeRef.setComponent(component); + for (Binding binding : targetReference.getBindings()) { + ReferenceBindingProvider bindingProvider = targetReference + .getBindingProvider(binding); + if (bindingProvider != null) { + bindingProvider.start(); + } + + } + + ImplementationProvider implementationProvider = source + .getImplementationProvider(); + if (implementationProvider != null) { + /* + * con la reflection cosi tolgo la dipendneza if + * ((implementationProvider.getClass().getName().equals("JavaImplementationProvider")) { + * Clazz cget } implementationProvider.getClass(). if + * (implementationProvider instanceof + * JavaImplementationProvider) { ((JavaImplementationProvider) + * implementationProvider). startReference(targetReference); } + */ + } + return targetReference; + } else { + throw new ComponentNotFoundException("Not found component " + + componentName + " for update"); + } + } + + public ComponentReference removeReferenceWire(String referenceName, + String targetComponent) throws ComponentUpdaterException, + ComponentNotFoundException { + List<DeployedArtifact> artifacts = contributionService.getContribution( + contribURI).getArtifacts(); + RuntimeComponent source = null; + Composite composite = ArtifactsFinder.findComposite(compositeURI, + artifacts); + ComponentReference toRemove = null; + + if (composite != null) { + source = (RuntimeComponent) ArtifactsFinder.findComponent( + composite, this.componentName); + } else { + throw new ComponentNotFoundException("Not found component " + + componentName + " for update"); + } + if ((source != null) && (targetComponent != null)) { + /* source target refenence */ + + List<ComponentReference> references = source.getReferences(); + for (ComponentReference ref : references) { + if (ref.getName().equals(targetComponent)) { + toRemove = ref; + break; + } + } + if (toRemove != null) { + CompositeActivatorImpl activator = (CompositeActivatorImpl) compositeActivator; + activator.stop(source, toRemove); + activator.deactivate(source, + (RuntimeComponentReference) toRemove); + compositeBuilder.detachWire(composite, source, toRemove); + } else { + throw new ComponentNotFoundException("Not found component " + + componentName + " for update"); + } + + } + return toRemove; + } +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/CompositeUpdaterImpl.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/CompositeUpdaterImpl.java new file mode 100644 index 0000000000..c5a15b5108 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/CompositeUpdaterImpl.java @@ -0,0 +1,156 @@ +/* + * 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.contribution.updater.impl; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.MetaComponent; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.contribution.Artifact; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.DeployedArtifact; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.contribution.updater.CompositeUpdater; +import org.apache.tuscany.sca.contribution.updater.CompositeUpdaterException; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.assembly.CompositeActivator; +import org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl; +import org.apache.tuscany.sca.contribution.updater.impl.ArtifactsFinder; +import org.apache.tuscany.sca.assembly.xml.MetaComponentProcessor; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +public class CompositeUpdaterImpl implements CompositeUpdater { + + private CompositeBuilder compositeBuilder; + private String compositeURI; + private AssemblyFactory assemblyFactory; + private String contribURI; + private CompositeActivator compositeActivator; + private ExtensionPointRegistry registry; + private ContributionService contribService; + + public CompositeUpdaterImpl(AssemblyFactory assembly, String contribURI, + String compositeURI, CompositeBuilder compositeBuilder, + CompositeActivator compositeActivator, + ExtensionPointRegistry registry, ContributionService contribService) { + this.compositeBuilder = compositeBuilder; + this.compositeURI = compositeURI; + this.assemblyFactory = assembly; + this.contribURI = contribURI; + this.compositeActivator = compositeActivator; + this.registry = registry; + this.contribService = contribService; + } + + public Component addComponent(MetaComponent c) + throws CompositeUpdaterException { + StAXArtifactProcessorExtensionPoint staxProcessors = registry + .getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + MetaComponentProcessor processor = (MetaComponentProcessor) staxProcessors + .getProcessor(Component.class); + Contribution contrib = contribService.getContribution(contribURI); + List<DeployedArtifact> artifacts = contrib.getArtifacts(); + Composite composite = ArtifactsFinder.findComposite(compositeURI, + artifacts); + boolean found = false; + + if (composite == null) + throw new CompositeUpdaterException( + "Composite not found in contribution" + contribURI); + else { + processor.setComposite(composite); + try { + processor.read(c.build()); + } catch (Exception e) { + throw new CompositeUpdaterException( + "Component error parsing in contribution" + contribURI); + + } + found = true; + } + + if (found) { + Component component = processor.getParsedComponent(); + Composite augmentedComposite = processor.getParsedComposite(); + try { + processor.resolve(component, contrib.getModelResolver()); + compositeBuilder.attach(augmentedComposite, component); + ((CompositeActivatorImpl) compositeActivator) + .activateComponent(component); + } catch (Exception e) { + + throw new CompositeUpdaterException( + "Cannot activate the component"); + } + + return component; + } + return null; + } + + public Component findComponent(String componentName) { + Contribution contrib = contribService.getContribution(contribURI); + List<Composite> artifacts = contrib.getDeployables(); + Composite composite = ArtifactsFinder.findComposite(compositeURI, + artifacts); + return ArtifactsFinder.findComponent(composite, componentName); + } + + public Component removeComponent(String componentName) + throws CompositeUpdaterException { + Contribution contrib = contribService.getContribution(contribURI); + List<DeployedArtifact> artifacts = contrib.getArtifacts(); + + Composite composite = ArtifactsFinder.findComposite(compositeURI, + artifacts); + List<Component> components = composite.getComponents(); + Component toRemove = null; + for (Component component : components) { + if (((RuntimeComponent) component).getName().equals(componentName)) { + toRemove = component; + break; + } + } + if (toRemove == null) { + throw new CompositeUpdaterException( + "Component not found in contribution" + contribURI); + } else { + // start again + try { + composite.getComponents().remove(toRemove); + CompositeActivatorImpl impl = (CompositeActivatorImpl) compositeActivator; + impl.stop(toRemove); + impl.deactivateComponent(toRemove); + CompositeBuilderImpl builder = (CompositeBuilderImpl) compositeBuilder; + builder.detach(composite, toRemove); + } catch (Exception e) { + throw new CompositeUpdaterException( + "Cannot remove composite from the contribution" + + contribURI); + } + return toRemove; + } + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ContributionUpdaterFactoryImpl.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ContributionUpdaterFactoryImpl.java new file mode 100644 index 0000000000..7f5870ad55 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/main/java/org/apache/tuscany/sca/contribution/updater/impl/ContributionUpdaterFactoryImpl.java @@ -0,0 +1,75 @@ +/* + * 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.contribution.updater.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.contribution.updater.ComponentUpdater; +import org.apache.tuscany.sca.contribution.updater.CompositeUpdater; +import org.apache.tuscany.sca.contribution.updater.ContributionUpdater; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.assembly.CompositeActivator; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.contribution.updater.impl.ComponentUpdaterImpl; +import org.apache.tuscany.sca.contribution.updater.impl.CompositeUpdaterImpl; +import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime; + +public class ContributionUpdaterFactoryImpl implements ContributionUpdater { + private AssemblyFactory assembly; + private JavaInterfaceFactory javaFactory; + private CompositeActivator compositeActivator; + private CompositeBuilder compositeBuilder; + private ExtensionPointRegistry registry; + private ContributionService contribService; + private InterfaceContractMapper mapper; + + public ContributionUpdaterFactoryImpl(ReallySmallRuntime runtime) { + this.assembly = runtime.getAssemblyFactory(); + this.javaFactory = runtime.getExtensionPointRegistry() + .getExtensionPoint(ModelFactoryExtensionPoint.class) + .getFactory(JavaInterfaceFactory.class); + this.compositeActivator = runtime.getCompositeActivator(); + this.compositeBuilder = runtime.getCompositeBuilder(); + this.registry = runtime.getExtensionPointRegistry(); + this.contribService = runtime.getContributionService(); + this.mapper = runtime.getInterfaceContractMapper(); + } + + public void setContributionService(ContributionService s) { + this.contribService = s; + } + + public ComponentUpdater getComponentUpdater(String contribURI, + String compositeURI, String componentName) { + + return new ComponentUpdaterImpl(contribURI, compositeURI, + componentName, assembly, javaFactory, compositeBuilder, + compositeActivator, contribService, registry, mapper); + } + + public CompositeUpdater getCompositeUpdater(String contribURI, + String compositeURI) { + return new CompositeUpdaterImpl(assembly, contribURI, compositeURI, + compositeBuilder, compositeActivator, registry, contribService); + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/ContributionUpdaterTestCase.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/ContributionUpdaterTestCase.java new file mode 100644 index 0000000000..83d0224ad4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/ContributionUpdaterTestCase.java @@ -0,0 +1,129 @@ +/* + * 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.contribution.updater.impl; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.node.SCANode; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Test ContributionUpdater. + * + */ +public class ContributionUpdaterTestCase { + + // private static SCADomain domain; + private static SCANode node; + private static MetaComponentHello helloMeta; + + @Before + public void setUp() throws Exception { + /* + * System.out.println("Setting up domain"); + * + * SCADomainFactory domainFactory = SCADomainFactory.newInstance(); + * domain = domainFactory.createSCADomain("http://localhost:9999"); + * + * System.out.println("Setting up calculator nodes"); + * + * ClassLoader cl = ContributionUpdaterTestCase.class.getClassLoader(); + * + * SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); try { + * log.info("Staring entropy handler"); prng = + * SecureRandom.getInstance("SHA1PRNG"); } catch + * (NoSuchAlgorithmException e) { // TODO Auto-generated catch block + * e.printStackTrace(); } componentName = + * "HelloComponent"+this.uniqueID(); + * t.setAttribute("componentName",componentName); + * + * node = nodeFactory.createSCANode("http://localhost:8100/nodeA", + * "http://localhost:9999"); node.addContribution("nodeA", + * cl.getResource("nodeA/")); node.addToDomainLevelComposite(new + * QName("http://test", "HelloComposite")); node.start(); + * SCADomainFinder domainFinder = SCADomainFinder.newInstance(); domain = + * domainFinder.getSCADomain("http://localhost:9999"); helloMeta = new + * MetaComponentHello(); + * helloMeta.setComponentClass("org.apache.tuscany.sca.contribution.updater.impl.HelloComponent"); + */ + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testAddNewComponent() throws ClassNotFoundException, + MalformedURLException { + /* + * String helloComponent1 = "<component + * xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" + * name=\"HelloComponent1\">\n" + "<implementation.java + * class=\"org.apache.tuscany.sca.contribution.updater.impl.HelloComponent\"/>"+ "</component>"; + * MetaComponent mc = + * MetaComponentFactory.newMetaComponent("HelloComponent1",helloComponent1); + * try { ((SCANodeImpl) node).addComponentToComposite(mc, "nodeA", + * "HelloComposite.composite"); GreetService greet = + * node.getDomain().getService(GreetService.class, "HelloComponent1"); + * greet.sayHello("Italian").equals("Ciao"); } catch (Exception e) { + * Assert.fail(e.getMessage()); } + */ + Assert.assertEquals("skip", "skip"); + } + + @Test + public void testWireComponents() throws ClassNotFoundException, + MalformedURLException { + Assert.assertEquals("skip", "skip"); + /* + * String helloComponent1 = "<component + * xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" + * name=\"HelloComponent1\">\n" + "<implementation.java + * class=\"org.apache.tuscany.sca.contribution.updater.impl.HelloComponent\"/>"+ "</component>"; + * String helloComponent2 = "<component + * xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" + * name=\"HelloComponent2\">\n" + "<implementation.java + * class=\"org.apache.tuscany.sca.contribution.updater.impl.HelloComponent\"/>"+ "</component>"; + * MetaComponent mc1 = + * MetaComponentFactory.newMetaComponent("HelloComponent1",helloComponent1); + * MetaComponent mc2 = + * MetaComponentFactory.newMetaComponent("HelloComponent2",helloComponent2); + * + * try { ((SCANodeImpl) node).addComponentToComposite(mc1, "nodeA", + * "HelloComposite.composite"); ((SCANodeImpl) + * node).addComponentToComposite(mc2, "nodeA", + * "HelloComposite.composite"); GreetService greet = + * node.getDomain().getService(GreetService.class, "HelloComponent1"); + * greet.sayHello("Italian").equals("Ciao"); } catch (Exception e) { + * Assert.fail(e.getMessage()); } + */ + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/GreetService.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/GreetService.java new file mode 100644 index 0000000000..0eb7fb692b --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/GreetService.java @@ -0,0 +1,26 @@ +/* + * 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.contribution.updater.impl; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface GreetService { + String sayHello(String language); +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/HelloComponent.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/HelloComponent.java new file mode 100644 index 0000000000..38fa2721bb --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/HelloComponent.java @@ -0,0 +1,39 @@ +/* + * 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.contribution.updater.impl; + +import org.osoa.sca.annotations.Service; + +@Service(GreetService.class) +public class HelloComponent implements GreetService { + private String[][] languageGreets = { + { "English", "Italian", "Japanese", "German" }, + { "Hello!", "Ciao!", "Konnici wa!", "Hallo!" } }; + + public String sayHello(String language) { + for (int i = 0; i < 4; ++i) + for (int j = 0; j < 4; ++j) { + if (language.equals(languageGreets[i][j])) { + return languageGreets[0][0]; + } + } + return "I don't speak your language"; + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/MetaComponentHello.java b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/MetaComponentHello.java new file mode 100644 index 0000000000..1495ff2cea --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/java/org/apache/tuscany/sca/contribution/updater/impl/MetaComponentHello.java @@ -0,0 +1,61 @@ +/* + * 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.contribution.updater.impl; + +import java.io.StringReader; +import java.net.URI; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.logging.Logger; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.assembly.MetaComponent; + +public class MetaComponentHello implements MetaComponent { + private String componentName; + private String scdl; + private boolean loadedFromString = false; + private Logger log = Logger.getLogger(MetaComponentHello.class.getName()); + + public MetaComponentHello() { + } + + private MetaComponentHello(String scdl, boolean loadedFromString) { + this.scdl = scdl; + this.loadedFromString = loadedFromString; + } + + public MetaComponent fromSCDL(String scdl) { + return new MetaComponentHello(scdl, true); + } + + public XMLStreamReader build() throws Exception { + XMLInputFactory factory = XMLInputFactory.newInstance(); + return factory.createXMLStreamReader(new StringReader(scdl)); + } + + public String getName() { + + return componentName; + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/resources/HelloComposite.composite b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/resources/HelloComposite.composite new file mode 100644 index 0000000000..76714a0e9c --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/resources/HelloComposite.composite @@ -0,0 +1,27 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://test" + xmlns:test="http://test" + name="HelloComposite"> + <component name="HelloComponentService"> + <implementation.java="org.apache.tuscany.sca.contribution.updater.impl.HelloComponent"/> + </component> +</composite>
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/resources/repository/sample-calculator.jar b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/resources/repository/sample-calculator.jar Binary files differnew file mode 100644 index 0000000000..9c46c679d2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater-impl/src/test/resources/repository/sample-calculator.jar diff --git a/sca-java-1.x/contrib/modules/contribution-updater/LICENSE b/sca-java-1.x/contrib/modules/contribution-updater/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/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/sca-java-1.x/contrib/modules/contribution-updater/NOTICE b/sca-java-1.x/contrib/modules/contribution-updater/NOTICE new file mode 100644 index 0000000000..94481d6cfa --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/contribution-updater/pom.xml b/sca-java-1.x/contrib/modules/contribution-updater/pom.xml new file mode 100644 index 0000000000..cbfa6772e4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/pom.xml @@ -0,0 +1,111 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-contribution-updater</artifactId> + <name>Apache Tuscany SCA Contribution Updater</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-namespace</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-domain-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.contribution.updater</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.contribution.updater*,org.apache.tuscany.sca.assembly*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/assembly/MetaComponent.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/assembly/MetaComponent.java new file mode 100644 index 0000000000..885fe8cfb0 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/assembly/MetaComponent.java @@ -0,0 +1,27 @@ +/* + * 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.assembly; + +import javax.xml.stream.XMLStreamReader; + +public interface MetaComponent { + XMLStreamReader build() throws Exception; + + String getName(); +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/assembly/xml/MetaComponentProcessor.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/assembly/xml/MetaComponentProcessor.java new file mode 100644 index 0000000000..44673bfdb9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/assembly/xml/MetaComponentProcessor.java @@ -0,0 +1,788 @@ +/* + * 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.assembly.xml; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +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.assembly.Binding; +import org.apache.tuscany.sca.assembly.Callback; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentProperty; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.Implementation; +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.Wire; +import org.apache.tuscany.sca.contribution.ContributionFactory; +import org.apache.tuscany.sca.contribution.DeployedArtifact; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyValidationException; +import org.w3c.dom.Document; + +/** + * A component processor. + * + * @version $Rev$ $Date$ + */ +public class MetaComponentProcessor extends BaseAssemblyProcessor implements + StAXArtifactProcessor<Component> { + + /** + * Construct a new composite processor + * + * @param contributionFactory + * @param assemblyFactory + * @param policyFactory + * @param extensionProcessor + */ + private Composite composite = null; + private Component generatedComponent = null; + + public MetaComponentProcessor(ContributionFactory contributionFactory, + AssemblyFactory factory, PolicyFactory policyFactory, + InterfaceContractMapper interfaceContractMapper, + StAXArtifactProcessor extensionProcessor) { + super(contributionFactory, factory, policyFactory, extensionProcessor); + } + + /** + * Construct a new composite processor + * + * @param assemblyFactory + * @param policyFactory + * @param extensionProcessor + * public CompositeProcessor(AssemblyFactory factory, + * PolicyFactory policyFactory, InterfaceContractMapper + * interfaceContractMapper, StAXArtifactProcessor + * extensionProcessor) { super(factory, policyFactory, + * extensionProcessor); } + */ + public void setComposite(Composite c) { + composite = c; + } + + public Component getParsedComponent() { + return this.generatedComponent; + } + + public Composite getParsedComposite() { + return this.composite; + } + + public Component read(XMLStreamReader reader) + throws ContributionReadException, XMLStreamException { + Composite include = null; + Component component = null; + Property property = null; + ComponentService componentService = null; + ComponentReference componentReference = null; + ComponentProperty componentProperty = null; + CompositeService compositeService = null; + CompositeReference compositeReference = null; + Contract contract = null; + Wire wire = null; + Callback callback = null; + QName name = null; + + // Read the component scdl + + while (reader.hasNext()) { + int event = reader.getEventType(); + switch (event) { + case START_ELEMENT: + QName itemName = reader.getName(); + if (!itemName.getNamespaceURI().equals(SCA10_NS)) + name = new QName(SCA10_NS, itemName.getLocalPart()); + else + name = itemName; + + if (SERVICE_QNAME.equals(name)) { + if (component != null) { + + // Read a <component><service> + componentService = assemblyFactory + .createComponentService(); + contract = componentService; + componentService.setName(getString(reader, NAME)); + component.getServices().add(componentService); + policyProcessor.readPolicies(contract, reader); + } + + } else if (REFERENCE_QNAME.equals(name)) { + if (component != null) { + // Read a <component><reference> + componentReference = assemblyFactory + .createComponentReference(); + contract = componentReference; + componentReference.setName(getString(reader, NAME)); + readMultiplicity(componentReference, reader); + if (isSet(reader, AUTOWIRE)) { + componentReference.setAutowire(getBoolean(reader, + AUTOWIRE)); + } + readTargets(componentReference, reader); + componentReference.setWiredByImpl(getBoolean(reader, + WIRED_BY_IMPL)); + component.getReferences().add(componentReference); + policyProcessor.readPolicies(contract, reader); + } + + } else if (PROPERTY_QNAME.equals(name)) { + if (component != null) { + + // Read a <component><property> + componentProperty = assemblyFactory + .createComponentProperty(); + property = componentProperty; + componentProperty.setSource(getString(reader, SOURCE)); + componentProperty.setFile(getString(reader, FILE)); + policyProcessor.readPolicies(property, reader); + readAbstractProperty(componentProperty, reader); + + // Read the property value + Document value = readPropertyValue(property + .getXSDElement(), property.getXSDType(), reader); + property.setValue(value); + + component.getProperties().add(componentProperty); + } + } else if (COMPONENT_QNAME.equals(name)) { + + // Read a <component> + component = assemblyFactory.createComponent(); + component.setName(getString(reader, NAME)); + if (isSet(reader, AUTOWIRE)) { + component.setAutowire(getBoolean(reader, AUTOWIRE)); + } + if (isSet(reader, URI)) { + component.setURI(getString(reader, URI)); + } + component.setConstrainingType(readConstrainingType(reader)); + composite.getComponents().add(component); + policyProcessor.readPolicies(component, reader); + + } else if (WIRE_QNAME.equals(name)) { + + // Read a <wire> + wire = assemblyFactory.createWire(); + ComponentReference source = assemblyFactory + .createComponentReference(); + source.setUnresolved(true); + source.setName(getString(reader, SOURCE)); + wire.setSource(source); + + ComponentService target = assemblyFactory + .createComponentService(); + target.setUnresolved(true); + target.setName(getString(reader, TARGET)); + wire.setTarget(target); + + composite.getWires().add(wire); + policyProcessor.readPolicies(wire, reader); + + } else if (CALLBACK_QNAME.equals(name)) { + + // Read a <callback> + callback = assemblyFactory.createCallback(); + contract.setCallback(callback); + policyProcessor.readPolicies(callback, reader); + + } else if (OPERATION_QNAME.equals(name)) { + + // Read an <operation> + Operation operation = assemblyFactory.createOperation(); + operation.setName(getString(reader, NAME)); + operation.setUnresolved(true); + if (callback != null) { + policyProcessor.readPolicies(callback, operation, + reader); + } else { + policyProcessor.readPolicies(contract, operation, + reader); + } + } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) { + + // Read an implementation.composite + Composite implementation = assemblyFactory + .createComposite(); + implementation.setName(getQName(reader, NAME)); + implementation.setUnresolved(true); + component.setImplementation(implementation); + policyProcessor.readPolicies(implementation, reader); + } else { + + // Read an extension element + Object extension = extensionProcessor.read(reader); + if (extension != null) { + if (extension instanceof InterfaceContract) { + + // <service><interface> and + // <reference><interface> + if (contract != null) { + contract + .setInterfaceContract((InterfaceContract) extension); + } else { + if (name.getNamespaceURI().equals(SCA10_NS)) { + throw new ContributionReadException( + "Unexpected <interface> element found. It should appear inside a <service> or <reference> element"); + } else { + composite.getExtensions().add(extension); + } + } + + } else if (extension instanceof Binding) { + // <service><binding> and + // <reference><binding> + if (callback != null) { + callback.getBindings().add((Binding) extension); + } else { + if (contract != null) { + contract.getBindings().add( + (Binding) extension); + } else { + if (name.getNamespaceURI().equals(SCA10_NS)) { + throw new ContributionReadException( + "Unexpected <binding> element found. It should appear inside a <service> or <reference> element"); + } else { + composite.getExtensions() + .add(extension); + } + } + } + + } else if (extension instanceof Implementation) { + + // <component><implementation> + if (component != null) { + component + .setImplementation((Implementation) extension); + } else { + if (name.getNamespaceURI().equals(SCA10_NS)) { + throw new ContributionReadException( + "Unexpected <implementation> element found. It should appear inside a <component> element"); + } else { + composite.getExtensions().add(extension); + } + } + } else { + + // Add the extension element to the current + // element + if (callback != null) { + callback.getExtensions().add(extension); + } else if (contract != null) { + contract.getExtensions().add(extension); + } else if (property != null) { + property.getExtensions().add(extension); + } else if (component != null) { + component.getExtensions().add(extension); + } else { + composite.getExtensions().add(extension); + } + } + } + } + break; + + case XMLStreamConstants.CHARACTERS: + break; + + case END_ELEMENT: + name = reader.getName(); + + // Clear current state when reading reaching end element + if (SERVICE_QNAME.equals(name)) { + componentService = null; + compositeService = null; + contract = null; + } else if (INCLUDE_QNAME.equals(name)) { + include = null; + } else if (REFERENCE_QNAME.equals(name)) { + componentReference = null; + compositeReference = null; + contract = null; + } else if (PROPERTY_QNAME.equals(name)) { + componentProperty = null; + property = null; + } else if (COMPONENT_QNAME.equals(name)) { + // component = null; + } else if (WIRE_QNAME.equals(name)) { + wire = null; + } else if (CALLBACK_QNAME.equals(name)) { + callback = null; + } + break; + } + + // Read the next element + if (reader.hasNext()) { + reader.next(); + } + } + this.generatedComponent = component; + return component; + } + + public void write(Composite composite, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + + // Write <composite> element + writeStartDocument(writer, COMPOSITE, writeConstrainingType(composite), + new XAttr(TARGET_NAMESPACE, composite.getName() + .getNamespaceURI()), new XAttr(NAME, composite + .getName().getLocalPart()), new XAttr(AUTOWIRE, + composite.getAutowire()), policyProcessor + .writePolicies(composite)); + + // Write <service> elements + for (Service service : composite.getServices()) { + CompositeService compositeService = (CompositeService) service; + Component promotedComponent = compositeService + .getPromotedComponent(); + ComponentService promotedService = compositeService + .getPromotedService(); + String promote; + if (promotedService != null) { + if (promotedService.getName() != null) { + promote = promotedComponent.getName() + '/' + + promotedService.getService(); + } else { + promote = promotedComponent.getName(); + } + } else { + promote = null; + } + writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), + new XAttr(PROMOTE, promote), policyProcessor + .writePolicies(service)); + + // Write service interface + extensionProcessor.write(service.getInterfaceContract(), writer); + + // Write bindings + for (Binding binding : service.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write <callback> element + if (service.getCallback() != null) { + Callback callback = service.getCallback(); + writeStart(writer, CALLBACK, policyProcessor + .writePolicies(callback)); + + // Write callback bindings + for (Binding binding : callback.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write extensions + for (Object extension : callback.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write extensions + for (Object extension : service.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write <component> elements + for (Component component : composite.getComponents()) { + writeStart(writer, COMPONENT, new XAttr(NAME, component.getName()), + new XAttr(URI, component.getURI()), new XAttr(AUTOWIRE, + component.getAutowire()), policyProcessor + .writePolicies(component)); + + // Write <service> elements + for (ComponentService service : component.getServices()) { + writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), + policyProcessor.writePolicies(service)); + + // Write service interface + extensionProcessor + .write(service.getInterfaceContract(), writer); + + // Write bindings + for (Binding binding : service.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write <callback> element + if (service.getCallback() != null) { + Callback callback = service.getCallback(); + writeStart(writer, CALLBACK, policyProcessor + .writePolicies(callback)); + + // Write bindings + for (Binding binding : callback.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write extensions + for (Object extension : callback.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write extensions + for (Object extension : service.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write <reference> elements + for (ComponentReference reference : component.getReferences()) { + writeStart(writer, REFERENCE, new XAttr(NAME, reference + .getName()), new XAttr(AUTOWIRE, reference + .getAutowire()), writeTargets(reference), + policyProcessor.writePolicies(reference)); + + // Write reference interface + extensionProcessor.write(reference.getInterfaceContract(), + writer); + + // Write bindings + for (Binding binding : reference.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write callback + if (reference.getCallback() != null) { + Callback callback = reference.getCallback(); + writeStart(writer, CALLBACK, policyProcessor + .writePolicies(callback)); + + // Write callback bindings + for (Binding binding : callback.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write extensions + for (Object extensions : callback.getExtensions()) { + extensionProcessor.write(extensions, writer); + } + + writeEnd(writer); + } + + // Write extensions + for (Object extensions : reference.getExtensions()) { + extensionProcessor.write(extensions, writer); + } + + writeEnd(writer); + } + + // Write <property> elements + for (ComponentProperty property : component.getProperties()) { + writeStart(writer, PROPERTY, + new XAttr(NAME, property.getName()), new XAttr( + MUST_SUPPLY, property.isMustSupply()), + new XAttr(MANY, property.isMany()), new XAttr(TYPE, + property.getXSDType()), new XAttr(ELEMENT, + property.getXSDElement()), new XAttr(SOURCE, + property.getSource()), new XAttr(FILE, property + .getFile()), policyProcessor + .writePolicies(property)); + + // Write property value + writePropertyValue(property.getValue(), property + .getXSDElement(), property.getXSDType(), writer); + + // Write extensions + for (Object extension : property.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write the component implementation + Implementation implementation = component.getImplementation(); + if (implementation instanceof Composite) { + writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, + composite.getName())); + writeEnd(writer); + } else { + extensionProcessor.write(component.getImplementation(), writer); + } + + writeEnd(writer); + } + + // Write <reference> elements + for (Reference reference : composite.getReferences()) { + CompositeReference compositeReference = (CompositeReference) reference; + + // Write list of promoted references + List<String> promote = new ArrayList<String>(); + for (ComponentReference promoted : compositeReference + .getPromotedReferences()) { + promote.add(promoted.getName()); + } + + // Write <reference> element + writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), + new XAttr(PROMOTE, promote), policyProcessor + .writePolicies(reference)); + + // Write reference interface + extensionProcessor.write(reference.getInterfaceContract(), writer); + + // Write bindings + for (Binding binding : reference.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write <callback> element + if (reference.getCallback() != null) { + Callback callback = reference.getCallback(); + writeStart(writer, CALLBACK); + + // Write callback bindings + for (Binding binding : callback.getBindings()) { + extensionProcessor.write(binding, writer); + } + + // Write extensions + for (Object extension : callback.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write extensions + for (Object extension : reference.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write <property> elements + for (Property property : composite.getProperties()) { + writeStart(writer, PROPERTY, new XAttr(NAME, property.getName()), + new XAttr(MUST_SUPPLY, property.isMustSupply()), new XAttr( + MANY, property.isMany()), new XAttr(TYPE, property + .getXSDType()), new XAttr(ELEMENT, property + .getXSDElement()), policyProcessor + .writePolicies(property)); + + // Write property value + writePropertyValue(property.getValue(), property.getXSDElement(), + property.getXSDType(), writer); + + // Write extensions + for (Object extension : property.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEnd(writer); + } + + // Write <wire> elements + for (Wire wire : composite.getWires()) { + writeStart(writer, WIRE, new XAttr(SOURCE, wire.getSource() + .getName()), new XAttr(TARGET, wire.getTarget().getName())); + + // Write extensions + for (Object extension : wire.getExtensions()) { + extensionProcessor.write(extension, writer); + } + writeEnd(writer); + } + + for (Object extension : composite.getExtensions()) { + extensionProcessor.write(extension, writer); + } + + writeEndDocument(writer); + } + + public void resolve(Composite composite, ModelResolver resolver) + throws ContributionResolveException, PolicyValidationException { + + // Resolve constraining type + ConstrainingType constrainingType = composite.getConstrainingType(); + if (constrainingType != null) { + constrainingType = resolver.resolveModel(ConstrainingType.class, + constrainingType); + composite.setConstrainingType(constrainingType); + } + + // Resolve includes in the composite + for (int i = 0, n = composite.getIncludes().size(); i < n; i++) { + Composite include = composite.getIncludes().get(i); + if (include != null) { + include = resolver.resolveModel(Composite.class, include); + composite.getIncludes().set(i, include); + } + } + + // Resolve extensions + for (Object extension : composite.getExtensions()) { + if (extension != null) { + extensionProcessor.resolve(extension, resolver); + } + } + + // Resolve component implementations, services and references + for (Component component : composite.getComponents()) { + constrainingType = component.getConstrainingType(); + if (constrainingType != null) { + constrainingType = resolver.resolveModel( + ConstrainingType.class, constrainingType); + component.setConstrainingType(constrainingType); + } + + Implementation implementation = component.getImplementation(); + if (implementation != null) { + implementation = resolveImplementation(implementation, resolver); + component.setImplementation(implementation); + } + + for (ComponentProperty componentProperty : component + .getProperties()) { + if (componentProperty.getFile() != null) { + DeployedArtifact deployedArtifact = contributionFactory + .createDeployedArtifact(); + deployedArtifact.setURI(componentProperty.getFile()); + deployedArtifact = resolver.resolveModel( + DeployedArtifact.class, deployedArtifact); + if (deployedArtifact.getLocation() != null) { + componentProperty.setFile(deployedArtifact + .getLocation()); + } + } + } + resolveIntents(component.getRequiredIntents(), resolver); + resolvePolicySets(component.getPolicySets(), resolver); + resolveContracts(component.getServices(), resolver); + resolveContracts(component.getReferences(), resolver); + } + + // Resolve composite services and references + resolveContracts(composite.getServices(), resolver); + resolveContracts(composite.getReferences(), resolver); + if (composite instanceof PolicySetAttachPoint) { + resolveIntents(((PolicySetAttachPoint) composite) + .getRequiredIntents(), resolver); + resolvePolicySets(((PolicySetAttachPoint) composite) + .getPolicySets(), resolver); + } + } + + public void write(Component model, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + write(this.composite, writer); + + } + + public void resolve(Component component, ModelResolver resolver) + throws ContributionResolveException { + // Resolve component implementations, services and references + ConstrainingType constrainingType = component.getConstrainingType(); + if (constrainingType != null) { + constrainingType = resolver.resolveModel(ConstrainingType.class, + constrainingType); + component.setConstrainingType(constrainingType); + } + + Implementation implementation = component.getImplementation(); + if (implementation != null) { + implementation = resolveImplementation(implementation, resolver); + component.setImplementation(implementation); + } + + for (ComponentProperty componentProperty : component.getProperties()) { + if (componentProperty.getFile() != null) { + DeployedArtifact deployedArtifact = contributionFactory + .createDeployedArtifact(); + deployedArtifact.setURI(componentProperty.getFile()); + deployedArtifact = resolver.resolveModel( + DeployedArtifact.class, deployedArtifact); + if (deployedArtifact.getLocation() != null) { + componentProperty.setFile(deployedArtifact.getLocation()); + } + } + } + resolveIntents(component.getRequiredIntents(), resolver); + resolvePolicySets(component.getPolicySets(), resolver); + resolveContracts(component.getServices(), resolver); + resolveContracts(component.getReferences(), resolver); + } + + public void resolveReference(ComponentReference reference, + ModelResolver resolver) throws ContributionResolveException { + resolveIntents(reference.getRequiredIntents(), resolver); + resolvePolicySets(reference.getPolicySets(), resolver); + List<ComponentReference> contracts = new ArrayList<ComponentReference>(); + contracts.add(reference); + resolveContracts(contracts, resolver); + } + + public QName getArtifactType() { + return COMPONENT_QNAME; + } + + public Class<Component> getModelType() { + + return Component.class; + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentNotFoundException.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentNotFoundException.java new file mode 100644 index 0000000000..d93a92b32c --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentNotFoundException.java @@ -0,0 +1,27 @@ +/* + * 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.contribution.updater; + +public class ComponentNotFoundException extends Exception { + + public ComponentNotFoundException(String string) { + super(string); + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentUpdater.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentUpdater.java new file mode 100644 index 0000000000..8743556538 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentUpdater.java @@ -0,0 +1,31 @@ +/* + * 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.contribution.updater; + +import org.apache.tuscany.sca.assembly.ComponentReference; + +public interface ComponentUpdater { + public ComponentReference addReferenceWire(String referenceName, + String className, Class<?> interfaceName, String targetComponent) + throws ComponentUpdaterException, ComponentNotFoundException; + + public ComponentReference removeReferenceWire(String referenceName, + String targetComponent) throws ComponentUpdaterException, + ComponentNotFoundException; +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentUpdaterException.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentUpdaterException.java new file mode 100644 index 0000000000..f94238089f --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ComponentUpdaterException.java @@ -0,0 +1,28 @@ +/* + * 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.contribution.updater; + +public class ComponentUpdaterException extends Exception { + + private static final long serialVersionUID = 33909120912033L; + + public ComponentUpdaterException(String string) { + super(string); + } +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeNotFoundException.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeNotFoundException.java new file mode 100644 index 0000000000..52d7e602b7 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeNotFoundException.java @@ -0,0 +1,25 @@ +/* + * 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.contribution.updater; + +public class CompositeNotFoundException extends Exception { + public CompositeNotFoundException(String msg) { + super(msg); + } +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeUpdater.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeUpdater.java new file mode 100644 index 0000000000..4f55148651 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeUpdater.java @@ -0,0 +1,31 @@ +/* + * 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.contribution.updater; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.MetaComponent; + +public interface CompositeUpdater { + Component addComponent(MetaComponent c) throws CompositeUpdaterException; + + Component removeComponent(String componentName) + throws CompositeUpdaterException; + + Component findComponent(String componentName); +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeUpdaterException.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeUpdaterException.java new file mode 100644 index 0000000000..3dc86d97f7 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/CompositeUpdaterException.java @@ -0,0 +1,29 @@ +/* + * 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.contribution.updater; + +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; + +public class CompositeUpdaterException extends Exception { + + public CompositeUpdaterException(String string) { + super(string); + } + +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ContributionUpdater.java b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ContributionUpdater.java new file mode 100644 index 0000000000..a364c23174 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/main/java/org/apache/tuscany/sca/contribution/updater/ContributionUpdater.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 org.apache.tuscany.sca.contribution.updater; + +/* + * This interface is used to get and modify artifacts from an existing + * contribution + */ +public interface ContributionUpdater { + CompositeUpdater getCompositeUpdater(String contribURI, String compositeURI); + + ComponentUpdater getComponentUpdater(String contribURI, + String compositeURI, String componentName); +} diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/test/resources/HelloComposite.composite b/sca-java-1.x/contrib/modules/contribution-updater/src/test/resources/HelloComposite.composite new file mode 100644 index 0000000000..76714a0e9c --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/test/resources/HelloComposite.composite @@ -0,0 +1,27 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://test" + xmlns:test="http://test" + name="HelloComposite"> + <component name="HelloComponentService"> + <implementation.java="org.apache.tuscany.sca.contribution.updater.impl.HelloComponent"/> + </component> +</composite>
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/contribution-updater/src/test/resources/repository/sample-calculator.jar b/sca-java-1.x/contrib/modules/contribution-updater/src/test/resources/repository/sample-calculator.jar Binary files differnew file mode 100644 index 0000000000..9c46c679d2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/contribution-updater/src/test/resources/repository/sample-calculator.jar diff --git a/sca-java-1.x/contrib/modules/core-spring/LICENSE b/sca-java-1.x/contrib/modules/core-spring/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/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/sca-java-1.x/contrib/modules/core-spring/NOTICE b/sca-java-1.x/contrib/modules/core-spring/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/core-spring/pom.xml b/sca-java-1.x/contrib/modules/core-spring/pom.xml new file mode 100644 index 0000000000..acbe20875c --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/pom.xml @@ -0,0 +1,126 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-core-spring</artifactId> + <name>Apache Tuscany SCA Spring-based Core Runtime</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>2.5.5</version> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>2.5.5</version> + </dependency> + + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>2.5.5</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java-xml</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-xml</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-impl</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-sca</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.core.spring</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.core.spring*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java new file mode 100644 index 0000000000..94bd5c8cf2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanAssemblyFactory.java @@ -0,0 +1,134 @@ +/* + * 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.core.spring.assembly.impl; + +import org.apache.tuscany.sca.assembly.AbstractProperty; +import org.apache.tuscany.sca.assembly.AbstractReference; +import org.apache.tuscany.sca.assembly.AbstractService; +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Callback; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentProperty; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.CompositeReference; +import org.apache.tuscany.sca.assembly.CompositeService; +import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +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.Wire; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; + +/** + * An alternate implementation of the SCA assembly model factory that creates SCA + * assembly model objects backed by Spring bean definitions. + * + * @version $Rev$ $Date$ + */ +public class BeanAssemblyFactory implements AssemblyFactory { + private AssemblyFactory defaultFactory; + private BeanDefinitionRegistry beanRegistry; + + public BeanAssemblyFactory(AssemblyFactory defaultFactory, BeanDefinitionRegistry beanRegistry) { + this.defaultFactory = defaultFactory; + this.beanRegistry = beanRegistry; + } + + public BeanAssemblyFactory(BeanDefinitionRegistry beanRegistry) { + this(new DefaultAssemblyFactory(), beanRegistry); + } + + public AbstractProperty createAbstractProperty() { + return defaultFactory.createAbstractProperty(); + } + + public AbstractReference createAbstractReference() { + return defaultFactory.createAbstractReference(); + } + + public AbstractService createAbstractService() { + return defaultFactory.createAbstractService(); + } + + public Callback createCallback() { + return defaultFactory.createCallback(); + } + + public Component createComponent() { + return new BeanComponentImpl(beanRegistry); + } + + public ComponentProperty createComponentProperty() { + return defaultFactory.createComponentProperty(); + } + + public ComponentReference createComponentReference() { + return defaultFactory.createComponentReference(); + } + + public ComponentService createComponentService() { + return defaultFactory.createComponentService(); + } + + public ComponentType createComponentType() { + return defaultFactory.createComponentType(); + } + + public Composite createComposite() { + return defaultFactory.createComposite(); + } + + public CompositeReference createCompositeReference() { + return defaultFactory.createCompositeReference(); + } + + public CompositeService createCompositeService() { + return defaultFactory.createCompositeService(); + } + + public ConstrainingType createConstrainingType() { + return defaultFactory.createConstrainingType(); + } + + public Property createProperty() { + return defaultFactory.createProperty(); + } + + public Reference createReference() { + return defaultFactory.createReference(); + } + + public Service createService() { + return defaultFactory.createService(); + } + + public Wire createWire() { + return defaultFactory.createWire(); + } + + public ConfiguredOperation createConfiguredOperation() { + return defaultFactory.createConfiguredOperation(); + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java new file mode 100644 index 0000000000..9d874262e9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanComponentImpl.java @@ -0,0 +1,239 @@ +/* + * 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.core.spring.assembly.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentProperty; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.GenericBeanDefinition; + +/** + * An implementation of the SCA assembly Component interface backed by a Spring + * Bean definition. + * + * @version $Rev$ $Date$ + */ +public class BeanComponentImpl extends GenericBeanDefinition implements Component, Cloneable { + private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); + + public IntentAttachPointType getType() { + // TODO Auto-generated method stub + return null; + } + + public void setType(IntentAttachPointType type) { + // TODO Auto-generated method stub + + } + + private static final long serialVersionUID = 1L; + + private ConstrainingType constrainingType; + private Implementation implementation; + private String name; + private String uri; + private List<ComponentService> services = new ArrayList<ComponentService>(); + private List<Intent> requiredIntents = new ArrayList<Intent>(); + private List<PolicySet> policySets = new ArrayList<PolicySet>(); + private List<Object> extensions = new ArrayList<Object>(); + private List<Extension> attributeExtensions = new ArrayList<Extension>(); + private boolean unresolved = false; + private BeanDefinitionRegistry beanRegistry; + + protected BeanComponentImpl(BeanDefinitionRegistry beanRegistry) { + //super((String)""); + this.beanRegistry = beanRegistry; + } + + @Override + public AbstractBeanDefinition cloneBeanDefinition() { + BeanComponentImpl clone = (BeanComponentImpl)super.cloneBeanDefinition(); + clone.getProperties().clear(); + try { + for (ComponentProperty property : getProperties()) { + clone.getProperties().add((ComponentProperty)property.clone()); + } + clone.getReferences().clear(); + for (ComponentReference reference : getReferences()) { + clone.getReferences().add((ComponentReference)reference.clone()); + } + clone.getServices().clear(); + for (ComponentService service : getServices()) { + clone.getServices().add((ComponentService)service.clone()); + } + return clone; + } catch (CloneNotSupportedException e) { + //throw new CloneNotSupportedException(e.getMessage()); + } + return clone; + } + + @Override + public String getParentName() { + //TODO find a better name for bean definitions representing component types + return String.valueOf(System.identityHashCode(implementation)); + } + + public ConstrainingType getConstrainingType() { + return constrainingType; + } + + public Implementation getImplementation() { + return implementation; + } + + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + + // Register this bean definition in the bean registry + this.beanRegistry.registerBeanDefinition(uri, this); + } + + public String getName() { + return name; + } + + //TODO use a better list implementation + private List<ComponentProperty> properties = new ArrayList<ComponentProperty>() { + private static final long serialVersionUID = 1L; + + // Add a property + @Override + public boolean add(ComponentProperty property) { + + // Add corresponding bean property value + getPropertyValues().addPropertyValue(property.getName(), property.getValue()); + + return super.add(property); + } + }; + + public List<ComponentProperty> getProperties() { + return properties; + } + + //TODO use a better list implementation + private List<ComponentReference> references = new ArrayList<ComponentReference>() { + private static final long serialVersionUID = 1L; + + // Add a reference + @Override + public boolean add(ComponentReference reference) { + + // Add corresponding bean property value + if (!reference.getName().startsWith("$self$.")) { + BeanReferenceImpl beanReference = new BeanReferenceImpl(reference); + getPropertyValues().addPropertyValue(reference.getName(), beanReference); + } + return super.add(reference); + } + }; + + public List<ComponentReference> getReferences() { + return references; + } + + public List<ComponentService> getServices() { + return services; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + this.constrainingType = constrainingType; + } + + public void setImplementation(Implementation implementation) { + this.implementation = implementation; + } + + public void setName(String name) { + this.name = name; + } + + public List<Intent> getRequiredIntents() { + return requiredIntents; + } + + public List<PolicySet> getPolicySets() { + return policySets; + } + + public boolean isAutowire() { + return super.getAutowireMode() == AUTOWIRE_BY_TYPE; + } + + public Boolean getAutowire() { + int autowire = super.getAutowireMode(); + if (autowire == AUTOWIRE_BY_TYPE) { + return Boolean.TRUE; + } else if (autowire == AUTOWIRE_NO) { + return Boolean.FALSE; + } else { + return null; + } + } + + public void setAutowire(Boolean autowire) { + super.setAutowireMode(autowire ? AUTOWIRE_BY_TYPE : AUTOWIRE_NO); + } + + public List<Object> getExtensions() { + return extensions; + } + + public List<Extension> getAttributeExtensions() { + return attributeExtensions; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean undefined) { + this.unresolved = undefined; + } + + public void setPolicySets(List<PolicySet> policySets) { + this.policySets = policySets; + } + + public void setRequiredIntents(List<Intent> intents) { + this.requiredIntents = intents; + } + + public List<PolicySet> getApplicablePolicySets() { + return applicablePolicySets; + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java new file mode 100644 index 0000000000..7b747372b4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/assembly/impl/BeanReferenceImpl.java @@ -0,0 +1,70 @@ +/* + * 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.core.spring.assembly.impl; + +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.SCABinding; +import org.springframework.beans.factory.config.RuntimeBeanReference; + +/** + * An implementation of RuntimeBeanReference wrapping an SCA assembly + * Reference + * + * @version $Rev$ $Date$ + */ +public class BeanReferenceImpl extends RuntimeBeanReference { + private Reference reference; + + protected BeanReferenceImpl(Reference reference) { + super("temp"); + this.reference = reference; + } + + @Override + public String getBeanName() { + SCABinding binding = reference.getBinding(SCABinding.class); + String name = binding.getURI(); + if (name.startsWith("/")) { + name = name.substring(1); + } + int s = name.lastIndexOf('/'); + if (s != -1) { + name = name.substring(0, s); + } + return name; + } + + @Override + public boolean equals(Object other) { + if (this != other) { + if (other instanceof RuntimeBeanReference) { + RuntimeBeanReference br = (RuntimeBeanReference)other; + return (getBeanName().equals(br.getBeanName()) && this.isToParent() == br.isToParent()); + } else + return false; + } else + return true; + } + + @Override + public int hashCode() { + return getBeanName().hashCode() * 29 + (this.isToParent() ? 1 : 0); + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java new file mode 100644 index 0000000000..b275bfa9a7 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/ModelResolverImpl.java @@ -0,0 +1,88 @@ +/* + * 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.core.spring.context; + +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.contribution.resolver.ClassReference; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; + + +/** + * A default implementation of an artifact resolver, based on a map. + * + * @version $Rev$ $Date$ + */ +public class ModelResolverImpl implements ModelResolver { + private static final long serialVersionUID = -7826976465762296634L; + + private Map<Object, Object> map = new HashMap<Object, Object>(); + + private WeakReference<ClassLoader> classLoader; + + public ModelResolverImpl(ClassLoader classLoader) { + this.classLoader = new WeakReference<ClassLoader>(classLoader); + } + + public <T> T resolveModel(Class<T> modelClass, T unresolved) { + Object resolved = map.get(unresolved); + if (resolved != null) { + + // Return the resolved object + return modelClass.cast(resolved); + + } else if (unresolved instanceof ClassReference) { + + // Load a class on demand + ClassReference classReference = (ClassReference)unresolved; + Class clazz; + try { + clazz = Class.forName(classReference.getClassName(), true, classLoader.get()); + } catch (ClassNotFoundException e) { + + // Return the unresolved object + return unresolved; + } + + // Store a new ClassReference wrapping the loaded class + resolved = new ClassReference(clazz); + map.put(resolved, resolved); + + // Return the resolved ClassReference + return modelClass.cast(resolved); + + } else { + + // Return the unresolved object + return unresolved; + } + } + + public void addModel(Object resolved) { + map.put(resolved, resolved); + } + + public Object removeModel(Object resolved) { + return map.remove(resolved); + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java new file mode 100644 index 0000000000..8fa5f4cd53 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/context/SCADomainContext.java @@ -0,0 +1,192 @@ +/* + * 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.core.spring.context; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.TransformerFactory; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.service.ContributionException; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.core.spring.assembly.impl.BeanAssemblyFactory; +import org.apache.tuscany.sca.core.spring.implementation.java.impl.BeanJavaImplementationFactory; +import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.BaseJavaClassVisitor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor; +import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; + +/** + * A mini test runtime that uses the SCA assembly model variant implementation + * backed by Spring bean definitions. + * + * @version $Rev$ $Date$ + */ +public class SCADomainContext { + + private DefaultListableBeanFactory beanFactory; + + public SCADomainContext(String... compositeFiles) { + + // Create Spring bean factory + beanFactory = new DefaultListableBeanFactory(); + + // Create SCA assembly and SCA Java factories + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = new BeanAssemblyFactory(new DefaultAssemblyFactory(), beanFactory); + modelFactories.addFactory(assemblyFactory); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); + JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); + PolicyFactory policyFactory = modelFactories.getFactory(PolicyFactory.class); + SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); + modelFactories.addFactory(javaFactory); + JavaImplementationFactory javaImplementationFactory = new BeanJavaImplementationFactory(beanFactory); + modelFactories.addFactory(javaImplementationFactory); + + BaseJavaClassVisitor[] extensions = new BaseJavaClassVisitor[] { + new ConstructorProcessor(assemblyFactory), + new AllowsPassByReferenceProcessor(assemblyFactory), + new ComponentNameProcessor(assemblyFactory), + new ContextProcessor(assemblyFactory), + new ConversationProcessor(assemblyFactory), + new DestroyProcessor(assemblyFactory), + new EagerInitProcessor(assemblyFactory), + new InitProcessor(assemblyFactory), + new PropertyProcessor(assemblyFactory), + new ReferenceProcessor(assemblyFactory, javaFactory), + new ResourceProcessor(assemblyFactory), + new ScopeProcessor(assemblyFactory), + new ServiceProcessor(assemblyFactory, javaFactory), + new HeuristicPojoProcessor(assemblyFactory, javaFactory), + new PolicyProcessor(assemblyFactory, policyFactory) + }; + for (JavaClassVisitor e : extensions) { + javaImplementationFactory.addClassVisitor(e); + } + + // Populate ArtifactProcessor registry + StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + StAXArtifactProcessor<Composite> compositeProcessor = staxProcessors.getProcessor(Composite.class); + + // Create a resolver + //FIXME The ClassLoader should be passed in + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + ModelResolverImpl resolver = new ModelResolverImpl(classLoader); + + try { + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + + // Read the composite files + List<Composite> composites = new ArrayList<Composite>(); + for (String compositeFile: compositeFiles) { + InputStream is = classLoader.getResourceAsStream(compositeFile); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = compositeProcessor.read(reader); + resolver.addModel(composite); + composites.add(composite); + } + + for (Composite composite: composites) { + + // Resolve the composite + compositeProcessor.resolve(composite, resolver); + } + + // Wire the top level component's composite + DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); + TransformerFactory transformerFactory = modelFactories.getFactory(TransformerFactory.class); + buildComposite(composites.get(0), assemblyFactory, scaBindingFactory, + documentBuilderFactory, transformerFactory, mapper); + + } catch (ContributionException e) { + throw new RuntimeException(e); + } catch (CompositeBuilderException e) { + throw new RuntimeException(e); + } catch (XMLStreamException e) { + throw new RuntimeException(e); + } + } + + private void buildComposite(Composite composite, AssemblyFactory assemblyFactory, + SCABindingFactory scaBindingFactory, + DocumentBuilderFactory documentBuilderFactory, + TransformerFactory transformerFactory, + InterfaceContractMapper interfaceContractMapper) throws CompositeBuilderException { + + Monitor monitor = new Monitor() { + + public void problem(Problem problem) { + System.out.println("Composite assembly problem: " + problem.toString()); + } + public List<Problem> getProblems() { + return null; + } + }; + + // Configure and wire the composite + CompositeBuilderImpl compositeUtil = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, new DefaultIntentAttachPointTypeFactory(), + documentBuilderFactory, transformerFactory, interfaceContractMapper, monitor); + compositeUtil.build(composite); + + } + + public <B> B getService(Class<B> businessInterface, String serviceName) { + Object bean = beanFactory.getBean(serviceName); + return businessInterface.cast(bean); + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java new file mode 100644 index 0000000000..493ffe3798 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanBaseJavaImplementationImpl.java @@ -0,0 +1,217 @@ +/* + * 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.core.spring.implementation.java.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Extension; +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.implementation.java.BaseJavaImplementation; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; +import org.springframework.beans.factory.support.AbstractBeanDefinition; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.GenericBeanDefinition; + +/** + * An implementation of the SCA assembly JavaImplementation interface backed by a Spring + * Bean definition. + * + * @version $Rev$ $Date$ + */ +public class BeanBaseJavaImplementationImpl extends GenericBeanDefinition implements BaseJavaImplementation, Cloneable { + private static final long serialVersionUID = 1L; + + private List<Service> services = new ArrayList<Service>(); + private ConstrainingType constrainingType; + private List<Object> extensions = new ArrayList<Object>(); + private List<Extension> attributeExtensions = new ArrayList<Extension>(); + private boolean unresolved; + private BeanDefinitionRegistry beanRegistry; + private String uri; + + private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); + private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>(); + private List<PolicySet> policySets = new ArrayList<PolicySet>(); + private List<Intent> requiredIntents = new ArrayList<Intent>(); + private IntentAttachPointType type = null; + + protected BeanBaseJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) { + this.beanRegistry = beanRegistry; + + // Register this bean definition in the bean registry + //TODO find a better name for bean definitions representing component types + String name = String.valueOf(System.identityHashCode(this)); + this.beanRegistry.registerBeanDefinition(name, this); + } + + @Override + public AbstractBeanDefinition cloneBeanDefinition() { + BeanBaseJavaImplementationImpl clone = (BeanBaseJavaImplementationImpl)super.cloneBeanDefinition(); + clone.getServices().clear(); + try { + for (Service service : getServices()) { + clone.getServices().add((Service)service.clone()); + } + clone.getReferences().clear(); + for (Reference reference : getReferences()) { + clone.getReferences().add((Reference)reference.clone()); + } + clone.getProperties().clear(); + for (Property property : getProperties()) { + clone.getProperties().add((Property)property.clone()); + } + return clone; + } catch (CloneNotSupportedException e) { + //throw new CloneNotSupportedException(e.getMessage()); + } + return clone; + } + + public Class<?> getJavaClass() { + return super.getBeanClass(); + } + + public String getName() { + return super.getBeanClassName(); + } + + public void setJavaClass(Class<?> javaClass) { + super.setBeanClass(javaClass); + } + + public void setName(String className) { + super.setBeanClassName(className); + } + + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public ConstrainingType getConstrainingType() { + return constrainingType; + } + + //TODO use a better list implementation + private List<Property> properties = new ArrayList<Property>() { + private static final long serialVersionUID = 1L; + + // Add a property + @Override + public boolean add(Property property) { + + // Add corresponding bean property value + getPropertyValues().addPropertyValue(property.getName(), property.getValue()); + + return super.add(property); + } + }; + + public List<Property> getProperties() { + return properties; + } + + //TODO use a better list implementation + private List<Reference> references = new ArrayList<Reference>() { + private static final long serialVersionUID = 1L; + + // Add a reference + @Override + public boolean add(Reference reference) { + + // Add corresponding bean property value + String target; + if (!reference.getTargets().isEmpty()) { + //TODO handle multiplicity + target = reference.getTargets().get(0).getName(); + int i = target.indexOf('/'); + if (i != -1) + target = target.substring(0, i); + } else { + target = null; + } + getPropertyValues().addPropertyValue(reference.getName(), target); + + return super.add(reference); + } + }; + + + public List<Reference> getReferences() { + return references; + } + + public List<Service> getServices() { + return services; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + this.constrainingType = constrainingType; + } + + public List<Object> getExtensions() { + return extensions; + } + + public List<Extension> getAttributeExtensions() { + return attributeExtensions; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public List<PolicySet> getApplicablePolicySets() { + return applicablePolicySets; + } + + public List<ConfiguredOperation> getConfiguredOperations() { + return configuredOperations; + } + + public List<PolicySet> getPolicySets() { + return policySets; + } + + public List<Intent> getRequiredIntents() { + return requiredIntents; + } + + public IntentAttachPointType getType() { + return type; + } + + public void setType(IntentAttachPointType type) { + this.type = type; + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java new file mode 100644 index 0000000000..6b19bac413 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationFactory.java @@ -0,0 +1,75 @@ +/* + * 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.core.spring.implementation.java.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.implementation.java.IntrospectionException; +import org.apache.tuscany.sca.implementation.java.JavaImplementation; +import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.apache.tuscany.sca.implementation.java.impl.JavaClassIntrospectorImpl; +import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; + +/** + * An alternate implementation of the SCA Java assembly model factory that + * creates SCA Java assembly model objects backed by Spring bean definitions. + * + * @version $Rev$ $Date$ + */ +public class BeanJavaImplementationFactory implements JavaImplementationFactory { + + private BeanDefinitionRegistry beanRegistry; + private List<JavaClassVisitor> visitors = new ArrayList<JavaClassVisitor>(); + private JavaClassIntrospectorImpl introspector; + + public BeanJavaImplementationFactory(BeanDefinitionRegistry beanRegistry) { + this.beanRegistry = beanRegistry; + introspector = new JavaClassIntrospectorImpl(visitors); + } + + public JavaImplementation createJavaImplementation() { + return new BeanJavaImplementationImpl(beanRegistry); + } + + public void createJavaImplementation(JavaImplementation javaImplementation, Class<?> implementationClass) + throws IntrospectionException { + introspector.introspectClass(javaImplementation, implementationClass); + } + + public JavaImplementation createJavaImplementation(Class<?> implementationClass) throws IntrospectionException { + JavaImplementation javaImplementation = createJavaImplementation(); + introspector.introspectClass(javaImplementation, implementationClass); + return javaImplementation; + } + + public void addClassVisitor(JavaClassVisitor visitor) { + visitors.add(visitor); + } + + public void removeClassVisitor(JavaClassVisitor visitor) { + visitors.remove(visitor); + } + + public List<JavaClassVisitor> getClassVisitors() { + return visitors; + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java new file mode 100644 index 0000000000..7fc82d8711 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java @@ -0,0 +1,175 @@ +/* + * 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.core.spring.implementation.java.impl; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.implementation.java.JavaImplementation; +import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl; +import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl; +import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl; +import org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl; +import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; + +/** + * An implementation of the SCA assembly JavaImplementation interface backed by a Spring + * Bean definition. + * + * @version $Rev$ $Date$ + */ +public class BeanJavaImplementationImpl extends BeanBaseJavaImplementationImpl implements JavaImplementation { + private static final long serialVersionUID = 6792198458193774178L; + + private JavaConstructorImpl<?> constructorDefinition; + private Map<Constructor, JavaConstructorImpl> constructors = new HashMap<Constructor, JavaConstructorImpl>(); + private Method initMethod; + private Method destroyMethod; + private final Map<String, JavaResourceImpl> resources = new HashMap<String, JavaResourceImpl>(); + private final Map<String, JavaElementImpl> propertyMembers = new HashMap<String, JavaElementImpl>(); + private final Map<String, JavaElementImpl> referenceMembers = new HashMap<String, JavaElementImpl>(); + private final Map<String, Collection<JavaElementImpl>> callbackMembers = new HashMap<String, Collection<JavaElementImpl>>(); + private List<Member> conversationIDMember = new ArrayList<Member>(); + private boolean eagerInit; + private boolean allowsPassByReference; + private List<Method> allowsPassByReferenceMethods = new ArrayList<Method>(); + private long maxAge = -1; + private long maxIdleTime = -1; + private JavaScopeImpl scope = JavaScopeImpl.STATELESS; + private List<PolicyHandlerTuple> policyHandlerClassNames = null; + + protected BeanJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) { + super(beanRegistry); + } + + public JavaConstructorImpl<?> getConstructor() { + return constructorDefinition; + } + + public void setConstructor(JavaConstructorImpl<?> definition) { + this.constructorDefinition = definition; + } + + public Method getInitMethod() { + return initMethod; + } + + public void setInitMethod(Method initMethod) { + this.initMethod = initMethod; + } + + public Method getDestroyMethod() { + return destroyMethod; + } + + public void setDestroyMethod(Method destroyMethod) { + this.destroyMethod = destroyMethod; + } + + public Map<String, JavaResourceImpl> getResources() { + return resources; + } + + public List<Member> getConversationIDMembers() { + return this.conversationIDMember; + } + + public void addConversationIDMember(Member conversationIDMember) { + this.conversationIDMember.add(conversationIDMember); + } + + public boolean isAllowsPassByReference() { + return allowsPassByReference; + } + + public void setAllowsPassByReference(boolean allowsPassByReference) { + this.allowsPassByReference = allowsPassByReference; + } + + public List<Method> getAllowsPassByReferenceMethods() { + return allowsPassByReferenceMethods; + } + + public boolean isAllowsPassByReference(Method method) { + return allowsPassByReference || allowsPassByReferenceMethods.contains(method); + } + + public Map<Constructor, JavaConstructorImpl> getConstructors() { + return constructors; + } + + public boolean isEagerInit() { + return eagerInit; + } + + public void setEagerInit(boolean eagerInit) { + this.eagerInit = eagerInit; + } + + public Map<String, Collection<JavaElementImpl>> getCallbackMembers() { + return callbackMembers; + } + + public Map<String, JavaElementImpl> getPropertyMembers() { + return propertyMembers; + } + + public Map<String, JavaElementImpl> getReferenceMembers() { + return referenceMembers; + } + + public JavaScopeImpl getJavaScope() { + return scope; + } + + public void setJavaScope(JavaScopeImpl scope) { + this.scope = scope; + } + + public long getMaxAge() { + return maxAge; + } + + public void setMaxAge(long maxAge) { + this.maxAge = maxAge; + } + + public long getMaxIdleTime() { + return maxIdleTime; + } + + public void setMaxIdleTime(long maxIdleTime) { + this.maxIdleTime = maxIdleTime; + } + + public List<PolicyHandlerTuple> getPolicyHandlerClassNames() { + return policyHandlerClassNames; + } + + public void setPolicyHandlerClassNames(List<PolicyHandlerTuple> policyHandlerClassNames) { + this.policyHandlerClassNames = policyHandlerClassNames; + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java new file mode 100644 index 0000000000..17a7e9084c --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceContractImpl.java @@ -0,0 +1,34 @@ +/* + * 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.core.spring.implementation.java.impl; + +import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceContractImpl; + +/** + * An implementation of a Java interface contract. + * + * @version $Rev$ $Date$ + */ +public class BeanJavaInterfaceContractImpl extends JavaInterfaceContractImpl { + + protected BeanJavaInterfaceContractImpl() { + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java new file mode 100644 index 0000000000..492ab2732e --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceFactory.java @@ -0,0 +1,75 @@ +/* + * 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.core.spring.implementation.java.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceIntrospectorImpl; +import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor; + +/** + * An alternate implementation of the SCA Java assembly model factory that creates SCA + * Java assembly model objects backed by Spring bean definitions. + * + * @version $Rev$ $Date$ + */ +public class BeanJavaInterfaceFactory implements JavaInterfaceFactory { + + private List<JavaInterfaceVisitor> visitors = new ArrayList<JavaInterfaceVisitor>(); + private JavaInterfaceIntrospectorImpl introspector; + + public BeanJavaInterfaceFactory() { + introspector = new JavaInterfaceIntrospectorImpl(this); + } + + public JavaInterface createJavaInterface() { + return new BeanJavaInterfaceImpl(); + } + + public JavaInterface createJavaInterface(Class<?> interfaceClass) throws InvalidInterfaceException { + JavaInterface javaInterface = createJavaInterface(); + introspector.introspectInterface(javaInterface, interfaceClass); + return javaInterface; + } + + public void createJavaInterface(JavaInterface javaInterface, Class<?> interfaceClass) throws InvalidInterfaceException { + introspector.introspectInterface(javaInterface, interfaceClass); + } + + public JavaInterfaceContract createJavaInterfaceContract() { + return new BeanJavaInterfaceContractImpl(); + } + + public void addInterfaceVisitor(JavaInterfaceVisitor extension) { + visitors.add(extension); + } + + public void removeInterfaceVisitor(JavaInterfaceVisitor extension) { + visitors.remove(extension); + } + + public List<JavaInterfaceVisitor> getInterfaceVisitors() { + return visitors; + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java new file mode 100644 index 0000000000..6c3afdb129 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java @@ -0,0 +1,149 @@ +/* + * 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.core.spring.implementation.java.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceImpl; +import org.apache.tuscany.sca.policy.Intent; + +/** + * An alternate implementation of the SCA Java assembly model JavaInterface + * interface. + * + * @version $Rev$ $Date$ + */ +public class BeanJavaInterfaceImpl extends JavaInterfaceImpl implements JavaInterface { + + private String className; + private Class<?> javaClass; + private Class<?> callbackClass; + private boolean conversational; + private boolean remotable; + List<Intent> requiredIntents = new ArrayList<Intent>(); + private List<Object> extensions = new ArrayList<Object>(); + private List<Operation> operations = new ArrayList<Operation>(); + private boolean unresolved = false; + + protected BeanJavaInterfaceImpl() { + } + + @Override + public String getName() { + if (isUnresolved()) { + return className; + } + else { + return javaClass.getName(); + } + } + + @Override + public void setName(String className) { + if (!isUnresolved()) + throw new IllegalStateException(); + this.className = className; + } + + @Override + public Class<?> getJavaClass() { + return javaClass; + } + + @Override + public void setJavaClass(Class<?> javaClass) { + this.javaClass = javaClass; + } + + @Override + public Class<?> getCallbackClass() { + return callbackClass; + } + + @Override + public void setCallbackClass(Class<?> callbackClass) { + this.callbackClass = callbackClass; + } + + @Override + public boolean isConversational() { + return conversational; + } + + @Override + public boolean isRemotable() { + return remotable; + } + + @Override + public void setConversational(boolean conversational) { + this.conversational = conversational; + } + + @Override + public void setRemotable(boolean local) { + this.remotable = local; + } + + @Override + public List<Intent> getRequiredIntents() { + return requiredIntents; + } + + public List<Object> getExtensions() { + return extensions; + } + + @Override + public List<Operation> getOperations() { + return operations; + } + + @Override + public boolean isUnresolved() { + return unresolved; + } + + @Override + public void setUnresolved(boolean undefined) { + this.unresolved = undefined; + } + + @Override + public void resetDataBinding(String dataBinding) { + } + + @Deprecated + @Override + public void setDefaultDataBinding(String dataBinding) { + } + + @Override + public boolean isDynamic() { + return false; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/AddService.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/AddService.java new file mode 100644 index 0000000000..f3a24ed6b2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/AddService.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 calculator; + +/** + * The Add Service interface. + * + * @version $Rev$ $Date$ + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/AddServiceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..61654ea811 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/AddServiceImpl.java @@ -0,0 +1,37 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Add service + * + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +@EagerInit +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + return n1 + n2; + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorClient.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..73aa028084 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorClient.java @@ -0,0 +1,43 @@ +/* + * 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 calculator; + +import org.apache.tuscany.sca.core.spring.context.SCADomainContext; + +/** + * This client program shows how to create an SCA runtime, start it, locate the + * Calculator service and invoke it. + * + * @version $Rev$ $Date$ + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + + SCADomainContext context = new SCADomainContext("org/apache/tuscany/core/spring/Calculator.composite"); + + CalculatorService calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorService.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..e0cf23dc17 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorService.java @@ -0,0 +1,36 @@ +/* + * 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 calculator; + +/** + * The Calculator service interface. + * + * @version $Rev$ $Date$ + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..c1fceb575d --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,73 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Calculator service. + * + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/DivideService.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/DivideService.java new file mode 100644 index 0000000000..7c69b10b25 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/DivideService.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 calculator; + +/** + * The Divide Service interface. + * + * @version $Rev$ $Date$ + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/DivideServiceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..e1f35f99b5 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Divide service. + * + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + return n1 / n2; + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/MultiplyService.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..686542c18e --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/MultiplyService.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 calculator; + +/** + * The Multiply Service interface. + * + * @version $Rev$ $Date$ + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..d621407908 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the Multiply service. + * + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + return n1 * n2; + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java new file mode 100644 index 0000000000..e8e4a6f71b --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/NestedCalculatorClient.java @@ -0,0 +1,46 @@ +/* + * 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 calculator; + +import org.apache.tuscany.sca.core.spring.context.SCADomainContext; + +/** + * This client program shows how to create an SCA runtime, start it, locate the + * Calculator service and invoke it. + * + * @version $Rev$ $Date$ + */ +public class NestedCalculatorClient { + public static void main(String[] args) throws Exception { + + SCADomainContext context = new SCADomainContext( + "org/apache/tuscany/core/spring/OuterCalculator.composite", + "org/apache/tuscany/core/spring/InnerCalculator.composite", + "org/apache/tuscany/core/spring/InnerOperations.composite"); + + CalculatorService calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent/CalculatorServiceComponent"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/SubtractService.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30632688f9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/SubtractService.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 calculator; + +/** + * The Subtract Service interface. + * + * @version $Rev$ $Date$ + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..4fed0a8c6a --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Scope; + +/** + * An implementation of the subtract service. + * + * @version $Rev$ $Date$ + */ +@Scope("COMPOSITE") +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + return n1 - n2; + } + +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java new file mode 100644 index 0000000000..44b447cc64 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/CalculatorTestCase.java @@ -0,0 +1,56 @@ +/* + * 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.core.spring; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.core.spring.context.SCADomainContext; + +import calculator.CalculatorService; + +/** + * This shows how to test the Calculator service component. + * + * @version $Rev$ $Date$ + */ +public class CalculatorTestCase extends TestCase { + + private SCADomainContext context; + private CalculatorService calculatorService; + + @Override + protected void setUp() throws Exception { + context = new SCADomainContext("org/apache/tuscany/sca/core/spring/Calculator.composite"); + + calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + } + + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java b/sca-java-1.x/contrib/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java new file mode 100644 index 0000000000..baf73ac197 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/java/org/apache/tuscany/sca/core/spring/NestedCalculatorTestCaseFIXME.java @@ -0,0 +1,59 @@ +/* + * 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.core.spring; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.core.spring.context.SCADomainContext; + +import calculator.CalculatorService; + +/** + * This shows how to test the Calculator service component. + * + * @version $Rev$ $Date$ + */ +public class NestedCalculatorTestCaseFIXME extends TestCase { + + private SCADomainContext context; + private CalculatorService calculatorService; + + @Override + protected void setUp() throws Exception { + context = new SCADomainContext( + "org/apache/tuscany/sca/core/spring/OuterCalculator.composite", + "org/apache/tuscany/sca/core/spring/InnerCalculator.composite", + "org/apache/tuscany/sca/core/spring/InnerOperations.composite"); + + calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent/InnerCalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + } + + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + + } +} diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite new file mode 100644 index 0000000000..6d998ba035 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/Calculator.composite @@ -0,0 +1,52 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:calc="http://sample.calculator" + name="calc:TestBeanCalculator"> + + <service name="CalculatorService" promote="CalculatorServiceComponent"> + <interface.java interface="calculator.CalculatorService"/> + </service> + + <component name="CalculatorServiceComponent"> + <implementation.java class="calculator.CalculatorServiceImpl"/> + <reference name="addService" target="AddServiceComponent"/> + <reference name="subtractService" target="SubtractServiceComponent"/> + <reference name="multiplyService" target="MultiplyServiceComponent"/> + <reference name="divideService" target="DivideServiceComponent"/> + </component> + + <component name="AddServiceComponent"> + <implementation.java class="calculator.AddServiceImpl"/> + </component> + + <component name="SubtractServiceComponent"> + <implementation.java class="calculator.SubtractServiceImpl"/> + </component> + + <component name="MultiplyServiceComponent"> + <implementation.java class="calculator.MultiplyServiceImpl"/> + </component> + + <component name="DivideServiceComponent"> + <implementation.java class="calculator.DivideServiceImpl"/> + </component> + +</composite> diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite new file mode 100644 index 0000000000..8b043f2b4f --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerCalculator.composite @@ -0,0 +1,42 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:calc="http://calc" + targetNamespace="http://calc" + name="InnerCalculator"> + + <service name="CalculatorService" promote="InnerCalculatorServiceComponent"> + <interface.java interface="calculator.CalculatorService"/> + </service> + + <component name="InnerCalculatorServiceComponent"> + <implementation.java class="calculator.CalculatorServiceImpl"/> + <reference name="addService"/> + <reference name="subtractService"/> + <reference name="multiplyService"/> + <reference name="divideService"/> + </component> + + <reference name="addService" promote="InnerCalculatorServiceComponent/addService"/> + <reference name="subtractService" promote="InnerCalculatorServiceComponent/subtractService"/> + <reference name="multiplyService" promote="InnerCalculatorServiceComponent/multiplyService"/> + <reference name="divideService" promote="InnerCalculatorServiceComponent/divideService"/> + +</composite> diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite new file mode 100644 index 0000000000..d7d1124050 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/InnerOperations.composite @@ -0,0 +1,57 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:calc="http://calc" + targetNamespace="http://calc" + name="InnerOperations"> + + <service name="AddService" promote="AddServiceComponent"> + <interface.java interface="calculator.AddService"/> + </service> + + <service name="SubtractService" promote="SubtractServiceComponent"> + <interface.java interface="calculator.SubtractService"/> + </service> + + <service name="MultiplyService" promote="MultiplyServiceComponent"> + <interface.java interface="calculator.MultiplyService"/> + </service> + + <service name="DivideService" promote="DivideServiceComponent"> + <interface.java interface="calculator.DivideService"/> + </service> + + <component name="AddServiceComponent"> + <implementation.java class="calculator.AddServiceImpl"/> + </component> + + <component name="SubtractServiceComponent"> + <implementation.java class="calculator.SubtractServiceImpl"/> + </component> + + <component name="MultiplyServiceComponent"> + <implementation.java class="calculator.MultiplyServiceImpl"/> + </component> + + <component name="DivideServiceComponent"> + <implementation.java class="calculator.DivideServiceImpl"/> + </component> + +</composite> diff --git a/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite new file mode 100644 index 0000000000..c2b6cced36 --- /dev/null +++ b/sca-java-1.x/contrib/modules/core-spring/src/test/resources/org/apache/tuscany/sca/core/spring/OuterCalculator.composite @@ -0,0 +1,41 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:calc="http://calc" + targetNamespace="http://calc" + name="OuterCalculator"> + + <service name="CalculatorService" promote="CalculatorServiceComponent"> + <interface.java interface="calculator.CalculatorService"/> + </service> + + <component name="CalculatorServiceComponent"> + <implementation.composite name="calc:InnerCalculator"/> + <reference name="addService" target="OperationsServiceComponent/AddService"/> + <reference name="subtractService" target="OperationsServiceComponent/SubtractService"/> + <reference name="multiplyService" target="OperationsServiceComponent/MultiplyService"/> + <reference name="divideService" target="OperationsServiceComponent/DivideService"/> + </component> + + <component name="OperationsServiceComponent"> + <implementation.composite name="calc:InnerOperations"/> + </component> + +</composite> diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/LICENSE b/sca-java-1.x/contrib/modules/data-engine-helper/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/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/sca-java-1.x/contrib/modules/data-engine-helper/NOTICE b/sca-java-1.x/contrib/modules/data-engine-helper/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/pom.xml b/sca-java-1.x/contrib/modules/data-engine-helper/pom.xml new file mode 100644 index 0000000000..52bf3b1cfe --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/pom.xml @@ -0,0 +1,153 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-data-engine-helper</artifactId> + <name>Apache Tuscany SCA Data Engine Helper</name> + + <repositories> + <repository> + <id>apache.incubator</id> + <url>http://people.apache.org/repo/m2-incubating-repository</url> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.das</groupId> + <artifactId>tuscany-das-rdb</artifactId> + <version>1.0-SNAPSHOT</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + <version>3.1</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-contribution-impl</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymock</artifactId> + <version>2.2</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <version>10.3.1.4</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.data.engine.helper</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.data.engine*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java new file mode 100644 index 0000000000..99709857b8 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/ConnectionInfoArtifactProcessor.java @@ -0,0 +1,197 @@ +/* + * 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.data.engine; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.data.engine.config.ConnectionInfo; +import org.apache.tuscany.sca.data.engine.config.ConnectionProperties; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; + +/** + * Implements a StAX artifact processor for ConnectionInfo. + * This processor is shared between implementation.das and implementation.data component type implementations, + * and can be used for other applications that require database connectivity information. + * + * The artifact processor is responsible for processing <ConnectionInfo> + * elements in SCA assembly XML composite files. + * + * @version $Rev$ $Date$ + */ +public class ConnectionInfoArtifactProcessor implements StAXArtifactProcessor<ConnectionInfo> { + public static final QName CONNECTION_INFO = new QName(Constants.SCA10_TUSCANY_NS, "connectionInfo"); + private static final QName CONNECTION_PROPERTIES = new QName(Constants.SCA10_TUSCANY_NS, "connectionProperties"); + + private Monitor monitor; + public ConnectionInfoArtifactProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + this.monitor = monitor; + } + + public QName getArtifactType() { + // Returns the QName of the XML element processed by this processor + return CONNECTION_INFO; + } + + /** + * Report a exception. + * + * @param problems + * @param message + * @param model + */ + private void error(String message, Object model, Exception ex) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "dataengine-helper-validation-messages", Severity.ERROR, model, message, ex); + monitor.problem(problem); + } + } + + public Class<ConnectionInfo> getModelType() { + // Returns the type of model processed by this processor + return ConnectionInfo.class; + } + + /* + * <component name="CompanyDataComponent"> + * <implementation.data table="company"> + * + * <connectionInfo> + * <connectionProperties + * driverClass="org.apache.derby.jdbc.EmbeddedDriver" + * databaseURL="jdbc:derby:target/test-classes/dastest; create = true" + * loginTimeout="600000"/> + * </connectionInfo> + * + * </implementation.data> + * </component> + */ + public ConnectionInfo read(XMLStreamReader reader) throws ContributionReadException { + assert CONNECTION_INFO.equals(reader.getName()); + + // Create a ConnectionInfo from the component type model + ConnectionInfo connectionInfo = new ConnectionInfo(); + + /* + * <connectionInfo dataSource="jdbc:derby:target/test-classes/dastest; create = true"/> + */ + String dataSource = reader.getAttributeValue(null, "datasource"); // exclusive with connection properties + if (dataSource != null && dataSource.length() > 0) { + connectionInfo.setDataSource(dataSource); + } else { + try { + int event = reader.next(); + while (event == XMLStreamConstants.CHARACTERS) { + event = reader.next(); + } + } catch (XMLStreamException e) { + ContributionReadException ce = new ContributionReadException(e); + error("ContributionReadException", reader, ce); + throw ce; + } + + QName element = reader.getName(); + + assert CONNECTION_PROPERTIES.equals(element); + + /* + * <connectionProperties + * driverClass="org.apache.derby.jdbc.EmbeddedDriver" + * databaseURL="jdbc:derby:target/test-classes/dastest; create = true" + * username="" + * password="" + * loginTimeout="600000"/> + */ + + String driverClass = reader.getAttributeValue(null, "driverClass"); + String databaseURL = reader.getAttributeValue(null, "databaseURL"); + String username = reader.getAttributeValue(null, "username"); + String password = reader.getAttributeValue(null, "password"); + String loginTimeout = reader.getAttributeValue(null, "loginTimeout"); + + // FIXME: validation sending info to monitor.... + ConnectionProperties connectionProperties = new ConnectionProperties(); + connectionProperties.setDriverClass(driverClass); + connectionProperties.setDatabaseURL(databaseURL); + connectionProperties.setUsername(username); + connectionProperties.setPassword(password); + if (loginTimeout != null) { + connectionProperties.setLoginTimeout(Integer.parseInt(loginTimeout)); + } + + connectionInfo.setConnectionProperties(connectionProperties); + } + + return connectionInfo; + } + + public void resolve(ConnectionInfo impl, ModelResolver resolver) throws ContributionResolveException { + + } + + public void write(ConnectionInfo connectionInfo, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + + writer.writeStartElement(CONNECTION_INFO.getNamespaceURI(), CONNECTION_INFO.getLocalPart()); + + if (connectionInfo.getDataSource() != null) { + writer.writeAttribute("dataSource", connectionInfo.getDataSource()); + } + + ConnectionProperties connectionProperties = connectionInfo.getConnectionProperties(); + if (connectionProperties != null) { + writer.writeStartElement(CONNECTION_PROPERTIES.getNamespaceURI(), CONNECTION_PROPERTIES.getLocalPart()); + + if (connectionProperties.getDriverClass() != null) { + writer.writeAttribute("driverClass", connectionProperties.getDriverClass()); + } + if (connectionProperties.getDatabaseURL() != null) { + writer.writeAttribute("databaseURL", connectionProperties.getDatabaseURL()); + } + if (connectionProperties.getUsername() != null) { + writer.writeAttribute("username", connectionProperties.getUsername()); + } + if (connectionProperties.getPassword() != null) { + writer.writeAttribute("password", connectionProperties.getPassword()); + } + if (connectionProperties.getLoginTimeout() != null) { + writer.writeAttribute("loginTimeout", String.valueOf(connectionProperties.getLoginTimeout())); + } + + writer.writeEndElement(); + } + + + writer.writeEndElement(); + + } +} diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java new file mode 100644 index 0000000000..aef9ac3261 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngine.java @@ -0,0 +1,286 @@ +/*
+ * 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.data.engine;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.DAS;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+
+/**
+ * Facade to hide DAS implementation details of handling commands
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataAccessEngine {
+ private final DAS das;
+
+ public DataAccessEngine(DAS das) {
+ this.das = das;
+ }
+
+ public DataObject executeGet(ArrayList keyVals, String table, String key) {//TODO need to consider compound keys
+ try {
+ String sqlQuery = "select * from " + table.toUpperCase();
+ List<String> keys = null;
+
+ if(key == null) {
+ if(keyVals != null && keyVals.size() == 1) {
+ sqlQuery += " where ID = " + keyVals.get(0);
+ }
+ } else {//can be other than ID , can be compound keys
+ keys = getKeys(key);
+ if(keyVals.size() != keys.size()) {
+ throw new RuntimeException("One or more PK values missing");
+ }
+
+ sqlQuery += " where ";
+
+ for(int i=0; i<keys.size(); i++) {
+ sqlQuery += keys.get(i)+" = ? AND ";
+ }
+
+ sqlQuery = sqlQuery.substring(0, sqlQuery.lastIndexOf(" AND "));
+ }
+
+ Command command = this.das.createCommand(sqlQuery);
+
+ if(key != null) {
+ for(int i=1; i<=keyVals.size(); i++) {
+ command.setParameter(i, keyVals.get(i-1));
+ }
+ }
+
+ DataObject returnDO = command.executeQuery();
+ return returnDO;
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ * @param table table'e Type name - should be same as table name
+ * @param key column's Property name - should be same as column name
+ * @return
+ */
+ public Map<Object, DataObject> executeGetAll(String table, String key) {
+ try {
+ String sqlQuery = "select * from " + table.toUpperCase();
+ Command command = this.das.createCommand(sqlQuery);
+ DataObject result = command.executeQuery();
+ List<String> keys = getKeys(key);
+ List<DataObject> resultDataObjects = result.getList(table);
+
+ return getMappedDataObjects(resultDataObjects, keys);
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Map<Object, DataObject> executeQuery(String queryString, String table, String key) {
+ try {
+ Command command = this.das.createCommand(queryString);
+ DataObject result = command.executeQuery();
+ List<String> keys = getKeys(key);
+ List<DataObject> resultDataObjects = result.getList(table);
+
+ return getMappedDataObjects(resultDataObjects, keys);
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ //origDataObject should be with change summary. table, pk is already known to DAS, so no need to have these here
+ public void executePut(DataObject origDataObject) {
+ this.das.applyChanges(origDataObject);
+ return;
+ }
+
+ //return PK/s
+ public ArrayList executePost(DataObject origDataObject, String table, String key){
+ //TODO check that PKs are present before insert - this is not correct for auto incr PKs, so let it be upto user whether to send PK or not
+ /*List<String> keys = getKeys(key);
+ for(int i=0; i<keys.size(); i++) {
+ String currentKey = keys.get(i);
+ Object currentKeyValue = origDataObject.get(currentKey);
+ if(currentKeyValue == null) {
+ throw new RuntimeException("PK missing during INSERT");
+ }
+ }*/
+
+ String sqlString = "insert into "+table+" (";
+ List props = origDataObject.getType().getProperties();
+ if(props.size() != 0) {
+ for(int i=0; i<props.size(); i++) {
+ String currPropName = ((Property)props.get(i)).getName();
+ if(origDataObject.get(currPropName) != null) {
+ sqlString += currPropName+",";
+ }
+ }
+ sqlString = sqlString.substring(0, sqlString.length()-1);
+ sqlString += ") values (";
+ for(int i=0; i<props.size(); i++) {
+ String currPropName = ((Property)props.get(i)).getName();
+ if(origDataObject.get(currPropName) != null) {
+ sqlString += "?,";
+ }
+ }
+
+ sqlString = sqlString.substring(0, sqlString.length()-1);
+ sqlString += ")";
+
+ Command insertCommand = this.das.createCommand(sqlString);
+ int paramIdx = 1;
+ for(int i=1; i<=props.size(); i++) {
+ String currPropName = ((Property)props.get(i-1)).getName();
+ if(origDataObject.get(currPropName) != null) {
+ insertCommand.setParameter(paramIdx, origDataObject.get(currPropName));
+ paramIdx++;
+ }
+ }
+
+ insertCommand.execute();
+
+ //there can be different possibilities
+ //1- there is autogen key - insertCommand.getGeneratedKey() will return value and not exception
+ //2- there is no autogen key - insertCommand.getGeneratedKey() will return exception and value needs to be taken from origDataObject
+ //for 2 it is straight forward to know the column name same as property name
+ //for 1 it is possible for only 1 column so no question of compound PK
+
+ //now get the PK/s to be returned
+ ArrayList pks = new ArrayList();
+
+ try {
+ int newId = insertCommand.getGeneratedKey();
+ pks.add(newId);
+ return pks;
+ } catch(Exception e) {
+ List<String> keys = getKeys(key);
+ for(int i=0; i<keys.size(); i++) {
+ String currentKey = keys.get(i);
+ Object currentKeyValue = origDataObject.get(currentKey);
+ if(currentKeyValue == null) {
+ throw new RuntimeException("PK missing during INSERT");
+ }
+ pks.add(currentKeyValue);
+ }
+ return pks;
+ }
+
+ }
+ return null;
+ }
+
+ //when keyVal is null can be used as deleteAll
+ public void executeDelete(ArrayList keyVals, String table, String key) {
+ try {
+ String sqlQuery = "select * from " + table.toUpperCase();
+ List<String> keys = null;
+
+ if(key == null) {
+ if(keyVals != null && keyVals.size() == 1) {
+ sqlQuery += " where ID = " + keyVals.get(0);
+ }
+ } else {//can be other than ID , can be compound keys
+ keys = getKeys(key);
+ if(keyVals.size() != keys.size()) {
+ throw new RuntimeException("One or more PK values missing");
+ }
+
+ sqlQuery += " where ";
+
+ for(int i=0; i<keys.size(); i++) {
+ sqlQuery += keys.get(i)+" = ? AND ";
+ }
+
+ sqlQuery = sqlQuery.substring(0, sqlQuery.lastIndexOf(" AND "));
+ }
+
+ Command command = this.das.createCommand(sqlQuery);
+
+ if(key != null) {
+ for(int i=1; i<=keyVals.size(); i++) {
+ command.setParameter(i, keyVals.get(i-1));
+ }
+ }
+
+ DataObject result = command.executeQuery();
+ List<DataObject> resultDOs = result.getList(table);
+ if(resultDOs != null) {
+ for(int i=0; i<resultDOs.size(); i++) {
+ ((DataObject)resultDOs.get(i)).delete();
+ }
+ }
+ this.das.applyChanges(result);
+ } catch (Exception e) {
+ //e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Map<Object, DataObject> getMappedDataObjects(List<DataObject> resultDataObjects, List<String> keys) {
+ Map<Object, DataObject> resultMap = new HashMap<Object, DataObject>();
+ ArrayList<Object> keyCols = null;
+ for(int j=0; j<resultDataObjects.size(); j++) {
+ DataObject currentDO = resultDataObjects.get(j);
+
+ keyCols = new ArrayList<Object>();
+ for(int i=0; i<keys.size(); i++) {
+ String currentKey = keys.get(i);
+ Object currentKeyValue = currentDO.get(currentKey);
+ keyCols.add(currentKeyValue);
+ }
+
+ resultMap.put(keyCols, currentDO);
+ }
+ return resultMap;
+ }
+
+ public static List<String> getKeys(String key) {
+ String[] keys = key.split(",");
+ return Arrays.asList(keys);
+ }
+
+ public DataObject executeCommand(String commandName) {
+ try {
+ Command command = this.das.getCommand(commandName);
+ return command.executeQuery();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public DataObject executeCommand(String commandName, String xPath) {
+ DataObject root = executeCommand(commandName);
+ return root.getDataObject(xPath);
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java new file mode 100644 index 0000000000..572c190037 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/DataAccessEngineManager.java @@ -0,0 +1,141 @@ +/*
+ * 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.data.engine;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.tuscany.das.rdb.ConfigHelper;
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper;
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+
+/**
+ * The DataAccessEngineManager acts like a registry and factory for DAS instances
+ * It holds DAS by it's config file name, reusing the same DAS for all components
+ * using the same config file.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataAccessEngineManager {
+ //private final Map<String, DAS> registry = new HashMap<String, DAS>();
+
+ public DataAccessEngineManager() {
+ super();
+ }
+
+ protected DAS initializeDAS(String config, ConnectionInfo connectionInfo, String table, String pkColumns) throws MissingConfigFileException {
+ //load the config file
+ //System.out.println("Initializing DAS");
+
+ ConfigHelper configHelper;
+
+ if(config == null) {
+ //no config information
+ configHelper = new ConfigHelper();
+ } else {
+ //initialize the config helper by loading config file
+ configHelper = new ConfigHelper(this.getConfigStream(config));
+ }
+
+ //add additional connectionInfo if provided in the SCA Composite file
+ if( connectionInfo != null) {
+ String dataSource = connectionInfo.getDataSource();
+ if(dataSource != null && dataSource.length() > 0) {
+ configHelper.addConnectionInfo(dataSource);
+ } else {
+ String driverClass = connectionInfo.getConnectionProperties().getDriverClass();
+ String connectionURL = connectionInfo.getConnectionProperties().getDatabaseURL();
+ String userName = connectionInfo.getConnectionProperties().getUsername();
+ String password = connectionInfo.getConnectionProperties().getPassword();
+ int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();
+
+ configHelper.addConnectionInfo(driverClass, connectionURL, userName, password, loginTimeout);
+ }
+
+ }
+
+ if(table != null && pkColumns != null) {
+ MappingWrapper configWrapper = new MappingWrapper(configHelper.getConfig());
+ List<String> pkColsList = DataAccessEngine.getKeys(pkColumns);
+ for(int i=0; i<pkColsList.size(); i++) {
+ configWrapper.addPrimaryKey(table+"."+pkColsList.get(i), pkColsList.get(i));
+ }
+ }
+
+ DAS das = DAS.FACTORY.createDAS(configHelper.getConfig());
+
+ return das;
+ }
+
+/*
+ public DAS getDAS(String config) throws MissingConfigFileException {
+ //DAS das = registry.get(config);
+ //if ( das == null) {
+ // das = this.initializeDAS(config);
+ // this.registry.put(config, das);
+ //}
+ return initializeDAS(config, null);
+ }
+
+ public DAS getDAS(ConnectionInfo connectionInfo) {
+ assert connectionInfo != null;
+
+ //FIXME: cache the das, we need to define the keys to use (datasource and databaseurl + hashed(username + password))
+ DAS das = null;
+ try {
+ das = initializeDAS(null, connectionInfo);
+ }catch (MissingConfigFileException e) {
+ //this should never happen, as configFile == null
+ }
+
+ return das;
+ }
+*/
+ public DAS getDAS(String config, ConnectionInfo connectionInfo) throws MissingConfigFileException {
+ assert connectionInfo != null;
+
+ //FIXME: cache the das, we need to define the keys to use (datasource and databaseurl + hashed(username + password))
+
+ return initializeDAS(config, connectionInfo, null, null);
+ }
+
+ public DAS getDAS(String config, ConnectionInfo connectionInfo, String table, String pkColumns) throws MissingConfigFileException {
+ assert connectionInfo != null;
+
+ //FIXME: cache the das, we need to define the keys to use (datasource and databaseurl + hashed(username + password))
+
+ return initializeDAS(config, connectionInfo, table, pkColumns);
+ }
+
+ protected InputStream getConfigStream(String config) throws MissingConfigFileException{
+ InputStream configStream = null;
+
+ try {
+ configStream = this.getClass().getClassLoader().getResourceAsStream(config);
+ } catch (Exception e) {
+ throw new MissingConfigFileException(config);
+ }
+
+ return configStream;
+ }
+
+
+}
diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java new file mode 100644 index 0000000000..a010e089e9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/MissingConfigFileException.java @@ -0,0 +1,44 @@ +/*
+ * 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.data.engine;
+
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+
+
+/**
+ * Exception to be used when DAS configuration side file is not available
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingConfigFileException extends ContributionReadException {
+
+ private static final long serialVersionUID = -2616590185174691724L;
+
+ public MissingConfigFileException(String message) {
+ super(message);
+ }
+
+ public MissingConfigFileException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MissingConfigFileException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java new file mode 100644 index 0000000000..c72308f733 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionInfo.java @@ -0,0 +1,47 @@ +/*
+ * 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.data.engine.config;
+
+/**
+ * Database connection information to be used for implementation.data
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConnectionInfo {
+ private ConnectionProperties connectionProperties;
+
+ private String dataSource;
+
+ public String getDataSource() {
+ return this.dataSource;
+ }
+
+ public void setDataSource(String dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public ConnectionProperties getConnectionProperties() {
+ return this.connectionProperties;
+ }
+
+ public void setConnectionProperties(ConnectionProperties connectionProperties) {
+ this.connectionProperties = connectionProperties;
+ }
+
+}
diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.java b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.java new file mode 100644 index 0000000000..df08a970b3 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/java/org/apache/tuscany/sca/data/engine/config/ConnectionProperties.java @@ -0,0 +1,78 @@ +/*
+ * 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.data.engine.config;
+
+/**
+ * Database connection properties to be used for implementation.data
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConnectionProperties {
+
+ private String driverClass;
+
+ private String databaseURL;
+
+ private String userName;
+
+ private String password;
+
+ private Integer loginTimeOut;
+
+ public String getDriverClass() {
+ return this.driverClass;
+ }
+
+ public void setDriverClass(String driverClass) {
+ this.driverClass = driverClass;
+ }
+
+ public String getDatabaseURL() {
+ return this.databaseURL;
+ }
+
+ public void setDatabaseURL(String databaseURL) {
+ this.databaseURL = databaseURL;
+ }
+
+ public String getUsername() {
+ return this.userName;
+ }
+
+ public void setUsername(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public Integer getLoginTimeout() {
+ return this.loginTimeOut;
+ }
+
+ public void setLoginTimeout(Integer loginTimeOut) {
+ this.loginTimeOut = loginTimeOut;
+ }
+
+}
diff --git a/sca-java-1.x/contrib/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties new file mode 100644 index 0000000000..b040d69cc5 --- /dev/null +++ b/sca-java-1.x/contrib/modules/data-engine-helper/src/main/resources/dataengine-helper-validation-messages.properties @@ -0,0 +1,21 @@ +# +# +# 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. +# +# +ContributionReadException = ContributionReadException occured due to :
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/databinding-job/LICENSE b/sca-java-1.x/contrib/modules/databinding-job/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/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/sca-java-1.x/contrib/modules/databinding-job/NOTICE b/sca-java-1.x/contrib/modules/databinding-job/NOTICE new file mode 100644 index 0000000000..94481d6cfa --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/databinding-job/pom.xml b/sca-java-1.x/contrib/modules/databinding-job/pom.xml new file mode 100644 index 0000000000..258da47ed9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/pom.xml @@ -0,0 +1,129 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-databinding-job</artifactId> + <name>Apache Tuscany SCA Data Binding for XML Jobs</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core-spi</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-databinding-axiom</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>javax.xml.stream</groupId> + <artifactId>stax-api</artifactId> + <version>1.0-2</version> + </dependency> + + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.2.2</version> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-api</artifactId> + <exclusions> + <exclusion> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + </exclusion> + </exclusions> + <version>1.2.7</version> + </dependency> + + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.8.1</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-impl</artifactId> + <version>1.2.7</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>wstx-asl</artifactId> + <version>3.2.4</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + </exclusion> + </exclusions> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.databinding.job</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.databinding.job*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/Job.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/Job.java new file mode 100644 index 0000000000..98ca6c7429 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/Job.java @@ -0,0 +1,32 @@ +/* + * 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.databinding.job; + +public interface Job<T, E> { + public T compute(E v); + + public boolean eos(); + + public int getType(); + + public static int NULL_JOB = 0; + public static int REGULAR_JOB = 1; + public static int RESULT_JOB = 2; + // public boolean reusable(); +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/Job2OMElement.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/Job2OMElement.java new file mode 100644 index 0000000000..9752815640 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/Job2OMElement.java @@ -0,0 +1,84 @@ +/* + * 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.databinding.job; + +import java.io.ByteArrayOutputStream; +import java.io.Externalizable; +import java.io.ObjectOutputStream; + +import javax.activation.DataHandler; +import javax.xml.namespace.QName; + +import org.apache.axiom.attachments.ByteArrayDataSource; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; +import org.apache.tuscany.sca.databinding.axiom.AxiomHelper; + +@SuppressWarnings("unchecked") +public class Job2OMElement extends BaseTransformer<Job, OMElement> implements + PullTransformer<Job, OMElement> { + + @Override + protected Class getSourceType() { + return Job.class; + } + + @Override + protected Class getTargetType() { + return OMElement.class; + } + + public OMElement transform(Job source, TransformationContext context) { + OMElement element = null; + + try { + // JobDataSource dataSource = new JobDataSource(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(bos); + out.writeObject(source); + out.close(); + byte[] bytes = bos.toByteArray(); + // ByteArrayDataSource ds = new ByteArrayDataSource(bytes); + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMNamespace ns = AxiomHelper.createOMNamespace(factory, new QName( + "http://job")); + element = factory.createOMElement("jobreference", ns); + // OMText data = factory.createOMText(new DataHandler(ds), true); + // element.addChild(data); + element.setText(Base64Binary.encode(bytes)); + return element; + } catch (Exception e) { + throw new TransformationException(e); + } + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobDataBinding.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobDataBinding.java new file mode 100644 index 0000000000..9d3c6fac5a --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobDataBinding.java @@ -0,0 +1,35 @@ +/* + * 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.databinding.job; + +import org.apache.tuscany.sca.databinding.impl.BaseDataBinding; + +/** + * DataBinding for Jobs + */ +public class JobDataBinding extends BaseDataBinding { + + public static final String NAME = Job.class.getName(); + + public JobDataBinding() { + super(NAME, Job.class); + } + +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobDataMap.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobDataMap.java new file mode 100644 index 0000000000..40ee2ff010 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobDataMap.java @@ -0,0 +1,70 @@ +/* + * 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.databinding.job; + +import java.util.HashMap; + +public class JobDataMap implements java.io.Serializable { + private static final long serialVersionUID = -2602843967597362950L; + private HashMap<String, Object> data = new HashMap<String, Object>(); + + public JobDataMap() { + super(); + } + + public <T> void addJobData(String name, T t) { + data.put(name, t); + } + + public Object getJobDataObject(String name) { + if (data.containsKey(name)) { + return data.get(name); + } + return null; + } + + public Class<?> getJobDataClass(String name) { + if (data.containsKey(name)) { + return data.get(name).getClass(); + } + return null; + } + + public Class<?>[] getJobDataClasses() { + int siz = data.keySet().size(); + int i = 0; + Class<?>[] claz = new Class<?>[siz]; + for (Object e : data.values()) { + claz[i] = e.getClass(); + ++i; + } + return claz; + } + + public Object[] getJobDataObjects() { + int siz = data.keySet().size(); + Object[] objs = new Object[siz]; + int i = 0; + for (Object e : data.values()) { + objs[i] = e.getClass(); + ++i; + } + return objs; + } +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobExecutionContext.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobExecutionContext.java new file mode 100644 index 0000000000..8c98fd2e26 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/JobExecutionContext.java @@ -0,0 +1,45 @@ +/* + * 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.databinding.job; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver; + +public class JobExecutionContext implements java.io.Serializable { + private JobDataMap jobData; + + public JobDataMap getJobData() { + return jobData; + } + + public void storeJSONData(String jsonData) { + XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); + jobData = (JobDataMap) xstream.fromXML(jsonData); + } + + public String getJSONData() { + XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); + String jsonData = xstream.toXML(jobData); + return jsonData; + } + + public void setJobData(JobDataMap jdm) { + this.jobData = jdm; + } +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/OMElement2Job.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/OMElement2Job.java new file mode 100644 index 0000000000..5665e4f492 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/OMElement2Job.java @@ -0,0 +1,69 @@ +/* + * 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.databinding.job; + +import java.io.ByteArrayInputStream; +import java.io.ObjectInputStream; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; + +/** + * Transformer to convert data from an OMElement to Job + */ +@SuppressWarnings("unchecked") +public class OMElement2Job extends BaseTransformer<OMElement, Job> implements + PullTransformer<OMElement, Job> { + + public Job transform(OMElement source, TransformationContext context) { + try { + + String value = (String) source.getText(); + ByteArrayInputStream bis = new ByteArrayInputStream(Base64Binary + .decode(value)); + ObjectInputStream ois = new ObjectInputStream(bis); + Object obj = ois.readObject(); + ois.close(); + Job aReference = (Job) obj; + return aReference; + } catch (Exception e) { + throw new TransformationException(e); + } + } + + @Override + public Class getSourceType() { + return OMElement.class; + } + + @Override + public Class getTargetType() { + return Job.class; + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/RemoteJob.java b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/RemoteJob.java new file mode 100644 index 0000000000..693e0f1af7 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/java/org/apache/tuscany/sca/databinding/job/RemoteJob.java @@ -0,0 +1,35 @@ +/* + * 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.databinding.job; + +/** + * This an abstract class to represent a Job with a Context + * + */ +public abstract class RemoteJob<T> implements Job<T, JobExecutionContext>, + java.io.Serializable { + protected JobExecutionContext context = new JobExecutionContext(); + + public abstract T compute(JobExecutionContext v); + + public JobExecutionContext getContext() { + return context; + } + +} diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sca-java-1.x/contrib/modules/databinding-job/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding new file mode 100644 index 0000000000..e9e7dc9d09 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding @@ -0,0 +1,20 @@ +# 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. + +# implementation classes for the databindings +org.apache.tuscany.sca.databinding.job.JobDataBinding;name=org.apache.tuscany.sca.databinding.job.Job + diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sca-java-1.x/contrib/modules/databinding-job/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer new file mode 100644 index 0000000000..f42a526a48 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer @@ -0,0 +1,18 @@ +# 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. +org.apache.tuscany.sca.databinding.job.Job2OMElement;source=org.apache.tuscany.sca.databinding.job.Job,target=org.apache.axiom.om.OMElement,weight=10 +org.apache.tuscany.sca.databinding.job.OMElement2Job;source=org.apache.axiom.om.OMElement,target=org.apache.tuscany.sca.databinding.job.Job,weight=10 diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/ipo.xml b/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/ipo.xml new file mode 100644 index 0000000000..df901d183d --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/ipo.xml @@ -0,0 +1,51 @@ +<?xml version="1.0"?> +<!-- + * 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. +--> +<ipo:purchaseOrder + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ipo="http://www.example.com/IPO" + xsi:schemaLocation="http://www.example.com/IPO ipo.xsd" + orderDate="1999-12-01"> + + <shipTo exportCode="1" xsi:type="ipo:UKAddress"> + <name>Helen Zoe</name> + <street>47 Eden Street</street> + <city>Cambridge</city> + <postcode>CB1 1JR</postcode> + </shipTo> + + <billTo xsi:type="ipo:USAddress"> + <name>Robert Smith</name> + <street>8 Oak Avenue</street> + <city>Old Town</city> + <state>PA</state> + <zip>95819</zip> + </billTo> + + <items> + <item partNum="833-AA"> + <productName>Lapis necklace</productName> + <quantity>1</quantity> + <USPrice>99.95</USPrice> + <ipo:comment>Want this for the holidays</ipo:comment> + <shipDate>1999-12-05</shipDate> + </item> + </items> +</ipo:purchaseOrder> + diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/ipo.xsd b/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/ipo.xsd new file mode 100644 index 0000000000..cce0cf1019 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/ipo.xsd @@ -0,0 +1,155 @@ +<!--
+ * 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.
+-->
+
+<!--
+ * 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.
+-->
+<schema targetNamespace="http://www.example.com/IPO"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+
+ <annotation>
+ <documentation xml:lang="en">
+ International Purchase order schema for Example.com
+ Copyright 2000 Example.com. All rights reserved.
+ </documentation>
+ </annotation>
+
+
+ <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
+
+ <element name="comment" type="string" />
+
+ <complexType name="PurchaseOrderType">
+ <sequence>
+ <element name="shipTo" type="ipo:Address" />
+ <element name="billTo" type="ipo:Address" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="items" type="ipo:Items" />
+ </sequence>
+ <attribute name="orderDate" type="date" />
+ </complexType>
+
+ <complexType name="Items">
+ <sequence>
+ <element name="item" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="productName" type="string" />
+ <element name="quantity">
+ <simpleType>
+ <restriction base="positiveInteger">
+ <maxExclusive value="100" />
+ </restriction>
+ </simpleType>
+ </element>
+ <element name="USPrice" type="decimal" />
+ <element ref="ipo:comment" minOccurs="0" />
+ <element name="shipDate" type="date"
+ minOccurs="0" />
+ </sequence>
+ <attribute name="partNum" type="ipo:SKU"
+ use="required" />
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+
+ <simpleType name="SKU">
+ <restriction base="string">
+ <pattern value="\d{3}-[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="Address">
+ <sequence>
+ <element name="name" type="string" />
+ <element name="street" type="string" />
+ <element name="city" type="string" />
+ </sequence>
+ </complexType>
+
+ <complexType name="USAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="state" type="ipo:USState" />
+ <element name="zip" type="positiveInteger" />
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="UKAddress">
+ <complexContent>
+ <extension base="ipo:Address">
+ <sequence>
+ <element name="postcode" type="ipo:UKPostcode" />
+ </sequence>
+ <attribute name="exportCode" type="positiveInteger"
+ fixed="1" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- other Address derivations for more countries -->
+
+ <simpleType name="USState">
+ <restriction base="string">
+ <enumeration value="AK" />
+ <enumeration value="AL" />
+ <enumeration value="AR" />
+ <enumeration value="CA" />
+ <enumeration value="PA" />
+ <!-- and so on ... -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="Postcode">
+ <restriction base="string">
+ <length value="7" fixed="true" />
+ </restriction>
+ </simpleType>
+
+
+ <simpleType name="UKPostcode">
+ <restriction base="ipo:Postcode">
+ <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
+ </restriction>
+ </simpleType>
+
+
+
+</schema>
+
diff --git a/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/order.wsdl b/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/order.wsdl new file mode 100644 index 0000000000..913d9e4928 --- /dev/null +++ b/sca-java-1.x/contrib/modules/databinding-job/src/test/resources/order.wsdl @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!-- + * 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. +--> +<definitions name="StockQuote" targetNamespace="http://example.com/order.wsdl" xmlns:tns="http://example.com/order.wsdl" + xmlns:xsd1="http://example.com/order.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + + <types> + <schema targetNamespace="http://example.com/order.xsd" xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:ipo="http://www.example.com/IPO"> + <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd"/> + <element name="checkOrderStatus"> + <complexType> + <sequence> + <element name="customerId" type="string" /> + <element name="order" type="ipo:PurchaseOrderType" /> + <element name="flag" type="int" /> + </sequence> + </complexType> + </element> + <element name="checkOrderStatusResponse"> + <complexType> + <sequence> + <element name="status" type="string" /> + </sequence> + </complexType> + </element> + <element name="note" type="string" /> + </schema> + </types> + + <message name="CheckOrderStatusInput1"> + <part name="body" element="xsd1:checkOrderStatus" /> + </message> + + <message name="CheckOrderStatusOutput1"> + <part name="body" element="xsd1:checkOrderStatusResponse" /> + </message> + + <message name="CheckOrderStatusInput2"> + <part name="p1" element="xsd1:checkOrderStatus" /> + <part name="p2" element="xsd1:note" /> + </message> + + <message name="CheckOrderStatusOutput2"> + <part name="p1" element="xsd1:checkOrderStatusResponse" /> + </message> + + <portType name="OrderPortType"> + <operation name="checkOrderStatus"> + <input message="tns:CheckOrderStatusInput1" /> + <output message="tns:CheckOrderStatusOutput1" /> + </operation> + <operation name="checkOrderStatus2"> + <input message="tns:CheckOrderStatusInput2" /> + <output message="tns:CheckOrderStatusOutput2" /> + </operation> + </portType> + +</definitions>
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/host-osgi/LICENSE b/sca-java-1.x/contrib/modules/host-osgi/LICENSE new file mode 100644 index 0000000000..4b5ab74408 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-osgi/LICENSE @@ -0,0 +1,251 @@ + + 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. + +=============================================================================================================== + +Apache Tuscany SCA for Java Subcomponents +=========================================: + +The Tuscany SCA for Java release includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +================================================================================================================= + +This module implementation-script temporarily includes one file under the following BSD license: + + Copyright (c) 2006, Sun Microsystems, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + - Neither the name of the Sun Microsystems, Inc. nor the names of + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +================================================================================================================= diff --git a/sca-java-1.x/contrib/modules/host-osgi/NOTICE b/sca-java-1.x/contrib/modules/host-osgi/NOTICE new file mode 100644 index 0000000000..a3c65715e5 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-osgi/NOTICE @@ -0,0 +1,17 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +Unless otherwise indicated, all distribution made available by the Apache Software Foundation +is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL"). +A copy of the AL is provided with this distribution as the LICENSE file present in the +root directory, and is also available at http://www.apache.org/licenses/. + +This product also includes software under the BSD license +(see the LICENSE file contained in this distribution), with +the following copyright: + +Copyright (c) 2006, Sun Microsystems, Inc. +All rights reserved. diff --git a/sca-java-1.x/contrib/modules/host-osgi/pom.xml b/sca-java-1.x/contrib/modules/host-osgi/pom.xml new file mode 100644 index 0000000000..40e305c854 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-osgi/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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-host-osgi</artifactId> + <name>Apache Tuscany Host for OSGi</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymock</artifactId> + <version>2.2</version> + <scope>test</scope> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.host.osgi</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.host.osgi*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/host-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-1.x/contrib/modules/host-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator new file mode 100644 index 0000000000..8bab603184 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator @@ -0,0 +1,18 @@ +# 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.
+# Implementation class for the ExtensionActivator
+org.apache.tuscany.sca.host.osgi.XxxxModuleActivator
diff --git a/sca-java-1.x/contrib/modules/host-webapp-junit/LICENSE b/sca-java-1.x/contrib/modules/host-webapp-junit/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-webapp-junit/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/sca-java-1.x/contrib/modules/host-webapp-junit/NOTICE b/sca-java-1.x/contrib/modules/host-webapp-junit/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-webapp-junit/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/contrib/modules/host-webapp-junit/pom.xml b/sca-java-1.x/contrib/modules/host-webapp-junit/pom.xml new file mode 100644 index 0000000000..4245aebbe8 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-webapp-junit/pom.xml @@ -0,0 +1,67 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-host-webapp-junit</artifactId> + <name>Apache Tuscany SCA Webapp JUnit Host</name> + + <dependencies> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version><!-- to keep compatible with older servlet containers --> + <scope>provided</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.host.webapp.junit</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.host.webapp.junit*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java b/sca-java-1.x/contrib/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java new file mode 100644 index 0000000000..b2d3d0abf1 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/JUnitServletFilter.java @@ -0,0 +1,355 @@ +/* + * 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.host.webapp.junit; + +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.logging.Logger; +import java.util.regex.Pattern; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import junit.framework.AssertionFailedError; + +import org.junit.runner.JUnitCore; +import org.junit.runner.Request; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; + +/** + * @version $Rev$ $Date$ + */ +public class JUnitServletFilter implements Filter { + private static final Logger logger = Logger.getLogger(JUnitServletFilter.class.getName()); + + private static final String JUNIT_TESTS_PATTERN = "junit.tests.pattern"; + private static final String JUNIT_TESTS_PATH = "junit.tests.path"; + private static final String JUNIT_ENABLED = "junit.enabled"; + private static final String TESTCASE_PATTERN = ".*TestCase"; + private static final String TESTS_JAR = "/WEB-INF/test-lib/junit-tests.jar"; + + private FilterConfig config; + private boolean junitEnabled = true; + private Set<String> allTestCases; + private ClassLoader testClassLoader; + + private Set<String> findTestCases(String testJarPath) throws IOException { + Pattern pattern = getTestCasePattern(); + if (testJarPath.endsWith(".jar")) { + return findTestCasesInJar(testJarPath, pattern); + } else { + return findTestCasesInDir(testJarPath, pattern); + } + } + + /** + * Search test cases in a JAR + * @param testJarPath + * @param pattern + * @return + * @throws IOException + */ + private Set<String> findTestCasesInJar(String testJarPath, Pattern pattern) throws IOException { + InputStream in = config.getServletContext().getResourceAsStream(testJarPath); + Set<String> tests = new HashSet<String>(); + if (in != null) { + JarInputStream jar = new JarInputStream(in); + try { + JarEntry entry = null; + + while ((entry = jar.getNextJarEntry()) != null) { + String name = entry.getName(); + + if (name.endsWith(".class")) { + String className = name.substring(0, name.length() - 6).replace('/', '.'); + if (pattern.matcher(className).matches()) { + tests.add(className); + } + } + } + } catch (EOFException e) { + } finally { + if (jar != null) { + try { + jar.close(); + } catch (IOException e) { + } + } + } + + } + return tests; + } + + private Pattern getTestCasePattern() { + String filter = config.getInitParameter(JUNIT_TESTS_PATTERN); + if (filter == null) { + filter = TESTCASE_PATTERN; + } + Pattern pattern = Pattern.compile(filter); + return pattern; + } + + public void destroy() { + } + + private void init() throws IOException { + testClassLoader = Thread.currentThread().getContextClassLoader(); + allTestCases = new HashSet<String>(); + String testsPath = config.getInitParameter(JUNIT_TESTS_PATH); + if (testsPath == null) { + testsPath = TESTS_JAR; + } + URL url = config.getServletContext().getResource(testsPath); + if (url != null) { + allTestCases = findTestCases(testsPath); + if (!(testsPath.startsWith("/WEB-INF/lib/") || testsPath.startsWith("/WEB-INF/classes/"))) { + // Create a new ClassLoader to load the test jar + testClassLoader = new URLClassLoader(new URL[] {url}, testClassLoader); + } + } + } + + /** + * Search test cases in a directory + * @param classesPath + * @param pattern + * @return + */ + private Set<String> findTestCasesInDir(String classesPath, Pattern pattern) { + ServletContext context = config.getServletContext(); + Set<String> tests = new HashSet<String>(); + String dir = classesPath; + findResources(context, pattern, tests, classesPath, dir); + return tests; + } + + @SuppressWarnings("unchecked") + private void findResources(ServletContext context, Pattern pattern, Set<String> tests, String root, String dir) { + Set<String> paths = context.getResourcePaths(dir); + if (paths != null) { + for (String name : paths) { + if (name.endsWith("/")) { + findResources(context, pattern, tests, root, name); + } + if (name.endsWith(".class")) { + String className = name.substring(root.length(), name.length() - 6).replace('/', '.'); + if (pattern.matcher(className).matches()) { + tests.add(className); + } + } + } + } + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, + ServletException { + + if (!junitEnabled) { + chain.doFilter(request, response); + return; + } + + HttpServletRequest req = (HttpServletRequest)request; + HttpServletResponse resp = (HttpServletResponse)response; + + if (!req.getRequestURI().equals(req.getContextPath() + "/junit")) { + // Intercept the /junit call + chain.doFilter(request, response); + return; + } + + String query = req.getQueryString(); + PrintStream ps = new PrintStream(response.getOutputStream()); + + Set<String> testCases = null; + // ClassLoader cl = Thread.currentThread().getContextClassLoader(); + String op = req.getParameter("op"); + if (query == null || op == null || "list".equalsIgnoreCase(op)) { + response.setContentType("text/html"); + resp.setStatus(HttpServletResponse.SC_OK); + ps.println("<html><body>"); + ps.println("<h2>Available Test Cases</h2><p>"); + ps.println("<form method=\"get\" action=\"junit\">"); + ps.println("<table border=\"1\">"); + for (String s : this.allTestCases) { + ps.print("<tr><td>"); + ps.print("<input type=\"checkbox\" name=\"test\" value=\"" + s + + "\"/><a href=\"junit?op=runSelected&test=" + + s + + "\">" + + s + + "</a>"); + ps.println("</td></tr>"); + } + ps.println("</table>"); + ps.println("<p><input type=\"submit\" name=\"op\" value=\"RunSelected\"/>"); + ps.println("<input type=\"submit\" name=\"op\" value=\"RunAll\"/>"); + ps.println("</form></body></html>"); + resp.flushBuffer(); + return; + } else { + if ("runAll".equalsIgnoreCase(op)) { + testCases = this.allTestCases; + } else { + String[] tests = req.getParameterValues("test"); + if (tests == null) { + tests = new String[0]; + } + testCases = new HashSet<String>(Arrays.asList(tests)); + } + } + + response.setContentType("application/xml"); + ps.println("<?xml version=\"1.0\" encoding=\"" + "UTF-8" + "\"?>"); + + ServletContext context = config.getServletContext(); + Object domain = context.getAttribute("org.apache.tuscany.sca.SCADomain"); + URL contribution = context.getResource("/META-INF/sca-contribution.xml"); + + long duration = 0L; + int errors = 0; + int failures = 0; + int runs = 0; + List<Class<?>> testClasses = new ArrayList<Class<?>>(); + List<Result> results = new ArrayList<Result>(); + for (String testClass : testCases) { + Class<?> test = null; + try { + test = Class.forName(testClass, false, testClassLoader); + if (domain != null && contribution != null) { + // Inject the SCADomain + inject(test, domain); + } + testClasses.add(test); + } catch (ClassNotFoundException e) { + String st = XMLFormatter.exceptionToString(e); + st = XMLFormatter.escape(st); + ps.println(st); + // ps.close(); + throw new ServletException(e); + } + + JUnitCore core = new JUnitCore(); + Result result = core.run(Request.aClass(test)); + results.add(result); + + duration += result.getRunTime(); + runs += result.getRunCount(); + + for (Failure f : result.getFailures()) { + if (f.getException() instanceof AssertionFailedError) { + failures++; + } else { + errors++; + } + } + } + + ps.println("<" + XMLFormatter.TESTSUITE + + " " + + XMLFormatter.ATTR_TESTS + + "=\"" + + runs + + "\" " + + XMLFormatter.ATTR_FAILURES + + "=\"" + + failures + + "\" " + + XMLFormatter.ATTR_ERRORS + + "=\"" + + errors + + "\" " + + XMLFormatter.ATTR_TIME + + "=\"" + + XMLFormatter.getDurationAsString(duration) + + "\">"); + for (int i = 0; i < testClasses.size(); i++) { + ps.println(XMLFormatter.toXML(results.get(i), testClasses.get(i))); + } + ps.println("</" + XMLFormatter.TESTSUITE + ">"); + + resp.addIntHeader("junit.errors", errors); + resp.addIntHeader("junit.failures", failures); + resp.addIntHeader("junit.runs", runs); + resp.setStatus(HttpServletResponse.SC_OK); + resp.flushBuffer(); + + ps.close(); + } + + private boolean inject(Class<?> cls, Object target) { + for (Field f : cls.getDeclaredFields()) { + if (Modifier.isStatic(f.getModifiers()) && f.getType().isInstance(target)) { + f.setAccessible(true); + try { + f.set(null, target); + return true; + } catch (IllegalArgumentException e) { + return false; + } catch (IllegalAccessException e) { + return false; + } + } + } + return false; + } + + public void init(FilterConfig config) throws ServletException { + this.config = config; + // Check if the /junit path should be allowed + String param = config.getInitParameter(JUNIT_ENABLED); + if (param != null && param.trim().equals("false")) { + junitEnabled = false; + return; + } + try { + init(); + } catch (IOException e) { + throw new ServletException(e); + } + } + + public boolean isJunitEnabled() { + return junitEnabled; + } + +} diff --git a/sca-java-1.x/contrib/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/XMLFormatter.java b/sca-java-1.x/contrib/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/XMLFormatter.java new file mode 100644 index 0000000000..72ec478cd6 --- /dev/null +++ b/sca-java-1.x/contrib/modules/host-webapp-junit/src/main/java/org/apache/tuscany/sca/host/webapp/junit/XMLFormatter.java @@ -0,0 +1,286 @@ +/* + * ======================================================================== + * + * Copyright 2001-2005 The Apache Software Foundation. + * + * 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. + * + * ======================================================================== + */ +package org.apache.tuscany.sca.host.webapp.junit; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; +import java.text.NumberFormat; +import java.util.Locale; + +import junit.framework.AssertionFailedError; + +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; + +/** + * Format the test results in XML. + * + * @version $Id: XMLFormatter.java 239169 2005-05-05 09:21:54Z vmassol $ + */ +public class XMLFormatter { + /** + * Errors attribute for TestSuite elements + */ + public static final String ATTR_ERRORS = "errors"; + + /** + * Failures attribute for TestSuite elements + */ + public static final String ATTR_FAILURES = "failures"; + + /** + * Message attribute for failure elements (message of the exception) + */ + public static final String ATTR_MESSAGE = "message"; + + /** + * Name attribute for property, TestCase and TestSuite elements + */ + public static final String ATTR_NAME = "name"; + + /** + * Tests attribute for TestSuite elements (number of tests executed) + */ + public static final String ATTR_TESTS = "tests"; + + /** + * Time attribute for TestCase and TestSuite elements + */ + public static final String ATTR_TIME = "time"; + + /** + * Type attribute for failure and error elements + */ + public static final String ATTR_TYPE = "type"; + + /** + * Default stack filter patterns. + */ + private static final String[] DEFAULT_STACK_FILTER_PATTERNS = + new String[] {"junit.framework.TestCase", "junit.framework.TestResult", "junit.framework.TestSuite", + "junit.framework.Assert.", // don't filter AssertionFailure + "java.lang.reflect.Method.invoke("}; + + /** + * The number format used to convert durations into strings. Don't use the + * default locale for that, because the resulting string needs to use + * dotted decimal notation for an XSLT transformation to work correctly. + */ + private static NumberFormat durationFormat = NumberFormat.getInstance(Locale.US); + + /** + * The error element (for a test case) + */ + public static final String ERROR = "error"; + + /** + * The failure element (for a test case) + */ + public static final String FAILURE = "failure"; + + /** + * A single TestCase element + */ + public static final String TESTCASE = "testcase"; + + /** + * A single test suite results. + */ + public static final String TESTSUITE = "testsuite"; + + /** + * Escapes reserved XML characters. + * + * @param theString the string to escape + * @return the escaped string + */ + public static String escape(String theString) { + String newString; + + // It is important to replace the "&" first as the other replacements + // also introduces "&" chars ... + newString = theString.replace("&", "&"); + + newString = newString.replace("<", "<"); + newString = newString.replace(">", ">"); + newString = newString.replace("\"", """); + + return newString; + } + + /** + * Returns the stack trace of an exception as String. + * + * @param theThrowable the exception from which to extract the stack trace + * as a String + * @return the exception stack trace as a String + */ + public static String exceptionToString(Throwable theThrowable) { + return exceptionToString(theThrowable, null); + } + + /** + * Returns the stack trace of an exception as String, optionally filtering + * out line from the stack trace + * + * @param theThrowable the exception from which to extract the stack trace + * as a String + * @param theFilterPatterns Array containing a list of patterns to filter + * out from the stack trace + * @return the exception stack trace as a String + */ + public static String exceptionToString(Throwable theThrowable, String[] theFilterPatterns) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + + theThrowable.printStackTrace(pw); + String stackTrace = sw.toString(); + return filterStackTrace(stackTrace, theFilterPatterns); + } + + /** + * + * + * @param theLine The line to check + * @param theFilterPatterns The patterns to filter out + * @return boolean Whether the specified line should be filtered from the + * stack trace + */ + public static boolean filterLine(String theLine, String[] theFilterPatterns) { + for (int i = 0; i < theFilterPatterns.length; i++) { + if (theLine.indexOf(theFilterPatterns[i]) > 0) { + return true; + } + } + return false; + } + + /** + * + * + * @param theStackTrace The original, unfiltered stack trace + * @param theFilterPatterns The patterns to filter out + * @return The filtered stack trace + */ + static String filterStackTrace(String theStackTrace, String[] theFilterPatterns) { + if ((theFilterPatterns == null) || (theFilterPatterns.length == 0) || (theStackTrace == null)) { + return theStackTrace; + } + + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(stringWriter); + StringReader stringReader = new StringReader(theStackTrace); + BufferedReader bufferedReader = new BufferedReader(stringReader); + + String line; + try { + while ((line = bufferedReader.readLine()) != null) { + if (!filterLine(line, theFilterPatterns)) { + printWriter.println(line); + } + } + } catch (IOException e) { + return theStackTrace; + } + return stringWriter.toString(); + } + + /** + * Convert a duration expressed as a long into a string. + * + * @param theDuration the duration to convert to string + * @return the total duration as a string + */ + public static String getDurationAsString(long theDuration) { + return durationFormat.format((double)theDuration / 1000); + } + + public static String toXML(Failure failure) { + StringBuffer xml = new StringBuffer(); + Throwable ex = failure.getException(); + String tag = (ex instanceof AssertionFailedError) ? FAILURE : ERROR; + xml.append("<" + tag + + " " + + ATTR_MESSAGE + + "=\"" + + escape(ex.getMessage()) + + "\" " + + ATTR_TYPE + + "=\"" + + ex.getClass().getName() + + "\">"); + xml.append(escape(exceptionToString(ex, DEFAULT_STACK_FILTER_PATTERNS))); + xml.append("</" + tag + ">"); + + return xml.toString(); + } + + /** + * Formats the test result as an XML string. + * + * @param result the test result object + * @return the XML string representation of the test results + */ + public static String toXML(Result result, Class<?> cls) { + int failures = 0, errors = 0; + for (Failure f : result.getFailures()) { + if (f.getException() instanceof AssertionFailedError) { + failures++; + } else { + errors++; + } + } + StringBuffer xml = new StringBuffer(); + + xml.append("<" + TESTCASE + + " " + + ATTR_NAME + + "=\"" + + cls.getName() + + "\" " + + ATTR_TESTS + + "=\"" + + result.getRunCount() + + "\" " + + ATTR_FAILURES + + "=\"" + + failures + + "\" " + + ATTR_ERRORS + + "=\"" + + errors + + "\" " + + ATTR_TIME + + "=\"" + + getDurationAsString(result.getRunTime()) + + "\">"); + + for (Failure f : result.getFailures()) { + xml.append(toXML(f)); + } + + xml.append("</" + TESTCASE + ">"); + + return xml.toString(); + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/LICENSE b/sca-java-1.x/contrib/modules/implementation-das/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/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/sca-java-1.x/contrib/modules/implementation-das/NOTICE b/sca-java-1.x/contrib/modules/implementation-das/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/implementation-das/company.sql b/sca-java-1.x/contrib/modules/implementation-das/company.sql new file mode 100644 index 0000000000..e9f8b06901 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/company.sql @@ -0,0 +1,28 @@ +-- +-- 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. +-- + +DROP TABLE COMPANY; + +CREATE TABLE COMPANY ( + ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30)); + +INSERT INTO COMPANY (NAME) VALUES('ACME Publishing'); +INSERT INTO COMPANY (NAME) VALUES('Do-rite plumbing'); +INSERT INTO COMPANY (NAME) VALUES('MegaCorp');
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/implementation-das/pom.xml b/sca-java-1.x/contrib/modules/implementation-das/pom.xml new file mode 100644 index 0000000000..10e9bb9692 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/pom.xml @@ -0,0 +1,197 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-das</artifactId>
+ <name>Apache Tuscany SCA DAS Implementation Extension</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.das</groupId>
+ <artifactId>tuscany-das-rdb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-engine-helper</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>create-db</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${pom.basedir}/target/test-classes/company;create=true</url>
+ <autocommit>true</autocommit>
+ <onError>continue</onError>
+ <onConnectionError>skip</onConnectionError>
+ <delimiter>;</delimiter>
+ <srcFiles>
+ <srcFile>${pom.basedir}/company.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+
+ <!-- Shutdown DB in order to be able to run unit tests -->
+ <execution>
+ <id>shutdown-database-sothat-test-can-run</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${pom.basedir}/target/test-classes/company;shutdown=true</url>
+ <skipOnConnectionError>true</skipOnConnectionError>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.implementation.das</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.implementation.das*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/Constants.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/Constants.java new file mode 100644 index 0000000000..b0b4b132e6 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/Constants.java @@ -0,0 +1,33 @@ +/* + * 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.implementation.das; + +/** + * Generic constants used in this implementation + * + * @version $Rev$ $Date$ + */ +public interface Constants { + /** + * Identify Relation Database data store + */ + String DATA_ACCESS_TYPE_RDB = "rdb"; + +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DAS.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DAS.java new file mode 100644 index 0000000000..1fc46ea710 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DAS.java @@ -0,0 +1,49 @@ +/* + * 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.implementation.das; + +import commonj.sdo.DataObject; + + +/** + * The service interface of a DAS service provided by DAS components. + * + * @version $Rev$ $Date$ + */ +public interface DAS { + + /** + * Execute a DAS Command specified on the DAS config file. + * @param commandName The name of the command + * @return + */ + DataObject executeCommand(String commandName); + + /**Execute a DAS Command specified on the DAS config file, + * and narrow the results based on the provided XPath + * + * @param commandName The name of the command + * @param xPath The xPath filter + * @return + */ + DataObject executeCommand(String commandName, String xPath); + + + +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java new file mode 100644 index 0000000000..0e0c689b41 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java @@ -0,0 +1,146 @@ +/* + * 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.implementation.das; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Implementation; +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.data.engine.config.ConnectionInfo; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + + +/** + * The model representing a sample DAS implementation in an SCA assembly model. + * + * @version $Rev$ $Date$ + */ +public class DASImplementation implements Implementation { + + private String dasConfig; + private String dataAccessType; + + private ConnectionInfo connectionInfo; + + private boolean unresolved; + private List<Service> services = new ArrayList<Service>(); + + /** + * Constructs a new DAS implementation. + */ + public DASImplementation(AssemblyFactory assemblyFactory, + JavaInterfaceFactory javaFactory) { + + // DAS implementation always provide a single service exposing + // the DAS interface, and have no references and properties + Service dasService = null; + dasService = assemblyFactory.createService(); + dasService.setName("DAS"); + JavaInterface javaInterface; + try { + javaInterface = javaFactory.createJavaInterface(DAS.class); + } catch (InvalidInterfaceException e) { + throw new IllegalArgumentException(e); + } + JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); + interfaceContract.setInterface(javaInterface); + dasService.setInterfaceContract(interfaceContract); + + services.add(dasService); + } + + /* DAS Model Information */ + + public String getConfig() { + return this.dasConfig; + } + + public void setConfig(String config) { + this.dasConfig = config; + } + + public String getDataAccessType() { + return this.dataAccessType; + } + + public void setDataAccessType (String dataAccessType) { + this.dataAccessType = dataAccessType; + } + + public ConnectionInfo getConnectionInfo() { + return this.connectionInfo; + } + + public void setConnectionInfo(ConnectionInfo connectionInfo) { + this.connectionInfo = connectionInfo; + } + + /* SCA Model Information */ + + public ConstrainingType getConstrainingType() { + // DAS implementation does not support constrainingTypes + return null; + } + + public List<Property> getProperties() { + // DAS implementation does not support properties + return Collections.emptyList(); + } + + public List<Reference> getReferences() { + // DAS implementation does not support references + return Collections.emptyList(); + } + + public List<Service> getServices() { + return services; + } + + public String getURI() { + // DAS implementation does not have a URI + return null; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + // DAS implementation does not support constrainingTypes + } + + public void setURI(String uri) { + // DAS implementation does not have a URI + + } + + public void setUnresolved(boolean undefined) { + this.unresolved = undefined; + } + +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationFactory.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationFactory.java new file mode 100644 index 0000000000..93d22d2d5a --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationFactory.java @@ -0,0 +1,36 @@ +/* + * 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.implementation.das; + +/** + * A factory for the sample DAS implementation model. + * + * @version $Rev$ $Date$ + */ +public interface DASImplementationFactory { + + /** + * Creates a new CRUD implementation. + * + * @return + */ + DASImplementation createDASImplementation(); + +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationProcessor.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationProcessor.java new file mode 100644 index 0000000000..0e90c90082 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationProcessor.java @@ -0,0 +1,271 @@ +/* + * 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.implementation.das; + +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +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.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.data.engine.ConnectionInfoArtifactProcessor; +import org.apache.tuscany.sca.data.engine.config.ConnectionInfo; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; + + +/** + * Implements a StAX artifact processor for DAS implementations. + * + * The artifact processor is responsible for processing <implementation.das> + * elements in SCA assembly XML composite files and populating the DAS + * implementation model, resolving its references to other artifacts in the SCA + * contribution, and optionally write the model back to SCA assembly XML. + * + * @version $Rev$ $Date$ + */ +public class DASImplementationProcessor implements StAXArtifactProcessor<DASImplementation> { + private static final QName IMPLEMENTATION_DAS = new QName(Constants.SCA10_TUSCANY_NS, "implementation.das"); + + private DASImplementationFactory dasFactory; + + private final AssemblyFactory assemblyFactory; + private final JavaInterfaceFactory javaFactory; + private Monitor monitor; + private StAXArtifactProcessor<ConnectionInfo> connectionInfoProcessor; + + public DASImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); + this.monitor = monitor; + this.dasFactory = new DefaultDASImplementationFactory(assemblyFactory, javaFactory); + this.connectionInfoProcessor = new ConnectionInfoArtifactProcessor(modelFactories, this.monitor); + } + + public QName getArtifactType() { + // Returns the QName of the XML element processed by this processor + return IMPLEMENTATION_DAS; + } + + public Class<DASImplementation> getModelType() { + // Returns the type of model processed by this processor + return DASImplementation.class; + } + + /** + * Report a error. + * + * @param problems + * @param message + * @param model + */ + private void error(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = new ProblemImpl(this.getClass().getName(), "impl-das-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + /* + * <component name="CompanyDataComponent"> + * <implementation.das config="/CompanyConfig.xml" dataAccessType="rdb"> + * <connectionInfo> + * <connectionProperties + * driverClass="org.apache.derby.jdbc.EmbeddedDriver" + * databaseURL="jdbc:derby:target/test-classes/dastest; create = true" + * loginTimeout="600000"/> + * </connectionInfo> + * </implementation.data> + * </component> + */ + public DASImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + assert IMPLEMENTATION_DAS.equals(reader.getName()); + + // Read an <implementation.das> element + + // Create an initialize the DAS implementation model + DASImplementation implementation = null; + + // Read the das config file attribute. + // This is das configuration side file to use + String config = reader.getAttributeValue(null, "config"); + + // Read the data access type attribute + // This is the type of data store in use (e.g RDB, XML, etc) + String dataAccessType = reader.getAttributeValue(null, "dataAccessType"); + + // Both config and dataAccessType are required attributes, hence validating. + if (config == null || dataAccessType == null) { + if (config == null) + error("ConfigAttributeMissing", reader); + if (dataAccessType == null) + error("DataAccessTypeAttributeMissing", reader); + return implementation; + } + + // Create an initialize the DAS implementation model + implementation = dasFactory.createDASImplementation(); + implementation.setConfig(config); + implementation.setDataAccessType(dataAccessType); + implementation.setUnresolved(true); + + while (true) { + int event = reader.next(); + switch (event) { + + case START_ELEMENT: + if (ConnectionInfoArtifactProcessor.CONNECTION_INFO.equals(reader.getName())) { + + // Read connection info + ConnectionInfo connectionInfo = (ConnectionInfo) connectionInfoProcessor.read(reader); + implementation.setConnectionInfo(connectionInfo); + } + break; + case XMLStreamConstants.END_ELEMENT: + if (IMPLEMENTATION_DAS.equals(reader.getName())) { + return implementation; + } + break; + } + } + } + + public void resolve(DASImplementation impl, ModelResolver resolver) throws ContributionResolveException { + if( impl != null && impl.isUnresolved()) { + //resolve component type + mergeComponentType(resolver, impl); + + //set current implementation resolved + impl.setUnresolved(false); + } + } + + public void write(DASImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + + writer.writeStartElement(IMPLEMENTATION_DAS.getNamespaceURI(), IMPLEMENTATION_DAS.getLocalPart()); + + if (implementation.getConfig() != null) { + writer.writeAttribute("config", implementation.getConfig()); + } + if (implementation.getDataAccessType() != null) { + writer.writeAttribute("dataAccessType", implementation.getDataAccessType()); + } + + if (implementation.getConnectionInfo() != null) { + connectionInfoProcessor.write(implementation.getConnectionInfo(), writer); + } + + writer.writeEndElement(); + } + + /** + * Merge the componentType from introspection and external file + * @param resolver + * @param impl + */ + private void mergeComponentType(ModelResolver resolver, DASImplementation impl) { + // FIXME: Need to clarify how to merge + ComponentType componentType = getComponentType(resolver, impl); + if (componentType != null && !componentType.isUnresolved()) { + /* + Map<String, Reference> refMap = new HashMap<String, Reference>(); + for (Reference ref : impl.getReferences()) { + refMap.put(ref.getName(), ref); + } + for (Reference reference : componentType.getReferences()) { + refMap.put(reference.getName(), reference); + } + impl.getReferences().clear(); + impl.getReferences().addAll(refMap.values()); + + // Try to match references by type + Map<String, JavaElementImpl> refMembers = impl.getReferenceMembers(); + for (Reference ref : impl.getReferences()) { + if (ref.getInterfaceContract() != null) { + Interface i = ref.getInterfaceContract().getInterface(); + if (i instanceof JavaInterface) { + Class<?> type = ((JavaInterface)i).getJavaClass(); + if (!refMembers.containsKey(ref.getName())) { + JavaElementImpl e = getMemeber(impl, ref.getName(), type); + if (e != null) { + refMembers.put(ref.getName(), e); + } + } + } + } + }*/ + + Map<String, Service> serviceMap = new HashMap<String, Service>(); + for (Service svc : impl.getServices()) { + if(svc != null) { + serviceMap.put(svc.getName(), svc); + } + } + for (Service service : componentType.getServices()) { + serviceMap.put(service.getName(), service); + } + impl.getServices().clear(); + impl.getServices().addAll(serviceMap.values()); + + Map<String, Property> propMap = new HashMap<String, Property>(); + for (Property prop : impl.getProperties()) { + propMap.put(prop.getName(), prop); + } + } + } + + private String getFileName(String filePath) { + int pos = filePath.lastIndexOf("."); + + return filePath.substring(0, pos); + + } + + private ComponentType getComponentType(ModelResolver resolver, DASImplementation impl) { + String dasConfig = this.getFileName(impl.getConfig()); + String componentTypeURI = dasConfig.replace('.', '/') + ".componentType"; + ComponentType componentType = assemblyFactory.createComponentType(); + componentType.setUnresolved(true); + componentType.setURI(componentTypeURI); + componentType = resolver.resolveModel(ComponentType.class, componentType); + if (!componentType.isUnresolved()) { + return componentType; + } + return null; + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java new file mode 100644 index 0000000000..2e18541b3b --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DefaultDASImplementationFactory.java @@ -0,0 +1,46 @@ +/* + * 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.implementation.das; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + + +/** + * A default factory for the DAS implementation model. + * + * @version $Rev$ $Date$ + */ +public class DefaultDASImplementationFactory implements DASImplementationFactory { + + private AssemblyFactory assemblyFactory; + private JavaInterfaceFactory javaFactory; + + public DefaultDASImplementationFactory(AssemblyFactory assemblyFactory, + JavaInterfaceFactory javaFactory) { + this.assemblyFactory = assemblyFactory; + this.javaFactory = javaFactory; + } + + public DASImplementation createDASImplementation() { + return new DASImplementation(assemblyFactory, javaFactory); + } + +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/annotations/Command.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/annotations/Command.java new file mode 100644 index 0000000000..c8c3fd75e6 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/annotations/Command.java @@ -0,0 +1,36 @@ +/* + * 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.implementation.das.annotations; + +/** + * + * @version $Rev$ $Date$ + */ +public @interface Command { + enum TYPE {SELECT, INSERT, DELETE, UPDATE} + + /** + * Defines an Ad hoc command query + * @return + */ + String query() default ""; + + TYPE type() default TYPE.SELECT; +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASImplementationProvider.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASImplementationProvider.java new file mode 100644 index 0000000000..40f414b7ef --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASImplementationProvider.java @@ -0,0 +1,75 @@ +/* + * 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.implementation.das.provider; + +import org.apache.tuscany.das.rdb.DAS; +import org.apache.tuscany.sca.data.engine.DataAccessEngine; +import org.apache.tuscany.sca.data.engine.DataAccessEngineManager; +import org.apache.tuscany.sca.implementation.das.DASImplementation; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * DAS Implementation provider + * + * @version $Rev$ $Date$ + */ +public class DASImplementationProvider implements ImplementationProvider { + + private RuntimeComponent component; + private DASImplementation implementation; + private final DataAccessEngineManager dataAccessEngineManager; + + /** + * Constructs a new DAS implementation. + */ + public DASImplementationProvider(RuntimeComponent component, DASImplementation implementation) { + this.component = component; + this.implementation = implementation; + this.dataAccessEngineManager = new DataAccessEngineManager(); + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + DAS das = null; + try { + das = dataAccessEngineManager.getDAS(implementation.getConfig(), implementation.getConnectionInfo()); + } catch(Exception e) { + e.printStackTrace(); + //what now ? + } + DASInvoker invoker = new DASInvoker(operation, new DataAccessEngine(das) ); + return invoker; + } + + public boolean supportsOneWayInvocation() { + return false; + } + + public void start() { + System.out.println("Starting " + component.getName()); + } + + public void stop() { + System.out.println("Stopping " + component.getName()); + } + +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASImplementationProviderFactory.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASImplementationProviderFactory.java new file mode 100644 index 0000000000..3ce182347c --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASImplementationProviderFactory.java @@ -0,0 +1,47 @@ +/* + * 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.implementation.das.provider; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.implementation.das.DASImplementation; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Factory for DAS Implementation Provider + * + * @version $Rev$ $Date$ + */ +public class DASImplementationProviderFactory implements ImplementationProviderFactory<DASImplementation> { + + /** + * Constructs a new DAS implementation. + */ + public DASImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, DASImplementation implementation) { + return new DASImplementationProvider(component, implementation); + } + + public Class<DASImplementation> getModelType() { + return DASImplementation.class; + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASInvoker.java b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASInvoker.java new file mode 100644 index 0000000000..4cd227717c --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/provider/DASInvoker.java @@ -0,0 +1,87 @@ +/* + * 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.implementation.das.provider; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.tuscany.sca.data.engine.DataAccessEngine; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + + +/** + * Implements a target invoker for DAS component implementations. + * + * The target invoker is responsible for dispatching invocations to the particular + * component implementation logic. The current component implementation will + * dispatch calls to the DAS APIs to retrieve the requested data from the back-end store + * + * @version $Rev$ $Date$ + */ +public class DASInvoker implements Invoker { + private final Operation operation; + private final DataAccessEngine dataAccessEngine; + + public DASInvoker(Operation operation, DataAccessEngine dataAccessEngine) { + this.operation = operation; + this.dataAccessEngine = dataAccessEngine; + } + + public Message invoke(Message msg) { + try { + Object[] args = msg.getBody(); + Object resp = doTheWork(args); + msg.setBody(resp); + } catch (InvocationTargetException e) { + msg.setFaultBody(e.getCause()); + } + return msg; + } + + public Object doTheWork(Object[] args) throws InvocationTargetException { + //check annotation +// try { +// Method methodDeclaration = this.getClass().getMethod(operation.getName(), null); +// methodDeclaration.getAnnotation(org.apache.tuscany.sca.implementation.das.annotations.Command.class); +// } catch (Exception e) { +// //ignore +// } + + //check if static way + if (operation.getName().equals("executeCommand")) { + String commandName, xPath; + + //simple execute command by name + if( args.length == 1){ + commandName = (String) args[0]; + return this.dataAccessEngine.executeCommand(commandName); + } else { + commandName = (String) args[0]; + xPath = (String) args[1]; + + return this.dataAccessEngine.executeCommand(commandName, xPath); + } + } else { // dynamic mapping to command + + return this.dataAccessEngine.executeCommand(operation.getName()); + } + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..417195c684 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.implementation.das.DASImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.das,model=org.apache.tuscany.sca.implementation.das.DASImplementation diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..290f05d03e --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -0,0 +1,19 @@ +# 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.
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.das.provider.DASImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.das.DASImplementation
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/impl-das-validation-messages.properties b/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/impl-das-validation-messages.properties new file mode 100644 index 0000000000..a002d3cef0 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/main/resources/impl-das-validation-messages.properties @@ -0,0 +1,23 @@ +# +# +# 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. +# +# +ConfigAttributeMissing = Attribute 'config' is missing. +DataAccessTypeAttributeMissing = Attribute 'dataAccessType' is missing. + diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/DASImplementationProcessorTestCase.java b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/DASImplementationProcessorTestCase.java new file mode 100644 index 0000000000..8659280891 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/DASImplementationProcessorTestCase.java @@ -0,0 +1,179 @@ +/* + * 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.implementation.das; + +import java.io.StringReader; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.data.engine.config.ConnectionInfo; +import org.apache.tuscany.sca.data.engine.config.ConnectionProperties; +import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +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.impl.DefaultMonitorFactoryImpl; +import org.apache.tuscany.sca.monitor.impl.DefaultMonitorImpl; + +/** + * @version $Rev$ $Date$ + */ +public class DASImplementationProcessorTestCase extends TestCase { + + protected static final QName IMPLEMENTATION_DAS = new QName(Constants.SCA10_TUSCANY_NS, "implementation.das"); + + private static final String COMPOSITE_USING_DATASOURCE = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">" + + " <component name=\"DasComponent\">" + + " <tuscany:implementation.das config=\"config.xml\" dataAccessType=\"rdb\">" + + " <tuscany:connectionInfo datasource=\"dataSource\"/>" + + " </tuscany:implementation.das>" + + "</component>"; + + private static final String COMPOSITE_USING_CONNECTION_PROPERTIES = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">" + + " <component name=\"DasComponent\">" + + " <tuscany:implementation.das config=\"config.xml\" dataAccessType=\"rdb\">" + + " <tuscany:connectionInfo>" + + " <tuscany:connectionProperties" + + " driverClass=\"driverClass\"" + + " databaseURL=\"databaseURL\"" + + " loginTimeout=\"1\"/>" + + " </tuscany:connectionInfo>" + + " </tuscany:implementation.das>" + + "</component>"; + + private static final String INVALID_XML = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">" + + " <component name=\"DasComponent\">" + + " <tuscany:implementation.das>" + + " <tuscany:connectionInfo datasource=\"dataSource\"/>" + + " </tuscany:implementation.das>" + + "</component>"; + + private XMLInputFactory xmlFactory; + private ModelFactoryExtensionPoint modelFactories; + private Monitor monitor; + + @Override + protected void setUp() throws Exception { + super.setUp(); + xmlFactory = XMLInputFactory.newInstance(); + // Create a monitor + MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl(); + if (monitorFactory != null) + this.monitor = monitorFactory.createMonitor(); + modelFactories = new DefaultModelFactoryExtensionPoint(); + AssemblyFactory assemblyFactory = new DefaultAssemblyFactory(); + modelFactories.addFactory(assemblyFactory); + JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(); + modelFactories.addFactory(javaFactory); + } + + public void testLoadCompositeUsingDatasource() throws Exception { + XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(COMPOSITE_USING_DATASOURCE)); + + DASImplementationProcessor dataProcessor = new DASImplementationProcessor(modelFactories, monitor); + + while(true) { + int event = reader.next(); + if(event == XMLStreamConstants.START_ELEMENT && IMPLEMENTATION_DAS.equals(reader.getName())) { + break; + } + } + + DASImplementation implementation = dataProcessor.read(reader); + + assertNotNull(implementation); + assertEquals("config.xml", implementation.getConfig()); + assertEquals("rdb", implementation.getDataAccessType()); + + ConnectionInfo connInfo = implementation.getConnectionInfo(); + assertNotNull(connInfo); + assertEquals("dataSource", connInfo.getDataSource()); + + ConnectionProperties connProperties = connInfo.getConnectionProperties(); + assertNull(connProperties); + } + + public void testLoadCompositeUsingConnectionProperties() throws Exception { + XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(COMPOSITE_USING_CONNECTION_PROPERTIES)); + + DASImplementationProcessor dataProcessor = new DASImplementationProcessor(modelFactories, monitor); + + while(true) { + int event = reader.next(); + if(event == XMLStreamConstants.START_ELEMENT && IMPLEMENTATION_DAS.equals(reader.getName())) { + break; + } + } + + DASImplementation implementation = dataProcessor.read(reader); + + assertNotNull(implementation); + assertEquals("config.xml", implementation.getConfig()); + assertEquals("rdb", implementation.getDataAccessType()); + + ConnectionInfo connInfo = implementation.getConnectionInfo(); + assertNotNull(connInfo); + assertNull("dataSource", connInfo.getDataSource()); + + ConnectionProperties connProperties = connInfo.getConnectionProperties(); + assertNotNull(connProperties); + assertEquals("driverClass",connProperties.getDriverClass()); + assertEquals("databaseURL",connProperties.getDatabaseURL()); + assertEquals(1,connProperties.getLoginTimeout().intValue()); + } + + /** + * Test loading an INVALID implementation.das element from a contribution metadata stream + */ + public void testLoadInvalid() throws Exception { + XMLStreamReader reader = xmlFactory.createXMLStreamReader(new StringReader(INVALID_XML)); + + DASImplementationProcessor dataProcessor = new DASImplementationProcessor(modelFactories, monitor); + + while(true) { + int event = reader.next(); + if(event == XMLStreamConstants.START_ELEMENT && IMPLEMENTATION_DAS.equals(reader.getName())) { + break; + } + } + + dataProcessor.read(reader); + Problem problem = ((DefaultMonitorImpl)monitor).getLastLoggedProblem(); + assertNotNull(problem); + assertEquals("DataAccessTypeAttributeMissing", problem.getMessageId()); + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/DASTestCase.java b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/DASTestCase.java new file mode 100644 index 0000000000..7d8b4181c1 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/DASTestCase.java @@ -0,0 +1,73 @@ +/*
+ * 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.implementation.das;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Tests the DAS service
+ *
+ * @version $Rev$ $Date$
+ */
+public class DASTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+ private DAS dasService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("das.composite");
+ dasService = scaDomain.getService(DAS.class, "DASServiceComponent/DAS");
+
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+
+ public void testExecuteCommand() throws Exception {
+ String commandName = "all companies";
+
+ DataObject resultRoot= dasService.executeCommand(commandName);
+ assertNotNull(resultRoot);
+ assertEquals(3, resultRoot.getList("COMPANY").size());
+ }
+
+ public void testExecuteCommandWithFilter() throws Exception {
+ String commandName = "all companies";
+
+ DataObject resultRoot= dasService.executeCommand(commandName, "COMPANY[1]");
+ assertNotNull(resultRoot);
+ }
+
+
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java new file mode 100644 index 0000000000..63d0c92683 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java @@ -0,0 +1,33 @@ +/*
+ * 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.implementation.das.company;
+
+import org.apache.tuscany.sca.implementation.das.annotations.Command;
+
+import commonj.sdo.DataObject;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompanyService {
+ @Command(query="select * from COMPANY")
+ DataObject getCompanies();
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java new file mode 100644 index 0000000000..565a930ebe --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java @@ -0,0 +1,62 @@ +/*
+ * 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.implementation.das.company;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Tests the DAS service
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompanyServiceTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+ private CompanyService dasCompanyService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("company.composite");
+ dasCompanyService = scaDomain.getService(CompanyService.class, "CompanyServiceComponent/CompanyService");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+ public void testGetCompanies() throws Exception {
+ DataObject root = dasCompanyService.getCompanies();
+ assertNotNull(root);
+ String nome = root.getString("COMPANY[1]/NAME");
+ assertEquals("ACME Publishing", root.getString("COMPANY[1]/NAME"));
+ }
+
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.componentType b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.componentType new file mode 100644 index 0000000000..5017cfcffd --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.componentType @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" + xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <service name="CompanyService"> + <interface.java interface="org.apache.tuscany.sca.implementation.das.company.CompanyService"/> + </service> + +</componentType>
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.composite b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.composite new file mode 100644 index 0000000000..ee6104360e --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.composite @@ -0,0 +1,35 @@ +<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://sample/das" + name="das">
+
+ <component name="CompanyServiceComponent">
+ <tuscany:implementation.das config="company.xml" dataAccessType="rdb">
+ <tuscany:connectionInfo>
+ <tuscany:connectionProperties
+ driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ databaseURL="jdbc:derby:target/test-classes/company; create = true"
+ loginTimeout="600000"/>
+ </tuscany:connectionInfo>
+ </tuscany:implementation.das>
+ </component>
+</composite>
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.xml b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.xml new file mode 100644 index 0000000000..350c8b99ce --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/company.xml @@ -0,0 +1,45 @@ +<?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.
+ -->
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd">
+
+ <Command name="getCompanies" SQL="select * from COMPANY" kind="Select"/>
+
+ <Command name="all companies" SQL="select * from COMPANY" kind="Select"/>
+
+ <Command name="all companies and departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID" kind="Select"/>
+
+ <Command name="all departments for company" SQL="select * from COMPANY inner join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/>
+
+ <Command name="company by id with departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/>
+
+ <Table tableName="COMPANY">
+ <Column columnName="ID" primaryKey="true" generated="true"/>
+ </Table>
+
+ <Table tableName="DEPARTMENT">
+ <Column columnName="ID" primaryKey="true" generated="true"/>
+ </Table>
+
+ <Relationship name="departments" primaryKeyTable="COMPANY" foreignKeyTable="DEPARTMENT" many="true">
+ <KeyPair primaryKeyColumn="ID" foreignKeyColumn="COMPANYID"/>
+ </Relationship>
+
+
+</Config>
diff --git a/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/das.composite b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/das.composite new file mode 100644 index 0000000000..e54f4390ac --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-das/src/test/resources/das.composite @@ -0,0 +1,35 @@ +<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://sample/das" + name="das">
+
+ <component name="DASServiceComponent">
+ <tuscany:implementation.das config="company.xml" dataAccessType="rdb">
+ <tuscany:connectionInfo>
+ <tuscany:connectionProperties
+ driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ databaseURL="jdbc:derby:target/test-classes/company; create = true"
+ loginTimeout="600000"/>
+ </tuscany:connectionInfo>
+ </tuscany:implementation.das>
+ </component>
+</composite>
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/LICENSE b/sca-java-1.x/contrib/modules/implementation-data-xml/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/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/sca-java-1.x/contrib/modules/implementation-data-xml/NOTICE b/sca-java-1.x/contrib/modules/implementation-data-xml/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/company.sql b/sca-java-1.x/contrib/modules/implementation-data-xml/company.sql new file mode 100644 index 0000000000..e9f8b06901 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/company.sql @@ -0,0 +1,28 @@ +-- +-- 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. +-- + +DROP TABLE COMPANY; + +CREATE TABLE COMPANY ( + ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, + NAME VARCHAR(30)); + +INSERT INTO COMPANY (NAME) VALUES('ACME Publishing'); +INSERT INTO COMPANY (NAME) VALUES('Do-rite plumbing'); +INSERT INTO COMPANY (NAME) VALUES('MegaCorp');
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/pom.xml b/sca-java-1.x/contrib/modules/implementation-data-xml/pom.xml new file mode 100644 index 0000000000..e2fb965ddb --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/pom.xml @@ -0,0 +1,219 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-data-xml</artifactId>
+ <name>Apache Tuscany SCA Data Implementation Extension</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.das</groupId>
+ <artifactId>tuscany-das-rdb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-engine-helper</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.3.1.4</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>create-db</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${pom.basedir}/target/test-classes/company;create=true</url>
+ <autocommit>true</autocommit>
+ <onError>continue</onError>
+ <onConnectionError>skip</onConnectionError>
+ <delimiter>;</delimiter>
+ <srcFiles>
+ <srcFile>${pom.basedir}/company.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+
+ <!-- Shutdown DB in order to be able to run unit tests -->
+ <execution>
+ <id>shutdown-database-sothat-test-can-run</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${pom.basedir}/target/test-classes/company;shutdown=true</url>
+ <skipOnConnectionError>true</skipOnConnectionError>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.implementation.data.xml</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.implementation.data*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java new file mode 100644 index 0000000000..3ce96e58da --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATA.java @@ -0,0 +1,64 @@ +/*
+ * 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.implementation.data;
+
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * The service interface of a DAS service provided by DAS components.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DATA {
+
+ /**
+ * Retrieve the Database table contents If a id is given, the results will
+ * be filtered to a matching row
+ *
+ * @param id The PK that identifies the row on the table
+ * @return The row content in XML format
+ */
+ XMLStreamReader get(String id);
+
+ /**
+ * Insert new content in the Database
+ *
+ * @param insertStream The insertion in XML format
+ * @return The number of rows affected
+ */
+ int insert(XMLStreamReader insertStream);
+
+ /**
+ * Update the Database table contents
+ *
+ * @param updateStream The updates in XML format
+ * @return The number of rows affected
+ */
+ int update(XMLStreamReader updateStream);
+
+ /**
+ * Delete the Database table contents If a id is given, only a specific row
+ * will be deleted
+ *
+ * @param id The PK that identifies the row on the table
+ * @return The number of rows affected
+ */
+ int delete(String id);
+
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java new file mode 100644 index 0000000000..1dc5673fe5 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATACollection.java @@ -0,0 +1,28 @@ +/* + * 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.implementation.data; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.data.collection.Collection; + +public interface DATACollection extends Collection<String, XMLStreamReader> { + +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java new file mode 100644 index 0000000000..a50ad89b64 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementation.java @@ -0,0 +1,161 @@ +/*
+ * 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.implementation.data;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Implementation;
+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.data.engine.config.ConnectionInfo;
+import org.apache.tuscany.sca.implementation.data.jdbc.JDBCHelper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+
+/**
+ * The model representing a sample DATA implementation in an SCA assembly model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DATAImplementation implements Implementation {
+ private AssemblyFactory assemblyFactory;
+ private JavaInterfaceFactory javaFactory;
+
+ private ConnectionInfo connectionInfo;
+ private List<Service> services = new ArrayList<Service>();
+
+ /**
+ * Constructs a new DAS implementation.
+ */
+ public DATAImplementation(AssemblyFactory assemblyFactory,
+ JavaInterfaceFactory javaFactory) {
+
+ // DATA implementation provides one service per database table
+ // exposing the DATA interface, and have no references and properties
+ this.assemblyFactory = assemblyFactory;
+ this.javaFactory = javaFactory;
+ }
+
+ private void introspectServices( AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+ Connection connection = null;
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ DatabaseMetaData databaseMetaData = connection.getMetaData();
+ ResultSet tables = databaseMetaData.getTables(null, null, "%", null);
+ while(tables.next()) {
+ //create the SCA service for the table
+ Service dataService = assemblyFactory.createService();
+ Service dataCollectionService = assemblyFactory.createService();
+
+ dataService.setName(tables.getString(3)+"_DATA");
+ dataCollectionService.setName(tables.getString(3));
+
+ JavaInterface dataInterface;
+ JavaInterface dataCollectionInterface;
+
+ try {
+ dataInterface = javaFactory.createJavaInterface(DATA.class);
+ dataCollectionInterface = javaFactory.createJavaInterface(DATACollection.class);
+ } catch (InvalidInterfaceException e) {
+ throw new IllegalArgumentException(e);
+ }
+ JavaInterfaceContract dataInterfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract dataCollectionInterfaceContract = javaFactory.createJavaInterfaceContract();
+
+ dataInterfaceContract.setInterface(dataInterface);
+ dataCollectionInterfaceContract.setInterface(dataCollectionInterface);
+
+ dataService.setInterfaceContract(dataInterfaceContract);
+ dataCollectionService.setInterfaceContract(dataCollectionInterfaceContract);
+
+ services.add(dataService);
+ services.add(dataCollectionService);
+
+ }
+ } catch(SQLException e) {
+
+ } finally {
+ JDBCHelper.cleanupResources(connection, null, null);
+ }
+ }
+
+ public ConnectionInfo getConnectionInfo() {
+ return this.connectionInfo;
+ }
+
+ public void setConnectionInfo(ConnectionInfo connectionInfo) {
+ this.connectionInfo = connectionInfo;
+ }
+
+ public ConstrainingType getConstrainingType() {
+ // The sample DATA implementation does not support constrainingTypes
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ // The sample DATA implementation does not support properties
+ return Collections.emptyList();
+ }
+
+ public List<Service> getServices() {
+ if(services == null || services.size() == 0) {
+ introspectServices(assemblyFactory, javaFactory);
+ }
+ return services;
+ }
+
+ public List<Reference> getReferences() {
+ // The sample DATA implementation does not support references
+ return Collections.emptyList();
+ }
+
+ public String getURI() {
+ // The sample DATA implementation does not have a URI
+ return null;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ // The sample DATA implementation does not support constrainingTypes
+ }
+
+ public void setURI(String uri) {
+ // The sample DATA implementation does not have a URI
+ }
+
+ public boolean isUnresolved() {
+ // The sample DATA implementation is always resolved
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample DATA implementation is always resolved
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java new file mode 100644 index 0000000000..d4cf816dbf --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationFactory.java @@ -0,0 +1,44 @@ +/*
+ * 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.implementation.data;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+/**
+ * A default factory for the DATA implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DATAImplementationFactory {
+
+ private AssemblyFactory assemblyFactory;
+ private JavaInterfaceFactory javaFactory;
+
+ public DATAImplementationFactory(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+ this.assemblyFactory = assemblyFactory;
+ this.javaFactory = javaFactory;
+ }
+
+ public DATAImplementation createDASImplementation() {
+ return new DATAImplementation(assemblyFactory, javaFactory);
+ }
+
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java new file mode 100644 index 0000000000..16c5a370ec --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessor.java @@ -0,0 +1,132 @@ +/* + * 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.implementation.data; + +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +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.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.data.engine.ConnectionInfoArtifactProcessor; +import org.apache.tuscany.sca.data.engine.config.ConnectionInfo; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.monitor.Monitor; + + +/** + * Implements a StAX artifact processor for DATA implementations. + * + * The artifact processor is responsible for processing <implementation.data> + * elements in SCA assembly XML composite files and populating the DATA + * implementation model, resolving its references to other artifacts in the SCA + * contribution, and optionally write the model back to SCA assembly XML. + * + * @version $Rev$ $Date$ + */ +public class DATAImplementationProcessor implements StAXArtifactProcessor<DATAImplementation> { + protected static final QName IMPLEMENTATION_DATA_XML = new QName(Constants.SCA10_TUSCANY_NS, "implementation.data.xml"); + + private DATAImplementationFactory dataFactory; + private Monitor monitor; + private StAXArtifactProcessor<ConnectionInfo> connectionInfoProcessor; + + public DATAImplementationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); + this.monitor = monitor; + this.dataFactory = new DATAImplementationFactory(assemblyFactory, javaFactory); + this.connectionInfoProcessor = new ConnectionInfoArtifactProcessor(modelFactories, this.monitor); + } + + public QName getArtifactType() { + // Returns the qname of the XML element processed by this processor + return IMPLEMENTATION_DATA_XML; + } + + public Class<DATAImplementation> getModelType() { + // Returns the type of model processed by this processor + return DATAImplementation.class; + } + + /* + * <component name="CompanyDataComponent"> + * <implementation.data.xml> + * <connectionInfo> + * <connectionProperties + * driverClass="org.apache.derby.jdbc.EmbeddedDriver" + * databaseURL="jdbc:derby:target/test-classes/dastest; create = true" + * loginTimeout="600000"/> + * </connectionInfo> + * </implementation.data> + * </component> + */ + public DATAImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + assert IMPLEMENTATION_DATA_XML.equals(reader.getName()); + + // Read an <implementation.data.xml> element + + // Create an initialize the DAS implementation model + DATAImplementation implementation = dataFactory.createDASImplementation(); + + while (true) { + int event = reader.next(); + switch (event) { + + case START_ELEMENT: + if (ConnectionInfoArtifactProcessor.CONNECTION_INFO.equals(reader.getName())) { + + // Read connection info + ConnectionInfo connectionInfo = (ConnectionInfo) connectionInfoProcessor.read(reader); + implementation.setConnectionInfo(connectionInfo); + } + break; + case XMLStreamConstants.END_ELEMENT: + if (IMPLEMENTATION_DATA_XML.equals(reader.getName())) { + return implementation; + } + break; + } + } + + } + + public void resolve(DATAImplementation impl, ModelResolver resolver) throws ContributionResolveException { + } + + public void write(DATAImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + writer.writeStartElement(IMPLEMENTATION_DATA_XML.getNamespaceURI(), IMPLEMENTATION_DATA_XML.getLocalPart()); + + if (implementation.getConnectionInfo() != null) { + connectionInfoProcessor.write(implementation.getConnectionInfo(), writer); + } + + writer.writeEndElement(); + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java new file mode 100644 index 0000000000..265f250717 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCHelper.java @@ -0,0 +1,215 @@ +/* + * 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.implementation.data.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Properties; + +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +import org.apache.tuscany.das.rdb.exception.DataSourceInitializationException; +import org.apache.tuscany.sca.data.engine.config.ConnectionInfo; + +/** + * JDBC Helper + * - JDBC Connection utility methods + * - JDBC Resource cleanup methods + * + * @version $Rev$ $Date$ + */ +public class JDBCHelper { + + /** + * protected constructor + */ + protected JDBCHelper() { + + } + + /** + * + * @param connectionInfo + * @return + */ + public static Connection getConnection(ConnectionInfo connectionInfo) { + if (connectionInfo.getDataSource() == null && connectionInfo.getConnectionProperties() == null) { + throw new IllegalArgumentException("Not enough information to create Database Connection."); + } + + if(connectionInfo.getDataSource() != null && connectionInfo.getConnectionProperties() != null) { + throw new IllegalArgumentException("Use either dataSource or ConnectionProperties. Can't use both !"); + } + + if(connectionInfo.getDataSource() != null) { + return getDataSourceConnection(connectionInfo); + } else { + return getDriverManagerConnection(connectionInfo); + } + } + + /** + * Initializes a DB connection on a managed environment (e.g inside Tomcat) + * + * @param connectionInfo + * @return + */ + private static Connection getDataSourceConnection(ConnectionInfo connectionInfo) { + Connection connection = null; + + InitialContext ctx; + try { + ctx = new InitialContext(); + } catch (NamingException e) { + throw new RuntimeException(e); + } + try { + DataSource ds = (DataSource) ctx.lookup(connectionInfo.getDataSource()); + try { + connection = ds.getConnection(); + if (connection == null) { + throw new RuntimeException("Could not obtain a Connection from DataSource"); + } + connection.setAutoCommit(false); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } catch (NamingException e) { + throw new RuntimeException(e); + } + + return connection; + } + + /** + * Initialize a DB connection on a J2SE environment + * For more info, see http://java.sun.com/j2se/1.3/docs/guide/jdbc/getstart/drivermanager.html + * + * @param connectionInfo + * @return + */ + private static Connection getDriverManagerConnection(ConnectionInfo connectionInfo) { + Connection connection = null; + + if (connectionInfo.getConnectionProperties() == null) { + throw new RuntimeException("No existing context and no connection properties"); + } + + if (connectionInfo.getConnectionProperties().getDriverClass() == null) { + throw new RuntimeException("No jdbc driver class specified!"); + } + + try { + Properties p = System.getProperties(); + p.put("derby.system.home", "target"); + + //initialize driver and register it with DriverManager + Class.forName(connectionInfo.getConnectionProperties().getDriverClass()); + + //prepare to initialize connection + String databaseUrl = connectionInfo.getConnectionProperties().getDatabaseURL(); + String userName = connectionInfo.getConnectionProperties().getUsername(); + String userPassword = connectionInfo.getConnectionProperties().getPassword(); + int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout(); + + DriverManager.setLoginTimeout(loginTimeout); + if( (userName == null || userName.length() ==0) && (userPassword == null || userPassword.length()==0) ){ + //no username or password supplied + connection = DriverManager.getConnection(databaseUrl); + }else{ + connection = DriverManager.getConnection(databaseUrl, userName, userPassword); + } + + if(connection == null){ + throw new DataSourceInitializationException("Error initializing connection : null"); + } + + //FIXME we should make this flexible, we can't autocommit when participating in transactions + connection.setAutoCommit(true); + + }catch(ClassNotFoundException cnf){ + throw new DataSourceInitializationException("JDBC Driver '" + connectionInfo.getConnectionProperties().getDriverClass() + "' not found", cnf); + }catch(SQLException sqle){ + throw new DataSourceInitializationException(sqle.getMessage(), sqle); + } + + return connection; + } + + /** + * Cleanup and close all JDBC resources in the proper order and ignoring erros + * @param connection The connection to be closed + * @param queryStatement The statement to be closed + * @param resultSet The ResultSet to be closed + */ + public static void cleanupResources(Connection connection, PreparedStatement queryStatement, ResultSet resultSet) { + cleanupResultSet(resultSet); + cleanupPreparedStatement(queryStatement); + cleanupConnection(connection); + } + + /** + * Proper cleanup the ResultSet + * @param resultSet + */ + private static void cleanupResultSet(ResultSet resultSet) { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + // We should log the error. Since we're trying to close, we don't re-throw. + } + } + } + + /** + * Proper cleanup the prepared statement + * @param queryStatement + */ + private static void cleanupPreparedStatement(PreparedStatement queryStatement) { + if (queryStatement != null) { + try { + queryStatement.close(); + } catch (SQLException e) { + // We should log the error. Since we're trying to close, we don't re-throw. + } + } + } + + /** + * proper cleanup the connection + * @param connection + */ + private static void cleanupConnection(Connection connection) { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + // We should log the error. Since we're trying to close, we don't re-throw. + } + } + } + +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java new file mode 100644 index 0000000000..316330243b --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/JDBCResultSetStreamReader.java @@ -0,0 +1,53 @@ +/* + * 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.implementation.data.jdbc; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import javax.xml.stream.XMLStreamException; + +import org.apache.tuscany.sca.databinding.xml.XmlTreeStreamReaderImpl; + +/** + * JDBCResultSetStreamReader perform streaming of database tables as XML + * + * @version $Rev$ $Date$ + */ +public class JDBCResultSetStreamReader extends XmlTreeStreamReaderImpl { + private ResultSet resultSet; + + /** + * @param root + */ + public JDBCResultSetStreamReader(ResultSet resultSet) { + super(new ResultSetXmlNodeImpl(resultSet)); + this.resultSet = resultSet; + } + + @Override + public void close() throws XMLStreamException { + try { + resultSet.close(); + } catch (SQLException e) { + } + } +} + diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java new file mode 100644 index 0000000000..576fe5605d --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/jdbc/ResultSetXmlNodeImpl.java @@ -0,0 +1,251 @@ +/* + * 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.implementation.data.jdbc; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.databinding.xml.SimpleXmlNodeImpl; +import org.apache.tuscany.sca.databinding.xml.XmlNode; + +/** + * @version $Rev$ $Date$ + */ +public class ResultSetXmlNodeImpl implements XmlNode { + private static final String NS = ""; + private static final QName RESULT_SET = new QName(NS, "resultSet"); + private static final QName RECORD = new QName(NS, "record"); + private static final QName COLUMN = new QName(NS, "column"); + private static final QName NAME = new QName(NS, "name"); + + private ResultSet resultSet; + private String[] columnNames; + + /** + * @param resultSet + */ + public ResultSetXmlNodeImpl(ResultSet resultSet) { + super(); + this.resultSet = resultSet; + try { + ResultSetMetaData metaData = resultSet.getMetaData(); + columnNames = new String[metaData.getColumnCount()]; + for (int i = 0; i < columnNames.length; i++) { + columnNames[i] = metaData.getColumnName(i + 1); + } + } catch (SQLException e) { + throw new IllegalStateException(e); + } + } + + /** + * @see org.apache.tuscany.sca.databinding.xml.XmlNode#attributes() + */ + public List<XmlNode> attributes() { + return Collections.emptyList(); + } + + public Type getType() { + return Type.ELEMENT; + } + + + /** + * @see org.apache.tuscany.sca.databinding.xml.XmlNode#children() + */ + public Iterator<XmlNode> children() { + return new ResultSetIteraror(); + } + + private class ResultSetIteraror implements Iterator<XmlNode> { + private Boolean hasNext; + + public ResultSetIteraror() { + } + + public boolean hasNext() { + try { + if (hasNext == null) { + hasNext = resultSet.next(); + } + return hasNext; + } catch (SQLException e) { + throw new IllegalStateException(e); + } + } + + public XmlNode next() { + hasNext(); + hasNext = null; + return new RecordXmlNodeImpl(); + } + + public void remove() { + } + } + + /** + * @see org.apache.tuscany.sca.databinding.xml.XmlNode#getName() + */ + public QName getName() { + return RESULT_SET; + } + + /** + * @see org.apache.tuscany.sca.databinding.xml.XmlNode#getValue() + */ + public String getValue() { + return null; + } + + /** + * @see org.apache.tuscany.sca.databinding.xml.XmlNode#namespaces() + */ + public Map<String, String> namespaces() { + return Collections.emptyMap(); + } + + private class RecordXmlNodeImpl extends XmlNodeImpl { + int index = 0; + + @Override + public Iterator<XmlNode> children() { + return new Iterator<XmlNode>() { + + public boolean hasNext() { + return index < columnNames.length; + } + + public XmlNode next() { + return new ColumnXmlNodeImpl(index++); + } + + public void remove() { + } + + }; + } + + @Override + public QName getName() { + return RECORD; + } + + } + + private class ColumnXmlNodeImpl extends XmlNodeImpl { + private int index; + + /** + * @param index + */ + public ColumnXmlNodeImpl(int index) { + super(); + this.index = index; + } + + @Override + public List<XmlNode> attributes() { + XmlNode attr = new SimpleXmlNodeImpl(NAME, columnNames[index], XmlNode.Type.ATTRIBUTE); + return Arrays.asList(attr); + } + + @Override + public Iterator<XmlNode> children() { + XmlNode[] nodes = {new ValueXmlNodeImpl(index)}; + return Arrays.asList(nodes).iterator(); + } + + @Override + public QName getName() { + return COLUMN; + } + + } + + private class ValueXmlNodeImpl extends XmlNodeImpl { + private int index; + + /** + * @param index + */ + public ValueXmlNodeImpl(int index) { + super(); + this.index = index; + } + + @Override + public String getValue() { + try { + return String.valueOf(resultSet.getObject(index + 1)); + } catch (SQLException e) { + throw new IllegalStateException(e); + } + } + + @Override + public Type getType() { + return Type.CHARACTERS; + } + + } + + private static abstract class XmlNodeImpl implements XmlNode { + + public List<XmlNode> attributes() { + return Collections.emptyList(); + } + + public Iterator<XmlNode> children() { + return null; + } + + public QName getName() { + return null; + } + + public String getValue() { + return null; + } + + public boolean isLeaf() { + return false; + } + + public Map<String, String> namespaces() { + return Collections.emptyMap(); + } + + public Type getType() { + return Type.ELEMENT; + } + + } + + +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java new file mode 100644 index 0000000000..bbd963922c --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProvider.java @@ -0,0 +1,98 @@ +/*
+ * 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.implementation.data.provider;
+
+import org.apache.tuscany.sca.implementation.data.DATAImplementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * DATA Implementation provider
+ *
+ * @version $Rev$ $Date$
+ */
+public class DATAImplementationProvider implements ImplementationProvider {
+ //private RuntimeComponent component;
+ private DATAImplementation implementation;
+
+ /**
+ * Constructs a new DATA implementation.
+ */
+ public DATAImplementationProvider(RuntimeComponent component, DATAImplementation implementation) {
+ //this.component = component;
+ this.implementation = implementation;
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ String operationName = operation.getName();
+ String tableName = service.getName();
+
+ String interfaceFullName = operation.getInterface().toString();
+ int index = interfaceFullName.lastIndexOf(".") + 1;
+ String interfaceName = interfaceFullName.substring(index, interfaceFullName.length());
+
+ if (interfaceName.equals("DATACollection")) {
+
+ if (operationName.equals("getAll")) {
+ return new DATAInvoker.GetAllInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("query")) {
+ return new DATAInvoker.QueryInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("post")) {
+ return new DATAInvoker.PostInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("get")) {
+ return new DATAInvoker.GetInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("put")) {
+ return new DATAInvoker.PutInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("delete")) {
+ return new DATAInvoker.DeleteInvoker(operation, implementation.getConnectionInfo(), tableName);
+ }
+
+ } else if (interfaceName.equals("DATA")) {
+
+ tableName = tableName.split("_")[0];
+
+ if (operationName.equals("get")) {
+ return new DATAInvoker.GetDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("insert")) {
+ return new DATAInvoker.InsertDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("update")) {
+ return new DATAInvoker.UpdateDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
+ } else if (operationName.equals("delete")) {
+ return new DATAInvoker.DeleteDATAInvoker(operation, implementation.getConnectionInfo(), tableName);
+ }
+ }
+
+ return new DATAInvoker(operation, implementation.getConnectionInfo(), tableName);
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ // System.out.println("Starting " + component.getName());
+ }
+
+ public void stop() {
+ // System.out.println("Stopping " + component.getName());
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java new file mode 100644 index 0000000000..e1af9ecd92 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAImplementationProviderFactory.java @@ -0,0 +1,47 @@ +/*
+ * 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.implementation.data.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.data.DATAImplementation;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Factory for DATA Implementation Provider
+ *
+ * @version $Rev$ $Date$
+ */
+public class DATAImplementationProviderFactory implements ImplementationProviderFactory<DATAImplementation> {
+
+ /**
+ * Constructs a new DATA implementation.
+ */
+ public DATAImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, DATAImplementation implementation) {
+ return new DATAImplementationProvider(component, implementation);
+ }
+
+ public Class<DATAImplementation> getModelType() {
+ return DATAImplementation.class;
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java new file mode 100644 index 0000000000..e74bf4d134 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/java/org/apache/tuscany/sca/implementation/data/provider/DATAInvoker.java @@ -0,0 +1,583 @@ +/*
+ * 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.implementation.data.provider;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.data.engine.config.ConnectionInfo;
+import org.apache.tuscany.sca.implementation.data.jdbc.JDBCHelper;
+import org.apache.tuscany.sca.implementation.data.jdbc.JDBCResultSetStreamReader;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Implements a target invoker for DAS component implementations.
+ *
+ * The target invoker is responsible for dispatching invocations to the particular
+ * component implementation logic. The current component implementation will
+ * dispatch calls to the DAS APIs to retrieve the requested data from the back-end store
+ *
+ * @version $Rev$ $Date$
+ */
+public class DATAInvoker implements Invoker {
+
+ protected final Operation operation;
+ protected final ConnectionInfo connectionInfo;
+ protected final String table;
+
+ public DATAInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ this.operation = operation;
+ this.connectionInfo = connectionInfo;
+ this.table = table;
+ }
+
+ public Message invoke(Message msg) {
+ // Shouldn't get here, as the only supported operations
+ // are the ones defined DATA interface and implemented
+ // by specific invoker subclasses
+
+ throw new UnsupportedOperationException(operation.getName());
+ }
+
+ /****************************************************************
+ *
+ * Internal invoker implementations for each supported operation
+ *
+ *****************************************************************/
+ /**
+ * GetAll operation invoker
+ */
+ public static class GetAllInvoker extends DATAInvoker {
+
+ public GetAllInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ return msg;
+ }
+ }
+
+ /**
+ * Query operation invoker
+ */
+ public static class QueryInvoker extends DATAInvoker {
+
+ public QueryInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ return msg;
+ }
+ }
+
+ /**
+ * Post operation invoker
+ */
+ public static class PostInvoker extends DATAInvoker {
+
+ public PostInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ StringBuilder sqlInsert = new StringBuilder();
+ XMLStreamReader insertStream = (XMLStreamReader) ((Object[]) msg.getBody())[1];
+
+ if (insertStream == null) {
+ throw new IllegalArgumentException("The XMLStreamReader \"insertStream\" must not be null");
+ }
+
+
+ Connection connection = null;
+ PreparedStatement inStmt = null;
+
+ List<String> colNames = new ArrayList<String>();
+ List<String> values = new ArrayList<String>();
+
+ int result = 0;
+ try {
+
+ connection = JDBCHelper.getConnection(connectionInfo);
+
+ while (insertStream.hasNext()) {
+
+ insertStream.next();
+ if (insertStream.isStartElement()) {
+ if (insertStream.getLocalName().equals("record")) {
+ sqlInsert.append("INSERT INTO " + this.table + " (");
+ } else if (insertStream.getLocalName().equals("column")) {
+ colNames.add(insertStream.getAttributeValue(0));
+ insertStream.next();
+ if (insertStream.isCharacters()) {
+ values.add(insertStream.getText());
+ }
+ }
+ } else if (insertStream.isEndElement() && insertStream.getLocalName().equals("record")) {
+ for (String c : colNames) {
+ sqlInsert.append(" " + c + ",");
+ }
+
+ sqlInsert.deleteCharAt(sqlInsert.length() - 1);
+ sqlInsert.append(" ) VALUES (");
+
+ for (String v : values) {
+ sqlInsert.append(" '" + v + "',");
+ }
+
+ sqlInsert.deleteCharAt(sqlInsert.length() - 1);
+ sqlInsert.append(" )");
+
+ inStmt = connection.prepareStatement(sqlInsert.toString());
+
+ result += inStmt.executeUpdate();
+
+ // Clean up resources
+ inStmt.close();
+ sqlInsert.delete(0, sqlInsert.length());
+ values.clear();
+ colNames.clear();
+ }
+ }
+ } catch (XMLStreamException e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } catch (SQLException sqle) {
+ sqle.printStackTrace();
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ JDBCHelper.cleanupResources(connection, inStmt, null);
+ }
+
+ msg.setBody(Integer.toString(result));
+ return msg;
+ }
+ }
+
+ /**
+ * Get operation invoker
+ */
+ public static class GetInvoker extends DATAInvoker {
+
+ public GetInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Get an entry
+ String sqlQuery = null;
+ String id = (String) ((Object[]) msg.getBody())[0];
+
+ if (id == null) {
+ sqlQuery = "SELECT * FROM " + this.table;
+ } else {
+ sqlQuery = "SELECT * FROM " + this.table + " WHERE ID = " + id;
+ }
+
+ Connection connection = null;
+ PreparedStatement queryStatement = null;
+ ResultSet resultSet = null;
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ queryStatement = connection.prepareStatement(sqlQuery);
+ resultSet = queryStatement.executeQuery();
+
+
+ } catch (SQLException sqle) {
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
+ } finally {
+ //default we leave the connection open to pass to the JDBCStreamReader
+ }
+
+ msg.setBody(new JDBCResultSetStreamReader(resultSet));
+ return msg;
+ }
+ }
+
+ /**
+ * Put operation invoker
+ */
+ public static class PutInvoker extends DATAInvoker {
+
+ public PutInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ XMLStreamReader updateStream = (XMLStreamReader) ((Object[]) msg.getBody())[1];
+
+ if (updateStream == null) {
+ throw new IllegalArgumentException("The XMLStreamReader \"updateStream\" must not be null");
+ }
+
+ Connection connection = null;
+ PreparedStatement upStmt = null;
+
+ String id = null;
+ String columnName = null;
+ String newValue = null;
+ int result = 0;
+
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ while (updateStream.hasNext()) {
+ updateStream.next();
+
+ if (updateStream.isStartElement() && updateStream.getLocalName().equals("column")) {
+ columnName = updateStream.getAttributeValue(0);
+ updateStream.next();
+ if (updateStream.isCharacters()) {
+ if (columnName.equals("ID")) {
+ id = updateStream.getText();
+ } else {
+ newValue = updateStream.getText();
+
+ upStmt = connection.prepareStatement("UPDATE " + this.table + " SET " + columnName + " = '" + newValue + "' WHERE ID = " + id);
+
+ result += upStmt.executeUpdate();
+ upStmt.close();
+ }
+ }
+ }
+ }
+ } catch (XMLStreamException e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } catch (SQLException sqle) {
+ sqle.printStackTrace();
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ JDBCHelper.cleanupResources(connection, upStmt, null);
+ }
+
+ msg.setBody(result);
+ return msg;
+ }
+ }
+
+ /**
+ * Delete operation invoker
+ */
+ public static class DeleteInvoker extends DATAInvoker {
+
+ public DeleteInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Get an entry
+ String sqlDelete = null;
+ String id = (String) ((Object[]) msg.getBody())[0];
+
+ if (id == null) {
+ sqlDelete = "DELETE FROM " + this.table;
+ } else {
+ sqlDelete = "DELETE FROM " + this.table + " WHERE ID = " + id;
+ }
+
+ Connection connection = null;
+ PreparedStatement deleteStatement = null;
+ int result = -1;
+
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ deleteStatement = connection.prepareStatement(sqlDelete);
+ result = deleteStatement.executeUpdate();
+
+ } catch (SQLException sqle) {
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ JDBCHelper.cleanupResources(connection, deleteStatement, null);
+ }
+
+ msg.setBody(result);
+ return msg;
+ }
+ }
+ /**
+ * Get operation invoker
+ *
+ * @version $Rev$ $Date$
+ */
+ public static class GetDATAInvoker extends DATAInvoker {
+
+ public GetDATAInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Get an entry
+ String sqlQuery = null;
+ String id = (String) ((Object[]) msg.getBody())[0];
+
+ if (id == null) {
+ sqlQuery = "SELECT * FROM " + this.table;
+ } else {
+ sqlQuery = "SELECT * FROM " + this.table + " WHERE ID = " + id;
+ }
+
+ Connection connection = null;
+ PreparedStatement queryStatement = null;
+ ResultSet resultSet = null;
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ queryStatement = connection.prepareStatement(sqlQuery);
+ resultSet = queryStatement.executeQuery();
+
+
+ } catch (SQLException sqle) {
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ JDBCHelper.cleanupResources(connection, queryStatement, resultSet);
+ } finally {
+ //default we leave the connection open to pass to the JDBCStreamReader
+ }
+
+ msg.setBody(new JDBCResultSetStreamReader(resultSet));
+ return msg;
+ }
+ }
+
+ /**
+ * Insert operation invoker
+ */
+ public static class InsertDATAInvoker extends DATAInvoker {
+
+ public InsertDATAInvoker(Operation operation,
+ ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) throws IllegalArgumentException {
+ StringBuilder sqlInsert = new StringBuilder();
+ XMLStreamReader insertStream = (XMLStreamReader) ((Object[]) msg.getBody())[0];
+
+ if (insertStream == null) {
+ throw new IllegalArgumentException("The XMLStreamReader \"insertStream\" must not be null");
+ }
+
+
+ Connection connection = null;
+ PreparedStatement inStmt = null;
+
+ List<String> colNames = new ArrayList<String>();
+ List<String> values = new ArrayList<String>();
+
+ int result = 0;
+ try {
+
+ connection = JDBCHelper.getConnection(connectionInfo);
+
+ while (insertStream.hasNext()) {
+
+ insertStream.next();
+ if (insertStream.isStartElement()) {
+ if (insertStream.getLocalName().equals("record")) {
+ sqlInsert.append("INSERT INTO " + this.table + " (");
+ } else if (insertStream.getLocalName().equals("column")) {
+ colNames.add(insertStream.getAttributeValue(0));
+ insertStream.next();
+ if (insertStream.isCharacters()) {
+ values.add(insertStream.getText());
+ }
+ }
+ } else if (insertStream.isEndElement() && insertStream.getLocalName().equals("record")) {
+ for (String c : colNames) {
+ sqlInsert.append(" " + c + ",");
+ }
+
+ sqlInsert.deleteCharAt(sqlInsert.length() - 1);
+ sqlInsert.append(" ) VALUES (");
+
+ for (String v : values) {
+ sqlInsert.append(" '" + v + "',");
+ }
+
+ sqlInsert.deleteCharAt(sqlInsert.length() - 1);
+ sqlInsert.append(" )");
+
+ inStmt = connection.prepareStatement(sqlInsert.toString());
+ result += inStmt.executeUpdate();
+
+ // Clean up resources
+ inStmt.close();
+ sqlInsert.delete(0, sqlInsert.length());
+ values.clear();
+ colNames.clear();
+ }
+ }
+ } catch (XMLStreamException e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } catch (SQLException sqle) {
+ sqle.printStackTrace();
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ JDBCHelper.cleanupResources(connection, inStmt, null);
+ }
+
+ msg.setBody(result);
+ return msg;
+ }
+ }
+
+ /**
+ * Update operation invoker
+ */
+ public static class UpdateDATAInvoker extends DATAInvoker {
+
+ public UpdateDATAInvoker(Operation operation,
+ ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) throws IllegalArgumentException {
+
+ XMLStreamReader updateStream = (XMLStreamReader) ((Object[]) msg.getBody())[0];
+
+ if (updateStream == null) {
+ throw new IllegalArgumentException("The XMLStreamReader \"updateStream\" must not be null");
+ }
+
+ Connection connection = null;
+ PreparedStatement upStmt = null;
+
+ String id = null;
+ String columnName = null;
+ String newValue = null;
+ int result = 0;
+
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ while (updateStream.hasNext()) {
+ updateStream.next();
+
+ if (updateStream.isStartElement() && updateStream.getLocalName().equals("column")) {
+ columnName = updateStream.getAttributeValue(0);
+ updateStream.next();
+ if (updateStream.isCharacters()) {
+ if (columnName.equals("ID")) {
+ id = updateStream.getText();
+ } else {
+ newValue = updateStream.getText();
+
+ upStmt = connection.prepareStatement("UPDATE " + this.table + " SET " + columnName + " = '" + newValue + "' WHERE ID = " + id);
+
+ result += upStmt.executeUpdate();
+ upStmt.close();
+ }
+ }
+ }
+ }
+ } catch (XMLStreamException e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } catch (SQLException sqle) {
+ sqle.printStackTrace();
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ JDBCHelper.cleanupResources(connection, upStmt, null);
+ }
+
+ msg.setBody(result);
+ return msg;
+ }
+ }
+
+ /**
+ * Delete operation invoker
+ */
+ public static class DeleteDATAInvoker extends DATAInvoker {
+
+ public DeleteDATAInvoker(Operation operation, ConnectionInfo connectionInfo, String table) {
+ super(operation, connectionInfo, table);
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+
+ // Get an entry
+ String sqlDelete = null;
+ String id = (String) ((Object[]) msg.getBody())[0];
+
+ if (id == null) {
+ sqlDelete = "DELETE FROM " + this.table;
+ } else {
+ sqlDelete = "DELETE FROM " + this.table + " WHERE ID = " + id;
+ }
+
+ Connection connection = null;
+ PreparedStatement deleteStatement = null;
+ int result = -1;
+
+ try {
+ connection = JDBCHelper.getConnection(connectionInfo);
+ deleteStatement = connection.prepareStatement(sqlDelete);
+ result = deleteStatement.executeUpdate();
+
+ } catch (SQLException sqle) {
+ msg.setFaultBody(new ServiceRuntimeException(sqle.getCause()));
+ } catch (Exception e) {
+ msg.setFaultBody(new ServiceRuntimeException(e));
+ } finally {
+ JDBCHelper.cleanupResources(connection, deleteStatement, null);
+ }
+
+ msg.setBody(result);
+ return msg;
+ }
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..5cd3334e3f --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# 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. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.implementation.data.DATAImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.data.xml,model=org.apache.tuscany.sca.implementation.data.DATAImplementation diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..e20f1a6379 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -0,0 +1,19 @@ +# 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.
+
+# Implementation class for the implementation extension
+org.apache.tuscany.sca.implementation.data.provider.DATAImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.data.DATAImplementation
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java new file mode 100644 index 0000000000..458025dd66 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATACollectionTestCaseFIXME.java @@ -0,0 +1,118 @@ +/* + * 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.implementation.data; + +import java.io.FileInputStream; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; +import junit.framework.TestCase; +import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.implementation.data.DATACollection; + +public class DATACollectionTestCaseFIXME extends TestCase { + + private SCADomain scaDomain; + private DATACollection dataService; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("data.composite"); + dataService = scaDomain.getService(DATACollection.class, "DataComponent/COMPANY"); + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testInsert() throws Exception { + System.out.println(">testInsert"); + + //Read and process the XML file + FileInputStream fileInputStream = new FileInputStream("src/test/resources/insert.xml"); + XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + String result = dataService.post(null, reader); + assertEquals(result, "2"); + + System.out.println("Number of rows inserted: " + result); + + reader.close(); + } + + public void testGet() throws Exception { + + System.out.println(">testGet"); + + XMLStreamReader reader = dataService.get(null); + assertNotNull(reader); + String xml = new XMLStreamReader2String().transform(reader, null); + System.out.println(xml); + reader.close(); + } + + public void testUpdate() throws Exception { + + System.out.println(">testUpdate"); + + //Read and process the XML file + FileInputStream fileInputStream = new FileInputStream("src/test/resources/update.xml"); + XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + dataService.put(null,reader); + + reader.close(); + } + + public void testGetByID() throws Exception { + System.out.println(">testGetByID"); + + Integer companyID = new Integer(4); + + XMLStreamReader reader = dataService.get(companyID.toString()); + assertNotNull(reader); + String xml = new XMLStreamReader2String().transform(reader, null); + System.out.println(xml); + reader.close(); + } + + public void testDeleteByID() throws Exception { + System.out.println(">testDeleteByID"); + + Integer companyID = new Integer(4); + dataService.delete(companyID.toString()); + } + + public void testDelete() throws Exception { + System.out.println(">testDelete"); + + dataService.delete(null); + + System.out.println("recreating database..."); + //Helper.createDB(); + System.out.println("done!"); + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java new file mode 100644 index 0000000000..dcf87d8c68 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATAImplementationProcessorTestCase.java @@ -0,0 +1,133 @@ +/* + * 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.implementation.data; + +import java.io.StringReader; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.SCABindingFactory; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +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.UtilityExtensionPoint; +import org.apache.tuscany.sca.data.engine.config.ConnectionInfo; +import org.apache.tuscany.sca.data.engine.config.ConnectionProperties; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl; +import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory; + +/** + * @version $Rev: 538445 $ $Date: 2007-05-15 23:20:37 -0700 (Tue, 15 May 2007) $ + */ +public class DATAImplementationProcessorTestCase extends TestCase { + + protected static final QName IMPLEMENTATION_DATA = new QName(Constants.SCA10_TUSCANY_NS, "implementation.data.xml"); + + private static final String COMPOSITE_USING_DATASOURCE = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">" + + " <component name=\"DataComponent\">" + + " <tuscany:implementation.data.xml>" + + " <tuscany:connectionInfo datasource=\"dataSource\"/>" + + " </tuscany:implementation.data.xml>" + + " </component>" + + "</composite>"; + + private static final String COMPOSITE_USING_CONNECTION_PROPERTIES = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://data\" name=\"data\">" + + " <component name=\"DataComponent\">" + + " <tuscany:implementation.data.xml>" + + " <tuscany:connectionInfo>" + + " <tuscany:connectionProperties" + + " driverClass=\"driverClass\"" + + " databaseURL=\"databaseURL\"" + + " loginTimeout=\"1\"/>" + + " </tuscany:connectionInfo>" + + " </tuscany:implementation.data.xml>" + + " </component>" + + "</composite>"; + + private XMLInputFactory inputFactory; + private StAXArtifactProcessor<Object> staxProcessor; + private CompositeBuilder compositeBuilder; + + @Override + protected void setUp() throws Exception { + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); + + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class); + IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class); + compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper, null); + } + + public void testLoadCompositeUsingDatasource() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_USING_DATASOURCE)); + + Composite composite = (Composite)staxProcessor.read(reader); + DATAImplementation implementation = (DATAImplementation)composite.getComponents().get(0).getImplementation(); + assertNotNull(implementation); + + ConnectionInfo connInfo = implementation.getConnectionInfo(); + assertNotNull(connInfo); + assertEquals("dataSource", connInfo.getDataSource()); + + ConnectionProperties connProperties = connInfo.getConnectionProperties(); + assertNull(connProperties); + } + + public void testLoadCompositeUsingConnectionProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_USING_CONNECTION_PROPERTIES)); + + Composite composite = (Composite)staxProcessor.read(reader); + DATAImplementation implementation = (DATAImplementation)composite.getComponents().get(0).getImplementation(); + assertNotNull(implementation); + + ConnectionInfo connInfo = implementation.getConnectionInfo(); + assertNotNull(connInfo); + assertNull("dataSource", connInfo.getDataSource()); + + ConnectionProperties connProperties = connInfo.getConnectionProperties(); + assertNotNull(connProperties); + assertEquals("driverClass",connProperties.getDriverClass()); + assertEquals("databaseURL",connProperties.getDatabaseURL()); + assertEquals(1,connProperties.getLoginTimeout().intValue()); + } +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java new file mode 100644 index 0000000000..4010cb63d3 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/DATATestCase.java @@ -0,0 +1,133 @@ +/* + * 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.implementation.data; + +import java.io.FileInputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.implementation.data.DATA; + +/** + * Tests the DAS service + * + * @version $Rev$ $Date$ + */ +public class DATATestCase extends TestCase { + private SCADomain scaDomain; + private DATA dataService; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("data.composite"); + dataService = scaDomain.getService(DATA.class, "DataComponent/COMPANY_DATA"); + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testInsert() throws Exception { + System.out.println(">testInsert"); + + //Read and process the XML file + FileInputStream fileInputStream = new FileInputStream("src/test/resources/insert.xml"); + XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + int result = dataService.insert(reader); + assertEquals(result,2); + + System.out.println("Number of rows inserted: "+result); + + reader.close(); + } + + public void testGet() throws Exception { + + System.out.println(">testGet"); + + XMLStreamReader reader = dataService.get(null); + assertNotNull(reader); + String xml = new XMLStreamReader2String().transform(reader, null); + System.out.println(xml); + reader.close(); + } + + public void testUpdate() throws Exception { + + System.out.println(">testUpdate"); + + //Read and process the XML file + FileInputStream fileInputStream = new FileInputStream("src/test/resources/update.xml"); + XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(fileInputStream); + + int result = dataService.update(reader); + assertEquals(result,1); + System.out.println("Number of rows affected: "+result); + + reader.close(); + } + + public void testGetByID() throws Exception { + System.out.println(">testGetByID"); + + Integer companyID = new Integer(4); + + XMLStreamReader reader = dataService.get(companyID.toString()); + assertNotNull(reader); + String xml = new XMLStreamReader2String().transform(reader, null); + System.out.println(xml); + reader.close(); + } + + public void testDeleteByID() throws Exception { + System.out.println(">testDeleteByID"); + + Integer companyID = new Integer(4); + int result = dataService.delete(companyID.toString()); + assertEquals(result,1); + System.out.println("Number of rows deleted: "+result); + } + + public void testDelete() throws Exception { + System.out.println(">testDelete"); + + int result = dataService.delete(null); + assertEquals(result,4); + System.out.println("Number of rows deleted: "+result); + + System.out.println("recreating database..."); + //Helper.createDB(); + System.out.println("done!"); + } + +} diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java new file mode 100644 index 0000000000..7f0707c0bc --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java @@ -0,0 +1,62 @@ +/*
+ * 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.implementation.data.companyFeed;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
+import org.apache.tuscany.sca.implementation.data.DATA;
+import org.osoa.sca.annotations.Reference;
+
+import commonj.sdo.DataObject;
+
+public class CompanyFeed implements Collection<String, DataObject> {
+
+ @Reference
+ protected DATA dataService;
+
+ public Entry<String, DataObject>[] getAll() {
+ return null;
+ }
+
+ public DataObject get(String id) throws NotFoundException{
+
+ DataObject data = null;//dataService.get(id);
+ if(data == null) {
+ throw new NotFoundException();
+ } else {
+ return data;
+ }
+ }
+
+ public void delete(String id) throws NotFoundException {
+ }
+
+ public String post(String key, DataObject item) {
+ return null;
+ }
+
+ public void put(String key, DataObject item) throws NotFoundException {
+ }
+
+ public Entry<String, DataObject>[] query(String queryString) {
+ return null;
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java new file mode 100644 index 0000000000..b72ff89e3b --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeedTestCaseFIXME.java @@ -0,0 +1,51 @@ +/*
+ * 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.implementation.data.companyFeed;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * @version $Rev: 543175 $ $Date: 2007-05-31 09:09:12 -0700 (Thu, 31 May 2007) $
+ */
+public class CompanyFeedTestCaseFIXME extends TestCase {
+ private SCADomain scaDomain;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ scaDomain = SCADomain.newInstance("data-feed.composite");
+ //System.in.read();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ scaDomain.close();
+ }
+
+ public void testPing() throws IOException {
+ new Socket("127.0.0.1", 8085);
+ }
+
+}
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/data-feed.composite b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/data-feed.composite new file mode 100644 index 0000000000..40c755b134 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/data-feed.composite @@ -0,0 +1,50 @@ +<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + targetNamespace="http://data" + name="data-feed">
+
+
+ <service name="CompanyFeed" promote="CompanyFeedComponent">
+ <tuscany:binding.atom uri="http://localhost:8085/comnpanyfeed/*"/>
+ </service>
+
+ <component name="CompanyFeedComponent">
+ <implementation.java class="org.apache.tuscany.sca.implementation.data.companyFeed.CompanyFeed"/>
+ <reference name="dataService" target="CompanyDataComponent"/>
+ </component>
+
+ <!-- service name="CompanyDataServiceComponent" promote="CompanyDataComponent">
+ <binding.atom uri="http://localhost:8085/comnpanyfeed/"/>
+ </service -->
+
+ <component name="CompanyDataComponent">
+ <tuscany:implementation.data.xml table="company">
+ <tuscany:connectionInfo>
+ <tuscany:connectionProperties
+ driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ databaseURL="jdbc:derby:target/test-classes/company; create = true"
+ loginTimeout="600000"/>
+ </tuscany:connectionInfo>
+ </tuscany:implementation.data.xml>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/data.composite b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/data.composite new file mode 100644 index 0000000000..f30b15e34c --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/data.composite @@ -0,0 +1,36 @@ +<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://data"
+ name="data">
+
+ <component name="DataComponent">
+ <tuscany:implementation.data.xml>
+ <tuscany:connectionInfo>
+ <tuscany:connectionProperties
+ driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ databaseURL="jdbc:derby:target/test-classes/company; create = true"
+ loginTimeout="600000"/>
+ </tuscany:connectionInfo>
+ </tuscany:implementation.data.xml>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/insert.xml b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/insert.xml new file mode 100644 index 0000000000..c0a5ada4bf --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/insert.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<resultSet> + <record> + <column name="NAME">New Coorporation I</column> + </record> + <record> + <column name="NAME">New Coorporation II</column> + </record> +</resultSet> diff --git a/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/update.xml b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/update.xml new file mode 100644 index 0000000000..c6cef75274 --- /dev/null +++ b/sca-java-1.x/contrib/modules/implementation-data-xml/src/test/resources/update.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<result_set> + <record> + <column name="ID">4</column> + <column name="NAME">Update Coorporation</column> + </record> +</result_set> diff --git a/sca-java-1.x/contrib/modules/node-dynamic/LICENSE b/sca-java-1.x/contrib/modules/node-dynamic/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-dynamic/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/sca-java-1.x/contrib/modules/node-dynamic/NOTICE b/sca-java-1.x/contrib/modules/node-dynamic/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-dynamic/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/contrib/modules/node-dynamic/pom.xml b/sca-java-1.x/contrib/modules/node-dynamic/pom.xml new file mode 100644 index 0000000000..6afaa70c14 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-dynamic/pom.xml @@ -0,0 +1,93 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-node-dynamic</artifactId>
+ <name>Apache Tuscany SCA Dynamic Node</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-jms</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.tuscany.sca.node.DynamicNodeMain</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+
+ <configuration>
+ <instructions>
+ <Bundle-Version>${tuscany.version}</Bundle-Version>
+ <Bundle-SymbolicName>org.apache.tuscany.sca.node.dynamic</Bundle-SymbolicName>
+ <Bundle-Description>${pom.name}</Bundle-Description>
+ <Export-Package>org.apache.tuscany.sca.node*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/node-dynamic/src/main/java/org/apache/tuscany/sca/node/DynamicNodeMain.java b/sca-java-1.x/contrib/modules/node-dynamic/src/main/java/org/apache/tuscany/sca/node/DynamicNodeMain.java new file mode 100644 index 0000000000..af6155e500 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-dynamic/src/main/java/org/apache/tuscany/sca/node/DynamicNodeMain.java @@ -0,0 +1,50 @@ +/*
+ * 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.node;
+
+import java.io.File;
+
+public class DynamicNodeMain {
+
+ /**
+ * Start an SCA node
+ * @param args a list of contribution jars for the node to run
+ */
+ public static void main(String[] args) throws Exception {
+
+ SCAContribution[] contributions = new SCAContribution[args.length];
+ for (int i=0; i<args.length; i++) {
+ File f = new File(args[i]);
+ if (!f.exists()) {
+ System.err.println("contribution not found: " + f);
+ System.exit(1);
+ }
+ contributions[i] = new SCAContribution(args[i], f.toURL().toString());
+ }
+
+ SCANode node = SCANodeFactory.newInstance().createSCANode(null, contributions);
+ node.start();
+
+ System.out.println("Hit enter to stop node...");
+ System.in.read();
+
+ node.stop();
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/node-dynamic/src/main/resources/log4j.properties b/sca-java-1.x/contrib/modules/node-dynamic/src/main/resources/log4j.properties new file mode 100644 index 0000000000..e5b3f8ebfb --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-dynamic/src/main/resources/log4j.properties @@ -0,0 +1,51 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# +# +log4j.rootLogger=INFO, stdout, out +log4j.logger.org.apache.activemq.spring=WARN +log4j.logger.org.springframework=WARN +log4j.logger.org.apache.xbean.spring=WARN + +# When debugging or reporting problems to the ActiveMQ team, +# comment out the above lines and uncomment the next. + +#log4j.rootLogger=DEBUG, out, stdout + +# Or for more fine grained debug logging uncomment one of these +#log4j.logger.org.apache.activemq=DEBUG +#log4j.logger.org.apache.camel=DEBUG + + + +#The logging properties used during tests.. +# CONSOLE appender not used by default +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%-5p %-30.30c{1} - %m%n +#log4j.appender.stdout.threshold=INFO + +# File appender +log4j.appender.out=org.apache.log4j.RollingFileAppender +log4j.appender.out.file=${activemq.base}/data/activemq.log +log4j.appender.out.maxFileSize=1024KB +log4j.appender.out.maxBackupIndex=5 +log4j.appender.out.append=true +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/LICENSE b/sca-java-1.x/contrib/modules/node-launcher-equinox/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/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/sca-java-1.x/contrib/modules/node-launcher-equinox/NOTICE b/sca-java-1.x/contrib/modules/node-launcher-equinox/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/pom.xml b/sca-java-1.x/contrib/modules/node-launcher-equinox/pom.xml new file mode 100644 index 0000000000..7378edc5e9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/pom.xml @@ -0,0 +1,125 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-node-launcher-equinox</artifactId> + <name>Apache Tuscany SCA Node Equinox OSGi Launcher</name> + + <dependencies> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> <!-- To be compatible with Jetty 6 --> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.eclipse</groupId> + <artifactId>osgi</artifactId> + <version>3.3.0-v20070530</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.eclipse.core</groupId> + <artifactId>runtime</artifactId> + <version>3.3.100-v20070530</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-node-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-extensibility-equinox</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-domain-manager</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-http-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>org.apache.tuscany.sca.node.equinox.launcher.NodeMain</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.node.launcher.equinox</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <!-- + <Bundle-Activator>org.apache.tuscany.sca.node.equinox.launcher.LauncherBundleActivator</Bundle-Activator> + --> + <Export-Package>org.apache.tuscany.sca.node.equinox.launcher*</Export-Package> + <Eclipse-AutoStart>true</Eclipse-AutoStart> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java new file mode 100644 index 0000000000..892412b395 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java @@ -0,0 +1,48 @@ +/* + * 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.node.equinox.launcher; + +/** + * Represents an SCA contribution uri + location. + * + * @version $Rev$ $Date$ + */ +public final class Contribution { + private String uri; + private String location; + + /** + * Constructs a new SCA contribution. + * + * @param uri + * @param location + */ + public Contribution(String uri, String location) { + this.uri = uri; + this.location = location; + } + + public String getURI() { + return uri; + } + + public String getLocation() { + return location; + } +}
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java new file mode 100644 index 0000000000..61187eecac --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java @@ -0,0 +1,172 @@ +/* + * 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.node.equinox.launcher; + +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.domainManager; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Simple launcher for the SCA domain manager. + * + * @version $Rev$ $Date$ + */ +public class DomainManagerLauncher { + + static final Logger logger = Logger.getLogger(DomainManagerLauncher.class.getName()); + + /** + * Constructs a new DomainManagerLauncher. + */ + private DomainManagerLauncher() { + } + + /** + * Returns a new launcher instance. + * + * @return a new launcher instance + */ + public static DomainManagerLauncher newInstance() { + return new DomainManagerLauncher(); + } + + /** + * Creates a new DomainManager. + * + * @return a new DomainManager + * @throws LauncherException + */ + public <T> T createDomainManager() throws LauncherException { + return (T)domainManager("."); + } + + /** + * Creates a new DomainManager. + * + * @param rootDirectory the domain's root configuration directory + * + * @return a new DomainManager + * @throws LauncherException + */ + public <T> T createDomainManager(String rootDirectory) throws LauncherException { + return (T)domainManager(rootDirectory); + } + + public static void main(String[] args) throws Exception { + logger.info("Apache Tuscany SCA Domain Manager is starting..."); + + // Create a launcher + DomainManagerLauncher launcher = newInstance(); + + EquinoxHost equinox = null; + Object domainManager = null; + ShutdownThread shutdown = null; + try { + + // Start the OSGi host + equinox = new EquinoxHost(); + equinox.start(); + + // Start the domain manager + domainManager = launcher.createDomainManager(); + try { + domainManager.getClass().getMethod("start").invoke(domainManager); + } catch (Exception e) { + logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e); + throw e; + } + logger.info("SCA Domain Manager is now started."); + + // Install a shutdown hook + ShutdownThread hook = new ShutdownThread(domainManager, equinox); + Runtime.getRuntime().addShutdownHook(hook); + + logger.info("Press enter to shutdown."); + try { + System.in.read(); + } catch (IOException e) { + + // Wait forever + Object lock = new Object(); + synchronized(lock) { + lock.wait(); + } + } + + } finally { + + // Remove the shutdown hook + if (shutdown != null) { + Runtime.getRuntime().removeShutdownHook(shutdown); + } + + // Stop the domain manager and OSGi host + if (domainManager != null) { + stopDomainManager(domainManager); + } + if (equinox != null) { + equinox.stop(); + } + } + } + + + /** + * Stop the given domain manager. + * + * @param domainManager + * @throws Exception + */ + private static void stopDomainManager(Object domainManager) throws Exception { + try { + domainManager.getClass().getMethod("stop").invoke(domainManager); + logger.info("SCA Domain Manager is now stopped."); + } catch (Exception e) { + logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e); + throw e; + } + } + + private static class ShutdownThread extends Thread { + private Object domainManager; + private EquinoxHost equinox; + + public ShutdownThread(Object domainManager, EquinoxHost equinox) { + super(); + this.domainManager = domainManager; + this.equinox = equinox; + } + + public void run() { + try { + stopDomainManager(domainManager); + } catch (Exception e) { + // Ignore + } + try { + equinox.stop(); + } catch (Exception e) { + // Ignore + } + } + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java new file mode 100644 index 0000000000..efe4d7bf8a --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHookConfigurator.java @@ -0,0 +1,72 @@ +/* + * 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.node.equinox.launcher; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.jar.Manifest; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.osgi.baseadaptor.HookConfigurator; +import org.eclipse.osgi.baseadaptor.HookRegistry; + +/** + * Hook Configurator for Equinox. + * + * @version $Rev: $ $Date: $ + */ +public class EquinoxHookConfigurator implements HookConfigurator { + private static Logger logger = Logger.getLogger(HookConfigurator.class.getName()); + + private String[] jarFiles; + private Manifest manifest; + + public EquinoxHookConfigurator() { + + // Get the list of JAR files to install + String jarFilesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.jarFiles"); + jarFiles = jarFilesProperty.split(";"); + + // Create a single 'library' bundle for them + long libraryStart = System.currentTimeMillis(); + manifest = NodeLauncherUtil.libraryManifest(jarFiles); + + if (logger.isLoggable(Level.FINE)) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + manifest.write(bos); + bos.close(); + logger.fine(new String(bos.toByteArray())); + } catch (IOException e) { + } + } + + logger.info("Third-party library manifest generated in " + (System.currentTimeMillis() - libraryStart) + " ms"); + + } + + public void addHooks(HookRegistry registry) { + + // Register our BundleFileFactory hook + registry.addBundleFileFactoryHook(new LibrariesBundleFileFactoryHook(manifest)); + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java new file mode 100644 index 0000000000..63313b6f39 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java @@ -0,0 +1,252 @@ +/* + * 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.node.equinox.launcher; + +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.bundleLocation; +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.string; +import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.JarFile; +import java.util.jar.Manifest; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.core.runtime.adaptor.EclipseStarter; +import org.eclipse.core.runtime.adaptor.LocationManager; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +/** + * Wraps the Equinox runtime. + */ +public class EquinoxHost { + private static Logger logger = Logger.getLogger(EquinoxHost.class.getName()); + + private BundleContext bundleContext; + private Bundle launcherBundle; + private EquinoxLauncherBundleHelper launcherActivator; + + private final static String systemPackages = + "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0, " + + "org.osgi.service.startlevel; version=1.0.0, " + + "org.osgi.service.url; version=1.0.0, " + + "org.osgi.util.tracker; version=1.3.2, " + + "javax.xml, " + + "javax.xml.datatype, " + + "javax.xml.namespace, " + + "javax.xml.parsers, " + + "javax.xml.transform, " + + "javax.xml.transform.dom, " + + "javax.xml.transform.sax, " + + "javax.xml.transform.stream, " + + "javax.xml.validation, " + + "javax.xml.xpath, " + // Force the classes to be imported from the system bundle + // + "javax.xml.stream, " + // + "javax.xml.stream.util, " + + "javax.sql," + + "org.w3c.dom, " + + "org.xml.sax, " + + "org.xml.sax.ext, " + + "org.xml.sax.helpers, " + + "javax.security.auth, " + + "javax.security.cert, " + + "javax.security.auth.login, " + + "javax.security.auth.callback, " + + "javax.naming, " + + "javax.naming.spi, " + + "javax.naming.directory, " + + "javax.management, " + + "javax.imageio, " + + "sun.misc, " + + "javax.net, " + + "javax.net.ssl, " + + "javax.crypto, " + + "javax.rmi, " + + "javax.transaction, " + + "javax.transaction.xa"; + + public BundleContext start() { + try { + // Configure Eclipse properties + Map<Object, Object> props = new HashMap<Object, Object>(); + + // Set system packages + props.put("org.osgi.framework.system.packages", systemPackages); + + // Use the boot classloader as the parent classloader + props.put("osgi.contextClassLoaderParent", "boot"); + + // Set the extension bundle + props.put("osgi.framework.extensions", "org.apache.tuscany.sca.node.launcher.equinox"); + + // Set startup properties + props.put(EclipseStarter.PROP_CLEAN, "true"); + + if (logger.isLoggable(Level.FINE)) { + props.put("osgi.console", "8085"); + } + + // Set location properties + // FIXME Use proper locations + props.put(LocationManager.PROP_INSTANCE_AREA, new File("target/workspace").toURI().toString()); + props.put(LocationManager.PROP_INSTALL_AREA, new File("target/eclipse/install").toURI().toString()); + props.put(LocationManager.PROP_CONFIG_AREA, new File("target/eclipse/config").toURI().toString()); + props.put(LocationManager.PROP_USER_AREA, new File("target/eclipse/user").toURI().toString()); + + // Find the Tuscany JARs + File tuscanyInstallDir = findTuscanyInstallDir(); + List<URL> urls; + if (tuscanyInstallDir != null) { + urls = JarFileFinder.findJarFiles(tuscanyInstallDir, new JarFileFinder.StandAloneJARFileNameFilter()); + } else { + urls = JarFileFinder.getClassPathEntries(JarFileFinder.class.getClassLoader(), false); + } + + // Sort out which are bundles (and not already installed) and which are just + // regular JARs + StringBuffer bundleFiles = new StringBuffer(); + StringBuffer bundleNames = new StringBuffer(); + StringBuffer jarFiles = new StringBuffer(); + for (URL url : urls) { + File file = NodeLauncherUtil.file(url); + String bundleName = getBundleName(file); + if (bundleName != null) { + bundleFiles.append(url.toString() + ";"); + bundleNames.append(bundleName + ";"); + } else { + if (file.isFile()) { + jarFiles.append(url.toString() + ";"); + } + } + } + props.put("org.apache.tuscany.sca.node.launcher.equinox.bundleFiles", bundleFiles.toString()); + props.put("org.apache.tuscany.sca.node.launcher.equinox.bundleNames", bundleNames.toString()); + props.put("org.apache.tuscany.sca.node.launcher.equinox.jarFiles", jarFiles.toString()); + + EclipseStarter.setInitialProperties(props); + + // Start Eclipse + bundleContext = EclipseStarter.startup(new String[]{}, null); + + // Install the launcher bundle + String bundleLocation = bundleLocation(); + logger.info("Installing launcher bundle: " + bundleLocation); + launcherBundle = bundleContext.installBundle(bundleLocation); + logger.info("Starting bundle: " + string(launcherBundle, false)); + launcherBundle.start(); + + // Manually call the LauncherBundleActivator for now + launcherActivator = new EquinoxLauncherBundleHelper(); + launcherActivator.start(launcherBundle.getBundleContext()); + + // Start all bundles for now to help diagnose any class loading issues + long activateStart = System.currentTimeMillis(); + for (Bundle bundle: bundleContext.getBundles()) { + if ((bundle.getState() & Bundle.ACTIVE) == 0) { + logger.info("Starting bundle: " + string(bundle, false)); + try { + bundle.start(); + } catch (Exception e) { + logger.log(Level.SEVERE, e.getMessage(), e); + } + logger.info("Bundle: " + string(bundle, false)); + } + } + logger.info("Tuscany bundles are started in " + (System.currentTimeMillis() - activateStart) + " ms."); + return bundleContext; + + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + public void stop() { + try { + + // Uninstall the launcher bundle + if (launcherActivator != null) { + launcherActivator.stop(launcherBundle.getBundleContext()); + } + if (launcherBundle != null) { + logger.info("Uninstalling bundle: " + string(launcherBundle, false)); + launcherBundle.uninstall(); + } + + // Shutdown Eclipse + EclipseStarter.shutdown(); + + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + private static File findTuscanyInstallDir() throws IOException { + String tuscanyDirName = JarFileFinder.getProperty(JarFileFinder.TUSCANY_HOME); + if (tuscanyDirName != null) { + File tuscanyInstallDir = new File(tuscanyDirName); + if (tuscanyInstallDir.exists() && tuscanyInstallDir.isDirectory()) + return tuscanyInstallDir; + } + return null; + } + + /** + * Returns the name of a bundle, or null if the given file is not a bundle. + * + * @param file + * @return + * @throws IOException + */ + private static String getBundleName(File file) throws IOException { + if (!file.exists()) { + return null; + } + String bundleName = null; + if (file.isDirectory()) { + File mf = new File(file, "META-INF/MANIFEST.MF"); + if (mf.isFile()) { + Manifest manifest = new Manifest(new FileInputStream(mf)); + bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME); + } + } else { + JarFile jar = new JarFile(file, false); + Manifest manifest = jar.getManifest(); + bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME); + jar.close(); + } + if (bundleName == null) { + return bundleName; + } + int sc = bundleName.indexOf(';'); + if (sc != -1) { + bundleName = bundleName.substring(0, sc); + } + return bundleName; + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java new file mode 100644 index 0000000000..90d682a74b --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java @@ -0,0 +1,123 @@ +/* + * 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.node.equinox.launcher; + +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.BundleListener; + +/** + * Bundle activator which installs Tuscany modules into an OSGi runtime. + * + */ +public class EquinoxLauncherBundleHelper implements BundleListener { + private static Logger logger = Logger.getLogger(EquinoxLauncherBundleHelper.class.getName()); + + private List<Bundle> installedBundles = new ArrayList<Bundle>(); + private BundleContext bundleContext; + + public EquinoxLauncherBundleHelper() { + super(); + } + + public void start(BundleContext bundleContext) throws Exception { + this.bundleContext = bundleContext; + this.bundleContext.addBundleListener(this); + + // Install the Tuscany bundles + long start = System.currentTimeMillis(); + + // FIXME: SDO bundles dont have the correct dependencies + System.setProperty("commonj.sdo.impl.HelperProvider", "org.apache.tuscany.sdo.helper.HelperProviderImpl"); + + // Get the list of JAR files to install + String jarFilesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.jarFiles"); + String[] jarFiles = jarFilesProperty.split(";"); + + // Create a single 'library' bundle for them + long libraryStart = System.currentTimeMillis(); + //InputStream library = NodeLauncherUtil.libraryBundle(jarFiles); + Bundle libraryBundle = bundleContext.installBundle("org.apache.tuscany.sca.node.launcher.equinox.libraries", new ByteArrayInputStream(new byte[0])); + logger.info("Third-party library bundle installed in " + (System.currentTimeMillis() - libraryStart) + " ms: " + NodeLauncherUtil.string(libraryBundle, false)); + installedBundles.add(libraryBundle); + + // Get the set of already installed bundles + Set<String> alreadyInstalledBundleNames = new HashSet<String>(); + for (Bundle bundle: bundleContext.getBundles()) { + alreadyInstalledBundleNames.add(bundle.getSymbolicName()); + } + + // Get the list of bundle files and names to install + String bundleFilesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.bundleFiles"); + String[] bundleFiles = bundleFilesProperty.split(";"); + String bundleNamesProperty = System.getProperty("org.apache.tuscany.sca.node.launcher.equinox.bundleNames"); + String[] bundleNames = bundleNamesProperty.split(";"); + + // Install all the bundles that are not already installed + for (int i =0, n = bundleFiles.length; i < n; i++) { + String bundleFile = bundleFiles[i]; + String bundleName = bundleNames[i]; + if (!alreadyInstalledBundleNames.contains(bundleName)) { + if (bundleName.contains("org.eclipse.jdt.junit")) { + continue; + } + long installStart = System.currentTimeMillis(); + Bundle bundle = bundleContext.installBundle(bundleFile); + logger.info("Bundle installed in " + (System.currentTimeMillis() - installStart) + " ms: " + NodeLauncherUtil.string(bundle, false)); + installedBundles.add(bundle); + } + } + + long end = System.currentTimeMillis(); + logger.info("Tuscany bundles are installed in " + (end - start) + " ms."); + } + + public void stop(BundleContext bundleContext) throws Exception { + + // Uninstall all the bundles we've installed + for (int i = installedBundles.size() -1; i >= 0; i--) { + Bundle bundle = installedBundles.get(i); + try { + //if (logger.isLoggable(Level.FINE)) { + logger.info("Uninstalling bundle: " + NodeLauncherUtil.string(bundle, false)); + //} + bundle.uninstall(); + } catch (Exception e) { + logger.log(Level.SEVERE, e.getMessage(), e); + } + } + installedBundles.clear(); + + this.bundleContext.removeBundleListener(this); + this.bundleContext = null; + } + + public void bundleChanged(BundleEvent event) { + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/JarFileFinder.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/JarFileFinder.java new file mode 100644 index 0000000000..0f595df758 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/JarFileFinder.java @@ -0,0 +1,373 @@ +/* + * 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.node.equinox.launcher; + +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.file; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FilenameFilter; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.logging.Logger; + +/** + * + */ +public class JarFileFinder { + /** + * A file name filter used to filter JAR files. + */ + static class StandAloneJARFileNameFilter implements FilenameFilter { + + public boolean accept(File dir, String name) { + name = name.toLowerCase(); + + // Exclude tuscany-sca-all and tuscany-sca-manifest as they duplicate + // code in the individual runtime module JARs + if (name.startsWith("tuscany-sca-all")) { + return false; + } + if (name.startsWith("tuscany-sca-manifest")) { + return false; + } + + // Filter out the Tomcat and Webapp hosts + if (name.startsWith("tuscany-host-tomcat") || name.startsWith("tuscany-host-webapp")) { + //FIXME This is temporary + return false; + } + + // Include JAR and MAR files + if (name.endsWith(".jar")) { + return true; + } + if (name.endsWith(".mar")) { + return true; + } + return false; + } + } + + /** + * A file name filter used to filter JAR files. + */ + static class WebAppJARFileNameFilter extends StandAloneJARFileNameFilter { + + public boolean accept(File dir, String name) { + if (!super.accept(dir, name)) { + return false; + } + name = name.toLowerCase(); + + // Exclude servlet-api JARs + if (name.startsWith("servlet-api")) { + return false; + } + + // Exclude the Tomcat and Jetty hosts + if (name.startsWith("tuscany-host-tomcat") || name.startsWith("tuscany-host-jetty")) { + //FIXME This is temporary + return false; + } + + return true; + } + } + + private static final Logger logger = Logger.getLogger(JarFileFinder.class.getName()); + + static final String TUSCANY_HOME = "TUSCANY_HOME"; + private static final String TUSCANY_PATH = "TUSCANY_PATH"; + + /** + * Collect JAR files in the given directory + * @param directory + * @param urls + * @param filter + * @throws MalformedURLException + */ + private static void collectJARFiles(File directory, List<URL> urls, FilenameFilter filter) + throws MalformedURLException { + String[] files = directory.list(filter); + if (files != null) { + URL directoryURL = new URL(directory.toURI().toString() + "/"); + int count = 0; + for (String file : files) { + URL url = new URL(directoryURL, file); + urls.add(url); + count++; + } + if (count != 0) { + logger.fine("Runtime classpath: " + count + + " JAR" + + (count > 1 ? "s" : "") + + " from " + + directory.toString()); + } + } + } + + /** + * Collect JAR files under the given directory. + * + * @param directory + * @param jarDirectoryURLs + * @param jarURLs + * @param filter + * @throws MalformedURLException + */ + private static void collectJARFiles(String directory, + Set<URL> jarDirectoryURLs, + List<URL> jarURLs, + FilenameFilter filter) throws MalformedURLException { + File directoryFile = new File(directory); + URL directoryURL = directoryFile.toURI().toURL(); + if (!jarDirectoryURLs.contains(directoryURL) && directoryFile.exists()) { + + // Collect files under $TUSCANY_HOME + jarDirectoryURLs.add(directoryURL); + collectJARFiles(directoryFile, jarURLs, filter); + + // Collect files under $TUSCANY_HOME/modules + File modulesDirectory = new File(directoryFile, "modules"); + URL modulesDirectoryURL = modulesDirectory.toURI().toURL(); + if (!jarDirectoryURLs.contains(modulesDirectoryURL) && modulesDirectory.exists()) { + jarDirectoryURLs.add(modulesDirectoryURL); + collectJARFiles(modulesDirectory, jarURLs, filter); + } + + // Collect files under $TUSCANY_HOME/lib + File libDirectory = new File(directoryFile, "lib"); + URL libDirectoryURL = libDirectory.toURI().toURL(); + if (!jarDirectoryURLs.contains(libDirectoryURL) && libDirectory.exists()) { + jarDirectoryURLs.add(libDirectoryURL); + collectJARFiles(libDirectory, jarURLs, filter); + } + } + } + + /** + * Returns a ClassLoader for the Tuscany runtime JARs. + * + * @param parentClassLoader + * @param filter + * + * @return + */ + public static List<URL> findJarFiles(File root, FilenameFilter filter) throws FileNotFoundException, + URISyntaxException, MalformedURLException { + + // Build list of runtime JARs + Set<URL> jarDirectoryURLs = new HashSet<URL>(); + List<URL> jarURLs = new ArrayList<URL>(); + + URL url = null; + if (root != null) { + url = root.toURI().toURL(); + } else { + // First determine the path to the launcher class + String resource = JarFileFinder.class.getName().replace('.', '/') + ".class"; + url = JarFileFinder.class.getClassLoader().getResource(resource); + if (url == null) { + throw new FileNotFoundException(resource); + } + + url = getContainer(url, resource); + } + URI uri = url.toURI(); + + // If the launcher class is in a JAR, add all runtime JARs from directory containing + // that JAR (e.g. the Tuscany modules directory) as well as the ../modules and + // ../lib directories + if (url != null && "file".equals(url.getProtocol())) { + + File file = new File(uri); + if (file.exists()) { + File jarDirectory = file.getParentFile(); + if (jarDirectory != null && jarDirectory.exists()) { + + // Collect JAR files from the directory containing the input JAR + // (e.g. the Tuscany modules directory) + URL jarDirectoryURL = jarDirectory.toURI().toURL(); + jarDirectoryURLs.add(jarDirectoryURL); + collectJARFiles(jarDirectory, jarURLs, filter); + + File homeDirectory = jarDirectory.getParentFile(); + if (homeDirectory != null && homeDirectory.exists()) { + + // Collect JARs from the ../modules directory + File modulesDirectory = new File(homeDirectory, "modules"); + URL modulesDirectoryURL = modulesDirectory.toURI().toURL(); + if (!jarDirectoryURLs.contains(modulesDirectoryURL) && modulesDirectory.exists()) { + jarDirectoryURLs.add(modulesDirectoryURL); + collectJARFiles(modulesDirectory, jarURLs, filter); + } + + // Collect JARs from the ../lib directory + File libDirectory = new File(homeDirectory, "lib"); + URL libDirectoryURL = libDirectory.toURI().toURL(); + if (!jarDirectoryURLs.contains(libDirectoryURL) && libDirectory.exists()) { + jarDirectoryURLs.add(libDirectoryURL); + collectJARFiles(libDirectory, jarURLs, filter); + } + } + } + } + } + + // Look for a TUSCANY_HOME system property or environment variable + // Add all the JARs found under $TUSCANY_HOME, $TUSCANY_HOME/modules + // and $TUSCANY_HOME/lib + String home = getProperty(TUSCANY_HOME); + if (home != null && home.length() != 0) { + logger.fine(TUSCANY_HOME + ": " + home); + collectJARFiles(home, jarDirectoryURLs, jarURLs, filter); + } + + // Look for a TUSCANY_PATH system property or environment variable + // Add all the JARs found under $TUSCANY_PATH, $TUSCANY_PATH/modules + // and $TUSCANY_PATH/lib + String ext = getProperty(TUSCANY_PATH); + if (ext != null && ext.length() != 0) { + logger.fine(TUSCANY_PATH + ": " + ext); + String separator = getProperty("path.separator"); + for (StringTokenizer tokens = new StringTokenizer(ext, separator); tokens.hasMoreTokens();) { + collectJARFiles(tokens.nextToken(), jarDirectoryURLs, jarURLs, filter); + } + } + + return jarURLs; + + } + + + /** + * Returns contribution JARs available on the classpath. + * + * @return + */ + static List<URL> getClassPathEntries(ClassLoader classLoader, boolean recursive) { + Set<URL> entries = new HashSet<URL>(); + list(entries, classLoader, recursive); + return new ArrayList<URL>(entries); + } + + /** + * Collect JARs on the classpath of a URLClassLoader + * @param urls + * @param cl + */ + private static void list(Set<URL> urls, ClassLoader cl, boolean recursive) { + if (cl == null) { + return; + } + + // Collect JARs from the URLClassLoader's classpath + if (cl instanceof URLClassLoader) { + URL[] jarURLs = ((URLClassLoader)cl).getURLs(); + if (jarURLs != null) { + for (URL jarURL : jarURLs) { + urls.add(jarURL); + } + } + } + + // Collect JARs from the parent ClassLoader + if (recursive) { + list(urls, cl.getParent(), recursive); + } + } + + + static String getProperty(final String prop) { + return AccessController.doPrivileged(new PrivilegedAction<String>() { + public String run() { + String value = System.getProperty(prop); + if (value == null || value.length() == 0) { + return System.getenv(prop); + } else { + return value; + } + } + }); + } + + private static URL getContainer(URL resourceURL, String resourceName) { + URL root = null; + // "jar:file://....../something.jar!/a/b/c/app.composite" + try { + String url = resourceURL.toExternalForm(); + String protocol = resourceURL.getProtocol(); + if ("file".equals(protocol)) { + // directory contribution + if (url.endsWith("/" + resourceName)) { + final String location = url.substring(0, url.length() - resourceName.length() - 1); + // workaround from evil URL/URI form Maven + // contributionURL = FileHelper.toFile(new URL(location)).toURI().toURL(); + // Allow privileged access to open URL stream. Add FilePermission to added to + // security policy file. + try { + root = AccessController.doPrivileged(new PrivilegedExceptionAction<URL>() { + public URL run() throws IOException { + return file(new URL(location)).toURI().toURL(); + } + }); + } catch (PrivilegedActionException e) { + throw (MalformedURLException)e.getException(); + } + } + + } else if ("jar".equals(protocol)) { + // jar contribution + String location = url.substring(4, url.lastIndexOf("!/")); + // workaround for evil URL/URI from Maven + root = file(new URL(location)).toURI().toURL(); + + } else if ("wsjar".equals(protocol)) { + // See https://issues.apache.org/jira/browse/TUSCANY-2219 + // wsjar contribution + String location = url.substring(6, url.lastIndexOf("!/")); + // workaround for evil url/uri from maven + root = file(new URL(location)).toURI().toURL(); + + } else if (protocol != null && (protocol.equals("bundle") || protocol.equals("bundleresource"))) { + root = new URL(resourceURL.getProtocol(), resourceURL.getHost(), resourceURL.getPort(), "/"); + } + } catch (MalformedURLException mfe) { + throw new IllegalArgumentException(mfe); + } + return root; + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java new file mode 100644 index 0000000000..b9bb70b5d7 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java @@ -0,0 +1,55 @@ +/* + * 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.node.equinox.launcher; + + +/** + * Denotes an error launching an SCA domain manager or node. + * + * @version $Rev$ $Date$ + */ +public class LauncherException extends Exception { + private static final long serialVersionUID = 4581189418849190567L; + + public LauncherException() { + super(); + } + + /** + * @param message + * @param cause + */ + public LauncherException(String message, Throwable cause) { + super(message, cause); + } + + /** + * @param message + */ + public LauncherException(String message) { + super(message); + } + + /** + * @param cause + */ + public LauncherException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java new file mode 100644 index 0000000000..4ff93ea84b --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LibrariesBundleFileFactoryHook.java @@ -0,0 +1,148 @@ +/* + * 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.node.equinox.launcher; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; +import java.util.jar.Manifest; + +import org.eclipse.osgi.baseadaptor.BaseData; +import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry; +import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile; + +/** + * A bundle file factory hook that. + * + * @version $Rev: $ $Date: $ +*/ +public class LibrariesBundleFileFactoryHook implements org.eclipse.osgi.baseadaptor.hooks.BundleFileFactoryHook { + + private Manifest manifest; + + private static class LibrariesBundleFile extends BundleFile { + + private static class ManifestBundleEntry extends BundleEntry { + + private byte[] bytes; + + public ManifestBundleEntry(Manifest manifest) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + manifest.write(bos); + bytes = bos.toByteArray(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + @Override + public URL getFileURL() { + return null; + } + + @Override + public InputStream getInputStream() throws IOException { + return new ByteArrayInputStream(bytes); + } + + @Override + public URL getLocalURL() { + return null; + } + + @Override + public String getName() { + return "META-INF/MANIFEST.MF"; + } + + @Override + public long getSize() { + return bytes.length; + } + + @Override + public long getTime() { + return -1; + } + + @Override + public byte[] getBytes() throws IOException { + return bytes; + } + } + + private Manifest manifest; + + public LibrariesBundleFile(Object baseFile, Manifest manifest) { + super((File)baseFile); + this.manifest = manifest; + } + + @Override + public void close() throws IOException { + } + + @Override + public boolean containsDir(String dir) { + return false; + } + + @Override + public BundleEntry getEntry(String path) { + if ("META-INF/MANIFEST.MF".equals(path)) { + return new ManifestBundleEntry(manifest); + } + return null; + } + + @Override + public Enumeration getEntryPaths(String path) { + return null; + } + + @Override + public File getFile(String path, boolean nativeCode) { + return null; + } + + @Override + public void open() throws IOException { + } + } + + public LibrariesBundleFileFactoryHook(Manifest manifest) { + this.manifest = manifest; + } + + public BundleFile createBundleFile(Object content, BaseData data, boolean base) throws IOException { + // Equinox will resolve external classpath against the base bundle + if ("org.apache.tuscany.sca.node.launcher.equinox.libraries".equals(data.getLocation()) && base) { + return new LibrariesBundleFile(content, manifest); + } else { + return null; + } + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java new file mode 100644 index 0000000000..b77382d6a0 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java @@ -0,0 +1,159 @@ +/* + * 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.node.equinox.launcher; + +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.nodeDaemon; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A launcher for the SCA Node daemon. + * + * @version $Rev$ $Date$ + */ +public class NodeDaemonLauncher { + + static final Logger logger = Logger.getLogger(NodeDaemonLauncher.class.getName()); + + /** + * Constructs a new node daemon launcher. + */ + private NodeDaemonLauncher() { + } + + /** + * Returns a new launcher instance. + * + * @return a new launcher instance + */ + public static NodeDaemonLauncher newInstance() { + return new NodeDaemonLauncher(); + } + + /** + * Creates a new node daemon. + * + * @param + * @return a new node daemon + * @throws LauncherException + */ + public <T> T createNodeDaemon() throws LauncherException { + return (T)nodeDaemon(); + } + + public static void main(String[] args) throws Exception { + logger.info("Apache Tuscany SCA Node Daemon is starting..."); + + // Create a node launcher + NodeDaemonLauncher launcher = newInstance(); + + EquinoxHost equinox = null; + Object node = null; + ShutdownThread shutdown = null; + try { + + // Start the OSGi host + equinox = new EquinoxHost(); + equinox.start(); + + // Start the node + node = launcher.createNodeDaemon(); + try { + node.getClass().getMethod("start").invoke(node); + } catch (Exception e) { + logger.log(Level.SEVERE, "SCA Node Daemon could not be started", e); + throw e; + } + logger.info("SCA Node Daemon is now started."); + + // Install a shutdown hook + shutdown = new ShutdownThread(node, equinox); + Runtime.getRuntime().addShutdownHook(shutdown); + + logger.info("Press enter to shutdown."); + try { + System.in.read(); + } catch (IOException e) { + + // Wait forever + Object lock = new Object(); + synchronized(lock) { + lock.wait(); + } + } + } finally { + + // Remove the shutdown hook + if (shutdown != null) { + Runtime.getRuntime().removeShutdownHook(shutdown); + } + + // Stop the node + if (node != null) { + stopNode(node); + } + if (equinox != null) { + equinox.stop(); + } + } + } + + /** + * Stop the given node. + * + * @param node + * @throws Exception + */ + private static void stopNode(Object node) throws Exception { + try { + node.getClass().getMethod("stop").invoke(node); + logger.info("SCA Node Daemon is now stopped."); + } catch (Exception e) { + logger.log(Level.SEVERE, "SCA Node Daemon could not be stopped", e); + throw e; + } + } + + private static class ShutdownThread extends Thread { + private Object node; + private EquinoxHost equinox; + + public ShutdownThread(Object node, EquinoxHost equinox) { + super(); + this.node = node; + this.equinox = equinox; + } + + public void run() { + try { + stopNode(node); + } catch (Exception e) { + // Ignore + } + try { + equinox.stop(); + } catch (Exception e) { + // Ignore + } + } + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java new file mode 100644 index 0000000000..f3bb8c04ae --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java @@ -0,0 +1,232 @@ +/* + * 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.node.equinox.launcher; + +import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.node; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.osgi.framework.BundleContext; + +/** + * A launcher for SCA nodes. + * + * @version $Rev$ $Date$ + */ +public class NodeLauncher { + + static final Logger logger = Logger.getLogger(NodeLauncher.class.getName()); + private EquinoxHost host; + private BundleContext bundleContext; + + /** + * Constructs a new node launcher. + */ + private NodeLauncher() { + host = new EquinoxHost(); + bundleContext = host.start(); + } + + /** + * Returns a new launcher instance. + * + * @return a new launcher instance + */ + public static NodeLauncher newInstance() { + return new NodeLauncher(); + } + + /** + * Creates a new SCA node from the configuration URL + * + * @param configurationURL the URL of the node configuration which is the ATOM feed + * that contains the URI of the composite and a collection of URLs for the contributions + * + * @return a new SCA node. + * @throws LauncherException + */ + public <T> T createNodeFromURL(String configurationURL) throws LauncherException { + return (T)node(configurationURL, null, null, null, null, bundleContext); + } + + /** + * Creates a new SCA OSGi Node. + * + * @param compositeURI the URI of the composite to use + * @param contributions the URI of the contributions that provides the composites and related + * artifacts. If the list is empty, then we will use the thread context classloader to discover + * the contribution on the classpath + * + * @return a new SCA node. + * @throws LauncherException + */ + public <T> T createNode(String compositeURI, Contribution... contributions) throws LauncherException { + return (T)node(null, compositeURI, null, contributions, null, bundleContext); + } + + /** + * Creates a new SCA OSGi Node. + * + * @param compositeURI the URI of the composite to use + * @param compositeContent the XML content of the composite to use + * @param contributions the URI of the contributions that provides the composites and related artifacts + * @return a new SCA node. + * @throws LauncherException + */ + public <T> T createNode(String compositeURI, String compositeContent, Contribution... contributions) + throws LauncherException { + return (T)node(null, compositeURI, compositeContent, contributions, null, bundleContext); + } + + /** + * Create a SCA node based on the discovery of the contribution on the classpath for the + * given classloader. This method should be treated a convenient shortcut with the following + * assumptions: + * <ul> + * <li>This is a standalone application and there is a deployable composite file on the classpath. + * <li>There is only one contribution which contains the deployable composite file physically in its packaging hierarchy. + * </ul> + * + * @param compositeURI The URI of the composite file relative to the root of the enclosing contribution + * @param classLoader The ClassLoader used to load the composite file as a resource. If the value is null, + * then thread context classloader will be used + * @return A newly created SCA node + */ + public <T> T createNodeFromClassLoader(String compositeURI, ClassLoader classLoader) throws LauncherException { + return (T)node(null, compositeURI, null, null, classLoader, bundleContext); + } + + public static void main(String[] args) throws Exception { + logger.info("Apache Tuscany SCA Node is starting..."); + + // Create a node launcher + NodeLauncher launcher = newInstance(); + + EquinoxHost equinox = launcher.host; + Object node = null; + ShutdownThread shutdown = null; + try { + + if (args.length ==1) { + + // Create a node from a configuration URI + String configurationURI = args[0]; + logger.info("SCA Node configuration: " + configurationURI); + node = launcher.createNodeFromURL(configurationURI); + } else { + + // Create a node from a composite URI and a contribution location + String compositeURI = args[0]; + String contributionLocation = args[1]; + logger.info("SCA composite: " + compositeURI); + logger.info("SCA contribution: " + contributionLocation); + node = launcher.createNode(compositeURI, new Contribution("default", contributionLocation)); + } + + // Start the node + try { + node.getClass().getMethod("start").invoke(node); + } catch (Exception e) { + logger.log(Level.SEVERE, "SCA Node could not be started", e); + throw e; + } + logger.info("SCA Node is now started."); + + // Install a shutdown hook + shutdown = new ShutdownThread(node, equinox); + Runtime.getRuntime().addShutdownHook(shutdown); + + logger.info("Press enter to shutdown."); + try { + System.in.read(); + } catch (IOException e) { + + // Wait forever + Object lock = new Object(); + synchronized(lock) { + lock.wait(); + } + } + } finally { + + // Remove the shutdown hook + if (shutdown != null) { + Runtime.getRuntime().removeShutdownHook(shutdown); + } + + // Stop the node + if (node != null) { + stopNode(node); + } + if (equinox != null) { + equinox.stop(); + } + } + } + + public void destroy() { + if (host != null) { + host.stop(); + bundleContext = null; + } + } + + /** + * Stop the given node. + * + * @param node + * @throws Exception + */ + private static void stopNode(Object node) throws Exception { + try { + node.getClass().getMethod("stop").invoke(node); + logger.info("SCA Node is now stopped."); + } catch (Exception e) { + logger.log(Level.SEVERE, "SCA Node could not be stopped", e); + throw e; + } + } + + private static class ShutdownThread extends Thread { + private Object node; + private EquinoxHost equinox; + + public ShutdownThread(Object node, EquinoxHost equinox) { + super(); + this.node = node; + this.equinox = equinox; + } + + public void run() { + try { + stopNode(node); + } catch (Exception e) { + // Ignore + } + try { + equinox.stop(); + } catch (Exception e) { + // Ignore + } + } + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java new file mode 100644 index 0000000000..b422651244 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java @@ -0,0 +1,374 @@ +/* + * 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.node.equinox.launcher; + +import static org.osgi.framework.Constants.BUNDLE_CLASSPATH; +import static org.osgi.framework.Constants.BUNDLE_MANIFESTVERSION; +import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME; +import static org.osgi.framework.Constants.DYNAMICIMPORT_PACKAGE; +import static org.osgi.framework.Constants.EXPORT_PACKAGE; +import static org.osgi.framework.Constants.IMPORT_PACKAGE; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import java.util.jar.Attributes; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import java.util.logging.Level; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +/** + * Common functions and constants used by the admin components. + * + * @version $Rev$ $Date$ + */ +final class NodeLauncherUtil { + + private static final String LAUNCHER_EQUINOX_LIBRARIES = "org.apache.tuscany.sca.node.launcher.equinox.libraries"; + + private static final String SCANODE_FACTORY = "org.apache.tuscany.sca.node.SCANodeFactory"; + + private static final String DOMAIN_MANAGER_LAUNCHER_BOOTSTRAP = + "org.apache.tuscany.sca.domain.manager.launcher.DomainManagerLauncherBootstrap"; + + private static final String NODE_IMPLEMENTATION_DAEMON_BOOTSTRAP = + "org.apache.tuscany.sca.implementation.node.launcher.NodeImplementationDaemonBootstrap"; + + private static final String NODE_IMPLEMENTATION_LAUNCHER_BOOTSTRAP = + "org.apache.tuscany.sca.implementation.node.launcher.NodeImplementationLauncherBootstrap"; + + /** + * Collect JAR files under the given directory. + * @param contributions + * @param bundleContext TODO + * @throws LauncherException + */ + static Object node(String configurationURI, + String compositeURI, + String compositeContent, + Contribution[] contributions, + ClassLoader contributionClassLoader, BundleContext bundleContext) throws LauncherException { + try { + Bundle bundle = null; + for (Bundle b : bundleContext.getBundles()) { + if ("org.apache.tuscany.sca.implementation.node.runtime".equals(b.getSymbolicName())) { + bundle = b; + break; + } + } + if (bundle == null) { + throw new IllegalStateException( + "Bundle org.apache.tuscany.sca.implementation.node.runtime is not installed"); + } + // Use Java reflection to create the node as only the runtime class + // loader knows the runtime classes required by the node + Class<?> bootstrapClass = bundle.loadClass(NODE_IMPLEMENTATION_LAUNCHER_BOOTSTRAP); + + Object bootstrap; + if (configurationURI != null) { + + // Construct the node with a configuration URI + bootstrap = bootstrapClass.getConstructor(String.class).newInstance(configurationURI); + + } else if (contributionClassLoader != null) { + + // Construct the node with a compositeURI and a classloader + Constructor<?> constructor = bootstrapClass.getConstructor(String.class, ClassLoader.class); + bootstrap = constructor.newInstance(compositeURI, contributionClassLoader); + + } else if (compositeContent != null) { + + // Construct the node with a composite URI, the composite content and + // the URIs and locations of a list of contributions + Constructor<?> constructor = + bootstrapClass.getConstructor(String.class, String.class, String[].class, String[].class); + String[] uris = new String[contributions.length]; + String[] locations = new String[contributions.length]; + for (int i = 0; i < contributions.length; i++) { + uris[i] = contributions[i].getURI(); + locations[i] = contributions[i].getLocation(); + } + bootstrap = constructor.newInstance(compositeURI, compositeContent, uris, locations); + + } else { + + // Construct the node with a composite URI and the URIs and + // locations of a list of contributions + Constructor<?> constructor = + bootstrapClass.getConstructor(String.class, String[].class, String[].class); + String[] uris = new String[contributions.length]; + String[] locations = new String[contributions.length]; + for (int i = 0; i < contributions.length; i++) { + uris[i] = contributions[i].getURI(); + locations[i] = contributions[i].getLocation(); + } + bootstrap = constructor.newInstance(compositeURI, uris, locations); + } + + Object node = bootstrapClass.getMethod("getNode").invoke(bootstrap); + try { + Class<?> type = Class.forName(SCANODE_FACTORY); + type = type.getDeclaredClasses()[0]; + return type.getMethod("createProxy", Class.class, Object.class).invoke(null, type, node); + } catch (ClassNotFoundException e) { + // Ignore + } + return node; + + } catch (Exception e) { + NodeLauncher.logger.log(Level.SEVERE, "SCA Node could not be created", e); + throw new LauncherException(e); + } + } + + /** + * Creates a new node daemon. + * + * @throws LauncherException + */ + static Object nodeDaemon() throws LauncherException { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + try { + + // Use Java reflection to create the node daemon as only the runtime class + // loader knows the runtime classes required by the node + String className = NODE_IMPLEMENTATION_DAEMON_BOOTSTRAP; + Class<?> bootstrapClass; + bootstrapClass = Class.forName(className, false, tccl); + Object bootstrap = bootstrapClass.getConstructor().newInstance(); + + Object nodeDaemon = bootstrapClass.getMethod("getNode").invoke(bootstrap); + return nodeDaemon; + + } catch (Exception e) { + NodeDaemonLauncher.logger.log(Level.SEVERE, "SCA Node Daemon could not be created", e); + throw new LauncherException(e); + } finally { + Thread.currentThread().setContextClassLoader(tccl); + } + } + + /** + * Creates a new domain manager. + * + * @throws LauncherException + */ + static Object domainManager(String rootDirectory) throws LauncherException { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + try { + + // Use Java reflection to create the node daemon as only the runtime class + // loader knows the runtime classes required by the node + String className = DOMAIN_MANAGER_LAUNCHER_BOOTSTRAP; + Class<?> bootstrapClass; + bootstrapClass = Class.forName(className, false, tccl); + Constructor<?> constructor = bootstrapClass.getConstructor(String.class); + Object bootstrap = constructor.newInstance(rootDirectory); + + Object domainManager = bootstrapClass.getMethod("getNode").invoke(bootstrap); + return domainManager; + + } catch (Exception e) { + DomainManagerLauncher.logger.log(Level.SEVERE, "SCA Domain Manager could not be created", e); + throw new LauncherException(e); + } finally { + Thread.currentThread().setContextClassLoader(tccl); + } + } + + static File file(URL url) { + if (url == null || !url.getProtocol().equals("file")) { + return null; + } else { + String filename = url.getFile().replace('/', File.separatorChar); + int pos = 0; + while ((pos = filename.indexOf('%', pos)) >= 0) { + if (pos + 2 < filename.length()) { + String hexStr = filename.substring(pos + 1, pos + 3); + char ch = (char)Integer.parseInt(hexStr, 16); + filename = filename.substring(0, pos) + ch + filename.substring(pos + 3); + } + } + return new File(filename); + } + } + + static Pattern pattern = Pattern.compile("-([0-9.]+)"); + + private static String version(String jarFile) { + Matcher matcher = pattern.matcher(jarFile); + String version = "1.0.0"; + if (matcher.find()) { + version = matcher.group(); + if (version.endsWith(".")) { + version = version.substring(1, version.length() - 1); + } else { + version = version.substring(1); + } + } + return version; + } + + private static void addPackages(String jarFile, Set<String> packages) throws IOException { + String version = ";version=" + version(jarFile); + ZipInputStream is = new ZipInputStream(new FileInputStream(file(new URL(jarFile)))); + ZipEntry entry; + while ((entry = is.getNextEntry()) != null) { + String entryName = entry.getName(); + if (!entry.isDirectory() && entryName != null + && entryName.length() > 0 + && !entryName.startsWith(".") + && entryName.endsWith(".class") // Exclude resources from Export-Package + && entryName.lastIndexOf("/") > 0) { + String pkg = entryName.substring(0, entryName.lastIndexOf("/")).replace('/', '.') + version; + packages.add(pkg); + } + } + is.close(); + } + + static Manifest libraryManifest(String[] jarFiles) throws IllegalStateException { + try { + + // List exported packages and bundle classpath entries + StringBuffer classpath = new StringBuffer(); + StringBuffer exports = new StringBuffer(); + StringBuffer imports = new StringBuffer(); + Set<String> packages = new HashSet<String>(); + for (String jarFile : jarFiles) { + addPackages(jarFile, packages); + classpath.append("\"external:"); + classpath.append(file(new URL(jarFile)).getPath().replace(File.separatorChar, '/')); + classpath.append("\","); + } + + Set<String> importPackages = new HashSet<String>(); + for (String pkg : packages) { + exports.append(pkg); + exports.append(','); + + String importPackage = pkg; + int index = pkg.indexOf(';'); + if (index != -1) { + importPackage = pkg.substring(0, index); + } + if (!importPackages.contains(importPackage)) { + imports.append(importPackage); + imports.append(','); + importPackages.add(importPackage); + } + } + + // Create a manifest + Manifest manifest = new Manifest(); + Attributes attributes = manifest.getMainAttributes(); + attributes.putValue("Manifest-Version", "1.0"); + attributes.putValue(BUNDLE_MANIFESTVERSION, "2"); + attributes.putValue(BUNDLE_SYMBOLICNAME, LAUNCHER_EQUINOX_LIBRARIES); + attributes.putValue(EXPORT_PACKAGE, exports.substring(0, exports.length() - 1)); + attributes.putValue(IMPORT_PACKAGE, imports.substring(0, imports.length() - 1)); + attributes.putValue(BUNDLE_CLASSPATH, classpath.substring(0, classpath.length() - 1)); + attributes.putValue(DYNAMICIMPORT_PACKAGE, "*"); + + return manifest; + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + static byte[] generateBundle(Manifest mf) throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + JarOutputStream jos = new JarOutputStream(bos, mf); + jos.close(); + return bos.toByteArray(); + } + + /** + * Returns the location of this bundle. + * + * @return + * @throws IOException + */ + static String bundleLocation() throws IOException, URISyntaxException { + String resource = NodeLauncherUtil.class.getName().replace('.', '/') + ".class"; + URL url = NodeLauncherUtil.class.getClassLoader().getResource(resource); + if (url == null) { + throw new FileNotFoundException(resource); + } + URI uri = url.toURI(); + + String scheme = uri.getScheme(); + if (scheme.equals("jar")) { + String path = uri.toString().substring(4); + int i = path.indexOf("!/"); + path = path.substring(0, i); + return path; + } else { + String path = uri.toString(); + path = path.substring(0, path.length() - resource.length()); + return path; + } + } + + static String string(Bundle b, boolean verbose) { + StringBuffer sb = new StringBuffer(); + sb.append(b.getBundleId()).append(" ").append(b.getSymbolicName()); + int s = b.getState(); + if ((s & Bundle.UNINSTALLED) != 0) { + sb.append(" UNINSTALLED"); + } + if ((s & Bundle.INSTALLED) != 0) { + sb.append(" INSTALLED"); + } + if ((s & Bundle.RESOLVED) != 0) { + sb.append(" RESOLVED"); + } + if ((s & Bundle.STARTING) != 0) { + sb.append(" STARTING"); + } + if ((s & Bundle.STOPPING) != 0) { + sb.append(" STOPPING"); + } + if ((s & Bundle.ACTIVE) != 0) { + sb.append(" ACTIVE"); + } + + if (verbose) { + sb.append(" ").append(b.getLocation()); + sb.append(" ").append(b.getHeaders()); + } + return sb.toString(); + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java new file mode 100644 index 0000000000..17172dbd5e --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java @@ -0,0 +1,44 @@ +/* + * 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.node.equinox.launcher; + + +/** + * Main class for this JAR. + * With no arguments this class launches the SCA Node Daemon. + * With a "domain" argument it launches the SCA domain admin node. + * With any other argument it launches an SCA Node. + * + * @version $Rev$ $Date$ + */ +public class NodeMain { + + public static void main(String[] args) throws Exception { + if (args.length != 0) { + if (args[0].equals("domain")) { + DomainManagerLauncher.main(args); + } else { + NodeLauncher.main(args); + } + } else { + NodeDaemonLauncher.main(args); + } + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/resources/hookconfigurators.properties b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/resources/hookconfigurators.properties new file mode 100644 index 0000000000..cf9c0f74df --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/main/resources/hookconfigurators.properties @@ -0,0 +1,16 @@ +# 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. +hook.configurators=org.apache.tuscany.sca.node.equinox.launcher.EquinoxHookConfigurator
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorld.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorld.java new file mode 100644 index 0000000000..2f519cb81d --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/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; + +import org.osoa.sca.annotations.Remotable; + +/** + * HelloWorld interface + */ +@Remotable +public interface HelloWorld { + String hello(String name); +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java new file mode 100644 index 0000000000..11e008619c --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java @@ -0,0 +1,50 @@ +/* + * 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; + +import org.osoa.sca.annotations.EagerInit; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +@EagerInit +public class HelloWorldClient { + + private HelloWorld hw; + + @Reference + public void setHelloWorld(HelloWorld hw) { + this.hw = hw; + } + + @Init + public void hello() { + // Say hello + System.out.println("Contribution ClassLoader: " + getClass().getClassLoader()); + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); + System.out.println(hw.hello("Equinox")); + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java new file mode 100644 index 0000000000..e51d3c79d9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/hello/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; + +/** + * HelloWorldImpl + */ +public class HelloWorldImpl implements HelloWorld { + public String hello(String name) { + System.out.println("Name: " + name); + return "Hello, " + name; + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java new file mode 100644 index 0000000000..da0ab774a3 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java @@ -0,0 +1,95 @@ +/* + * 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.node.equinox.launcher; + +import java.util.Dictionary; +import java.util.Enumeration; + +import junit.framework.Assert; + +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + + +/** + * + */ +public class EquinoxOSGiHostTestCase { + @Test + public void testStartThenStop() { + EquinoxHost host = new EquinoxHost(); + BundleContext context = host.start(); + Assert.assertNotNull(context); + for (Bundle b : context.getBundles()) { + System.out.println(toString(b, false)); + } + host.stop(); + } + + @Test + public void testStartTwice() { + EquinoxHost host = new EquinoxHost(); + host.start(); + try { + host.start(); + Assert.fail(); + } catch (IllegalStateException e) { + Assert.assertTrue(IllegalStateException.class.isInstance(e.getCause())); + } finally { + host.stop(); + } + } + + public static String toString(Bundle b, boolean verbose) { + StringBuffer sb = new StringBuffer(); + sb.append(b.getBundleId()).append(" ").append(b.getSymbolicName()); + int s = b.getState(); + if ((s & Bundle.UNINSTALLED) != 0) { + sb.append(" UNINSTALLED"); + } + if ((s & Bundle.INSTALLED) != 0) { + sb.append(" INSTALLED"); + } + if ((s & Bundle.RESOLVED) != 0) { + sb.append(" RESOLVED"); + } + if ((s & Bundle.STARTING) != 0) { + sb.append(" STARTING"); + } + if ((s & Bundle.STOPPING) != 0) { + sb.append(" STOPPING"); + } + if ((s & Bundle.ACTIVE) != 0) { + sb.append(" ACTIVE"); + } + + sb.append(" ").append(b.getLocation()); + if (verbose) { + Dictionary<Object, Object> dict = b.getHeaders(); + Enumeration<Object> keys = dict.keys(); + while (keys.hasMoreElements()) { + Object key = keys.nextElement(); + sb.append(" ").append(key).append("=").append(dict.get(key)); + } + } + return sb.toString(); + } +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java new file mode 100644 index 0000000000..b16045a103 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java @@ -0,0 +1,64 @@ +/* + * 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.node.equinox.launcher; + +import org.apache.tuscany.sca.node.SCANode; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + */ +public class NodeLauncherTestCase { + private static NodeLauncher launcher; + + @BeforeClass + public static void setUp() { + try { + launcher = NodeLauncher.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void tearDown() { + if (launcher != null) { + launcher.destroy(); + } + + } + + @Test + public void testLaunch() throws Exception { + SCANode node = launcher.createNodeFromClassLoader("HelloWorld.composite", getClass().getClassLoader()); + node.start(); + node.stop(); + } + + @Test + @Ignore("contribution-osgi issue") + public void testLaunchDomain() throws Exception { + DomainManagerLauncher.main(new String[] {}); + } + +} diff --git a/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite new file mode 100644 index 0000000000..0608e70ca5 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite @@ -0,0 +1,34 @@ +<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://sample/composite"
+ xmlns:sc="http://sample/composite"
+ name="HelloWorld">
+
+ <component name="HelloWorld">
+ <implementation.java class="hello.HelloWorldImpl" />
+ </component>
+ <component name="HelloWorldClient">
+ <implementation.java class="hello.HelloWorldClient" />
+ <reference name="helloWorld" target="HelloWorld"></reference>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/contrib/modules/node-launcher-webapp/LICENSE b/sca-java-1.x/contrib/modules/node-launcher-webapp/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-webapp/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/sca-java-1.x/contrib/modules/node-launcher-webapp/NOTICE b/sca-java-1.x/contrib/modules/node-launcher-webapp/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-webapp/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/contrib/modules/node-launcher-webapp/pom.xml b/sca-java-1.x/contrib/modules/node-launcher-webapp/pom.xml new file mode 100644 index 0000000000..32c7ca00b9 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-webapp/pom.xml @@ -0,0 +1,62 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>tuscany-node-launcher-webapp</artifactId> + <packaging>war</packaging> + <name>Apache Tuscany SCA Node WebApp</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-launcher</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.node.launcher.webapp</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.node*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..78bbebbb83 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,21 @@ +<?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://www.osoa.org/xmlns/sca/1.0"> +</contribution> diff --git a/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..6c2c943c99 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + * 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. +--> + +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web +Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app> + + <display-name>Apache Tuscany SCA Node</display-name> + + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.node.launcher.NodeServletFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list id="WelcomeFileList"> + <welcome-file>index.jsp</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/index.jsp b/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/index.jsp new file mode 100644 index 0000000000..3cc6c7b504 --- /dev/null +++ b/sca-java-1.x/contrib/modules/node-launcher-webapp/src/main/webapp/index.jsp @@ -0,0 +1,27 @@ +<%-- + * 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. +--%>
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<html> +<head><title>Apache Tuscany SCA Node</title></head> + +<body> +<h1>It works!</h1> +</body> +</html>
diff --git a/sca-java-1.x/contrib/modules/runtime-standalone/LICENSE b/sca-java-1.x/contrib/modules/runtime-standalone/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/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/sca-java-1.x/contrib/modules/runtime-standalone/NOTICE b/sca-java-1.x/contrib/modules/runtime-standalone/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/runtime-standalone/pom.xml b/sca-java-1.x/contrib/modules/runtime-standalone/pom.xml new file mode 100644 index 0000000000..3217da778b --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/pom.xml @@ -0,0 +1,77 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-runtime-standalone</artifactId> + <name>Apache Tuscany SCA Standalone Runtime</name> + + <dependencies> + + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-runtime</artifactId> + <version>${pom.version}</version> + </dependency> + + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-host-tomcat</artifactId> + <version>${pom.version}</version> + </dependency> + + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.0</version> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.runtime.standalone</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.runtime.standalone*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/runtime-standalone/src/main/java/org/apache/tuscany/sca/runtime/standalone/StandaloneLauncher.java b/sca-java-1.x/contrib/modules/runtime-standalone/src/main/java/org/apache/tuscany/sca/runtime/standalone/StandaloneLauncher.java new file mode 100644 index 0000000000..ae05f0bd29 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/src/main/java/org/apache/tuscany/sca/runtime/standalone/StandaloneLauncher.java @@ -0,0 +1,78 @@ +/* + * 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.runtime.standalone; + +import java.io.File; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.PosixParser; +import org.apache.tuscany.sca.runtime.Launcher; + +/** + * Strawman for a J2SE standalone launcher + * Try it with: + * + * mvn -o + * mvn dependency:copy-dependencies -o + * java -Djava.ext.dirs=target/dependency -jar target\tuscany-sca.jar C:\MyTuscanyRepository + * + * where MyTuscanyRepository is a folder containing SCA contribution jars + */ +public class StandaloneLauncher { + + private Launcher launcher; + + public StandaloneLauncher(File repository) { + this.launcher = new Launcher(repository); + launcher.start(); + } + + public void stop() { + launcher.stop(); + } + + public static void main(String[] args) throws Exception { + + Options options = new Options(); + options.addOption("domain", true, "the url of the remote domain this node should connect to"); + CommandLineParser parser = new PosixParser(); + CommandLine cmd = parser.parse( options, args); + if (cmd.getArgs().length != 1) { + System.err.println("missing contributions folder parameter"); + System.exit(1); + } + File f = new File(cmd.getArgs()[0]); + if (!f.exists()) { + System.err.println("repository not found: " + cmd.getArgs()[0]); + System.exit(1); + } + + StandaloneLauncher launcher = new StandaloneLauncher(f); + + System.out.println("Press enter to exit..."); + System.in.read(); + + launcher.stop(); + + } + +} diff --git a/sca-java-1.x/contrib/modules/runtime-standalone/src/test/java/org/apache/tuscany/sca/runtime/standalone/LauncherTestCase.java b/sca-java-1.x/contrib/modules/runtime-standalone/src/test/java/org/apache/tuscany/sca/runtime/standalone/LauncherTestCase.java new file mode 100644 index 0000000000..d29d4a3851 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/src/test/java/org/apache/tuscany/sca/runtime/standalone/LauncherTestCase.java @@ -0,0 +1,54 @@ +/* + * 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.runtime.standalone; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.domain.DomainException; +import org.apache.tuscany.sca.node.NodeException; +import org.apache.tuscany.sca.runtime.Launcher; + +public class LauncherTestCase extends TestCase { + + private File repo; + private Launcher launcher; + + public void test1() throws NodeException, URISyntaxException, InterruptedException, DomainException, MalformedURLException { + launcher.start(); + } + + public void setUp() throws URISyntaxException { + URL propsURL = getClass().getClassLoader().getResource("repo/tuscany.properties"); + repo = new File(propsURL.toURI()).getParentFile(); + launcher = new Launcher(repo); + } + + public void tearDown() throws NodeException, URISyntaxException, InterruptedException, DomainException { + if (launcher != null) { + launcher.stop(); + } + } + +} diff --git a/sca-java-1.x/contrib/modules/runtime-standalone/src/test/resources/repo/bla/helloworld-ws-js.jar b/sca-java-1.x/contrib/modules/runtime-standalone/src/test/resources/repo/bla/helloworld-ws-js.jar Binary files differnew file mode 100644 index 0000000000..6978bee727 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/src/test/resources/repo/bla/helloworld-ws-js.jar diff --git a/sca-java-1.x/contrib/modules/runtime-standalone/src/test/resources/repo/tuscany.properties b/sca-java-1.x/contrib/modules/runtime-standalone/src/test/resources/repo/tuscany.properties new file mode 100644 index 0000000000..2735d130e8 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-standalone/src/test/resources/repo/tuscany.properties @@ -0,0 +1,5 @@ +nodeName=http://localhost:8080/myNode/ +#domainName=http://localhost:8777/tuscany/foo/ +#startManager=true +#hotDeployInterval=10000 +#useHotUpdate=true diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/LICENSE b/sca-java-1.x/contrib/modules/runtime-tomcat/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/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/sca-java-1.x/contrib/modules/runtime-tomcat/NOTICE b/sca-java-1.x/contrib/modules/runtime-tomcat/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/pom.xml b/sca-java-1.x/contrib/modules/runtime-tomcat/pom.xml new file mode 100644 index 0000000000..f737801dad --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/pom.xml @@ -0,0 +1,104 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-runtime-tomcat</artifactId> + <name>Apache Tuscany SCA Runtime for Tomcat deep integration</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>catalina</artifactId> + <version>6.0.14</version> + <exclusions> + <exclusion> + <groupId>org.apache.tomcat</groupId> + <artifactId>servlet-api</artifactId> + </exclusion> + </exclusions> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>coyote</artifactId> + <version>6.0.14</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> <!-- to keep compatible with older servlet containers --> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <exclusions> + <exclusion> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-endpoint</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-webapp</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-sca-jms</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.runtime.tomcat</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.runtime.tomcat*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/EndpointResolverFactoryImpl.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/EndpointResolverFactoryImpl.java new file mode 100644 index 0000000000..45ea279889 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/EndpointResolverFactoryImpl.java @@ -0,0 +1,49 @@ +/* + * 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.runtime.tomcat; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.endpointresolver.EndpointResolver; +import org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory; + +/** + * The factory for creating endpoint Binding providers + * + * @version $Rev$ $Date$ + */ +public class EndpointResolverFactoryImpl implements EndpointResolverFactory<Endpoint> { + + private ExtensionPointRegistry extensionPoints; + + public EndpointResolverFactoryImpl(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + } + + public EndpointResolver createEndpointResolver(Endpoint endpoint, Binding binding) { + + return new EndpointResolverImpl(extensionPoints, endpoint); + } + + public Class<Endpoint> getModelType() { + return Endpoint.class; + } +} diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/EndpointResolverImpl.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/EndpointResolverImpl.java new file mode 100644 index 0000000000..e05004160c --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/EndpointResolverImpl.java @@ -0,0 +1,136 @@ +/* + * 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.runtime.tomcat; + + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.apache.catalina.core.StandardContext; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.builder.DefaultEndpointBuilder; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.endpointresolver.EndpointResolver; +import org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory; +import org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain; +import org.apache.tuscany.sca.host.webapp.WebAppServletHost; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; + + +/** + * The endpoint resolver allows unresolved endpoints to be plumbed into + * the runtime start and message send processing as a hook to late resolution + * of target services + * + * @version $Rev$ $Date$ + */ +public class EndpointResolverImpl implements EndpointResolver { + + private final static Logger logger = Logger.getLogger(EndpointResolverImpl.class.getName()); + + private Endpoint endpoint; + private List<EndpointResolver> endpointResolvers = new ArrayList<EndpointResolver>(); + + public EndpointResolverImpl(ExtensionPointRegistry extensionPoints, + Endpoint endpoint) { + this.endpoint = endpoint; + + EndpointResolverFactoryExtensionPoint resolverFactories = + extensionPoints.getExtensionPoint(EndpointResolverFactoryExtensionPoint.class); + + for (Binding binding : endpoint.getCandidateBindings()){ + EndpointResolverFactory resolverFactory = resolverFactories.getEndpointResolverFactory(binding.getClass()); + + // if the binding in question has a endpoint resolver factory they try and + // create an endpoint resolver + if (resolverFactory != null){ + EndpointResolver resolver = resolverFactory.createEndpointResolver(endpoint, binding); + + if (resolver != null){ + endpointResolvers.add(resolver); + } + } + } + } + + public void start(){ + // do nothing + } + + public void resolve() { + if (endpoint.isUnresolved()){ + logger.info("resolving endpoint: " + endpoint.getTargetName()); + + Component target = findTarget(); + if (target != null) { + logger.info("endpoint target found: " + endpoint.getTargetName() + " component " + target); + resolveEndpoint(target); + } else { + logger.info("endpoint target not found: " + endpoint.getTargetName()); + } + + } + } + + protected void resolveEndpoint(Component targetComponent) { + + endpoint.setTargetComponent(targetComponent); + endpoint.setTargetComponentService(targetComponent.getServices().get(0)); // TODO real service + + DefaultEndpointBuilder ebi = new DefaultEndpointBuilder(new Monitor() { + public void problem(Problem problem) { + logger.warning(problem.toString()); + } + + public List<Problem> getProblems() { + return null; + } + }); + + ebi.build(endpoint); + } + + protected Component findTarget() { + for (StandardContext sc : TuscanyHost.scaApps) { + SCADomain scaDomain = (SCADomain)sc.getServletContext().getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE); + if (scaDomain != null) { + Component component = ((DefaultSCADomain)scaDomain).getComponent(endpoint.getTargetName()); + if ( component != null) { + return component; + } + } + } + return null; + } + + public void stop() { + if (!endpoint.isUnresolved()){ + // Currently the CompositeActivator stop() should take care of the providers and + // wires that have been added. + } + } + +} diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyAnnotationProcessor.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyAnnotationProcessor.java new file mode 100644 index 0000000000..7351ecabe0 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyAnnotationProcessor.java @@ -0,0 +1,108 @@ +/*
+ * 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.runtime.tomcat;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.naming.NamingException;
+
+import org.apache.AnnotationProcessor;
+import org.apache.catalina.core.StandardContext;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.host.webapp.WebAppServletHost;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * A Tuscany specific Tomcat annotation processor for processing SCA annotations
+ */
+public class TuscanyAnnotationProcessor implements AnnotationProcessor {
+
+ private StandardContext scaApp;
+
+ public TuscanyAnnotationProcessor(StandardContext scaApp) {
+ this.scaApp = scaApp;
+ }
+
+ public void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException {
+ }
+
+ public void preDestroy(Object instance) throws IllegalAccessException, InvocationTargetException {
+ }
+
+ public void processAnnotations(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException {
+
+ // Initialize fields annotations
+ Field[] fields = instance.getClass().getDeclaredFields();
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].isAnnotationPresent(Reference.class)) {
+ Reference annotation = fields[i].getAnnotation(Reference.class);
+ injectFieldResource(instance, fields[i], annotation);
+ }
+ }
+
+ // Initialize methods annotations
+ Method[] methods = instance.getClass().getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].isAnnotationPresent(Reference.class)) {
+ Reference annotation = methods[i].getAnnotation(Reference.class);
+ injectMethodResource(instance, methods[i], annotation);
+ }
+ }
+
+ }
+
+ protected void injectFieldResource(Object instance, Field field, Reference annotation) throws IllegalArgumentException, IllegalAccessException {
+
+ String serviceName = annotation.name();
+ if (serviceName == null || serviceName.length() < 1) {
+ serviceName = field.getName();
+ }
+
+ Object service = getSCADomain().getService(field.getType(), serviceName);
+
+ boolean accessibility = field.isAccessible();
+ field.setAccessible(true);
+ field.set(instance, service);
+ field.setAccessible(accessibility);
+ }
+
+ protected void injectMethodResource(Object instance, Method method, Reference annotation) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+
+ String serviceName = annotation.name();
+ if (serviceName == null || serviceName.length() < 1) {
+ StringBuilder setterName = new StringBuilder(method.getName());
+ setterName.setCharAt(4, Character.toLowerCase(setterName.charAt(4)));
+ serviceName = setterName.substring(4);
+ }
+
+ Object service = getSCADomain().getService(method.getParameterTypes()[0], serviceName);
+
+ boolean accessibility = method.isAccessible();
+ method.setAccessible(true);
+ method.invoke(instance, service);
+ method.setAccessible(accessibility);
+ }
+
+ protected SCADomain getSCADomain() {
+ return (SCADomain)scaApp.getServletContext().getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE);
+ }
+}
diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java new file mode 100644 index 0000000000..c8d3aa7a46 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContext.java @@ -0,0 +1,270 @@ +/* + * 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.runtime.tomcat; + +import java.util.Hashtable; + +import javax.naming.Binding; +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NameClassPair; +import javax.naming.NameParser; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.ModificationItem; +import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; + +import org.apache.catalina.core.StandardContext; + +/** + * + * @version $Rev$ $Date$ + */ +public class TuscanyContext extends StandardContext { + private static final long serialVersionUID = 1L; + + public TuscanyContext() { + setProcessTlds(false); + } + + @Override + public boolean getConfigured() { + return true; + } + + @Override + public DirContext getResources() { + return DUMMY_CONTEXT; + } + + @Override + public synchronized void setResources(DirContext resources) { + setDocBase("tuscany"); + super.setResources(DUMMY_CONTEXT); + } + + private static final DirContext DUMMY_CONTEXT = new DirContext(){ + + public void bind(Name name, Object obj, Attributes attrs) throws NamingException { + } + + public void bind(String name, Object obj, Attributes attrs) throws NamingException { + } + + public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException { + return null; + } + + public DirContext createSubcontext(String name, Attributes attrs) throws NamingException { + return null; + } + + public Attributes getAttributes(Name name) throws NamingException { + return null; + } + + public Attributes getAttributes(String name) throws NamingException { + return null; + } + + public Attributes getAttributes(Name name, String[] attrIds) throws NamingException { + return null; + } + + public Attributes getAttributes(String name, String[] attrIds) throws NamingException { + return null; + } + + public DirContext getSchema(Name name) throws NamingException { + return null; + } + + public DirContext getSchema(String name) throws NamingException { + return null; + } + + public DirContext getSchemaClassDefinition(Name name) throws NamingException { + return null; + } + + public DirContext getSchemaClassDefinition(String name) throws NamingException { + return null; + } + + public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException { + } + + public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException { + } + + public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException { + } + + public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException { + } + + public void rebind(Name name, Object obj, Attributes attrs) throws NamingException { + } + + public void rebind(String name, Object obj, Attributes attrs) throws NamingException { + } + + public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(Name name, String filter, SearchControls cons) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException { + return null; + } + + public NamingEnumeration<SearchResult> search(String name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException { + return null; + } + + public Object addToEnvironment(String propName, Object propVal) throws NamingException { + return null; + } + + public void bind(Name name, Object obj) throws NamingException { + } + + public void bind(String name, Object obj) throws NamingException { + } + + public void close() throws NamingException { + } + + public Name composeName(Name name, Name prefix) throws NamingException { + return null; + } + + public String composeName(String name, String prefix) throws NamingException { + return null; + } + + public Context createSubcontext(Name name) throws NamingException { + return null; + } + + public Context createSubcontext(String name) throws NamingException { + return null; + } + + public void destroySubcontext(Name name) throws NamingException { + } + + public void destroySubcontext(String name) throws NamingException { + } + + public Hashtable<?, ?> getEnvironment() throws NamingException { + return null; + } + + public String getNameInNamespace() throws NamingException { + return null; + } + + public NameParser getNameParser(Name name) throws NamingException { + return null; + } + + public NameParser getNameParser(String name) throws NamingException { + return null; + } + + public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { + return null; + } + + public NamingEnumeration<NameClassPair> list(String name) throws NamingException { + return null; + } + + public NamingEnumeration<Binding> listBindings(Name name) throws NamingException { + return null; + } + + public NamingEnumeration<Binding> listBindings(String name) throws NamingException { + throw new NamingException(); + } + + public Object lookup(Name name) throws NamingException { + return null; + } + + public Object lookup(String name) throws NamingException { + return null; + } + + public Object lookupLink(Name name) throws NamingException { + return null; + } + + public Object lookupLink(String name) throws NamingException { + return null; + } + + public void rebind(Name name, Object obj) throws NamingException { + } + + public void rebind(String name, Object obj) throws NamingException { + } + + public Object removeFromEnvironment(String propName) throws NamingException { + return null; + } + + public void rename(Name oldName, Name newName) throws NamingException { + } + + public void rename(String oldName, String newName) throws NamingException { + } + + public void unbind(Name name) throws NamingException { + } + + public void unbind(String name) throws NamingException { + } + }; + +} diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java new file mode 100644 index 0000000000..b19e2326a2 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyContextListener.java @@ -0,0 +1,69 @@ +/* + * 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.runtime.tomcat; + +import java.io.File; + +import org.apache.catalina.Context; +import org.apache.catalina.Lifecycle; +import org.apache.catalina.LifecycleEvent; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.core.StandardContext; +//import org.apache.tuscany.sca.runtime.Launcher; + +/** + * + * @version $Rev$ $Date$ + */ +public class TuscanyContextListener implements LifecycleListener { + +// private Launcher launcher; + +// public TuscanyContextListener(Launcher launcher) { +// this.launcher = launcher; +// } + + public void lifecycleEvent(LifecycleEvent event) { + String type = event.getType(); + if (Lifecycle.AFTER_START_EVENT.equals(type)) { + startContext((Context) event.getLifecycle()); + } else if (Lifecycle.STOP_EVENT.equals(type)) { + stopContext((Context) event.getLifecycle()); + } + } + + protected void startContext(Context context) { + StandardContext sc = (StandardContext) context; + String path = sc.getServletContext().getRealPath("/"); + try { + File f = new File(path + "WEB-INF/classes"); + if (f.exists()) { + System.out.println("adding contribution: "+ path); +// launcher.addContribution(f.toURL()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + protected void stopContext(Context context) { + } + +} diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java new file mode 100644 index 0000000000..38280443f0 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyHost.java @@ -0,0 +1,159 @@ +/* + * 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.runtime.tomcat; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.jar.JarFile; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.catalina.Container; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.core.StandardEngine; +import org.apache.catalina.core.StandardHost; +import org.apache.catalina.deploy.FilterDef; +import org.apache.catalina.deploy.FilterMap; + +/** + * To use this copy all the Tuscany jars to the Tomcat lib folder and update + * the Tomcat conf/server.xml <Host> to include className="org.apache.tuscany.sca.runtime.tomcat.TomcatHost" + * + * For example: + * + * <Host name="localhost" appBase="webapps" + * className="org.apache.tuscany.sca.runtime.tomcat.TuscanyHost" + * unpackWARs="true" autoDeploy="true" + * xmlValidation="false" xmlNamespaceAware="false"> + * + * + * @version $Rev$ $Date$ + */ +public class TuscanyHost extends StandardHost { + private static final long serialVersionUID = 1L; + private static final Logger logger = Logger.getLogger(TuscanyHost.class.getName()); + + // TODO static for expedience, find a better way to share when/if this is working properly + protected static List<StandardContext> scaApps = new ArrayList<StandardContext>(); + + @Override + public synchronized void start() throws LifecycleException { + try { + logger.log(Level.INFO, "Starting Tuscany/SCA runtime"); + + super.start(); + + } catch (Exception e) { + logger.log(Level.SEVERE, "Exception starting Tuscany/SCA runtime", e); + } + } + + @Override + public synchronized void stop() throws LifecycleException { + try { + logger.log(Level.INFO, "Stopping Tuscany/SCA runtime"); + + super.stop(); + + } catch (Exception e) { + logger.log(Level.SEVERE, "Exception Stopping Tuscany/SCA runtime", e); + } + } + + @Override + public synchronized void addChild(Container child) { + try { + if (isSCAApp(child)) { + initSCAApplication((StandardContext)child); + } + } catch (Exception e) { + logger.log(Level.WARNING, "Exception detecting SCA application " + child.getName(), e); + } + super.addChild(child); + } + + /** + * Tests if the child is an SCA application by checking for the presence + * of either an sca-contribution.xml file or a sca-deployables folder + */ + protected boolean isSCAApp(Container child) throws IOException { + if (child instanceof StandardContext) { + StandardContext sc = (StandardContext) child; + + if (sc.getDocBase().endsWith(".war")) { + JarFile jar = null; + try { + jar = new JarFile(((StandardEngine)this.getParent()).getBaseDir() + "/" + getAppBase() + "/" + sc.getDocBase()); + + if (jar.getEntry("META-INF/sca-deployables/") != null) { + return true; + } + + if (jar.getEntry("META-INF/sca-contribution.xml") != null) { + return true; + } + + } finally { + if (jar != null) { + jar.close(); + } + } + } else { + File webappRoot = new File(sc.getConfigFile()).getParentFile().getParentFile(); + + File scaDeployables = new File(webappRoot, "META-INF/sca-deployables"); + if (scaDeployables.exists()) { + return true; + } + + File scaContribution = new File(webappRoot, "META-INF/sca-contribution.xml"); + if (scaContribution.exists()) { + return true; + } + } + } + return false; + } + + protected void initSCAApplication(StandardContext scaApp) { + logger.log(Level.INFO, "Initilizing SCA application: " + scaApp.getName()); + + // Add the Tuscany ContextListener + scaApp.addApplicationListener(org.apache.tuscany.sca.host.webapp.TuscanyContextListener.class.getName()); + + // Add the Tuscany Servlet Filter + FilterDef filterDef = new FilterDef(); + filterDef.setFilterClass(org.apache.tuscany.sca.host.webapp.TuscanyServletFilter.class.getName()); + filterDef.setFilterName(org.apache.tuscany.sca.host.webapp.TuscanyServletFilter.class.getName()); + scaApp.addFilterDef(filterDef); + FilterMap filterMap = new FilterMap(); + filterMap.setFilterName(filterDef.getFilterName()); + filterMap.addURLPattern("/*"); + scaApp.addFilterMap(filterMap); + + scaApp.setAnnotationProcessor(new TuscanyAnnotationProcessor(scaApp)); + + scaApps.add(scaApp); + } + +} diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java new file mode 100644 index 0000000000..112b404515 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyServlet.java @@ -0,0 +1,65 @@ +/* + * 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.runtime.tomcat; + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; + +import org.apache.tuscany.sca.host.webapp.WebAppServletHost; + +/** + * A Servlet that forwards requests to the Servlets registered with the Tuscany + * ServletHost. + * + * TODO: Copy of host-webapp TuscanyServlet. Can be removed once host-webapp TuscanyServlet + * moved over to latest SCADomain API. + * + * @version $Rev$ $Date$ + */ +public class TuscanyServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + private transient WebAppServletHost servletHost; + + @Override + public void init(ServletConfig config) throws ServletException { + servletHost = WebAppServletHost.getInstance(); + servletHost.init(config); + } + + @Override + public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { + String path = ((HttpServletRequest)req).getPathInfo(); + RequestDispatcher dispatcher = servletHost.getRequestDispatcher(path); + if (dispatcher == null) { + throw new IllegalStateException("No servlet registered for path: " + path); + } + + dispatcher.forward(req, res); + } + +} diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java new file mode 100644 index 0000000000..8764094d48 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/java/org/apache/tuscany/sca/runtime/tomcat/TuscanyWrapper.java @@ -0,0 +1,51 @@ +/* + * 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.runtime.tomcat; + +import javax.servlet.Servlet; + +import org.apache.catalina.core.StandardWrapper; + +/** + * Override the StandardWrapper so that Servlets are not instantiated from the + * class name but just the instance Tuscany passes in the constructor is always used. + * + * @version $Rev$ $Date$ + */ +public class TuscanyWrapper extends StandardWrapper { + private static final long serialVersionUID = 1L; + + private final Servlet servlet; + + public TuscanyWrapper(Servlet servlet) { + super(); + this.servlet = servlet; + } + + @Override + public synchronized Servlet loadServlet() { + return servlet; + } + + @Override + public Servlet getServlet() { + return servlet; + } +}
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory new file mode 100644 index 0000000000..e59ade0150 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactory @@ -0,0 +1,19 @@ +# 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.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.runtime.tomcat.EndpointResolverFactoryImpl;model=org.apache.tuscany.sca.assembly.Endpoint
diff --git a/sca-java-1.x/contrib/modules/runtime-tomcat/src/test/resources/content/test.html b/sca-java-1.x/contrib/modules/runtime-tomcat/src/test/resources/content/test.html new file mode 100644 index 0000000000..f4b79d7f01 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-tomcat/src/test/resources/content/test.html @@ -0,0 +1,21 @@ +<html> +<!-- + * 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. +--> +<body><p>hello</body> +</html>
\ No newline at end of file diff --git a/sca-java-1.x/contrib/modules/runtime-war/LICENSE b/sca-java-1.x/contrib/modules/runtime-war/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-war/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/sca-java-1.x/contrib/modules/runtime-war/NOTICE b/sca-java-1.x/contrib/modules/runtime-war/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-war/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/runtime-war/pom.xml b/sca-java-1.x/contrib/modules/runtime-war/pom.xml new file mode 100644 index 0000000000..aad5c68a55 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime-war/pom.xml @@ -0,0 +1,56 @@ +<?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-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <name>Apache Tuscany SCA WAR Runtime</name> + <artifactId>tuscany-runtime-war</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-host-webapp</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-runtime</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> <!-- to keep compatible with older servlet containers --> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <finalName>tuscany</finalName> + </build> +</project> + diff --git a/sca-java-1.x/contrib/modules/runtime/LICENSE b/sca-java-1.x/contrib/modules/runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime/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/sca-java-1.x/contrib/modules/runtime/NOTICE b/sca-java-1.x/contrib/modules/runtime/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/contrib/modules/runtime/pom.xml b/sca-java-1.x/contrib/modules/runtime/pom.xml new file mode 100644 index 0000000000..8b962801cc --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime/pom.xml @@ -0,0 +1,386 @@ +<?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-sca</artifactId> + <version>1.6-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <name>Apache Tuscany SCA Runtime</name> + <artifactId>tuscany-runtime</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-assembly</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-dwr</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-ejb</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-feed</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-http</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-jms</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-jsonrpc</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-notification</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-rmi-runtime</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-sca</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-sca-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-ws</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>${pom.version}</version> + <exclusions> + <exclusion> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </exclusion> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-binding-ws-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-contribution</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-contribution-impl</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-contribution-java</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-contribution-namespace</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-contribution-resource</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-core</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-core-databinding</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-core-spi</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-core-spring</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-databinding</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-databinding-axiom</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-databinding-jaxb</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-databinding-sdo</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-databinding-sdo-axiom</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-definitions</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-definitions-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-api</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-launcher</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-domain-manager</artifactId> + <version>1.6-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-node-runtime</artifactId> + <version>1.6-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-extension-helper</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-host-embedded</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-host-http</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-host-rmi</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-java</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-java-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-node</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-node-runtime</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-notification</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-resource</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-script</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-spring</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-interface</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-interface-java</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-interface-java-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-interface-wsdl</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-interface-wsdl-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-policy</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-policy-xml</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.3</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-fileupload</groupId> + <artifactId>commons-fileupload</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>1.2</version> + </dependency> + <dependency> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + <version>3.1</version> + </dependency> + <dependency> + <groupId>org.apache.activemq</groupId> + <artifactId>activemq-core</artifactId> + <version>5.2.0</version> + </dependency> + </dependencies> + + <build> + <finalName>tuscany-sca</finalName> + <resources> + <resource> + <directory>src/main/java</directory> + <includes> + <include>**/*</include> + </includes> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>org.apache.tuscany.sca.runtime.standalone.Launcher</mainClass> + <addClasspath>false</addClasspath> + </manifest> + <manifestEntries> + <!-- Add an entry for the renamed bundle jar in the distro --> + <Class-Path>tuscany-standalone-${pom.version}.jar</Class-Path> + </manifestEntries> + </archive> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/sca-java-1.x/contrib/modules/runtime/src/main/java/org/apache/tuscany/sca/runtime/Launcher.java b/sca-java-1.x/contrib/modules/runtime/src/main/java/org/apache/tuscany/sca/runtime/Launcher.java new file mode 100644 index 0000000000..1f03ade970 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime/src/main/java/org/apache/tuscany/sca/runtime/Launcher.java @@ -0,0 +1,424 @@ +/* + * 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.runtime; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.namespace.QName; + +//import org.apache.tuscany.sca.node.NodeException; +//import org.apache.tuscany.sca.node.SCANode; +//import org.apache.tuscany.sca.node.SCANodeFactory; + +/** + * A Launcher using a multiple nodes part as part of a domain + * + * @version $Rev$ $Date$ + */ +public class Launcher { + private static final Logger logger = Logger.getLogger(Launcher.class.getName()); + +// protected SCANodeFactory scaNodeFactory; +// protected List<SCANode> scaNodes; + protected String domainName; + protected File repository; + + protected boolean started; + + protected String cp; + + public Launcher(File repository) { + this(repository, "http://localhost:8080/Tuscany"); + } + + public Launcher(File repository, String cp) { + this.repository = repository; + this.cp = cp; + + initFromPropertyFile(); + + logger.info("SCA runtime starting"); + logger.info("repository: " + repository.getAbsolutePath()); + logger.info("domain: " + ((domainName != null) ? domainName : "STANDALONE")); + +// scaNodeFactory = SCANodeFactory.newInstance(); +// scaNodes = new ArrayList<SCANode>(); + + if (repository != null && repository.exists()) { +// if (isExplodedContribution(repository)) { +// addContributionFolder(repository); +// } else { +// addTopLevelJARs(repository); +// addSubFolders(repository); +// } + } + } + + protected boolean isExplodedContribution(File folder) { + return getJARsInFolder(folder).length < 1 && containsCompositeFile(folder); + } + +// protected void addContributionFolder(File folder) { +// SCANode repoNode; +// try { +// repoNode = createNode(cp); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// +// try { +// repoNode.addContribution(folder.toURL().toString(), folder.toURL()); +// logger.info("added contribution folder: " + folder.toURL()); +// } catch (Exception e) { +// e.printStackTrace(); +// logger.log(Level.WARNING, "exception adding contribution folder: " + folder, e); +// } +// } +// +// protected URL[] addTopLevelJARs(File repository) { +// SCANode repoNode; +// try { +// repoNode = createNode(cp); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// +// URL[] jars = getJARsInFolder(repository); +// for (URL jarURL : jars) { +// try { +// repoNode.addContribution(jarURL.toString(), jarURL); +// logger.info("added contribution: " + jarURL); +// } catch (NodeException e) { +// e.printStackTrace(); +// logger.log(Level.WARNING, "exception adding contribution: " + jarURL, e); +// } +// } +// +// return jars; +// } +// +// protected URL[] addSubFolders(File repository) { +// URL[] folders = getSubFolders(repository); +// for (URL folderURL : folders) { +// try { +// SCANode scaNode = createNode(cp + "/" + folderURL); +// scaNode.addContribution(folderURL.toString(), folderURL); +// logger.info("added contribution: " + folderURL); +// } catch (Exception e) { +// e.printStackTrace(); +// logger.log(Level.WARNING, "exception adding contribution: " + folderURL, e); +// } +// } +// return folders; +// } +// +// public void addContribution(URL contributionURL) throws NodeException { +// SCANode scaNode = createNode(cp + "/" + contributionURL); +// +// if (started && domainName == null) { +// scaNode.stop(); +// } +// +// scaNode.addContribution(contributionURL.toString(), contributionURL); +// logger.info("added contribution: " + contributionURL); +// +// if (started) { +// if (domainName == null) { +// scaNode.addToDomainLevelComposite((QName)null); +// scaNode.start(); +// } else { +// scaNode.addToDomainLevelComposite((QName)null); +// scaNode.start(); +// } +// } +// } +// +// public void start() { +// try { +// +// for (SCANode scaNode : scaNodes) { +// scaNode.addToDomainLevelComposite((QName)null); +// scaNode.start(); +// } +// +// } catch (NodeException e) { +// throw new RuntimeException(e); +// } +// started = true; +// } +// +// public void stop() { +// try { +// for (SCANode scaNode : scaNodes) { +// scaNode.stop(); +// } +// } catch (NodeException e) { +// throw new RuntimeException(e); +// } +// started = false; +// } +// +// public void destroy() { +// try { +// stop(); +// for (SCANode scaNode : scaNodes) { +// scaNode.destroy(); +// } +// } catch (NodeException e) { +// throw new RuntimeException(e); +// } +// } + + protected URL[] getJARsInFolder(File repository) { + + String[] jarNames = repository.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(".jar"); + } + }); + + List<URL> contributionJars = new ArrayList<URL>(); + if (jarNames != null) { + for (String jar : jarNames) { + try { + contributionJars.add(new File(repository, jar).toURL()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + } + + return contributionJars.toArray(new URL[contributionJars.size()]); + } + + protected URL[] getSubFolders(File repositoryDir) { + String[] folderNames = repositoryDir.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return new File(dir, name).isDirectory(); + } + }); + + List<URL> contributionFolders = new ArrayList<URL>(); + if (folderNames != null) { + for (String folder : folderNames) { + try { + contributionFolders.add(new File(repositoryDir, folder).toURL()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + } + + return contributionFolders.toArray(new URL[contributionFolders.size()]); + } + + /** + * Tests if the directory or any sub-directories contains a .composite file + */ + protected boolean containsCompositeFile(File repository) { + String[] compositesFileNames = repository.list(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(".composite"); + } + }); + + if (compositesFileNames == null || compositesFileNames.length < 1) { + for (URL subFolder : getSubFolders(repository)) { + try { + if (containsCompositeFile(new File(subFolder.toURI()))) { + return true; + } + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + return false; + } else { + return true; + } + } + + /** + * Creates a new SCA Node unless running as a standalone node in + * which case just a single node is used to run for all contributions + */ +// protected SCANode createNode(String nodeName) throws NodeException { +// SCANode scaNode; +// +// if (domainName == null || domainName.length() < 1) { +// if (scaNodes.size() < 1) { +// scaNode = scaNodeFactory.createSCANode(nodeName, null); +// scaNodes.add(scaNode); +// } else { +// scaNode = scaNodes.get(0); +// } +// } else { +// scaNode = scaNodeFactory.createSCANode(nodeName, null); +// scaNodes.add(scaNode); +// } +// +// return scaNode; +// } + + protected void initFromPropertyFile() { + File file = new File(repository, "tuscany.properties"); + if (!file.exists()) { + return; + } + + Properties properties = new Properties(); + try { + properties.load(new FileInputStream(file)); + } catch (IOException e) { + throw new RuntimeException(e); + } + +// if (properties.getProperty("nodeName") != null) { +// this.nodeName = properties.getProperty("nodeName"); +// } + if (properties.getProperty("domainName") != null && properties.getProperty("domainName").length() > 0) { + this.domainName = properties.getProperty("domainName"); + } +// if (properties.getProperty("hotDeployInterval") != null) { +// this.hotDeployInterval = Long.parseLong(properties.getProperty("hotDeployInterval")); +// } + } + +// protected void initHotDeploy(final File repository) { +// +// if (hotDeployInterval == 0) { +// return; // hotUpdateInterval of 0 disables hotupdate +// } +// +// Runnable runable = new Runnable() { +// +// public void run() { +// logger.info("Contribution hot deploy activated"); +// while (!stopHotDeployThread) { +// try { +// Thread.sleep(hotDeployInterval); +// } catch (InterruptedException e) { +// } +// if (!stopHotDeployThread) { +// checkForUpdates(repository); +// } +// } +// logger.info("contribution hot deploy stopped"); +// } +// }; +// hotDeployThread = new Thread(runable, "TuscanyHotDeploy"); +// stopHotDeployThread = false; +// hotDeployThread.start(); +// } +// +// protected void checkForUpdates(File repository) { +// URL[] currentContributions = getContributionJarURLs(repository); +// if (areContributionsAltered(currentContributions)) { +// restartNode(node); +// } +// } +// +// protected boolean areContributionsAltered(URL[] currentContrabutions) { +// try { +// +// List addedContributions = getAddedContributions(currentContrabutions); +// List removedContributions = getRemovedContributions(currentContrabutions); +// List updatedContributions = getUpdatedContributions(currentContrabutions); +// +// return (addedContributions.size() > 0 || removedContributions.size() > 0 || updatedContributions.size() > 0); +// +// } catch (URISyntaxException e) { +// throw new RuntimeException(e); +// } +// } +// +// protected List<URL> getAddedContributions(URL[] currentContrabutions) { +// List<URL> urls = new ArrayList<URL>(); +// for (URL url : currentContrabutions) { +// if (!existingContributions.containsKey(url)) { +// urls.add(url); +// } +// } +// return urls; +// } +// +// protected List<URL> getUpdatedContributions(URL[] currentContrabutions) throws URISyntaxException { +// List<URL> urls = new ArrayList<URL>(); +// for (URL url : currentContrabutions) { +// if (existingContributions.containsKey(url)) { +// File curentFile = new File(url.toURI()); +// if (curentFile.lastModified() != existingContributions.get(url)) { +// urls.add(url); +// logger.info("updated contribution: " + curentFile.getName()); +// } +// } +// } +// return urls; +// } +// +// protected List getRemovedContributions(URL[] currentContrabutions) throws URISyntaxException { +// List<URL> currentUrls = Arrays.asList(currentContrabutions); +// List<URL> urls = new ArrayList<URL>(); +// for (URL url : existingContributions.keySet()) { +// if (!currentUrls.contains(url)) { +// urls.add(url); +// } +// } +// for (URL url : urls) { +// logger.info("removed contributions: " + new File(url.toURI()).getName()); +// } +// return urls; +// } +// +// protected void copyFiles(File origin, File destination) throws IOException { +// if (origin.isDirectory()) { +// if (!destination.exists()) { +// destination.mkdir(); +// } +// for (String file : origin.list()) { +// copyFiles(new File(origin, file), new File(destination, file)); +// } +// } else { +// InputStream in = new FileInputStream(origin); +// OutputStream out = new FileOutputStream(destination); +// try { +// byte[] buf = new byte[4096]; +// int len; +// while ((len = in.read(buf)) > 0) { +// out.write(buf, 0, len); +// } +// } finally { +// in.close(); +// out.close(); +// } +// } +// } +} diff --git a/sca-java-1.x/contrib/modules/runtime2/pom.xml b/sca-java-1.x/contrib/modules/runtime2/pom.xml new file mode 100644 index 0000000000..d53552d896 --- /dev/null +++ b/sca-java-1.x/contrib/modules/runtime2/pom.xml @@ -0,0 +1,329 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-runtime2</artifactId>
+ <name>Apache Tuscany SCA runtime</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-impl</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-java</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-namespace</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-xml</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedGroupFilter>org.apache.tuscany.sca</shadedGroupFilter>
+
+ <shadedArtifactAttached>false</shadedArtifactAttached>
+ <createSourcesJar>${createSourcesJar}</createSourcesJar>
+ <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+
+ <!-- artifactSet>
+ <includes>
+ <include>org.apache.tuscany.sca:sca-api</include>
+ </includes>
+ <excludes>
+ <exclude>org.apache.tuscany.sca:extensibility</exclude>
+ </excludes>
+ </artifactSet -->
+
+ <filters>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-host-embedded</artifact>
+ <!-- excludes>
+ <exclude>org/apache/tuscany/sca/host/embedded/*</exclude>
+ </excludes -->
+ <includes>
+ <include>org/apache/tuscany/sca/host/embedded/impl/**</include>
+ </includes>
+ </filter>
+ <filter>
+ <artifact>${project.groupId}:${project.artifactId}</artifact>
+
+ <excludes>
+ <exclude>org/**</exclude>
+ </excludes>
+ </filter>
+ </filters>
+
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.feed.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.rss.RSSBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.binding.http.HTTPResourceBindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.definitions.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/scdl4j/pom.xml b/sca-java-1.x/contrib/modules/scdl4j/pom.xml new file mode 100644 index 0000000000..7b23beb489 --- /dev/null +++ b/sca-java-1.x/contrib/modules/scdl4j/pom.xml @@ -0,0 +1,315 @@ +<?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>1.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <name>Apache Tuscany SCDL4J</name>
+ <artifactId>tuscany-scdl4j</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-definitions</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-definitions-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- extensions -->
+
+ <!--
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-atom</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-corba</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-ejb</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-binding-jsonrpc</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+-->
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java-xml</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!-- dependencies to keep in the shaded pom.xml -->
+
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0-2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <version>3.2.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <!-- promoteTransitiveDependencies>true</promoteTransitiveDependencies -->
+ <!-- shadedArtifactAttached>true</shadedArtifactAttached -->
+ <artifactSet>
+ <excludes>
+ <exclude>javax.xml.stream:stax-api</exclude>
+ <exclude>stax:stax-api</exclude>
+ <exclude>com.sun.xml.bind:jaxb-impl</exclude>
+ <exclude>xml-apis:xml-apis</exclude>
+ <exclude>javax.jws:jsr181-api</exclude>
+ <exclude>javax.xml.bind:jaxb-api</exclude>
+ <exclude>org.jvnet.jaxb.reflection:jaxb2-reflection</exclude>
+ <exclude>org.codehaus.woodstox:wstx-asl</exclude>
+ <exclude>asm:asm-all</exclude>
+ <exclude>javax.annotation:jsr250-api</exclude>
+ <exclude>javax.activation:activation</exclude>
+ <exclude>cglib:cglib-nodep</exclude>
+ <exclude>javax.xml.ws:jaxws-api</exclude>
+ <exclude>javax.xml.soap:saaj-api</exclude>
+ <exclude>org.apache.geronimo.specs:geronimo-commonj_1.1_spec</exclude>
+ <exclude>org.apache.ws.commons.schema:XmlSchema</exclude>
+ </excludes>
+ </artifactSet>
+ <filters>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-interface-java-jaxws</artifact>
+ <excludes>
+ <exclude>com/example/**</exclude>
+ </excludes>
+ </filter>
+ <filter>
+ <artifact>org.apache.tuscany.sca:tuscany-databinding-jaxb</artifact>
+ <excludes>
+ <exclude>com/example/**</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.ContributionPostProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListener</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBinding</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.extension.helper.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.implementation.resource.ResourceImplementationFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.work.WorkScheduler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory</resource>
+ </transformer>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <resource>META-INF/services/org.apache.tuscany.sca.definitions.SCADefinitionsProvider</resource>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/contrib/modules/thirdparty-library/pom.xml b/sca-java-1.x/contrib/modules/thirdparty-library/pom.xml new file mode 100644 index 0000000000..c7da9d224d --- /dev/null +++ b/sca-java-1.x/contrib/modules/thirdparty-library/pom.xml @@ -0,0 +1,88 @@ +<?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>1.6-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-thirdparty-library</artifactId> + <name>Apache Tuscany OSGi Bundle for Third Party Jars</name> + <properties> + <maven.test.skip>true</maven.test.skip> + <tuscany.version>${pom.version}</tuscany.version> + </properties> + <dependencies> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-core</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>${pom.version}</version> + </dependency> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>${pom.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <!-- + <plugin> <artifactId>maven-eclipse-plugin</artifactId> <version>2.5.1</version> <configuration> + <pde>true</pde> </configuration> </plugin> + --> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifestFile>${basedir}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-maven-bundle-plugin</artifactId> + <configuration> + <copyJars>false</copyJars> + </configuration> + <executions> + <execution> + <id>build-manifest</id> + <goals> + <goal>build</goal> + </goals> + <phase>process-sources</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> |