Copy modules for event prototype

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@705212 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rsivaram 2008-10-16 11:51:49 +00:00
parent 1068208765
commit b771a05508
3682 changed files with 350606 additions and 0 deletions

View file

@ -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.

View file

@ -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/).

View file

@ -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.4-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.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.4-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>

View file

@ -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.

View file

@ -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/).

View file

@ -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.4-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.4-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>

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -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 {
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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 {
}

View file

@ -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.

View file

@ -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/).

View file

@ -0,0 +1,141 @@
<?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.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tuscany-assembly-xml</artifactId>
<name>Apache Tuscany SCA XML Assembly Model</name>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-definitions</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-policy</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-namespace</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-java</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<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.4</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-definitions-xml</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-policy-xml</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-policy-xml-ws</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xsd</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-contribution-impl</artifactId>
<version>1.4-SNAPSHOT</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.assembly.xml</Bundle-SymbolicName>
<Bundle-Description>${pom.name}</Bundle-Description>
<Export-Package>org.apache.tuscany.sca.assembly.xml*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,905 @@
/*
* 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.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMSource;
import org.apache.tuscany.sca.assembly.AbstractContract;
import org.apache.tuscany.sca.assembly.AbstractProperty;
import org.apache.tuscany.sca.assembly.AbstractReference;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Base;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
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.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Multiplicity;
import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
import org.apache.tuscany.sca.contribution.ContributionFactory;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
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.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
import org.apache.tuscany.sca.policy.util.PolicyValidationException;
import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* A base class with utility methods for the other artifact processors in this module.
*
* @version $Rev$ $Date$
*/
abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implements Constants {
protected ContributionFactory contributionFactory;
protected AssemblyFactory assemblyFactory;
protected PolicyFactory policyFactory;
protected StAXArtifactProcessor<Object> extensionProcessor;
protected PolicyAttachPointProcessor policyProcessor;
private DocumentBuilderFactory documentBuilderFactory;
protected IntentAttachPointTypeFactory intentAttachPointTypeFactory;
private Monitor monitor;
/**
* Constructs a new BaseArtifactProcessor.
* @param contribFactory
* @param factory
* @param policyFactory
*/
@SuppressWarnings("unchecked")
public BaseAssemblyProcessor(ContributionFactory contribFactory,
AssemblyFactory factory,
PolicyFactory policyFactory,
StAXArtifactProcessor extensionProcessor,
Monitor monitor) {
this.assemblyFactory = factory;
this.policyFactory = policyFactory;
this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
this.contributionFactory = contribFactory;
this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
this.intentAttachPointTypeFactory = new IntentAttachPointTypeFactoryImpl();
this.monitor = monitor;
}
/**
* Constructs a new BaseArtifactProcessor.
* @param factory
* @param policyFactory
*/
@SuppressWarnings("unchecked")
public BaseAssemblyProcessor(AssemblyFactory factory,
PolicyFactory policyFactory,
StAXArtifactProcessor extensionProcessor,
Monitor monitor) {
this.assemblyFactory = factory;
this.policyFactory = policyFactory;
this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
this.monitor = monitor;
//TODO - this constructor should take a monitor too.
}
/**
* Marshals warnings into the monitor
*
* @param message
* @param model
* @param messageParameters
*/
protected void warning(String message, Object model, String... messageParameters) {
if (monitor != null){
Problem problem = new ProblemImpl(this.getClass().getName(), "assembly-xml-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
monitor.problem(problem);
}
}
/**
* Marshals errors into the monitor
*
* @param problems
* @param message
* @param model
*/
protected void error(String message, Object model, Object... messageParameters) {
if (monitor != null) {
Problem problem = new ProblemImpl(this.getClass().getName(), "assembly-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
monitor.problem(problem);
}
}
/**
* Marshals exceptions into the monitor
*
* @param problems
* @param message
* @param model
*/
protected void error(String message, Object model, Exception ex) {
if (monitor != null) {
Problem problem = new ProblemImpl(this.getClass().getName(), "assembly-xml-validation-messages", Severity.ERROR, model, message, ex);
monitor.problem(problem);
}
}
/**
* Start an element.
* @param writer
* @param name
* @param attrs
* @throws XMLStreamException
*/
protected void writeStart(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
writeStart(writer, SCA10_NS, name, attrs);
}
/**
* Start a document.
* @param writer
* @throws XMLStreamException
*/
protected void writeStartDocument(XMLStreamWriter writer, String name, XAttr... attrs) throws XMLStreamException {
writer.writeStartDocument();
writer.setDefaultNamespace(SCA10_NS);
writeStart(writer, SCA10_NS, name, attrs);
writer.writeDefaultNamespace(SCA10_NS);
}
/**
* Read list of reference targets
* @param reference
* @param reader
*/
protected void readTargets(Reference reference, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, TARGET);
ComponentService target = null;
if (value != null) {
for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
target = assemblyFactory.createComponentService();
target.setUnresolved(true);
target.setName(tokens.nextToken());
reference.getTargets().add(target);
}
}
}
/**
* Write a list of targets into an attribute
* @param reference
* @return
*/
protected XAttr writeTargets(Reference reference) {
List<String> targets = new ArrayList<String>();
for (Service target : reference.getTargets()) {
targets.add(target.getName());
}
return new XAttr(TARGET, targets);
}
/**
* Read a multiplicity attribute.
* @param reference
* @param reader
*/
protected void readMultiplicity(AbstractReference reference, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, MULTIPLICITY);
if (ZERO_ONE.equals(value)) {
reference.setMultiplicity(Multiplicity.ZERO_ONE);
} else if (ONE_N.equals(value)) {
reference.setMultiplicity(Multiplicity.ONE_N);
} else if (ZERO_N.equals(value)) {
reference.setMultiplicity(Multiplicity.ZERO_N);
}
}
/**
* Returns the value of a constrainingType attribute.
* @param reader
* @return
*/
protected ConstrainingType readConstrainingType(XMLStreamReader reader) {
QName constrainingTypeName = getQName(reader, Constants.CONSTRAINING_TYPE);
if (constrainingTypeName != null) {
ConstrainingType constrainingType = assemblyFactory.createConstrainingType();
constrainingType.setName(constrainingTypeName);
constrainingType.setUnresolved(true);
return constrainingType;
} else {
return null;
}
}
/**
* Reads an abstract property element.
* @param property
* @param reader
* @throws XMLStreamException
* @throws ContributionReadException
*/
protected void readAbstractProperty(AbstractProperty property, XMLStreamReader reader) throws XMLStreamException,
ContributionReadException {
property.setName(getString(reader, NAME));
property.setMany(getBoolean(reader, MANY));
property.setMustSupply(getBoolean(reader, MUST_SUPPLY));
property.setXSDElement(getQName(reader, ELEMENT));
property.setXSDType(getQName(reader, TYPE));
}
/**
* Resolve an implementation.
* @param implementation
* @param resolver
* @return
* @throws ContributionResolveException
*/
protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver)
throws ContributionResolveException, PolicyValidationException {
if (implementation != null) {
if (implementation.isUnresolved()) {
implementation = resolver.resolveModel(Implementation.class, implementation);
// Lazily resolve implementations
if (implementation.isUnresolved()) {
extensionProcessor.resolve(implementation, resolver);
if (!implementation.isUnresolved()) {
//resolve policies
if ( implementation instanceof PolicySetAttachPoint ) {
PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
resolveIntents(policiedImpl.getRequiredIntents(), resolver);
PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
resolvePolicySets(policiedImpl.getPolicySets(), resolver);
PolicyValidationUtils.validatePolicySets(policiedImpl);
if ( implementation instanceof OperationsConfigurator ) {
OperationsConfigurator opsConfigurator = (OperationsConfigurator)implementation;
for ( ConfiguredOperation implOp : opsConfigurator.getConfiguredOperations() ) {
resolveIntents(implOp.getRequiredIntents(), resolver);
PolicyValidationUtils.validateIntents(implOp, policiedImpl.getType());
resolvePolicySets(implOp.getPolicySets(), resolver);
PolicyValidationUtils.validatePolicySets(implOp,
policiedImpl.getType(),
policiedImpl.getApplicablePolicySets());
}
}
for ( Service service : implementation.getServices() ) {
resolveIntents(service.getRequiredIntents(), resolver);
resolvePolicySets(service.getPolicySets(), resolver);
for ( ConfiguredOperation svcOp : service.getConfiguredOperations() ) {
resolveIntents(svcOp.getRequiredIntents(), resolver);
resolvePolicySets(svcOp.getPolicySets(), resolver);
}
}
for ( Reference reference : implementation.getReferences() ) {
resolveIntents(reference.getRequiredIntents(), resolver);
resolvePolicySets(reference.getPolicySets(), resolver);
}
}
resolver.addModel(implementation);
}
}
}
if ( implementation instanceof IntentAttachPoint &&
((IntentAttachPoint)implementation).getType() != null &&
((IntentAttachPoint)implementation).getType().isUnresolved() ) {
((IntentAttachPoint)implementation).setType(
resolver.resolveModel(IntentAttachPointType.class,
((IntentAttachPoint)implementation).getType()));
}
}
return implementation;
}
/**
* Resolve interface, callback interface and bindings on a list of contracts.
* @param contracts the list of contracts
* @param resolver the resolver to use to resolve models
*/
protected <C extends Contract> void resolveContracts(List<C> contracts, ModelResolver resolver)
throws ContributionResolveException {
resolveContracts(null, contracts, resolver);
}
/**
* Resolve interface, callback interface and bindings on a list of contracts.
* @param parent element for the contracts
* @param contracts the list of contracts
* @param resolver the resolver to use to resolve models
*/
protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver)
throws ContributionResolveException {
String parentName = (parent instanceof Composite) ? ((Composite)parent).getName().toString() :
(parent instanceof Component) ? ((Component)parent).getName() : "UNKNOWN";
for (Contract contract : contracts) {
try {
//resolve the intents and policysets as they need to be copied over into the
//child binding elements
resolveIntents(contract.getRequiredIntents(), resolver);
resolvePolicySets(contract.getPolicySets(), resolver);
resolvePolicySets(contract.getApplicablePolicySets(), resolver);
// Inherit the composite / component level applicable policy sets.
if ( parent != null && parent instanceof PolicySetAttachPoint ) {
addInheritedPolicySets(((PolicySetAttachPoint)parent).getApplicablePolicySets(), contract.getApplicablePolicySets());
}
for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
resolveIntents(confOp.getRequiredIntents(), resolver);
resolvePolicySets(confOp.getPolicySets(), resolver);
resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
//inherit applicable policy sets from parent contract
addInheritedPolicySets(contract.getApplicablePolicySets(), confOp.getApplicablePolicySets());
}
// Resolve the interface contract
InterfaceContract interfaceContract = contract.getInterfaceContract();
if (interfaceContract != null) {
extensionProcessor.resolve(interfaceContract, resolver);
}
// Resolve bindings
for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
Binding binding = contract.getBindings().get(i);
extensionProcessor.resolve(binding, resolver);
if (binding instanceof IntentAttachPoint) {
IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
if ( policiedBinding.getType() != null && policiedBinding.getType().isUnresolved() ) {
IntentAttachPointType resolved =
resolver.resolveModel(IntentAttachPointType.class,
policiedBinding.getType());
policiedBinding.setType(resolved);
}
resolveIntents(policiedBinding.getRequiredIntents(), resolver);
PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
}
if (binding instanceof PolicySetAttachPoint) {
PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
resolvePolicySets(policiedBinding.getPolicySets(), resolver);
//validate if attached policysets apply to the binding
resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
//inherit the applicable policysets from parent contract as whatever applies to that
//applies to the binding as well
addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
PolicyValidationUtils.validatePolicySets(policiedBinding);
}
if (binding instanceof OperationsConfigurator) {
OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
resolveIntents(confOp.getRequiredIntents(), resolver);
PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
resolvePolicySets(confOp.getPolicySets(), resolver);
resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
//inherit the applicable policysets from parent binding as whatever applies to that
//applies to the binding as well
addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
confOp.getApplicablePolicySets());
PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
}
}
}
// Resolve callback bindings
if (contract.getCallback() != null) {
resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
//inherit the contract's policy intents and policysets
addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
Binding binding = contract.getCallback().getBindings().get(i);
extensionProcessor.resolve(binding, resolver);
if (binding instanceof IntentAttachPoint) {
IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
if ( policiedBinding.getType().isUnresolved() ) {
IntentAttachPointType resolved =
resolver.resolveModel(IntentAttachPointType.class,
policiedBinding.getType());
policiedBinding.setType(resolved);
}
resolveIntents(policiedBinding.getRequiredIntents(), resolver);
PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
}
if (binding instanceof PolicySetAttachPoint) {
PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
resolvePolicySets(policiedBinding.getPolicySets(), resolver);
//validate if attached policysets apply to the binding
resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
//inherit the applicable policysets from parent contract as whatever applies to that
//applies to the binding as well
addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
PolicyValidationUtils.validatePolicySets(policiedBinding);
}
if (binding instanceof OperationsConfigurator) {
OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
resolveIntents(confOp.getRequiredIntents(), resolver);
PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
resolvePolicySets(confOp.getPolicySets(), resolver);
resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
//inherit the applicable policysets from parent binding as whatever applies to that
//applies to the binding as well
addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
confOp.getApplicablePolicySets());
PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
}
}
}
}
} catch ( PolicyValidationException e ) {
error("PolicyServiceValidationException", contract, contract.getName(), parentName, e.getMessage());
//throw new ContributionResolveException("PolicyValidation exceptions when processing service/reference '"
//+ contract.getName() + "' in '" + parentName + "'");
}
}
}
/**
* Resolve interface and callback interface on a list of abstract contracts.
* @param contracts the list of contracts
* @param resolver the resolver to use to resolve models
*/
protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver)
throws ContributionResolveException {
for (AbstractContract contract : contracts) {
// Resolve the interface contract
InterfaceContract interfaceContract = contract.getInterfaceContract();
if (interfaceContract != null) {
extensionProcessor.resolve(interfaceContract, resolver);
}
}
}
/**
* Returns a constrainingType attribute.
* @param componentType
* @return
*/
protected XAttr writeConstrainingType(ComponentType componentType) {
ConstrainingType constrainingType = componentType.getConstrainingType();
if (constrainingType != null)
return new XAttr(Constants.CONSTRAINING_TYPE, constrainingType.getName());
else
return null;
}
/**
* Read a property value into a DOM document.
* @param element
* @param type
* @param reader
* @return
* @throws XMLStreamException
* @throws ContributionReadException
* @throws ParserConfigurationException
*/
protected Document readPropertyValue(QName element, QName type, XMLStreamReader reader) throws XMLStreamException,
ContributionReadException {
Document document;
try {
if (documentBuilderFactory == null) {
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
}
document = documentBuilderFactory.newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", documentBuilderFactory, ce);
throw ce;
}
// root element has no namespace and local name "value"
Element root = document.createElementNS(null, "value");
if (type != null) {
org.w3c.dom.Attr xsi = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
root.setAttributeNodeNS(xsi);
String prefix = type.getPrefix();
if (prefix == null || prefix.length() == 0) {
prefix = "ns";
}
declareNamespace(root, prefix, type.getNamespaceURI());
org.w3c.dom.Attr xsiType = document.createAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI, "xsi:type");
xsiType.setValue(prefix + ":" + type.getLocalPart());
root.setAttributeNodeNS(xsiType);
}
document.appendChild(root);
loadElement(reader, root);
return document;
}
/**
* Create a DOM element
* @param document
* @param name
* @return
*/
private Element createElement(Document document, QName name) {
String prefix = name.getPrefix();
String qname =
(prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name.getLocalPart();
return document.createElementNS(name.getNamespaceURI(), qname);
}
/**
* Declare a namespace.
* @param element
* @param prefix
* @param ns
*/
private void declareNamespace(Element element, String prefix, String ns) {
if (ns == null) {
ns = "";
}
if (prefix == null) {
prefix = "";
}
String qname = null;
if ("".equals(prefix)) {
qname = "xmlns";
} else {
qname = "xmlns:" + prefix;
}
Node node = element;
boolean declared = false;
while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
NamedNodeMap attrs = node.getAttributes();
if (attrs == null) {
break;
}
Node attr = attrs.getNamedItem(qname);
if (attr != null) {
declared = ns.equals(attr.getNodeValue());
break;
}
node = node.getParentNode();
}
if (!declared) {
org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname);
attr.setValue(ns);
element.setAttributeNodeNS(attr);
}
}
/**
* Load a property value specification from an StAX stream into a DOM
* Document. Only elements, text and attributes are processed; all comments
* and other whitespace are ignored.
*
* @param reader the stream to read from
* @param root the DOM node to load
* @throws javax.xml.stream.XMLStreamException
*/
private void loadElement(XMLStreamReader reader, Element root) throws XMLStreamException {
Document document = root.getOwnerDocument();
Node current = root;
while (true) {
switch (reader.next()) {
case XMLStreamConstants.START_ELEMENT:
QName name = reader.getName();
Element child = createElement(document, name);
// push the new element and make it the current one
current.appendChild(child);
current = child;
int count = reader.getNamespaceCount();
for (int i = 0; i < count; i++) {
String prefix = reader.getNamespacePrefix(i);
String ns = reader.getNamespaceURI(i);
declareNamespace(child, prefix, ns);
}
if (!"".equals(name.getNamespaceURI())) {
declareNamespace(child, name.getPrefix(), name.getNamespaceURI());
}
// add the attributes for this element
count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
String ns = reader.getAttributeNamespace(i);
String prefix = reader.getAttributePrefix(i);
String qname = reader.getAttributeLocalName(i);
String value = reader.getAttributeValue(i);
if (prefix != null && prefix.length() != 0) {
qname = prefix + ":" + qname;
}
child.setAttributeNS(ns, qname, value);
if (ns != null) {
declareNamespace(child, prefix, ns);
}
}
break;
case XMLStreamConstants.CDATA:
current.appendChild(document.createCDATASection(reader.getText()));
break;
case XMLStreamConstants.CHARACTERS:
current.appendChild(document.createTextNode(reader.getText()));
break;
case XMLStreamConstants.END_ELEMENT:
// if we are back at the root then we are done
if (current == root) {
return;
}
// pop the element off the stack
current = current.getParentNode();
}
}
}
/**
* Resolve policy intents attached to a specific SCA Artifact
* @param policyIntents list of policy intents
* @param resolver
*/
protected void resolveIntents(List<Intent> policyIntents, ModelResolver resolver) {
List<Intent> requiredIntents = new ArrayList<Intent>();
Intent resolvedIntent = null;
for (Intent intent : policyIntents) {
resolvedIntent = resolver.resolveModel(Intent.class, intent);
requiredIntents.add(resolvedIntent);
}
policyIntents.clear();
policyIntents.addAll(requiredIntents);
}
/**
* Resolve policy sets attached to a specific SCA Construct
* @param policySets list of attached policy sets
* @param resolver
*/
protected void resolvePolicySets(List<PolicySet> policySets, ModelResolver resolver) {
List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
PolicySet resolvedPolicySet = null;
for (PolicySet policySet : policySets) {
if (policySet.isUnresolved()) {
resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
resolvedPolicySets.add(resolvedPolicySet);
} else {
resolvedPolicySets.add(policySet);
}
}
policySets.clear();
policySets.addAll(resolvedPolicySets);
}
/**
* Write the value of a property
* @param document
* @param element
* @param type
* @param writer
* @throws XMLStreamException
*/
protected void writePropertyValue(Object propertyValue, QName element, QName type, XMLStreamWriter writer)
throws XMLStreamException {
if (propertyValue instanceof Document) {
Document document = (Document)propertyValue;
NodeList nodeList = document.getDocumentElement().getChildNodes();
for (int item = 0; item < nodeList.getLength(); ++item) {
Node node = nodeList.item(item);
int nodeType = node.getNodeType();
if (nodeType == Node.ELEMENT_NODE) {
XMLStreamReader reader =
XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(node));
while (reader.hasNext()) {
switch (reader.next()) {
case XMLStreamConstants.START_ELEMENT:
QName name = reader.getName();
writer.writeStartElement(name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
int namespaces = reader.getNamespaceCount();
for (int i = 0; i < namespaces; i++) {
String prefix = reader.getNamespacePrefix(i);
String ns = reader.getNamespaceURI(i);
writer.writeNamespace(prefix, ns);
}
if (!"".equals(name.getNamespaceURI())) {
writer.writeNamespace(name.getPrefix(), name.getNamespaceURI());
}
// add the attributes for this element
namespaces = reader.getAttributeCount();
for (int i = 0; i < namespaces; i++) {
String ns = reader.getAttributeNamespace(i);
String prefix = reader.getAttributePrefix(i);
String qname = reader.getAttributeLocalName(i);
String value = reader.getAttributeValue(i);
writer.writeAttribute(prefix, ns, qname, value);
}
break;
case XMLStreamConstants.CDATA:
writer.writeCData(reader.getText());
break;
case XMLStreamConstants.CHARACTERS:
writer.writeCharacters(reader.getText());
break;
case XMLStreamConstants.END_ELEMENT:
writer.writeEndElement();
break;
}
}
} else {
writer.writeCharacters(node.getTextContent());
}
}
}
}
protected void addInheritedIntents(List<Intent> sourceList, List<Intent> targetList) {
if (sourceList != null) {
targetList.addAll(sourceList);
}
}
protected void addInheritedPolicySets(List<PolicySet> sourceList, List<PolicySet> targetList) {
if (sourceList != null) {
targetList.addAll(sourceList);
}
}
/**
*
* @param reader
* @param elementName
* @param estensibleElement
* @param extensionAttributeProcessor
* @throws ContributionReadException
* @throws XMLStreamException
*/
protected void readExtendedAttributes(XMLStreamReader reader, QName elementName, Extensible estensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionReadException, XMLStreamException {
for (int a = 0; a < reader.getAttributeCount(); a++) {
QName attributeName = reader.getAttributeName(a);
if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
if( ! elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) {
String attributeExtension = (String) extensionAttributeProcessor.read(attributeName, reader);
estensibleElement.getExtensions().add(attributeExtension);
}
}
}
}
/**
*
* @param attributeModel
* @param writer
* @param extensibleElement
* @param extensionAttributeProcessor
* @throws ContributionWriteException
* @throws XMLStreamException
*/
protected void writeExtendedAttributes(XMLStreamWriter writer, Extensible extensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionWriteException, XMLStreamException {
for(Object o : extensibleElement.getExtensions()) {
//FIXME How to identify it's a extended attribute ?
if(o instanceof String) {
extensionAttributeProcessor.write(o, writer);
}
}
}
/*protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
throws ContributionResolveException {
validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
}
protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
List<PolicySet> applicablePolicySets) throws ContributionResolveException {
//Since the applicablePolicySets in a policySetAttachPoint will already have the
//list of policysets that might ever be applicable to this attachPoint, just check
//if the defined policysets feature in the list of applicable policysets
IntentAttachPointType attachPointType = policySetAttachPoint.getType();
for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) {
if ( !definedPolicySet.isUnresolved() ) {
if ( !applicablePolicySets.contains(definedPolicySet)) {
throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ "' does not apply to binding type "
+ attachPointType.getName());
}
} else {
throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ "' is not defined in this domain ");
}
}
}*/
}

View file

@ -0,0 +1,143 @@
/*
* 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 java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
/**
* A componentType processor.
*
* @version $Rev$ $Date$
*/
public class ComponentTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ComponentType> {
private XMLInputFactory inputFactory;
/**
* Constructs a new componentType processor.
* @param factory
* @param policyFactory
* @param registry
*/
public ComponentTypeDocumentProcessor(StAXArtifactProcessor staxProcessor,
XMLInputFactory inputFactory,
Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.inputFactory = inputFactory;
}
/**
* Constructs a new componentType processor.
* @param modelFactories
* @param staxProcessor
*/
public ComponentTypeDocumentProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor staxProcessor,
Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
}
public ComponentType read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
InputStream urlStream = null;
try {
// Create a stream reader
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
urlStream = connection.getInputStream();
XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
reader.nextTag();
// Reader the componentType model
ComponentType componentType = (ComponentType)extensionProcessor.read(reader);
if (componentType != null) {
componentType.setURI(uri.toString());
}
// For debugging purposes, write it back to XML
// if (componentType != null) {
// try {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
// extensionProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos));
// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
// OutputFormat format = new OutputFormat();
// format.setIndenting(true);
// format.setIndent(2);
// XMLSerializer serializer = new XMLSerializer(System.out, format);
// serializer.serialize(document);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
return componentType;
} catch (XMLStreamException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", inputFactory, ce);
throw ce;
} catch (IOException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", inputFactory, ce);
throw ce;
} finally {
try {
if (urlStream != null) {
urlStream.close();
urlStream = null;
}
} catch (IOException ioe) {
//ignore
}
}
}
public void resolve(ComponentType componentType, ModelResolver resolver) throws ContributionResolveException {
extensionProcessor.resolve(componentType, resolver);
}
public String getArtifactType() {
return ".componentType";
}
public Class<ComponentType> getModelType() {
return ComponentType.class;
}
}

View file

@ -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.assembly.xml;
import java.util.HashMap;
import java.util.Map;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Import;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.java.JavaImport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* A Model Resolver for ComponentType models.
*
* @version $Rev$ $Date$
*/
public class ComponentTypeModelResolver implements ModelResolver {
private Contribution contribution;
private Map<String, ComponentType> map = new HashMap<String, ComponentType>();
public ComponentTypeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
this.contribution = contribution;
}
public void addModel(Object resolved) {
ComponentType componentType = (ComponentType)resolved;
map.put(componentType.getURI(), componentType);
}
public Object removeModel(Object resolved) {
return map.remove(((ComponentType)resolved).getURI());
}
public <T> T resolveModel(Class<T> modelClass, T unresolved) {
//get componentType artifact URI
String uri = ((ComponentType)unresolved).getURI();
if (uri == null) {
return (T)unresolved;
}
//lookup the componentType
ComponentType resolved = (ComponentType) map.get(uri);
if (resolved != null) {
return modelClass.cast(resolved);
}
//If not found, delegate the resolution to the imports (in this case based on the java imports)
//compute the package name from the componentType URI
if (unresolved instanceof ComponentType) {
//FIXME The core assembly model now depends on java imports to
// resolve componentTypes of all kinds, this is not right at all!!!
int s = uri.lastIndexOf('/');
if (s != -1) {
String packageName = uri.substring(0, uri.lastIndexOf("/"));
for (Import import_ : this.contribution.getImports()) {
if (import_ instanceof JavaImport) {
JavaImport javaImport = (JavaImport)import_;
//check the import location against the computed package name from the componentType URI
if (javaImport.getPackage().equals(packageName)) {
// Delegate the resolution to the import resolver
resolved = javaImport.getModelResolver().resolveModel(ComponentType.class, (ComponentType)unresolved);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}
}
}
}
}
return (T)unresolved;
}
}

View file

@ -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.assembly.xml;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import javax.xml.namespace.QName;
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.ComponentType;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Extensible;
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.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
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.Operation;
import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.w3c.dom.Document;
/**
* A componentType processor.
*
* @version $Rev$ $Date$
*/
public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ComponentType> {
/**
* Constructs a new componentType processor.
* @param factory
* @param policyFactory
* @param registry
*/
public ComponentTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory,
StAXArtifactProcessor extensionProcessor, StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) {
super(factory, policyFactory, extensionProcessor, monitor);
}
/**
* Constructs a new componentType processor.
*
* @param modelFactories
* @param extensionProcessor
*/
public ComponentTypeProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor extensionProcessor,
StAXAttributeProcessor extensionAttributeProcessor,
Monitor monitor) {
super(modelFactories.getFactory(AssemblyFactory.class),
modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
}
public ComponentType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
ComponentType componentType = null;
Service service = null;
Reference reference = null;
Contract contract = null;
Property property = null;
Callback callback = null;
QName name = null;
// Read the componentType document
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
name = reader.getName();
if (Constants.COMPONENT_TYPE_QNAME.equals(name)) {
// Read a <componentType>
componentType = assemblyFactory.createComponentType();
componentType.setConstrainingType(readConstrainingType(reader));
} else if (Constants.SERVICE_QNAME.equals(name)) {
// Read a <service>
service = assemblyFactory.createService();
contract = service;
service.setName(getString(reader, Constants.NAME));
componentType.getServices().add(service);
policyProcessor.readPolicies(service, reader);
} else if (Constants.REFERENCE_QNAME.equals(name)) {
// Read a <reference>
reference = assemblyFactory.createReference();
contract = reference;
reference.setName(getString(reader, Constants.NAME));
reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL));
readMultiplicity(reference, reader);
readTargets(reference, reader);
componentType.getReferences().add(reference);
policyProcessor.readPolicies(reference, reader);
} else if (Constants.PROPERTY_QNAME.equals(name)) {
// Read a <property>
property = assemblyFactory.createProperty();
readAbstractProperty(property, reader);
policyProcessor.readPolicies(property, reader);
// Read the property value
Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
property.setValue(value);
componentType.getProperties().add(property);
} else if (Constants.IMPLEMENTATION_QNAME.equals(name)) {
// Read an <implementation> element
policyProcessor.readPolicies(componentType, reader);
} else if (Constants.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 = new OperationImpl();
operation.setName(getString(reader, NAME));
operation.setUnresolved(true);
if (callback != null) {
policyProcessor.readPolicies(callback, operation, reader);
} else {
policyProcessor.readPolicies(contract, operation, reader);
}
} else {
// Read an extension element
Object extension = extensionProcessor.read(reader);
if (extension != null) {
if (extension instanceof InterfaceContract) {
// <service><interface> and <reference><interface>
contract.setInterfaceContract((InterfaceContract)extension);
} else if (extension instanceof Binding) {
// <service><binding> and <reference><binding>
if (callback != null) {
callback.getBindings().add((Binding)extension);
} else {
contract.getBindings().add((Binding)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 (componentType instanceof Extensible) {
((Extensible)componentType).getExtensions().add(extension);
}
}
}
}
}
break;
case END_ELEMENT:
name = reader.getName();
// Clear current state when reading reaching end element
if (SERVICE_QNAME.equals(name)) {
service = null;
contract = null;
} else if (REFERENCE_QNAME.equals(name)) {
reference = null;
contract = null;
} else if (PROPERTY_QNAME.equals(name)) {
property = null;
} else if (CALLBACK_QNAME.equals(name)) {
callback = null;
}
break;
}
// Read the next element
if (reader.hasNext()) {
reader.next();
}
}
return componentType;
}
public void write(ComponentType componentType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
// Write <componentType> element
writeStartDocument(writer, COMPONENT_TYPE,
writeConstrainingType(componentType));
// Write <service> elements
for (Service service : componentType.getServices()) {
writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
policyProcessor.writePolicies(service));
if (service.getInterfaceContract() != null) {
extensionProcessor.write(service.getInterfaceContract(), writer);
}
for (Binding binding: service.getBindings()) {
extensionProcessor.write(binding, writer);
}
if (service.getCallback() != null) {
Callback callback = service.getCallback();
writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
for (Binding binding: callback.getBindings()) {
extensionProcessor.write(binding, writer);
}
for (Object extension: callback.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
for (Object extension: service.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
// Write <reference> elements
for (Reference reference : componentType.getReferences()) {
writeStart(writer, REFERENCE,
new XAttr(NAME, reference.getName()),
writeTargets(reference),
policyProcessor.writePolicies(reference));
extensionProcessor.write(reference.getInterfaceContract(), writer);
for (Binding binding: reference.getBindings()) {
extensionProcessor.write(binding, writer);
}
if (reference.getCallback() != null) {
Callback callback = reference.getCallback();
writeStart(writer, CALLBACK,
policyProcessor.writePolicies(callback));
for (Binding binding: callback.getBindings()) {
extensionProcessor.write(binding, writer);
}
for (Object extension: callback.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
for (Object extension: reference.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
// Write <property> elements
for (Property property : componentType.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 extension elements
if (componentType instanceof Extensible) {
for (Object extension: ((Extensible)componentType).getExtensions()) {
extensionProcessor.write(extension, writer);
}
}
// Write <implementation> elements if the componentType has
// any intents or policySets
boolean writeImplementation = false;
if (componentType instanceof IntentAttachPoint) {
if (!((IntentAttachPoint)componentType).getRequiredIntents().isEmpty()) {
writeImplementation = true;
}
}
if (componentType instanceof PolicySetAttachPoint) {
if (!((PolicySetAttachPoint)componentType).getPolicySets().isEmpty()) {
writeImplementation = true;
}
}
if (writeImplementation) {
writeStart(writer, IMPLEMENTATION,
policyProcessor.writePolicies(componentType));
}
writeEndDocument(writer);
}
public void resolve(ComponentType componentType, ModelResolver resolver) throws ContributionResolveException {
// Resolve component type services and references
resolveContracts(componentType.getServices(), resolver);
resolveContracts(componentType.getReferences(), resolver);
if ( componentType instanceof PolicySetAttachPoint ) {
resolveIntents(((PolicySetAttachPoint)componentType).getRequiredIntents(), resolver);
resolvePolicySets(((PolicySetAttachPoint)componentType).getPolicySets(), resolver);
}
}
public QName getArtifactType() {
return COMPONENT_TYPE_QNAME;
}
public Class<ComponentType> getModelType() {
return ComponentType.class;
}
}

View file

@ -0,0 +1,229 @@
/*
* 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 java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
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.definitions.SCADefinitions;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
/**
* A composite processor.
*
* @version $Rev$ $Date$
*/
public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<Composite> {
private XMLInputFactory inputFactory;
private DocumentBuilderFactory documentBuilderFactory;
private List scaDefnSink;
private Collection<PolicySet> domainPolicySets = null;
private int scaDefnsCount = 0;
/**
* Construct a new composite processor
* @param assemblyFactory
* @param policyFactory
* @param staxProcessor
*/
@Deprecated
public CompositeDocumentProcessor(StAXArtifactProcessor staxProcessor,
XMLInputFactory inputFactory,
List scaDefnsSink, Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.inputFactory = inputFactory;
this.scaDefnSink = scaDefnsSink;
}
/**
* Construct a new composite processor
* @param assemblyFactory
* @param policyFactory
* @param staxProcessor
*/
public CompositeDocumentProcessor(StAXArtifactProcessor staxProcessor,
XMLInputFactory inputFactory,
DocumentBuilderFactory documentBuilderFactory,
List scaDefnsSink, Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.documentBuilderFactory = documentBuilderFactory;
this.inputFactory = inputFactory;
this.scaDefnSink = scaDefnsSink;
}
/**
* Constructs a new composite processor.
* @param modelFactories
* @param staxProcessor
*/
public CompositeDocumentProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor staxProcessor, Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
}
public Composite read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
InputStream scdlStream = null;
try {
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
scdlStream = connection.getInputStream();
} catch (IOException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", url, ce);
throw ce;
}
return read(uri, scdlStream);
}
public Composite read(URI uri, InputStream scdlStream) throws ContributionReadException {
try {
if (scaDefnSink != null ) {
fillDomainPolicySets(scaDefnSink);
}
Composite composite = null;
byte[] transformedArtifactContent;
try {
if ( domainPolicySets != null ) {
transformedArtifactContent =
PolicyComputationUtils.addApplicablePolicySets(scdlStream, domainPolicySets, documentBuilderFactory);
scdlStream = new ByteArrayInputStream(transformedArtifactContent);
}
} catch ( IOException e ) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", scdlStream, ce);
throw ce;
} catch ( Exception e ) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", scdlStream, ce);
//throw ce;
}
XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream);
reader.nextTag();
// Read the composite model
composite = (Composite)extensionProcessor.read(reader);
if (composite != null) {
composite.setURI(uri.toString());
}
// For debugging purposes, write it back to XML
// if (composite != null) {
// try {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
// extensionProcessor.write(composite, outputFactory.createXMLStreamWriter(bos));
// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
// OutputFormat format = new OutputFormat();
// format.setIndenting(true);
// format.setIndent(2);
// XMLSerializer serializer = new XMLSerializer(System.out, format);
// serializer.serialize(document);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
return composite;
} catch (XMLStreamException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", inputFactory, ce);
throw ce;
} finally {
try {
if (scdlStream != null) {
scdlStream.close();
scdlStream = null;
}
} catch (IOException ioe) {
//ignore
}
}
}
public void resolve(Composite composite, ModelResolver resolver) throws ContributionResolveException {
if (composite != null)
extensionProcessor.resolve(composite, resolver);
}
public String getArtifactType() {
return ".composite";
}
public Class<Composite> getModelType() {
return Composite.class;
}
private void fillDomainPolicySets(List scaDefnsSink) {
Map<QName, PolicySet> domainPolicySetMap = null;
if ( scaDefnsSink.size() > scaDefnsCount ) {
//if ( !scaDefnsSink.isEmpty() ) {
domainPolicySetMap = new Hashtable<QName, PolicySet>();
if ( domainPolicySets != null ) {
for ( PolicySet policySet : domainPolicySets ) {
domainPolicySetMap.put(policySet.getName(), policySet);
}
}
for ( Object object : scaDefnsSink ) {
if ( object instanceof SCADefinitions ) {
for ( PolicySet policySet : ((SCADefinitions)object).getPolicySets() ) {
domainPolicySetMap.put( policySet.getName(), policySet);
}
}
}
domainPolicySets = domainPolicySetMap.values();
//scaDefnsSink.clear();
scaDefnsCount = scaDefnsSink.size();
}
}
}

View file

@ -0,0 +1,83 @@
/*
* 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 java.util.HashMap;
import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Import;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* A Model Resolver for Composite models.
*
* @version $Rev$ $Date$
*/
public class CompositeModelResolver implements ModelResolver {
private Contribution contribution;
private Map<QName, Composite> map = new HashMap<QName, Composite>();
public CompositeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
this.contribution = contribution;
}
public void addModel(Object resolved) {
Composite composite = (Composite)resolved;
map.put(composite.getName(), composite);
}
public Object removeModel(Object resolved) {
return map.remove(((Composite)resolved).getName());
}
public <T> T resolveModel(Class<T> modelClass, T unresolved) {
// Lookup a definition for the given namespace
QName qname = ((Composite)unresolved).getName();
Composite resolved = (Composite) map.get(qname);
if (resolved != null) {
return modelClass.cast(resolved);
}
// No definition found, delegate the resolution to the imports
for (Import import_ : this.contribution.getImports()) {
if (import_ instanceof NamespaceImport) {
NamespaceImport namespaceImport = (NamespaceImport)import_;
if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
// Delegate the resolution to the import resolver
resolved = namespaceImport.getModelResolver().resolveModel(Composite.class, (Composite)unresolved);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}
}
}
return (T)unresolved;
}
}

View file

@ -0,0 +1,109 @@
/*
* 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 javax.xml.namespace.QName;
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.ConfiguredOperation;
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.policy.PolicyFactory;
import org.apache.tuscany.sca.monitor.Monitor;
/**
* Processor for dealing with 'operation' elements from composite definitions
*
* @version $Rev$ $Date$
*/
public class ConfiguredOperationProcessor implements StAXArtifactProcessor<ConfiguredOperation>, Constants{
private AssemblyFactory assemblyFactory;
private PolicyAttachPointProcessor policyProcessor;
private PolicyFactory policyFactory;
private Monitor monitor;
public ConfiguredOperationProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
this.monitor = monitor;
}
public ConfiguredOperation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
ConfiguredOperation configuredOp = assemblyFactory.createConfiguredOperation();
//Read an <operation>
configuredOp.setName(reader.getAttributeValue(null, NAME));
configuredOp.setContractName(reader.getAttributeValue(null, SERVICE));
configuredOp.setUnresolved(true);
// Read policies
policyProcessor.readPolicies(configuredOp, reader);
//Skip to end element
while (reader.hasNext()) {
if (reader.next() == END_ELEMENT && OPERATION_QNAME.equals(reader.getName())) {
break;
}
}
return configuredOp;
}
public void write(ConfiguredOperation configuredOperation, XMLStreamWriter writer)
throws ContributionWriteException, XMLStreamException {
// Write an <operation>
policyProcessor.writePolicyPrefixes(configuredOperation, writer);
writer.writeStartElement(Constants.SCA10_NS, OPERATION);
policyProcessor.writePolicyAttributes(configuredOperation, writer);
writer.writeAttribute(NAME, configuredOperation.getName());
if ( configuredOperation.getContractName() != null ) {
writer.writeAttribute(SERVICE, configuredOperation.getContractName());
}
writer.writeEndElement();
}
public void resolve(ConfiguredOperation configuredOperation, ModelResolver resolver)
throws ContributionResolveException {
}
public QName getArtifactType() {
return OPERATION_QNAME;
}
public Class<ConfiguredOperation> getModelType() {
return ConfiguredOperation.class;
}
}

View file

@ -0,0 +1,97 @@
/*
* 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 javax.xml.namespace.QName;
/**
* Constants used in SCA assembly XML files.
*
* @version $Rev$ $Date$
*/
public interface Constants {
String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
String COMPONENT_TYPE = "componentType";
QName COMPONENT_TYPE_QNAME = new QName(SCA10_NS, COMPONENT_TYPE);
String SERVICE = "service";
QName SERVICE_QNAME = new QName(SCA10_NS, SERVICE);
String REFERENCE = "reference";
QName REFERENCE_QNAME = new QName(SCA10_NS, REFERENCE);
String PROPERTY = "property";
QName PROPERTY_QNAME = new QName(SCA10_NS, PROPERTY);
String CONSTRAINING_TYPE = "constrainingType";
QName CONSTRAINING_TYPE_QNAME = new QName(SCA10_NS, CONSTRAINING_TYPE);
String COMPOSITE = "composite";
QName COMPOSITE_QNAME = new QName(SCA10_NS, COMPOSITE);
String INCLUDE = "include";
QName INCLUDE_QNAME = new QName(SCA10_NS, INCLUDE);
String COMPONENT = "component";
QName COMPONENT_QNAME = new QName(SCA10_NS, COMPONENT);
String WIRE = "wire";
QName WIRE_QNAME = new QName(SCA10_NS, WIRE);
String OPERATION = "operation";
QName OPERATION_QNAME = new QName(SCA10_NS, OPERATION);
String CALLBACK = "callback";
QName CALLBACK_QNAME = new QName(SCA10_NS, CALLBACK);
String IMPLEMENTATION_COMPOSITE = "implementation.composite";
QName IMPLEMENTATION_COMPOSITE_QNAME = new QName(SCA10_NS, IMPLEMENTATION_COMPOSITE);
String IMPLEMENTATION = "implementation";
QName IMPLEMENTATION_QNAME = new QName(SCA10_NS, IMPLEMENTATION);
String BINDING_SCA = "binding.sca";
QName BINDING_SCA_QNAME = new QName(Constants.SCA10_NS, BINDING_SCA);
String NAME = "name";
String TARGET_NAMESPACE = "targetNamespace";
String LOCAL = "local";
String AUTOWIRE = "autowire";
String REQUIRES = "requires";
String POLICY_SETS = "policySets";
String APPLICABLE_POLICY_SETS = "applicablePolicySets";
String PROMOTE = "promote";
String TARGET = "target";
String WIRED_BY_IMPL = "wiredByImpl";
String MULTIPLICITY = "multiplicity";
String TYPE = "type";
String ELEMENT = "element";
String MANY = "many";
String MUST_SUPPLY = "mustSupply";
String SOURCE = "source";
String FILE = "file";
String URI = "uri";
String ZERO_ONE = "0..1";
String ZERO_N = "0..n";
String ONE_ONE = "1..1";
String ONE_N = "1..n";
}

View file

@ -0,0 +1,140 @@
/*
* 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 java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
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.monitor.Monitor;
/**
* A contrainingType content handler.
*
* @version $Rev$ $Date$
*/
public class ConstrainingTypeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<ConstrainingType> {
private XMLInputFactory inputFactory;
/**
* Construct a new constrainingType processor.
* @param factory
* @param policyFactory
* @param staxProcessor
*/
public ConstrainingTypeDocumentProcessor(StAXArtifactProcessor staxProcessor,
XMLInputFactory inputFactory,
Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.inputFactory = inputFactory;
}
/**
* Constructs a new constrainingType processor.
* @param modelFactories
* @param staxProcessor
*/
public ConstrainingTypeDocumentProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor staxProcessor,
Monitor monitor) {
super(null, null, staxProcessor, monitor);
this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
}
public ConstrainingType read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
InputStream urlStream = null;
try {
// Create a stream reader
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
urlStream = connection.getInputStream();
XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
reader.nextTag();
// Read the constrainingType model
ConstrainingType constrainingType = (ConstrainingType)extensionProcessor.read(reader);
// For debugging purposes, write it back to XML
// if (constrainingType != null) {
// try {
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
// XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
// outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
// extensionProcessor.write(constrainingType, outputFactory.createXMLStreamWriter(bos));
// Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(bos.toByteArray()));
// OutputFormat format = new OutputFormat();
// format.setIndenting(true);
// format.setIndent(2);
// XMLSerializer serializer = new XMLSerializer(System.out, format);
// serializer.serialize(document);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
return constrainingType;
} catch (XMLStreamException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", inputFactory, ce);
throw ce;
} catch (IOException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", inputFactory, ce);
throw ce;
} finally {
try {
if (urlStream != null) {
urlStream.close();
urlStream = null;
}
} catch (IOException ioe) {
//ignore
}
}
}
public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException {
extensionProcessor.resolve(constrainingType, resolver);
}
public String getArtifactType() {
return ".constrainingType";
}
public Class<ConstrainingType> getModelType() {
return ConstrainingType.class;
}
}

View file

@ -0,0 +1,83 @@
/*
* 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 java.util.HashMap;
import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.Import;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* A Model Resolver for ConstrainingType models.
*
* @version $Rev$ $Date$
*/
public class ConstrainingTypeModelResolver implements ModelResolver {
private Contribution contribution;
private Map<QName, ConstrainingType> map = new HashMap<QName, ConstrainingType>();
public ConstrainingTypeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
this.contribution = contribution;
}
public void addModel(Object resolved) {
ConstrainingType composite = (ConstrainingType)resolved;
map.put(composite.getName(), composite);
}
public Object removeModel(Object resolved) {
return map.remove(((ConstrainingType)resolved).getName());
}
public <T> T resolveModel(Class<T> modelClass, T unresolved) {
// Lookup a definition for the given namespace
QName qname = ((ConstrainingType)unresolved).getName();
ConstrainingType resolved = (ConstrainingType) map.get(qname);
if (resolved != null) {
return modelClass.cast(resolved);
}
// No definition found, delegate the resolution to the imports
for (Import import_ : this.contribution.getImports()) {
if (import_ instanceof NamespaceImport) {
NamespaceImport namespaceImport = (NamespaceImport)import_;
if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
// Delegate the resolution to the import resolver
resolved = namespaceImport.getModelResolver().resolveModel(ConstrainingType.class, (ConstrainingType)unresolved);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}
}
}
return (T)unresolved;
}
}

View file

@ -0,0 +1,273 @@
/*
* 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 javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AbstractContract;
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.ConstrainingType;
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.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.w3c.dom.Document;
/**
* A constrainingType processor.
*
* @version $Rev$ $Date$
*/
public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ConstrainingType> {
/**
* Construct a new constrainingType processor.
* @param factory
* @param policyFactory
* @param extensionProcessor
*/
public ConstrainingTypeProcessor(AssemblyFactory factory, PolicyFactory policyFactory,
StAXArtifactProcessor extensionProcessor, Monitor monitor) {
super(factory, policyFactory, extensionProcessor, monitor);
}
/**
* Constructs a new constrainingType processor.
*
* @param modelFactories
* @param extensionProcessor
*/
public ConstrainingTypeProcessor(ModelFactoryExtensionPoint modelFactories,
StAXArtifactProcessor extensionProcessor,
Monitor monitor) {
super(modelFactories.getFactory(AssemblyFactory.class),
modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
}
public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
ConstrainingType constrainingType = null;
AbstractService abstractService = null;
AbstractReference abstractReference = null;
AbstractProperty abstractProperty = null;
AbstractContract abstractContract = null;
QName name = null;
// Read the constrainingType document
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
name = reader.getName();
// Read a <constrainingType>
if (Constants.CONSTRAINING_TYPE_QNAME.equals(name)) {
constrainingType = assemblyFactory.createConstrainingType();
constrainingType.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
policyProcessor.readPolicies(constrainingType, reader);
} else if (Constants.SERVICE_QNAME.equals(name)) {
// Read a <service>
abstractService = assemblyFactory.createAbstractService();
abstractContract = abstractService;
abstractService.setName(getString(reader, Constants.NAME));
constrainingType.getServices().add(abstractService);
policyProcessor.readPolicies(abstractService, reader);
} else if (Constants.REFERENCE_QNAME.equals(name)) {
// Read a <reference>
abstractReference = assemblyFactory.createAbstractReference();
abstractContract = abstractReference;
abstractReference.setName(getString(reader, Constants.NAME));
readMultiplicity(abstractReference, reader);
constrainingType.getReferences().add(abstractReference);
policyProcessor.readPolicies(abstractReference, reader);
} else if (Constants.PROPERTY_QNAME.equals(name)) {
// Read a <property>
abstractProperty = assemblyFactory.createAbstractProperty();
readAbstractProperty(abstractProperty, reader);
// Read the property value
Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), reader);
abstractProperty.setValue(value);
constrainingType.getProperties().add(abstractProperty);
policyProcessor.readPolicies(abstractProperty, reader);
} else if (OPERATION_QNAME.equals(name)) {
// Read an <operation>
Operation operation = new OperationImpl();
operation.setName(getString(reader, NAME));
operation.setUnresolved(true);
policyProcessor.readPolicies(abstractContract, operation, reader);
} else {
// Read an extension element
Object extension = extensionProcessor.read(reader);
if (extension instanceof InterfaceContract) {
// <service><interface> and <reference><interface>
abstractContract.setInterfaceContract((InterfaceContract)extension);
} else {
// Add the extension element to the current element
if (abstractContract != null) {
abstractContract.getExtensions().add(extension);
} else {
constrainingType.getExtensions().add(extension);
}
}
}
break;
case END_ELEMENT:
name = reader.getName();
// Clear current state when reading reaching end element
if (SERVICE_QNAME.equals(name)) {
abstractService = null;
abstractContract = null;
} else if (REFERENCE_QNAME.equals(name)) {
abstractReference = null;
abstractContract = null;
} else if (PROPERTY_QNAME.equals(name)) {
abstractProperty = null;
}
break;
}
if (reader.hasNext()) {
reader.next();
}
}
return constrainingType;
}
public void write(ConstrainingType constrainingType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
// Write <constrainingType> element
writeStartDocument(writer, CONSTRAINING_TYPE,
new XAttr(TARGET_NAMESPACE, constrainingType.getName().getNamespaceURI()),
new XAttr(NAME, constrainingType.getName().getLocalPart()),
policyProcessor.writePolicies(constrainingType));
// Write <service> elements
for (AbstractService service : constrainingType.getServices()) {
writeStart(writer, SERVICE, new XAttr(NAME, service.getName()),
policyProcessor.writePolicies(service));
extensionProcessor.write(service.getInterfaceContract(), writer);
for (Object extension: service.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
// Write <reference> elements
for (AbstractReference reference : constrainingType.getReferences()) {
writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
policyProcessor.writePolicies(reference));
extensionProcessor.write(reference.getInterfaceContract(), writer);
for (Object extension: reference.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
// Write <property> elements
for (AbstractProperty abstractProperty : constrainingType.getProperties()) {
writeStart(writer,
PROPERTY,
new XAttr(NAME, abstractProperty.getName()),
new XAttr(MUST_SUPPLY, abstractProperty.isMustSupply()),
new XAttr(MANY, abstractProperty.isMany()),
new XAttr(TYPE, abstractProperty.getXSDType()),
new XAttr(ELEMENT, abstractProperty.getXSDElement()),
policyProcessor.writePolicies(abstractProperty));
// Write property value
writePropertyValue(abstractProperty.getValue(), abstractProperty.getXSDElement(), abstractProperty.getXSDType(), writer);
// Write extensions
for (Object extension : abstractProperty.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEnd(writer);
}
// Write extension elements
for (Object extension: constrainingType.getExtensions()) {
extensionProcessor.write(extension, writer);
}
writeEndDocument(writer);
}
public void resolve(ConstrainingType constrainingType, ModelResolver resolver) throws ContributionResolveException {
// Resolve component type services and references
resolveAbstractContracts(constrainingType.getServices(), resolver);
resolveAbstractContracts(constrainingType.getReferences(), resolver);
resolveIntents(constrainingType.getRequiredIntents(), resolver);
for ( AbstractService service : constrainingType.getServices() ) {
resolveIntents(service.getRequiredIntents(), resolver);
}
for ( AbstractReference reference : constrainingType.getReferences() ) {
resolveIntents(reference.getRequiredIntents(), resolver);
}
}
public QName getArtifactType() {
return CONSTRAINING_TYPE_QNAME;
}
public Class<ConstrainingType> getModelType() {
return ConstrainingType.class;
}
}

View file

@ -0,0 +1,256 @@
/*
* 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 java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
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.Base;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.monitor.Monitor;
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.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* Default Model Processor for beans.
*
* @version $Rev$ $Date$
*/
public class DefaultBeanModelProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor {
private QName artifactType;
private Class<Implementation> modelClass;
private Object modelFactory;
private Method factoryMethod;
private Map<String, Method> setterMethods = new HashMap<String, Method>();
private Map<String, Method> getterMethods = new HashMap<String, Method>();
public DefaultBeanModelProcessor(AssemblyFactory assemblyFactory,
PolicyFactory policyFactory,
QName artifactType,
Class<Implementation> modelClass,
Object modelFactory,
Monitor monitor) {
super(assemblyFactory, policyFactory, null, monitor);
this.artifactType = artifactType;
this.modelClass = modelClass;
this.modelFactory = modelFactory;
// Introspect the factory class and bean model class
if (modelFactory != null) {
// Find the model create method
for (Method method: modelFactory.getClass().getMethods()) {
if (method.getName().startsWith("create") && method.getReturnType() == modelClass) {
factoryMethod = method;
break;
}
}
}
// Index the bean's setter methods
for (Method method: modelClass.getMethods()) {
Method getter;
String name = method.getName();
if (name.startsWith("set") && name.length() > 3) {
// Get the corresponding getter method
try {
getter = modelClass.getMethod("get" + name.substring(3));
} catch (Exception e) {
getter = null;
continue;
}
// Get the property name
name = name.substring(3);
if (name.length() > 1) {
if (!name.toUpperCase().equals(name)) {
name = name.substring(0, 1).toLowerCase() + name.substring(1);
}
}
} else {
continue;
}
// Map an uppercase property name to a lowercase attribute name
if (name.toUpperCase().equals(name)) {
name = name.toLowerCase();
}
// Trim trailing _ from property names
if (name.endsWith("_")) {
name = name.substring(0, name.length()-1);
}
setterMethods.put(name, method);
getterMethods.put(name, getter);
}
}
public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
// Read an element
try {
// Create a new instance of the model
Object model;
if (modelFactory != null) {
// Invoke the factory create method
model = factoryMethod.invoke(modelFactory);
} else {
// Invoke the model bean class default constructor
model = modelClass.newInstance();
}
// Initialize the bean properties with the attributes found in the
// XML element
for (int i = 0, n = reader.getAttributeCount(); i < n; i++) {
String attributeName = reader.getAttributeLocalName(i);
Method setter = setterMethods.get(attributeName);
if (setter != null) {
String value = reader.getAttributeValue(i);
setter.invoke(model, value);
}
}
// Read policies
policyProcessor.readPolicies(model, reader);
// FIXME read extension elements
// By default mark the model object unresolved
if (model instanceof Base) {
((Base)model).setUnresolved(true);
}
// Skip to end element
while (reader.hasNext()) {
if (reader.next() == END_ELEMENT && artifactType.equals(reader.getName())) {
break;
}
}
return model;
} catch (Exception e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", reader, ce);
throw ce;
}
}
public void write(Object bean, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
try {
// Write the bean properties as attributes
List<XAttr> attrs = new ArrayList<XAttr>();
for (Map.Entry<String, Method> entry: getterMethods.entrySet()) {
if (entry.getValue().getReturnType() == String.class) {
String value = (String)entry.getValue().invoke(bean);
attrs.add(new XAttr(entry.getKey(), value));
}
}
// Write element
writeStart(writer, artifactType.getNamespaceURI(), artifactType.getLocalPart(),
policyProcessor.writePolicies(bean), new XAttr(null, attrs));
writeEnd(writer);
} catch (Exception e) {
ContributionWriteException ce = new ContributionWriteException(e);
error("ContributionWriteException", writer, ce);
throw ce;
}
}
public void resolve(Object bean, ModelResolver resolver) throws ContributionResolveException {
// Resolve and merge the component type associated with an
// implementation model
if (bean instanceof Implementation) {
Implementation implementation = (Implementation)bean;
String uri = implementation.getURI();
if (uri != null) {
int d = uri.lastIndexOf('.');
if (d != -1) {
uri = uri.substring(0, d) + ".componentType";
// Resolve the component type
ComponentType componentType = assemblyFactory.createComponentType();
componentType.setURI(uri);
componentType.setUnresolved(true);
componentType = resolver.resolveModel(ComponentType.class, componentType);
if (componentType != null && !componentType.isUnresolved()) {
// We found a component type, merge it into the implementation model
implementation.getServices().addAll(componentType.getServices());
implementation.getReferences().addAll(componentType.getReferences());
implementation.getProperties().addAll(componentType.getProperties());
implementation.setConstrainingType(componentType.getConstrainingType());
if (implementation instanceof PolicySetAttachPoint &&
componentType instanceof PolicySetAttachPoint ) {
PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
PolicySetAttachPoint policiedCompType = (PolicySetAttachPoint)componentType;
if ( policiedImpl.getPolicySets() != null) {
policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets());
}
if (policiedImpl.getRequiredIntents() != null) {
policiedImpl.getRequiredIntents().addAll(policiedCompType.getRequiredIntents());
}
}
}
}
}
}
// Mark the model resolved
if (bean instanceof Base) {
((Base)bean).setUnresolved(false);
}
}
public QName getArtifactType() {
return artifactType;
}
public Class<?> getModelType() {
return modelClass;
}
}

View file

@ -0,0 +1,266 @@
/*
* 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 java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* A Policy Attach Point processor.
*
* @version $Rev$ $Date$
*/
public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor implements Constants {
private PolicyFactory policyFactory;
public PolicyAttachPointProcessor(PolicyFactory policyFactory) {
this.policyFactory = policyFactory;
}
/**
* Read policy intents associated with an operation.
* @param attachPoint
* @param operation
* @param reader
*/
private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
if (!(attachPoint instanceof IntentAttachPoint))
return;
IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
String value = reader.getAttributeValue(null, REQUIRES);
if (value != null) {
List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
QName qname = getQNameValue(reader, tokens.nextToken());
Intent intent = policyFactory.createIntent();
intent.setName(qname);
if (operation != null) {
//FIXME Don't we need to handle intent specification
// on an operation basis?
//intent.getOperations().add(operation);
}
requiredIntents.add(intent);
}
}
}
/**
* Reads policy intents and policy sets associated with an operation.
* @param attachPoint
* @param operation
* @param reader
*/
public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) {
readIntents(attachPoint, operation, reader);
readPolicySets(attachPoint, operation, reader);
}
/**
* Reads policy intents and policy sets.
* @param attachPoint
* @param reader
*/
public void readPolicies(Object attachPoint, XMLStreamReader reader) {
readPolicies(attachPoint, null, reader);
}
/**
* Reads policy sets associated with an operation.
* @param attachPoint
* @param operation
* @param reader
*/
private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) {
if (!(attachPoint instanceof PolicySetAttachPoint)) {
return;
}
PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
String value = reader.getAttributeValue(null, POLICY_SETS);
if (value != null) {
List<PolicySet> policySets = policySetAttachPoint.getPolicySets();
for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
QName qname = getQNameValue(reader, tokens.nextToken());
PolicySet policySet = policyFactory.createPolicySet();
policySet.setName(qname);
if (operation != null) {
//FIXME Don't we need to handle policySet specification
// on an operation basis?
//policySet.getOperations().add(operation);
}
policySets.add(policySet);
}
}
value = reader.getAttributeValue(SCA10_TUSCANY_NS, APPLICABLE_POLICY_SETS);
if (value != null) {
List<PolicySet> applicablePolicySets = policySetAttachPoint.getApplicablePolicySets();
for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
QName qname = getQNameValue(reader, tokens.nextToken());
PolicySet policySet = policyFactory.createPolicySet();
policySet.setName(qname);
if (operation != null) {
//FIXME Don't we need to handle policySet specification
// on an operation basis?
//policySet.getOperations().add(operation);
}
applicablePolicySets.add(policySet);
}
}
}
/**
* Write policies
* @param attachPoint
* @return
*/
XAttr writePolicies(Object attachPoint) throws XMLStreamException {
return writePolicies(attachPoint, (Operation)null);
}
/**
* Write policies
* @param attachPoint
* @return
*/
public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
writePolicyAttributes(attachPoint, (Operation)null, writer);
}
/**
* Write policies
* @param attachPoint
* @return
*/
public void writePolicyPrefixes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
writePolicyPrefixes(attachPoint, (Operation)null, writer);
}
/**
* Write policies associated with an operation
* @param attachPoint
* @param operation
* @return
*/
XAttr writePolicies(Object attachPoint, Operation operation) {
List<XAttr> attrs =new ArrayList<XAttr>();
attrs.add(writeIntents(attachPoint, operation));
attrs.add(writePolicySets(attachPoint, operation));
return new XAttr(null, attrs);
}
/**
* Write policies
* @param attachPoint
* @return
*/
public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
XAttr attr = writePolicies(attachPoint, operation);
attr.write(writer);
}
/**
* Write policies
* @param attachPoint
* @return
*/
public void writePolicyPrefixes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
XAttr attr = writePolicies(attachPoint, operation);
attr.writePrefix(writer);
}
/**
* Write policy intents associated with an operation.
* @param attachPoint
* @param operation
*/
private XAttr writeIntents(Object attachPoint, Operation operation) {
if (!(attachPoint instanceof IntentAttachPoint)) {
return null;
}
IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
List<QName> qnames = new ArrayList<QName>();
for (Intent intent: intentAttachPoint.getRequiredIntents()) {
qnames.add(intent.getName());
}
return new XAttr(Constants.REQUIRES, qnames);
}
/**
* Write policy sets associated with an operation.
* @param attachPoint
* @param operation
*/
private XAttr writePolicySets(Object attachPoint, Operation operation) {
if (!(attachPoint instanceof PolicySetAttachPoint)) {
return null;
}
PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
List<QName> qnames = new ArrayList<QName>();
for (PolicySet policySet: policySetAttachPoint.getPolicySets()) {
qnames.add(policySet.getName());
}
return new XAttr(Constants.POLICY_SETS, qnames);
}
public void resolvePolicies(Object attachPoint, ModelResolver resolver) {
if ( attachPoint instanceof PolicySetAttachPoint ) {
PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
List<Intent> requiredIntents = new ArrayList<Intent>();
Intent resolvedIntent = null;
if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) {
for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
resolvedIntent = resolver.resolveModel(Intent.class, intent);
requiredIntents.add(resolvedIntent);
}
policySetAttachPoint.getRequiredIntents().clear();
policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
}
if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) {
List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
PolicySet resolvedPolicySet = null;
for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
resolvedPolicySets.add(resolvedPolicySet);
}
policySetAttachPoint.getPolicySets().clear();
policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
}
}
}
}

View file

@ -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.
# Implementation class for the artifact processor extension
org.apache.tuscany.sca.assembly.xml.ComponentTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#componentType,model=org.apache.tuscany.sca.assembly.ComponentType
org.apache.tuscany.sca.assembly.xml.ConstrainingTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#composite,model=org.apache.tuscany.sca.assembly.Composite

View file

@ -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.
# Implementation class for the artifact processor extension
org.apache.tuscany.sca.assembly.xml.ComponentTypeDocumentProcessor;type=.componentType,model=org.apache.tuscany.sca.assembly.ComponentType
org.apache.tuscany.sca.assembly.xml.ConstrainingTypeDocumentProcessor;type=.constrainingType,model=org.apache.tuscany.sca.assembly.ConstrainingType
org.apache.tuscany.sca.assembly.xml.CompositeDocumentProcessor;type=.composite,model=org.apache.tuscany.sca.assembly.Composite

View file

@ -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.
org.apache.tuscany.sca.assembly.xml.CompositeModelResolver;model=org.apache.tuscany.sca.assembly.Composite
org.apache.tuscany.sca.assembly.xml.ConstrainingTypeModelResolver;model=org.apache.tuscany.sca.assembly.ConstrainingType
org.apache.tuscany.sca.assembly.xml.ComponentTypeModelResolver;model=org.apache.tuscany.sca.assembly.ComponentType

View file

@ -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.
#
#
NoCompositeNamespace = No namespace found: Composite = {0}
UnexpectedInterfaceElement = Unexpected <interface> element found. It should appear inside a <service> or <reference> element.
UnexpectedBindingElement = Unexpected <binding> element found. It should appear inside a <service> or <reference> element.
UnexpectedImplementationElement = Unexpected <implementation> element found. It should appear inside a <component> element.
PolicyImplValidationException = PolicyValidation exception when processing implementation of component {0} due to {1}.
PolicyServiceValidationException = PolicyValidation exceptions when processing service/reference {0} in {1}. Error is {2}
ContributionReadException = ContributionReadException occured due to : {0}
ContributionWriteException = ContributionWriteException occured due to : {0}

View file

@ -0,0 +1,71 @@
/*
* 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 java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.junit.Test;
public class AnyElementReadWriteTestCase extends TestCase {
private XMLInputFactory inputFactory;
String XML = "<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><interface.java xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" target=\"AddServiceComponent\" /><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\" /><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /><x:unknownElement xmlns:x=\"http://x\" uknAttr=\"attribute1\"><x:subUnknownElement1 uknAttr1=\"attribute1\" /><x:subUnknownElement2 /></x:unknownElement></composite>";
private ExtensibleStAXArtifactProcessor staxProcessor;
@Override
public void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
}
@Override
public void tearDown() throws Exception {
}
@Test
public void testReadWriteComposite() throws Exception{
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite composite = (Composite)staxProcessor.read(reader);
assertNotNull(composite);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
staxProcessor.write(composite, bos);
System.out.println(bos.toString());
assertEquals(XML,bos.toString());
bos.close();
is.close();
}
}

View file

@ -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.assembly.xml;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.OperationsConfigurator;
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.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.DefaultURLArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.definitions.SCADefinitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl;
import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
/**
* Test reading SCA XML assembly documents.
*
* @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
*/
public class BuildPolicyTestCase extends TestCase {
private URLArtifactProcessor<Object> documentProcessor;
private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
private ModelResolver resolver;
private CompositeBuilder compositeBuilder;
private Composite composite;
private Monitor monitor;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
List<SCADefinitions> policyDefinitions = new ArrayList<SCADefinitions>();
resolver = new DefaultModelResolver();
MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl();
monitor = monitorFactory.createMonitor();
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper, monitor);
URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
policyDefinitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class);
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
URL url = getClass().getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
assertNotNull(constrainingType);
resolver.addModel(constrainingType);
url = getClass().getResource("TestAllPolicyCalculator.composite");
uri = URI.create("TestAllCalculator.constrainingType");
composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
url = getClass().getResource("another_test_definitions.xml");
uri = URI.create("another_test_definitions.xml");
SCADefinitions definitions = (SCADefinitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(definitions);
policyDefinitions.add(definitions);
documentProcessor.resolve(definitions, resolver);
documentProcessor.resolve(composite, resolver);
compositeBuilder.build(composite);
}
public void testPolicyIntentInheritance() throws Exception {
String namespaceUri = "http://test";
IntentAttachPoint policiedComposite = (IntentAttachPoint)composite;
assertEquals(policiedComposite.getRequiredIntents().size(), 1);
assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
//1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
//1 from the operation defined in this service and 2 from the operation defined in the promoted service
assertEquals(composite.getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3"));
//bindings will have only 2 intents since duplications will be cut out
assertEquals(((IntentAttachPoint)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().size(), 1);
assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getReferences().get(0).getConfiguredOperations().size(), 1);
assertEquals(composite.getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 4);
assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
assertEquals(((IntentAttachPoint)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
assertEquals(composite.getComponents().get(0).getRequiredIntents().size(), 3);
assertEquals(composite.getComponents().get(0).getRequiredIntents().get(2).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
assertEquals(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size(), 4);
assertEquals(composite.getComponents().get(0).getServices().get(0).getCallback().getRequiredIntents().size(), 4);
assertEquals(composite.getComponents().get(0).getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getComponents().get(0).getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
}
}

View file

@ -0,0 +1,145 @@
/*
* 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 java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Callback;
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.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Property;
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.policy.PolicySetAttachPoint;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Test reading SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class ReadAllTestCase extends TestCase {
private StAXArtifactProcessor<Object> staxProcessor;
private XMLInputFactory inputFactory;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
inputFactory = XMLInputFactory.newInstance();
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
}
public void testReadComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is));
assertNotNull(composite);
assertEquals(composite.getName(), new QName("http://calc", "TestAllCalculator"));
assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "CalculatorComponent"));
assertTrue(composite.isLocal());
assertFalse(composite.getAutowire() == Boolean.TRUE);
assertEquals(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
"confidentiality"));
assertEquals(((PolicySetAttachPoint)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
Composite include = composite.getIncludes().get(0);
assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));
CompositeService calcCompositeService = (CompositeService)composite.getServices().get(0);
assertEquals(calcCompositeService.getName(), "CalculatorService");
assertTrue(calcCompositeService.getPromotedService().isUnresolved());
assertEquals(calcCompositeService.getPromotedService().getName(),
"CalculatorService");
assertEquals(calcCompositeService.getRequiredIntents().get(0).getName(),
new QName("http://test", "confidentiality"));
assertEquals(calcCompositeService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
// TODO test operations
Callback calcServiceCallback = calcCompositeService.getCallback();
assertNotNull(calcServiceCallback);
assertEquals(calcServiceCallback.getRequiredIntents().get(0).getName(),
new QName("http://test", "confidentiality"));
assertEquals(calcServiceCallback.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
// TODO test operations
Component calcComponent = composite.getComponents().get(0);
assertEquals(calcComponent.getName(), "CalculatorServiceComponent");
assertEquals(calcComponent.getAutowire(), Boolean.FALSE);
assertEquals(calcComponent.getConstrainingType().getName(), new QName("http://calc",
"CalculatorComponent"));
assertEquals(calcComponent.getRequiredIntents().get(0).getName(), new QName("http://test",
"confidentiality"));
assertEquals(calcComponent.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
ComponentService calcComponentService = calcComponent.getServices().get(0);
assertEquals(calcComponentService.getName(), "CalculatorService");
assertEquals(calcComponentService.getRequiredIntents().get(0).getName(),
new QName("http://test", "confidentiality"));
assertEquals(calcComponentService.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
// TODO test operations
ComponentReference calcComponentReference = calcComponent.getReferences().get(0);
assertEquals(calcComponentReference.getName(), "addService");
assertEquals(calcComponentReference.getAutowire(), Boolean.FALSE);
assertEquals(calcComponentReference.isWiredByImpl(), false);
assertEquals(calcComponentReference.getRequiredIntents().get(0).getName(),
new QName("http://test", "confidentiality"));
assertEquals(calcComponentReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
// TODO test operations
Property property = calcComponent.getProperties().get(0);
assertEquals(property.getName(), "round");
Document doc = (Document) property.getValue();
Element element = doc.getDocumentElement();
String value = element.getTextContent();
assertEquals(value, "true");
assertEquals(property.getXSDType(), new QName("http://www.w3.org/2001/XMLSchema", "boolean"));
assertEquals(property.isMany(), false);
CompositeReference calcCompositeReference = (CompositeReference)composite.getReferences().get(0);
assertEquals(calcCompositeReference.getName(), "MultiplyService");
assertTrue(calcCompositeReference.getPromotedReferences().get(0).isUnresolved());
assertEquals(calcCompositeReference.getPromotedReferences().get(0).getName(),
"CalculatorServiceComponent/multiplyService");
assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
new QName("http://test", "confidentiality"));
assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
// TODO test operations
Callback calcCallback = calcCompositeReference.getCallback();
assertEquals(calcCompositeReference.getRequiredIntents().get(0).getName(),
new QName("http://test", "confidentiality"));
assertEquals(calcCompositeReference.getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
assertNotNull(calcCallback);
// TODO test operations
}
}

View file

@ -0,0 +1,207 @@
/*
* 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 java.net.URI;
import java.net.URL;
import javax.xml.XMLConstants;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.stream.XMLInputFactory;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.ValidatorHandler;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
import org.apache.tuscany.sca.contribution.processor.DefaultValidationSchemaExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
/**
* Test reading SCA XML assembly documents.
*
* @version $Rev$ $Date$
*/
public class ReadDocumentTestCase extends TestCase {
private URLArtifactProcessor<Object> documentProcessor;
private ModelResolver resolver;
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
inputFactory = XMLInputFactory.newInstance();
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
resolver = new DefaultModelResolver();
}
public void testValidateAssembly() throws Exception {
SchemaFactory schemaFactory;
try {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
} catch (Error e) {
// Some old JDKs don't support XMLSchema validation
return;
} catch (Exception e) {
// Some old JDKs don't support XMLSchema validation
return;
}
Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd"));
ValidatorHandler handler = schema.newValidatorHandler();
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
URL url = getClass().getResource("Calculator.composite");
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setContentHandler(handler);
reader.parse(new InputSource(url.openStream()));
}
public void testValidateImplementation() throws Exception {
SchemaFactory schemaFactory;
try {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
} catch (Error e) {
// Some old JDKs don't support XMLSchema validation
return;
} catch (Exception e) {
// Some old JDKs don't support XMLSchema validation
return;
}
Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd"));
ValidatorHandler handler = schema.newValidatorHandler();
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
URL url = getClass().getResource("JavaScriptReference.composite");
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setContentHandler(handler);
reader.parse(new InputSource(url.openStream()));
}
public void testReadImplementation() throws Exception {
ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
schemas.addSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd").toString());
XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null, null);
URL url = getClass().getResource("JavaScriptReference.composite");
URI uri = URI.create("JavaScriptReference.composite");
Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
assertNotNull(composite);
}
public void testValidateBinding() throws Exception {
SchemaFactory schemaFactory;
try {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
} catch (Error e) {
// Some old JDKs don't support XMLSchema validation
return;
} catch (Exception e) {
// Some old JDKs don't support XMLSchema validation
return;
}
Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd"));
ValidatorHandler handler = schema.newValidatorHandler();
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
URL url = getClass().getResource("RMIBindingTest.composite");
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setContentHandler(handler);
reader.parse(new InputSource(url.openStream()));
}
public void testReadBinding() throws Exception {
ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
schemas.addSchema(getClass().getClassLoader().getResource("tuscany-sca.xsd").toString());
XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(staxProcessor, validatingInputFactory, null, null);
URL url = getClass().getResource("RMIBindingTest.composite");
URI uri = URI.create("RMIBindingTest.composite");
Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
assertNotNull(composite);
}
public void testResolveConstrainingType() throws Exception {
URL url = getClass().getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
assertNotNull(constrainingType);
resolver.addModel(constrainingType);
url = getClass().getResource("TestAllCalculator.composite");
uri = URI.create("TestAllCalculator.constrainingType");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
documentProcessor.resolve(composite, resolver);
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
public void testResolveComposite() throws Exception {
URL url = getClass().getResource("Calculator.composite");
URI uri = URI.create("Calculator.composite");
Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(nestedComposite);
resolver.addModel(nestedComposite);
url = getClass().getResource("TestAllCalculator.composite");
uri = URI.create("TestAllCalculator.composite");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
documentProcessor.resolve(composite, resolver);
assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
}
}

View file

@ -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.assembly.xml;
import java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
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.ExtensionPointRegistry;
/**
* Test reading SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class ReadTestCase extends TestCase {
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
@Override
public void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
}
@Override
public void tearDown() throws Exception {
}
public void testReadComponentType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
assertNotNull(staxProcessor.read(reader));
is.close();
}
public void testReadConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
assertNotNull(staxProcessor.read(reader));
is.close();
}
public void testReadComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
assertNotNull(staxProcessor.read(reader));
is.close();
}
public void testReadCompositeAndWireIt() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
assertNotNull(staxProcessor.read(reader));
is.close();
}
}

View file

@ -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.assembly.xml;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
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.contribution.processor.StAXAttributeProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
/**
* Test reading SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class ReadWriteAttributeTestCase extends TestCase {
private XMLInputFactory inputFactory;
private ExtensibleStAXArtifactProcessor staxProcessor;
private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+
"<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\">"+
"<service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\">"+
"<interface.java xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" interface=\"calculator.CalculatorService\" />"+
"</service>"+
"<component name=\"CalculatorServiceComponent\" customAttribute=\"customValue\">"+
"<reference name=\"addService\" target=\"AddServiceComponent\" />"+
"<reference name=\"subtractService\" target=\"SubtractServiceComponent\" />"+
"<reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" />"+
"<reference name=\"divideService\" target=\"DivideServiceComponent\" />"+
"</component>"+
"<component name=\"AddServiceComponent\" />"+
"<component name=\"SubtractServiceComponent\" />"+
"<component name=\"MultiplyServiceComponent\" />"+
"<component name=\"DivideServiceComponent\" />"+
"</composite>";
@Override
public void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
StAXAttributeProcessorExtensionPoint staxAttributeProcessors = extensionPoints.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
staxAttributeProcessors.addArtifactProcessor(new TestAttributeProcessor());
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
}
@Override
public void tearDown() throws Exception {
}
public void testReadComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorExtended.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite composite = (Composite) staxProcessor.read(reader);
assertNotNull(composite);
is.close();
}
public void testWriteComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorExtended.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite composite = (Composite) staxProcessor.read(reader);
assertNotNull(composite);
is.close();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
staxProcessor.write(composite, bos);
System.out.println(bos.toString());
assertEquals(XML, bos.toString());
}
}

View file

@ -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.assembly.xml;
import java.net.URI;
import java.net.URL;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.SCADefinitions;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* Test reading SCA XML assembly documents.
*
* @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
*/
public class ResolvePolicyTestCase extends TestCase {
private URLArtifactProcessor<Object> documentProcessor;
private ModelResolver resolver;
private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
resolver = new DefaultModelResolver();
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
policyDefinitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class);
// Create StAX processors
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
}
public void testResolveConstrainingType() throws Exception {
URL url = getClass().getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
assertNotNull(constrainingType);
resolver.addModel(constrainingType);
url = getClass().getResource("TestAllCalculator.composite");
uri = URI.create("TestAllCalculator.constrainingType");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
url = getClass().getResource("test_definitions.xml");
uri = URI.create("test_definitions.xml");
SCADefinitions scaDefns = (SCADefinitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(scaDefns);
preResolvePolicyTests(composite);
documentProcessor.resolve(scaDefns, resolver);
documentProcessor.resolve(composite, resolver);
postResolvePolicyTests(composite);
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
private void preResolvePolicyTests(Composite composite) {
assertNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription());
assertTrue(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
}
private void postResolvePolicyTests(Composite composite) {
assertNotNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription());
assertFalse(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
}
public void testResolveComposite() throws Exception {
URL url = getClass().getResource("Calculator.composite");
URI uri = URI.create("Calculator.composite");
Composite nestedComposite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(nestedComposite);
resolver.addModel(nestedComposite);
url = getClass().getResource("TestAllCalculator.composite");
uri = URI.create("TestAllCalculator.composite");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
documentProcessor.resolve(composite, resolver);
assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
}
}

View file

@ -0,0 +1,97 @@
/*
* 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 java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
/**
* Test resolving SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class ResolveTestCase extends TestCase {
private XMLInputFactory inputFactory;
private StAXArtifactProcessorExtensionPoint staxProcessors;
private ModelResolver resolver;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
resolver = new DefaultModelResolver();
}
public void testResolveConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
StAXArtifactProcessor<ConstrainingType> constrainingTypeReader = staxProcessors.getProcessor(ConstrainingType.class);
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
ConstrainingType constrainingType = constrainingTypeReader.read(reader);
is.close();
assertNotNull(constrainingType);
resolver.addModel(constrainingType);
is = getClass().getResourceAsStream("TestAllCalculator.composite");
StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
reader = inputFactory.createXMLStreamReader(is);
Composite composite = compositeReader.read(reader);
is.close();
assertNotNull(composite);
compositeReader.resolve(composite, resolver);
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
public void testResolveComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite nestedComposite = compositeReader.read(reader);
is.close();
assertNotNull(nestedComposite);
resolver.addModel(nestedComposite);
is = getClass().getResourceAsStream("TestAllCalculator.composite");
reader = inputFactory.createXMLStreamReader(is);
Composite composite = compositeReader.read(reader);
is.close();
compositeReader.resolve(composite, resolver);
assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
}
}

View file

@ -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.assembly.xml;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
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;
/**
* A Policy Processor used for testing.
*
* @version $Rev$ $Date$
*/
public class TestAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<String> {
private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
public QName getArtifactType() {
return ATTRIBUTE;
}
public String read(QName attributeName, XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
return reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart());
}
public void write(String value, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
writer.setPrefix(ATTRIBUTE.getPrefix(), ATTRIBUTE.getNamespaceURI());
writer.writeAttribute(ATTRIBUTE.getLocalPart(), value);
}
public Class<String> getModelType() {
return String.class;
}
public void resolve(String arg0, ModelResolver arg1) throws ContributionResolveException {
}
}

View file

@ -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.assembly.xml;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
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.policy.Policy;
/**
* A Policy Processor used for testing.
*
* @version $Rev$ $Date$
*/
public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
public QName getArtifactType() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
public Policy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
return new MockPolicyImplOne();
}
public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException,
XMLStreamException {
}
public Class<Policy> getModelType() {
return Policy.class;
}
public void resolve(Policy arg0, ModelResolver arg1) throws ContributionResolveException {
}
public class MockPolicyImplOne implements Policy {
public QName getSchemaName() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
public boolean isUnresolved() {
return false;
}
public void setUnresolved(boolean unresolved) {
}
}
}

View file

@ -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.assembly.xml;
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
/**
* A factory for the SCA binding model.
*
* @version $Rev$ $Date$
*/
public class TestSCABindingFactoryImpl implements SCABindingFactory {
public SCABinding createSCABinding() {
return new TestSCABindingImpl();
}
}

View file

@ -0,0 +1,213 @@
/*
* 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 java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* A test cheel for the SCA binding.
*
* @version $Rev$ $Date$
*/
public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySetAttachPoint, OperationsConfigurator {
private String name;
private String uri;
private List<Object> extensions = new ArrayList<Object>();
private Component targetComponent;
private ComponentService targetComponentService;
private Binding targetBinding;
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private IntentAttachPointType bindingType = new TestSCABindingType();
private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
/**
* Constructs a new SCA binding.
*/
protected TestSCABindingImpl() {
}
public String getName() {
return name;
}
public String getURI() {
return uri;
}
public void setName(String name) {
this.name = name;
}
public void setURI(String uri) {
this.uri = uri;
}
public List<Object> getExtensions() {
return extensions;
}
public boolean isUnresolved() {
return false;
}
public void setUnresolved(boolean unresolved) {
}
/**
* @see java.lang.Object#clone()
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* @return the targetComponent
*/
public Component getTargetComponent() {
return targetComponent;
}
/**
* @param targetComponent the targetComponent to set
*/
public void setTargetComponent(Component targetComponent) {
this.targetComponent = targetComponent;
}
/**
* @return the targetComponentService
*/
public ComponentService getTargetComponentService() {
return targetComponentService;
}
/**
* @param targetComponentService the targetComponentService to set
*/
public void setTargetComponentService(ComponentService targetComponentService) {
this.targetComponentService = targetComponentService;
}
/**
* @return the targetBinding
*/
public Binding getTargetBinding() {
return targetBinding;
}
/**
* @param targetBinding the targetBinding to set
*/
public void setTargetBinding(Binding targetBinding) {
this.targetBinding = targetBinding;
}
public List<PolicySet> getPolicySets() {
// TODO Auto-generated method stub
return policySets;
}
public List<Intent> getRequiredIntents() {
// TODO Auto-generated method stub
return requiredIntents;
}
public IntentAttachPointType getType() {
// TODO Auto-generated method stub
return bindingType;
}
public void setType(IntentAttachPointType type) {
this.bindingType = type;
}
private class TestSCABindingType implements IntentAttachPointType {
private QName name = new QName("http://www.osoa.org/xmlns/sca/1.0","binding");
public List<Intent> getAlwaysProvidedIntents() {
// TODO Auto-generated method stub
return null;
}
public List<Intent> getMayProvideIntents() {
// TODO Auto-generated method stub
return null;
}
public QName getName() {
return name;
}
public boolean isUnresolved() {
// TODO Auto-generated method stub
return false;
}
public void setName(QName type) {
// TODO Auto-generated method stub
}
public void setUnresolved(boolean unresolved) {
// TODO Auto-generated method stub
}
}
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
public void setRequiredIntents(List<Intent> intents) {
this.requiredIntents = intents;
}
public List<ConfiguredOperation> getConfiguredOperations() {
return configuredOperations;
}
public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
this.configuredOperations = configuredOperations;
}
public List<PolicySet> getApplicablePolicySets() {
return applicablePolicySets;
}
}

View file

@ -0,0 +1,147 @@
/*
* 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 java.io.InputStream;
import java.net.URI;
import java.net.URL;
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.ConstrainingType;
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.contribution.ModelFactoryExtensionPoint;
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.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.definitions.SCADefinitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl;
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
/**
* Test the wiring of SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class WireTestCase extends TestCase {
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
private ModelResolver resolver;
private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
private CompositeBuilder compositeBuilder;
private Monitor monitor;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
resolver = new DefaultModelResolver();
MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl();
monitor = monitorFactory.createMonitor();
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper, monitor);
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
policyDefinitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class);
}
public void testResolveConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader);
is.close();
assertNotNull(constrainingType);
resolver.addModel(constrainingType);
is = getClass().getResourceAsStream("TestAllCalculator.composite");
reader = inputFactory.createXMLStreamReader(is);
Composite composite = (Composite)staxProcessor.read(reader);
is.close();
assertNotNull(composite);
URL url = getClass().getResource("test_definitions.xml");
URI uri = URI.create("test_definitions.xml");
SCADefinitions scaDefns = (SCADefinitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(scaDefns);
policyDefinitionsProcessor.resolve(scaDefns, resolver);
staxProcessor.resolve(composite, resolver);
compositeBuilder.build(composite);
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
public void testResolveComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite nestedComposite = (Composite)staxProcessor.read(reader);
is.close();
assertNotNull(nestedComposite);
resolver.addModel(nestedComposite);
is = getClass().getResourceAsStream("TestAllCalculator.composite");
reader = inputFactory.createXMLStreamReader(is);
Composite composite = (Composite)staxProcessor.read(reader);
is.close();
URL url = getClass().getResource("test_definitions.xml");
URI uri = URI.create("test_definitions.xml");
SCADefinitions scaDefns = (SCADefinitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(scaDefns);
policyDefinitionsProcessor.resolve(scaDefns, resolver);
staxProcessor.resolve(composite, resolver);
compositeBuilder.build(composite);
assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
}
}

View file

@ -0,0 +1,160 @@
/*
* 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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
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.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.definitions.SCADefinitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl;
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
/**
* Test writing SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class WriteAllTestCase extends TestCase {
private XMLInputFactory inputFactory;
private XMLOutputFactory outputFactory;
private ExtensibleStAXArtifactProcessor staxProcessor;
private ModelResolver resolver;
private CompositeBuilder compositeBuilder;
private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
private Monitor monitor;
@Override
public void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
outputFactory = XMLOutputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
resolver = new DefaultModelResolver();
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl();
monitor = monitorFactory.createMonitor();
compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper, monitor);
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
policyDefinitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class);
}
@Override
public void tearDown() throws Exception {
}
public void testReadWriteComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
Composite composite = staxProcessor.read(is, Composite.class);
verifyComposite(composite);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
staxProcessor.write(composite, bos);
bos.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
composite = staxProcessor.read(bis, Composite.class);
verifyComposite(composite);
}
public void testReadWireWriteComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
Composite composite = staxProcessor.read(is, Composite.class);
URL url = getClass().getResource("test_definitions.xml");
URI uri = URI.create("test_definitions.xml");
SCADefinitions scaDefns = (SCADefinitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(scaDefns);
policyDefinitionsProcessor.resolve(scaDefns, resolver);
staxProcessor.resolve(composite, resolver);
compositeBuilder.build(composite);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
staxProcessor.write(composite, bos);
}
public void testReadWriteComponentType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
ComponentType componentType = staxProcessor.read(is, ComponentType.class);
staxProcessor.resolve(componentType, resolver);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
staxProcessor.write(componentType, bos);
}
public void testReadWriteConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
staxProcessor.resolve(constrainingType, resolver);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
staxProcessor.write(constrainingType, bos);
}
private void verifyComposite(Composite composite) {
assertEquals(composite.getProperties().get(0).getName(),"prop1");
assertEquals(composite.getProperties().get(0).isMany(), true);
assertEquals(composite.getProperties().get(1).getName(),"prop2");
assertEquals(composite.getProperties().get(1).isMustSupply(), true);
assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType"));
assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://www.osoa.org/xmlns/sca/1.0", "MyComplexPropertyValue1"));
}
}

View file

@ -0,0 +1,91 @@
/*
* 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 java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import junit.framework.TestCase;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.Composite;
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.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
/**
* Test writing SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
public class WriteNamespacesTestCase extends TestCase {
private StAXArtifactProcessor<Composite> compositeProcessor;
private XMLOutputFactory outputFactory;
private XMLInputFactory inputFactory;
@Override
public void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
//outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
inputFactory = modelFactories.getFactory(XMLInputFactory.class);
StAXArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
compositeProcessor = artifactProcessors.getProcessor(Composite.class);
}
public void testReadWriteComposite() throws Exception {
// Read
InputStream is = getClass().getResourceAsStream("NestedCalculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
Composite composite = compositeProcessor.read(reader);
Component component = composite.getComponents().get(0);
Composite implementation = (Composite)component.getImplementation();
QName qname = implementation.getName();
// Write
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
compositeProcessor.write(composite, writer);
System.out.println(bos);
// Read again
is = new ByteArrayInputStream(bos.toByteArray());
reader = inputFactory.createXMLStreamReader(is);
composite = compositeProcessor.read(reader);
// Compare
component = composite.getComponents().get(0);
implementation = (Composite)component.getImplementation();
assertEquals(qname, implementation.getName());
}
}

View file

@ -0,0 +1,59 @@
<?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:x="http://x"
xmlns:calc="http://calc"
targetNamespace="http://calc"
name="Calculator">
<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>
<x:unknownElement uknAttr="attribute1">
<x:subUnknownElement1 uknAttr1="attribute1"/>
<x:subUnknownElement2/>
</x:unknownElement>
</composite>

View file

@ -0,0 +1,34 @@
<?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.
-->
<constrainingType xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:calc="http://calc"
targetNamespace="http://calc"
name="CalculatorComponent">
<service name="CalculatorService">
<interface.java class="calculator.CalculatorService" />
</service>
<reference name="divideService">
<interface.java class="calculator.DivideService" />
</reference>
</constrainingType>

View file

@ -0,0 +1,54 @@
<?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"
xmlns:test="http://test"
targetNamespace="http://calc"
name="Calculator">
<service name="CalculatorService" promote="CalculatorServiceComponent">
<interface.java interface="calculator.CalculatorService"/>
</service>
<component name="CalculatorServiceComponent" test:customAttribute="customValue">
<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>

View file

@ -0,0 +1,31 @@
<?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">
<service name="CalculatorService">
<interface.java class="calculator.CalculatorService" />
</service>
<reference name="divideService">
<interface.java class="calculator.DivideService" />
</reference>
</componentType>

View file

@ -0,0 +1,37 @@
<?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"
name="JavaScriptReference">
<component name="ClientComponent">
<implementation.java class="org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorldProxy"/>
</component>
<component name="ReferenceComponent">
<tuscany:implementation.script script="org/apache/tuscany/sca/implementation/script/itests/references/reference.js"/>
<reference name="ref" target="TargetComponent" />
</component>
<component name="TargetComponent">
<implementation.java class="org.apache.tuscany.sca.implementation.script.itests.references.HelloWorldTarget"/>
</component>
</composite>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:calc="http://calc"
targetNamespace="http://calc"
name="Calculator">
<component name="CalculatorServiceComponent">
<implementation.composite xmlns:n="http://inner" name="n:InnerCalculator"/>
</component>
</composite>

View file

@ -0,0 +1,43 @@
<?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"
name="HelloWorldRmiComposite">
<service name="HelloWorldRmiService" promote="HelloWorldServiceComponent">
<interface.java interface="helloworld.HelloWorldService"/>
<tuscany:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
</service>
<component name="HelloWorldServiceComponent">
<implementation.java class="helloworld.HelloWorldImpl"/>
</component>
<component name="HelloWorldRmiServiceComponent">
<implementation.java class="helloworld.HelloWorldRmiImpl"/>
<reference name="extService"></reference>
</component>
<reference name="HelloWorldRmiReference" promote="HelloWorldRmiServiceComponent/extService">
<interface.java interface="helloworld.HelloWorldService"/>
<tuscany:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService" />
</reference>
</composite>

View file

@ -0,0 +1,128 @@
<?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 autowire="false" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator" policySets="sns:SecureReliablePolicy"
requires="cns:confidentiality" targetNamespace="http://calc" xmlns:tns="http://calc"
xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0 "
xmlns:ext="http://extension"
xmlns:cns="http://test" xmlns:sns="http://test">
<include name="tns:TestAllDivide"/>
<ext:testExtension/>
<service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:confidentiality"
policySets="sns:SecureReliablePolicy">
<ext:testExtension/>
<interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
<operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
<binding.ws name="CalculatorWS" policySets="sns:SecureReliablePolicy" port="" requires="cns:confidentiality" uri="http://calc/ws">
<operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
<callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
<ext:testExtension/>
<binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
<operation name="addCallback" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
</callback>
</service>
<component name="CalculatorServiceComponent" autowire="false" constrainingType="tns:CalculatorComponent"
policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
<ext:testExtension/>
<service name="CalculatorService" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
<interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
</service>
<reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" wiredByImpl="false">
<ext:testExtension/>
<interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
</reference>
<reference name="subtractService" target="SubtractServiceComponent" />
<reference name="multiplyService" />
<reference name="divideService" target="DivideServiceComponent" />
<property name="round" type="xsd:boolean" many="false">true</property>
<implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="" />
</component>
<component name="AddServiceComponent">
<service name="AddService">
<interface.java interface="calculator.AddService" />
</service>
<implementation.java class="calculator.AddServiceImpl" />
</component>
<component name="NestedCompositeComponent">
<service name="CalculatorService">
<interface.java interface="calculator.CalculatorService" />
</service>
<implementation.composite name="tns:Calculator" />
</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>
<reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService" policySets="sns:SecureReliablePolicy"
requires="cns:confidentiality">
<interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
<operation name="multiply" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
<binding.ws name="MultiplyWS" port="" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" uri="http://calc/ws">
<operation name="multiply" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
<callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
<binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws" policySets="sns:SecureReliablePolicy"
requires="cns:confidentiality">
<operation name="multiplyCallback" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
</callback>
</reference>
<property name="prop1" xmlns:foo="http://foo" many="true" type="foo:MyComplexType">
<ext:testExtension/>
<MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
<foo:a>AValue</foo:a>
<bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
</MyComplexPropertyValue1>
<MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
<foo:a>BValue</foo:a>
<bar:b xmlns:bar="http://bar">BoringURI</bar:b>
</MyComplexPropertyValue2>
</property>
<property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="MyComplexPropertyValue1"/>
</composite>

View file

@ -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.
-->
<composite autowire="false"
constrainingType="tns:Calculator"
local="true"
name="TestAllDivide"
policySets="" requires=""
targetNamespace="http://calc"
xmlns:tns="http://calc"
xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0 ">
<include name="tns:CompleteDivide"/>
<service name="DivideService" policySets="" promote="CalculatorDivideComponent/DivideService" requires="">
<interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
<operation name="divide" policySets="" requires=""/>
<binding.ws name="CalculatorWS" policySets="" port="" requires="" uri="http://calc/ws">
<operation name="divide" policySets="" requires=""/>
</binding.ws>
<callback policySets="" requires="">
<binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
<operation name="divideCallback" policySets="" requires=""/>
</binding.ws>
</callback>
</service>
<component name="CalculatorDivideComponent" autowire="false" constrainingType="tns:CalculatorServiceComponent" policySets="" requires="">
<service name="DivideService" policySets="" requires="">
<interface.java interface="calculator.DivideService" callbackInterface="calculator.DivideCallback"/>
</service>
<implementation.java class="calculator.DivideImpl" policySets="" requires=""/>
</component>
</composite>

View file

@ -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.
-->
<composite autowire="false" constrainingType="tns:CalculatorComponent" local="true" name="TestAllCalculator"
requires="cns:tuscanyIntent_1" targetNamespace="http://calc" xmlns:tns="http://calc"
xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osoa.org/xmlns/sca/1.0 http://www.osoa.org/xmlns/sca/1.0 "
xmlns:ext="http://extension"
xmlns:cns="http://test" xmlns:sns="http://test">
<include name="tns:TestAllDivide"/>
<ext:testExtension/>
<service name="CalculatorService" promote="CalculatorServiceComponent/CalculatorService" requires="cns:tuscanyIntent_2 cns:tuscanyIntent_1">
<ext:testExtension/>
<interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
<operation name="add" requires="cns:tuscanyIntent_6"/>
<binding.ws name="CalculatorWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
</binding.ws>
<callback requires="cns:tuscanyIntent_4">
<ext:testExtension/>
<binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_5" uri="http://calc/callback/ws">
</binding.ws>
</callback>
</service>
<component name="CalculatorServiceComponent" autowire="false" constrainingType="tns:CalculatorComponent"
requires="cns:tuscanyIntent_2 cns:tuscanyIntent_3">
<ext:testExtension/>
<service name="CalculatorService" requires="cns:tuscanyIntent_3">
<interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
<operation name="add" requires="cns:tuscanyIntent_6 cns:tuscanyIntent_7"/>
<binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
</binding.ws>
<callback>
</callback>
</service>
<reference name="addService" target="AddServiceComponent/AddService" autowire="false" multiplicity="1..1"
requires="cns:tuscanyIntent_3 cns:tuscanyIntent_2.qualified" wiredByImpl="false">
<ext:testExtension/>
<interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
<operation name="add" requires="cns:tuscanyIntent_8 cns:tuscanyIntent_9"/>
<binding.ws name="addServiceWSRef" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
</binding.ws>
</reference>
<reference name="subtractService" target="SubtractServiceComponent" />
<reference name="multiplyService" />
<reference name="divideService" target="DivideServiceComponent" />
<property name="round" type="xsd:boolean" many="false">true</property>
<implementation.java class="calculator.CalculatorServiceImpl" policySets="" requires="cns:tuscanyIntent_4" />
</component>
<component name="AddServiceComponent">
<service name="AddService">
<interface.java interface="calculator.AddService" />
</service>
<implementation.java class="calculator.AddServiceImpl" />
</component>
<component name="NestedCompositeComponent">
<service name="CalculatorService">
<interface.java interface="calculator.CalculatorService" />
</service>
<implementation.composite name="tns:Calculator" />
</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>
<reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
requires="cns:tuscanyIntent_2">
<interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
<operation name="multiply" requires="cns:tuscanyIntent_6"/>
<binding.ws name="MultiplyWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
</binding.ws>
<callback policySets="sns:SecureReliablePolicy" requires="cns:tuscanyIntent_3">
<binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws"
requires="cns:tuscanyIntent_4">
</binding.ws>
</callback>
</reference>
<property name="prop1" xmlns:foo="http://foo">
<ext:testExtension/>
<MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
<foo:a>AValue</foo:a>
<bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
</MyComplexPropertyValue1>
<MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
<foo:a>BValue</foo:a>
<bar:b xmlns:bar="http://bar">BoringURI</bar:b>
</MyComplexPropertyValue2>
</property>
</composite>

View file

@ -0,0 +1,97 @@
<?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.
-->
<sca:definitions xmlns="http://test"
targetNamespace="http://test"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
<!-- simple intent -->
<sca:intent name="tuscanyIntent_1"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_2"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_3"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_4"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_5"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_6"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_7"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_8"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_9"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<sca:intent name="tuscanyIntent_10"
constrains="sca:binding">
<sca:description>
Sample Intent
</sca:description>
</sca:intent>
<!-- qualified intents -->
<sca:intent name="tuscanyIntent_1.qualified" />
<sca:intent name="tuscanyIntent_2.qualified" />
</sca:definitions>

View file

@ -0,0 +1,175 @@
<?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.
-->
<sca:definitions xmlns="http://test"
targetNamespace="http://test"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
<!-- qualified intents -->
<sca:intent name="confidentiality.transport" />
<sca:intent name="confidentiality.message" />
<sca:intent name="confidentiality.message.whole" />
<sca:intent name="confidentiality.message.body" />
<!-- POLICY SETS -->
<sca:policySet name="SecureReliablePolicy"
provides="confidentiality.transport integrity"
appliesTo="//sca:binding.ws | //sca:binding.sca"
xmlns="http://test"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:PolicyAttachment>
<!-- policy expression and policy subject for
"basic authentication" -->
</wsp:PolicyAttachment>
<wsp:PolicyAttachment>
<!-- policy expression and policy subject for
"reliability" -->
</wsp:PolicyAttachment>
</sca:policySet>
<sca:policySet name="SecureMessagingPolicies"
provides="confidentiality"
appliesTo="//sca:binding.ws"
xmlns="http://test"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<sca:intentMap provides="confidentiality" default="transport">
<sca:qualifier name="transport">
<wsp:Policy>
<!-- policy expression and policy subject for "transport" alternative -->
</wsp:Policy>
<wsp:Policy>...</wsp:Policy>
</sca:qualifier>
<sca:qualifier name="message">
<wsp:Policy>
<!-- policy expression and policy subject for "message" alternative" -->
</wsp:Policy>
</sca:qualifier>
</sca:intentMap>
</sca:policySet>
<sca:policySet name="SecurityPolicy" provides="confidentiality"
xmlns="http://test"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
<sca:intentMap provides="confidentiality" default="message">
<sca:qualifier name="message">
<sca:intentMap provides="message" default="whole">
<sca:qualifier name="body">
<wsp:Policy>
<!-- policy attachment for body encryption -->
</wsp:Policy>
</sca:qualifier>
<sca:qualifier name="whole">
<wsp:Policy>
<!-- policy attachment for whole message encryption -->
</wsp:Policy>
</sca:qualifier>
</sca:intentMap>
</sca:qualifier>
<sca:qualifier name="transport">
<wsp:Policy>
<!-- policy attachment for transport encryption -->
</wsp:Policy>
</sca:qualifier>
</sca:intentMap>
</sca:policySet>
<sca:policySet name="BasicAuthMsgProtSecurity"
provides="authentication confidentiality"
appliesTo="//sca:binding.ws"
xmlns="http://test">
<sca:policySetReference name="AuthenticationPolicies"/>
<sca:policySetReference name="ConfidentialityPolicies"/>
</sca:policySet>
<sca:policySet name="AuthenticationPolicies"
provides="authentication"
appliesTo="//sca:binding.ws"
xmlns="http://test"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:PolicyAttachment>
<!-- policy expression and policy subject for "basic
authentication" -->
</wsp:PolicyAttachment>
</sca:policySet>
<sca:policySet name="ConfidentialityPolicies"
provides="confidentiality"
bindings="binding.ws"
xmlns="http://test"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<sca:intentMap provides="confidentiality" default="transport">
<sca:qualifier name="transport">
<wsp:Policy>
<!-- policy expression and policy subject for "transport"
alternative -->
</wsp:Policy>
<wsp:Policy>...</wsp:Policy>
</sca:qualifier>
<sca:qualifier name="message">
<wsp:Policy>
<!-- policy expression and policy subject for "message"
alternative" -->...
</wsp:Policy>
</sca:qualifier>
</sca:intentMap>
</sca:policySet>
<!-- profile intent -->
<sca:intent name="reliableMessageProtection"
constrains="sca:binding"
requires="messageProtection">
<sca:description>
Protect messages from unauthorized reading or modification
</sca:description>
</sca:intent>
<sca:intent name="messageProtection"
constrains="sca:binding"
requires="confidentiality integrity">
<sca:description>
Protect messages from unauthorized reading or modification
</sca:description>
</sca:intent>
<!-- simple intent -->
<sca:intent name="confidentiality"
constrains="sca:binding">
<sca:description>
Communitcation thro this binding must prevent
unauthorized users from reading the messages.
</sca:description>
</sca:intent>
<sca:intent name="integrity"
constrains="sca:binding">
<sca:description>
Communitcation thro this binding must prevent
unauthorized modification of the messages.
</sca:description>
</sca:intent>
<sca:intent name="authentication"
constrains="sca:binding">
<sca:description>
Communitcation thro this binding required
Authentication.
</sca:description>
</sca:intent>
</sca:definitions>

View file

@ -0,0 +1,281 @@
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 includes XSD files under the following SCA Collaboration license:
License for the Service Component Architecture JavaDoc, Interface Definition files and XSD files.
Permission to copy, make derivative works of, and distribute the Service Component Architecture
JavaDoc, Interface Definition Files and XSD files in any medium without fee or royalty as part
of a compliant implementation of the Service Component Architecture Specification is hereby granted.
The Service Components Architecture Specification may be found at the following location:
http://www.osoa.org/download/attachments/35/SCA_AssemblyModel_V100.pdf
THE SERVICE COMPONENT ARCHITECTURE SPECIFICATION AND THE JAVADOC, INTERFACE DEFINITION FILES AND XSD FILES
ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS
SPECIFICATION OR THE JAVADOC, INTERFACE DEFINITION FILES AND XSD FILES AND THE IMPLEMENTATION OF THEIR CONTENTS,
INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
NON-INFRINGEMENT OR TITLE. THE AUTHORS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO ANY USE OR DISTRIBUTION OF THE
SERVICE COMPONENT ARCHITECTURE SPECIFICATION OR THE JAVADOC, INTERFACE DEFINTION FILES OR XSD FILES.
The name and trademarks of the Authors may NOT be used in any manner, including advertising or
publicity pertaining to the Service Component Architecture Specification or its contents without specific,
written prior permission. Title to copyright in the Service Component Architecture Specification and the
JavaDoc, Interface Definition Files and XSD Files will at all times remain with the Authors.
No other rights are granted by implication, estoppel or otherwise.
===============================================================================
This module includes XSD files under the following W3C(r) Software License:
W3C(r) SOFTWARE NOTICE AND LICENSE
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
This work (and included software, documentation such as READMEs, or other related items)
is being provided by the copyright holders under the following license. By obtaining,
using and/or copying this work, you (the licensee) agree that you have read, understood,
and will comply with the following terms and conditions.
Permission to copy, modify, and distribute this software and its documentation, with or
without modification, for any purpose and without fee or royalty is hereby granted, provided
that you include the following on ALL copies of the software and documentation or portions
thereof, including modifications:
1. The full text of this NOTICE in a location viewable to users of the redistributed or
derivative work.
2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions.
If none exist, the W3C Software Short Notice should be included (hypertext is preferred,
text is permitted) within the body of any redistributed or derivative code.
3. Notice of any changes or modifications to the files, including the date changes were
made. (We recommend you provide URIs to the location from which the code is derived.)
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES
OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER
RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL
DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
The name and trademarks of copyright holders may NOT be used in advertising or publicity
pertaining to the software without specific, written prior permission. Title to copyright
in this software and any associated documentation will at all times remain with copyright
holders.

View file

@ -0,0 +1,23 @@
${pom.name}
Copyright (c) 2005 - 2008 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
This product also includes software under the SCA Collaboration license
(see the LICENSE file contained in this distribution), with the following
copyright:
(c) Copyright SCA Collaboration 2006, 2007
This product also includes software under the W3C(r) Software License
(see the LICENSE file contained in this distribution), with the following
copyright:
Copyright (c) 2004 World Wide Web Consortium (Massachusetts Institute of Technology,
European Research Consortium for Informatics and Mathematics, Keio University).
All Rights Reserved. This work is distributed under the W3C(r) Software License [1]
in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231

View file

@ -0,0 +1,49 @@
<?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.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tuscany-assembly-xsd</artifactId>
<name>Apache Tuscany SCA Assembly Model XML Schemas</name>
<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.xsd</Bundle-SymbolicName>
<Bundle-Description>${pom.name}</Bundle-Description>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -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.
#
tuscany-sca.xsd

View file

@ -0,0 +1,33 @@
<?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.
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
<include schemaLocation="sca.xsd"/>
<include schemaLocation="sca-binding-ejb.xsd"/>
<include schemaLocation="sca-implementation-bpel.xsd"/>
<include schemaLocation="sca-implementation-spring.xsd"/>
<include schemaLocation="sca-implementation-ejb.xsd"/>
<include schemaLocation="sca-implementation-web.xsd"/>
</schema>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="binding.ejb" type="sca:EJBSessionBeanBinding"
substitutionGroup="sca:binding" />
<simpleType name="BeanType">
<restriction base="string">
<enumeration value="stateless"/>
<enumeration value="stateful"/>
</restriction>
</simpleType>
<simpleType name="VersionValue">
<restriction base="string">
<enumeration value="EJB2"/>
<enumeration value="EJB3"/>
</restriction>
</simpleType>
<complexType name="EJBSessionBeanBinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="homeInterface" type="NCName" use="optional"/>
<attribute name="ejb-link-name" type="NCName" use="optional"/>
<attribute name="session-type" type="sca:BeanType" use="optional" default="stateless"/>
<attribute name="ejb-version" type="sca:VersionValue" use="optional" default="EJB2"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<complexType name="JMSBinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<element name="destination" type="sca:Destination" minOccurs="0"/>
<element name="connectionFactory" type="sca:ConnectionFactory"
minOccurs="0"/>
<element name="activationSpec" type="sca:ActivationSpec"
minOccurs="0"/>
<element name="response" type="sca:Response" minOccurs="0"/>
<element name="headers" type="sca:Headers" minOccurs="0"/>
<element name="resourceAdapter" type="sca:ResourceAdapter"
minOccurs="0"/>
<element name="operationProperties" type="sca:OperationProperties"
minOccurs="0" maxOccurs="unbounded"/>
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="correlationScheme"
default="RequestMsgIDToCorrelID">
<simpleType>
<restriction base="string">
<enumeration value="RequestMsgIDToCorrelID"/>
<enumeration value="RequestCorrelIDToCorrelID"/>
<enumeration value="None"/>
</restriction>
</simpleType>
</attribute>
<attribute name="initialContextFactory" type="anyURI"/>
<attribute name="jndiURL" type="anyURI"/>
<attribute name="requestConnection" type="QName"/>
<attribute name="responseConnection" type="QName"/>
<attribute name="operationProperties" type="QName"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
<simpleType name="CreateResource">
<restriction base="string">
<enumeration value="always"/>
<enumeration value="never"/>
<enumeration value="ifnotexist"/>
</restriction>
</simpleType>
<complexType name="Destination">
<sequence>
<element name="property" type="string"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="anyURI" use="required"/>
<attribute name="type" use="optional" default="queue">
<simpleType>
<restriction base="string">
<enumeration value="queue"/>
<enumeration value="topic"/>
</restriction>
</simpleType>
</attribute>
<attribute name="create" type="sca:CreateResource"
use="optional" default="ifnotexist"/>
</complexType>
<complexType name="ConnectionFactory">
<sequence> <element name="property" type="string"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="anyURI" use="required"/>
<attribute name="create" type="sca:CreateResource"
use="optional" default="ifnotexist"/>
</complexType>
<complexType name="ActivationSpec">
<sequence>
<element name="property" type="string"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="anyURI" use="required"/>
<attribute name="create" type="sca:CreateResource"
use="optional" default="ifnotexist"/>
</complexType>
<complexType name="Response">
<sequence>
<element name="destination" type="sca:Destination" minOccurs="0"/>
<element name="connectionFactory" type="sca:ConnectionFactory"
minOccurs="0"/>
<element name="activationSpec" type="sca:ActivationSpec" minOccurs="0"/>
</sequence>
</complexType>
<complexType name="Headers">
<sequence>
<element name="property" type="string"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="JMSType" type="string"/>
<attribute name="JMSCorrelationID" type="string"/>
<attribute name="JMSDeliveryMode" type="string"/>
<attribute name="JMSTimeToLive" type="int"/>
<attribute name="JMSPriority" type="string"/>
</complexType>
<complexType name="SubscriptionHeaders">
<attribute name="JMSSelector" type="string"/>
</complexType>
<complexType name="ResourceAdapter">
<sequence>
<element name="property" type="string"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="string" use="required"/>
</complexType>
<complexType name="OperationProperties">
<sequence>
<element name="property" type="string"
minOccurs="0" maxOccurs="unbounded"/>
<element name="headers" type="sca:Headers"/>
</sequence>
<attribute name="name" type="string" use="required"/>
<attribute name="nativeOperation" type="string"/>
</complexType>
<element name="binding.jms" type="sca:JMSBinding"
substitutionGroup="sca:binding"/>
</schema>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="binding.sca" type="sca:SCABinding"
substitutionGroup="sca:binding"/>
<complexType name="SCABinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
xmlns:wsa="http://www.w3.org/2004/12/addressing"
elementFormDefault="qualified">
<import namespace="http://www.w3.org/2004/08/wsdl-instance"
schemaLocation="wsdli.xsd" />
<!-- import namespace="http://www.w3.org/2005/08/addressing"
schemaLocation="ws-addr.xsd" /-->
<include schemaLocation="sca-core.xsd"/>
<element name="binding.ws" type="sca:WebServiceBinding"
substitutionGroup="sca:binding"/>
<complexType name="WebServiceBinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<!-- element ref="wsa:EndpointReference" minOccurs="0"
maxOccurs="unbounded"/-->
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="wsdlElement" type="anyURI" use="optional"/>
<attribute ref="wsdli:wsdlLocation" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="contribution" type="sca:ContributionType"/>
<complexType name="ContributionType">
<sequence>
<element name="deployable" type="sca:DeployableType" minOccurs="1" maxOccurs="unbounded"/>
<element name="import" type="sca:ImportType" minOccurs="0" maxOccurs="unbounded"/>
<element name="export" type="sca:ExportType" minOccurs="0" maxOccurs="unbounded"/>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<anyAttribute namespace="##other" processContents="lax"/>
</complexType>
<complexType name="DeployableType">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="composite" type="QName" use="required"/>
<anyAttribute namespace="##other" processContents="lax"/>
</complexType>
<complexType name="ImportType">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="namespace" type="string" use="required"/>
<attribute name="location" type="anyURI" use="required"/>
<anyAttribute namespace="##other" processContents="lax"/>
</complexType>
<complexType name="ExportType">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="namespace" type="string" use="required"/>
<anyAttribute namespace="##other" processContents="lax"/>
</complexType>
</schema>

View file

@ -0,0 +1,348 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<element name="componentType" type="sca:ComponentType"/>
<complexType name="ComponentType">
<sequence>
<choice minOccurs="0" maxOccurs="1">
<element ref="sca:implementation"/>
<any namespace="##other" processContents="lax"/>
</choice>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="service" type="sca:ComponentService" />
<element name="reference" type="sca:ComponentReference"/>
<element name="property" type="sca:Property"/>
</choice>
<!--
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
-->
</sequence>
<attribute name="constrainingType" type="QName" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<element name="composite" type="sca:Composite"/>
<complexType name="Composite">
<sequence>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="include" type="sca:Include"/>
<element name="service" type="sca:Service"/>
<element name="property" type="sca:Property"/>
<element name="component" type="sca:Component"/>
<element name="reference" type="sca:Reference"/>
<element name="wire" type="sca:Wire"/>
<!-- <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> -->
</choice>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="NCName" use="required"/>
<attribute name="targetNamespace" type="anyURI" use="optional"/>
<attribute name="local" type="boolean" use="optional" default="false"/>
<attribute name="autowire" type="boolean" use="optional" default="false"/>
<attribute name="constrainingType" type="QName" use="optional"/>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="Service">
<sequence>
<element ref="sca:interface" minOccurs="0" maxOccurs="1" />
<element name="operation" type="sca:Operation" minOccurs="0"
maxOccurs="unbounded" />
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="sca:binding" />
<any namespace="##other" processContents="lax"/>
</choice>
<element ref="sca:callback" minOccurs="0" maxOccurs="1" />
<!--
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded" />
-->
</sequence>
<attribute name="name" type="NCName" use="required" />
<attribute name="promote" type="anyURI" use="required" />
<attribute name="requires" type="sca:listOfQNames" use="optional" />
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax" />
</complexType>
<element name="interface" type="sca:Interface" abstract="true" />
<complexType name="Interface" abstract="true"/>
<complexType name="Reference">
<sequence>
<element ref="sca:interface" minOccurs="0" maxOccurs="1" />
<element name="operation" type="sca:Operation" minOccurs="0"
maxOccurs="unbounded" />
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="sca:binding" />
<any namespace="##other" processContents="lax" />
</choice>
<element ref="sca:callback" minOccurs="0" maxOccurs="1" />
<!--
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded" />
-->
</sequence>
<attribute name="name" type="NCName" use="required" />
<attribute name="target" type="sca:listOfAnyURIs" use="optional"/>
<attribute name="wiredByImpl" type="boolean" use="optional" default="false"/>
<attribute name="multiplicity" type="sca:Multiplicity"
use="optional" default="1..1" />
<attribute name="promote" type="sca:listOfAnyURIs" use="required" />
<attribute name="requires" type="sca:listOfQNames" use="optional" />
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax" />
</complexType>
<complexType name="SCAPropertyBase" mixed="true">
<!-- mixed="true" to handle simple type -->
<sequence>
<any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="1" />
<!-- NOT an extension point; This xsd:any exists to accept
the element-based or complex type property
i.e. no element-based extension point under "sca:property" -->
</sequence>
</complexType>
<!-- complex type for sca:property declaration -->
<complexType name="Property" mixed="true">
<complexContent>
<extension base="sca:SCAPropertyBase">
<!-- extension defines the place to hold default value -->
<attribute name="name" type="NCName" use="required"/>
<attribute name="type" type="QName" use="optional"/>
<attribute name="element" type="QName" use="optional"/>
<attribute name="many" type="boolean" default="false"
use="optional"/>
<attribute name="mustSupply" type="boolean" default="false"
use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
<!-- an extension point ; attribute-based only -->
</extension>
</complexContent>
</complexType>
<complexType name="PropertyValue" mixed="true">
<complexContent>
<extension base="sca:SCAPropertyBase">
<attribute name="name" type="NCName" use="required"/>
<attribute name="type" type="QName" use="optional"/>
<attribute name="element" type="QName" use="optional"/>
<attribute name="many" type="boolean" default="false"
use="optional"/>
<attribute name="source" type="string" use="optional"/>
<attribute name="file" type="anyURI" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
<!-- an extension point ; attribute-based only -->
</extension>
</complexContent>
</complexType>
<element name="binding" type="sca:Binding" abstract="true"/>
<complexType name="Binding" abstract="true">
<sequence>
<element name="operation" type="sca:Operation" minOccurs="0"
maxOccurs="unbounded" />
</sequence>
<attribute name="uri" type="anyURI" use="optional"/>
<attribute name="name" type="QName" use="optional"/>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
</complexType>
<element name="bindingType" type="sca:BindingType"/>
<complexType name="BindingType">
<sequence minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax" />
</sequence>
<attribute name="type" type="QName" use="required"/>
<attribute name="alwaysProvides" type="sca:listOfQNames" use="optional"/>
<attribute name="mayProvide" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<element name="callback" type="sca:Callback"/>
<complexType name="Callback">
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="sca:binding"/>
<any namespace="##other" processContents="lax"/>
</choice>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="Component">
<sequence>
<choice minOccurs="0" maxOccurs="1">
<element ref="sca:implementation"/>
<any namespace="##other" processContents="lax"/>
</choice>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="service" type="sca:ComponentService"/>
<element name="reference" type="sca:ComponentReference"/>
<element name="property" type="sca:PropertyValue" />
</choice>
<!--
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
-->
</sequence>
<attribute name="name" type="NCName" use="required"/>
<attribute name="autowire" type="boolean" use="optional" default="false"/>
<attribute name="constrainingType" type="QName" use="optional"/>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="ComponentService">
<sequence>
<element ref="sca:interface" minOccurs="0" maxOccurs="1"/>
<element name="operation" type="sca:Operation" minOccurs="0"
maxOccurs="unbounded" />
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="sca:binding" />
<any namespace="##other" processContents="lax"/>
</choice>
<element ref="sca:callback" minOccurs="0" maxOccurs="1"/>
<!--
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
-->
</sequence>
<attribute name="name" type="NCName" use="required"/>
<attribute name="requires" type="sca:listOfQNames"
use="optional"/>
<attribute name="policySets" type="sca:listOfQNames"
use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="ComponentReference">
<sequence>
<element ref="sca:interface" minOccurs="0" maxOccurs="1" />
<element name="operation" type="sca:Operation" minOccurs="0"
maxOccurs="unbounded" />
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="sca:binding" />
<any namespace="##other" processContents="lax" />
</choice>
<element ref="sca:callback" minOccurs="0" maxOccurs="1" />
<!--
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded" />
-->
</sequence>
<attribute name="name" type="NCName" use="required" />
<attribute name="target" type="sca:listOfAnyURIs" use="optional"/>
<attribute name="multiplicity" type="sca:Multiplicity"
use="optional" default="1..1" />
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames"
use="optional"/>
<anyAttribute namespace="##any" processContents="lax" />
</complexType>
<element name="implementation" type="sca:Implementation"
abstract="true" />
<complexType name="Implementation" abstract="true">
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
</complexType>
<element name="implementationType" type="sca:ImplementationType"/>
<complexType name="ImplementationType">
<sequence minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax" />
</sequence>
<attribute name="type" type="QName" use="required"/>
<attribute name="alwaysProvides" type="sca:listOfQNames" use="optional"/>
<attribute name="mayProvide" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="Wire">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="source" type="anyURI" use="required"/>
<attribute name="target" type="anyURI" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<element name="include" type="sca:Include"/>
<complexType name="Include">
<attribute name="name" type="QName"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="Operation">
<attribute name="name" type="NCName" use="required"/>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="policySets" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<element name="constrainingType" type="sca:ConstrainingType"/>
<complexType name="ConstrainingType">
<sequence>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="service" type="sca:ComponentService"/>
<element name="reference" type="sca:ComponentReference"/>
<element name="property" type="sca:Property" />
</choice>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="NCName" use="required"/>
<attribute name="targetNamespace" type="anyURI"/>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<simpleType name="Multiplicity">
<restriction base="string">
<enumeration value="0..1"/>
<enumeration value="1..1"/>
<enumeration value="0..n"/>
<enumeration value="1..n"/>
</restriction>
</simpleType>
<simpleType name="OverrideOptions">
<restriction base="string">
<enumeration value="no"/>
<enumeration value="may"/>
<enumeration value="must"/>
</restriction>
</simpleType>
<!-- Global attribute definition for @requires to permit use of intents
within WSDL documents -->
<attribute name="requires" type="sca:listOfQNames"/>
<!-- Global attribute defintion for @endsConversation to mark operations
as ending a conversation -->
<attribute name="endsConversation" type="boolean" default="false"/>
<simpleType name="listOfQNames">
<list itemType="QName"/>
</simpleType>
<simpleType name="listOfAnyURIs">
<list itemType="anyURI"/>
</simpleType>
</schema>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<include schemaLocation="sca-policy.xsd"/>
<element name="definitions">
<complexType>
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="sca:intent"/>
<element ref="sca:policySet"/>
<element ref="sca:binding"/>
<element ref="sca:bindingType"/>
<element ref="sca:implementationType"/>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</choice>
<attribute name="targetNamespace" type="anyURI" use="optional"/>
</complexType>
</element>
</schema>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<xsd:schema xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:include schemaLocation="sca-core.xsd" />
<xsd:element name="implementation.bpel" type="BpelImplementation"
substitutionGroup="implementation" />
<xsd:complexType name="BpelImplementation">
<xsd:complexContent>
<xsd:extension base="Implementation">
<xsd:sequence>
<xsd:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="process" type="xsd:QName" use="required" />
<xsd:anyAttribute namespace="##any" processContents="lax" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="interface.partnerLinkType" type="BpelPartnerLinkType"
substitutionGroup="interface" />
<xsd:complexType name="BpelPartnerLinkType">
<xsd:complexContent>
<xsd:extension base="Interface">
<xsd:sequence>
<xsd:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="type" type="xsd:QName" use="required" />
<xsd:attribute name="serviceRole" type="xsd:NCName" use="optional" />
<xsd:anyAttribute namespace="##any" processContents="lax" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="implementation.composite" type="sca:SCAImplementation"
substitutionGroup="sca:implementation"/>
<complexType name="SCAImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="QName" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sdo="commonj.sdo/XML"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="implementation.cpp" type="sca:CPPImplementation" substitutionGroup="sca:implementation" />
<complexType name="CPPImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<element name="method" type="sca:CPPImplementationMethod" minOccurs="0" maxOccurs="unbounded" />
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="library" type="NCName" use="required"/>
<attribute name="header" type="NCName" use="required"/>
<attribute name="path" type="NCName" use="optional"/>
<attribute name="class" type="Name" use="optional"/>
<attribute name="scope" type="sca:CPPImplementationScope" use="optional"/>
<attribute name="eagerInit" type="boolean" use="optional"/>
<attribute name="allowsPassByReference" type="boolean" use="optional"/>
<attribute name="conversationMaxAge" type="string" use="optional"/>
<attribute name="conversationMaxIdle" type="string" use="optional"/>
<attribute name="conversationSinglePrincipal" type="boolean" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
<simpleType name="CPPImplementationScope">
<restriction base="string">
<enumeration value="stateless"/>
<enumeration value="composite"/>
<enumeration value="request"/>
<enumeration value="converstion"/>
</restriction>
</simpleType>
<complexType name="CPPImplementationMethod">
<complexContent>
<attribute name="name" type="NCName" use="required"/>
<attribute name="allowsPassByReference" type="boolean" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="implementation.ejb" type="sca:EJBImplementation"
substitutionGroup="sca:implementation"/>
<complexType name="EJBImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<!-- we might want to make this refer to the JEE ejb-link type -->
<attribute name="ejb-link" type="token" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="implementation.java" type="sca:JavaImplementation"
substitutionGroup="sca:implementation"/>
<complexType name="JavaImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="class" type="NCName" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="implementation.spring" type="sca:SpringImplementation"
substitutionGroup="sca:implementation"/>
<complexType name="SpringImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="location" type="anyURI" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="implementation.web" type="sca:WebImplementation"
substitutionGroup="sca:implementation"/>
<complexType name="WebImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="web-uri" type="string" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.commonj.org/xmlns/sca/1.0/"
xmlns:sca="http://www.commonj.org/xmlns/sca/1.0/"
xmlns:sdo="commonj.sdo/XML"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="interface.cpp" type="sca:CPPInterface" substitutionGroup="sca:interface"/>
<complexType name="CPPInterface">
<complexContent>
<extension base="sca:Interface">
<sequence>
<element name="method" type="sca:CPPMethod" minOccurs="0" maxOccurs="unbounded" />
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="header" type="NCName" use="required"/>
<attribute name="class" type="Name" use="required"/>
<attribute name="callbackHeader" type="NCName" use="optional"/>
<attribute name="callbackClass" type="Name" use="optional"/>
<attribute name="remotable" type="boolean" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
<complexType name="CPPMethod">
<complexContent>
<attribute name="name" type="NCName" use="required"/>
<attribute name="oneWay" type="boolean" use="optional"/>
<attribute name="endConversation" type="boolean" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="interface.java" type="sca:JavaInterface" substitutionGroup="sca:interface"/>
<complexType name="JavaInterface">
<complexContent>
<extension base="sca:Interface">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="interface" type="NCName" use="required"/>
<attribute name="callbackInterface" type="NCName" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="interface.wsdl" type="sca:WSDLPortType" substitutionGroup="sca:interface"/>
<complexType name="WSDLPortType">
<complexContent>
<extension base="sca:Interface">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="interface" type="anyURI" use="required"/>
<attribute name="callbackInterface" type="anyURI" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
elementFormDefault="qualified">
<include schemaLocation="sca-core.xsd"/>
<element name="intent" type="sca:Intent"/>
<complexType name="Intent">
<sequence>
<element name="description" type="string" minOccurs="0" maxOccurs="1" />
<any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="name" type="QName" use="required"/>
<attribute name="constrains" type="sca:listOfQNames" use="optional"/>
<attribute name="requires" type="sca:listOfQNames" use="optional"/>
<attribute name="excludes" type="sca:listOfQNames" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<element name="policySet" type="sca:PolicySet"/>
<complexType name="PolicySet">
<choice minOccurs="0" maxOccurs="unbounded">
<element name="policySetReference" type="sca:PolicySetReference"/>
<element name="intentMap" type="sca:IntentMap"/>
<any namespace="##other" processContents="lax"/>
</choice>
<attribute name="name" type="QName" use="required"/>
<attribute name="provides" type="sca:listOfQNames" use="optional"/>
<attribute name="appliesTo" type="string" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="PolicySetReference">
<attribute name="name" type="QName" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="IntentMap">
<choice minOccurs="1" maxOccurs="unbounded">
<element name="qualifier" type="sca:Qualifier"/>
<any namespace="##other" processContents="lax"/>
</choice>
<attribute name="provides" type="QName" use="required"/>
<attribute name="default" type="string" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<complexType name="Qualifier">
<choice minOccurs="1" maxOccurs="unbounded">
<element name="intentMap" type="sca:IntentMap"/>
<any namespace="##other" processContents="lax"/>
</choice>
<attribute name="name" type="string" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</complexType>
<element name="allow" type="sca:Allow"/>
<complexType name="Allow">
<attribute name="roles" type="string" use="required"/>
</complexType>
<element name="permitAll" type="sca:PermitAll"/>
<complexType name="PermitAll"/>
<element name="denyAll" type="sca:DenyAll"/>
<complexType name="DenyAll"/>
<element name="runAs" type="sca:RunAs"/>
<complexType name="RunAs">
<attribute name="role" type="string" use="required"/>
</complexType>
</schema>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright SCA Collaboration 2006, 2007 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
<include schemaLocation="sca-core.xsd"/>
<include schemaLocation="sca-interface-java.xsd"/>
<include schemaLocation="sca-interface-wsdl.xsd"/>
<include schemaLocation="sca-implementation-java.xsd"/>
<include schemaLocation="sca-implementation-composite.xsd"/>
<include schemaLocation="sca-binding-webservice.xsd"/>
<include schemaLocation="sca-binding-jms.xsd"/>
<include schemaLocation="sca-binding-sca.xsd"/>
<include schemaLocation="sca-contributions.xsd"/>
<include schemaLocation="sca-definitions.xsd"/>
<include schemaLocation="sca-policy.xsd"/>
</schema>

View file

@ -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.
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
<element name="binding.atom" type="t:AtomBinding"/>
<complexType name="AtomBinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<any namespace="##targetNamespace" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="title" type="string" use="optional"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -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.
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
<element name="binding.dwr" type="t:DWRBinding"/>
<complexType name="DWRBinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<any namespace="##targetNamespace" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

View file

@ -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.
-->
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
elementFormDefault="qualified">
<import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-core.xsd"/>
<element name="binding.http" type="t:HTTPBinding"/>
<complexType name="HTTPBinding">
<complexContent>
<extension base="sca:Binding">
<sequence>
<any namespace="##targetNamespace" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
</complexType>
</schema>

Some files were not shown because too many files have changed in this diff Show more