summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/core')
-rw-r--r--java/sca/modules/core/LICENSE205
-rw-r--r--java/sca/modules/core/META-INF/MANIFEST.MF67
-rw-r--r--java/sca/modules/core/NOTICE6
-rw-r--r--java/sca/modules/core/pom.xml89
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java74
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java531
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java208
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java105
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java98
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java121
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java111
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java66
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java565
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java524
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java43
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java41
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java124
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java487
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java105
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java427
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java48
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java47
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java35
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java57
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java60
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java49
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java47
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java139
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java95
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java113
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java51
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java184
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java48
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java87
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java53
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java97
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java55
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java93
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java68
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java195
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java77
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java261
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java178
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java36
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java114
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java45
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java313
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java236
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java156
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java299
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java196
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java62
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java158
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java32
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java43
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java65
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java44
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java44
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java44
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java44
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java87
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java70
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java61
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java195
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java228
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java65
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java80
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java167
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java32
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory17
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory17
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint19
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry19
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory19
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator19
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory18
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder18
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry18
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer17
-rw-r--r--java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler19
-rw-r--r--java/sca/modules/core/src/main/resources/endpoint-validation-messages.properties22
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java93
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java50
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java67
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java54
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java43
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java71
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java154
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java240
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java153
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java227
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java86
-rw-r--r--java/sca/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java66
-rw-r--r--java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest24
102 files changed, 0 insertions, 10878 deletions
diff --git a/java/sca/modules/core/LICENSE b/java/sca/modules/core/LICENSE
deleted file mode 100644
index 8aa906c321..0000000000
--- a/java/sca/modules/core/LICENSE
+++ /dev/null
@@ -1,205 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
-
diff --git a/java/sca/modules/core/META-INF/MANIFEST.MF b/java/sca/modules/core/META-INF/MANIFEST.MF
deleted file mode 100644
index 798bcb89c0..0000000000
--- a/java/sca/modules/core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,67 +0,0 @@
-Manifest-Version: 1.0
-Export-Package: org.apache.tuscany.sca.core.assembly;version="2.0.0";
- uses:="org.apache.tuscany.sca.assembly,org.apache.tuscany.sca.core",
- org.apache.tuscany.sca.core.assembly.impl;version="2.0.0";scope=internal;mandatory:=scope,
- org.apache.tuscany.sca.core.context;version="2.0.0";
- uses:="javax.xml.stream,
- org.apache.tuscany.sca.runtime,
- org.apache.tuscany.sca.assembly,
- org.apache.tuscany.sca.context,
- org.oasisopen.sca,
- org.apache.tuscany.sca.core",
- org.apache.tuscany.sca.core.factory;version="2.0.0",
- org.apache.tuscany.sca.core.invocation;version="2.0.0";
- uses:="org.apache.tuscany.sca.invocation,
- org.apache.tuscany.sca.runtime,
- org.apache.tuscany.sca.assembly,
- org.oasisopen.sca,
- org.apache.tuscany.sca.work,
- org.apache.tuscany.sca.core.factory,
- org.apache.tuscany.sca.core.context.impl,
- org.apache.tuscany.sca.core,
- org.apache.tuscany.sca.interfacedef",
- org.apache.tuscany.sca.core.scope;version="2.0.0";
- uses:="org.apache.tuscany.sca.runtime,
- org.apache.tuscany.sca.provider,
- org.apache.tuscany.sca.core.scope.impl,
- org.apache.tuscany.sca.core.factory"
-SCA-Version: 1.1
-Bundle-Name: Apache Tuscany SCA Core Runtime
-Bundle-Vendor: The Apache Software Foundation
-Bundle-Version: 2.0.0
-Bundle-ManifestVersion: 2
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
-Bundle-Description: Apache Tuscany SCA Core Runtime
-Import-Package: javax.security.auth,
- javax.xml.namespace,
- javax.xml.stream,
- net.sf.cglib.proxy;resolution:=optional,
- org.apache.tuscany.sca.assembly;version="2.0.0",
- org.apache.tuscany.sca.assembly.builder;version="2.0.0",
- org.apache.tuscany.sca.assembly.impl;version="2.0.0",
- org.apache.tuscany.sca.common.java.collection;version="2.0.0",
- org.apache.tuscany.sca.context;version="2.0.0",
- org.apache.tuscany.sca.contribution.processor;version="2.0.0",
- org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
- org.apache.tuscany.sca.core;version="2.0.0",
- org.apache.tuscany.sca.core.assembly;version="2.0.0",
- org.apache.tuscany.sca.core.context;version="2.0.0",
- org.apache.tuscany.sca.core.factory;version="2.0.0",
- org.apache.tuscany.sca.core.invocation;version="2.0.0",
- org.apache.tuscany.sca.core.scope;version="2.0.0",
- org.apache.tuscany.sca.extensibility;version="2.0.0",
- org.apache.tuscany.sca.interfacedef;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional,
- org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
- org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
- org.apache.tuscany.sca.invocation;version="2.0.0",
- org.apache.tuscany.sca.monitor;version="2.0.0",
- org.apache.tuscany.sca.policy;version="2.0.0",
- org.apache.tuscany.sca.provider;version="2.0.0",
- org.apache.tuscany.sca.runtime;version="2.0.0",
- org.apache.tuscany.sca.work;version="2.0.0",
- org.oasisopen.sca;version="2.0.0",
- org.oasisopen.sca.annotation;version="2.0.0"
-Bundle-SymbolicName: org.apache.tuscany.sca.core
-Bundle-DocURL: http://www.apache.org/
-Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/core/NOTICE b/java/sca/modules/core/NOTICE
deleted file mode 100644
index 25bb89c9b2..0000000000
--- a/java/sca/modules/core/NOTICE
+++ /dev/null
@@ -1,6 +0,0 @@
-${pom.name}
-Copyright (c) 2005 - 2009 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/java/sca/modules/core/pom.xml b/java/sca/modules/core/pom.xml
deleted file mode 100644
index 422ddfa783..0000000000
--- a/java/sca/modules/core/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-modules</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-core</artifactId>
- <name>Apache Tuscany SCA Core Runtime</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-extensibility</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-core-spi</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-contribution</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-interface-java</artifactId>
- <version>2.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-stax-api_1.0_spec</artifactId>
- <version>1.0.1</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>cglib</groupId>
- <artifactId>cglib</artifactId>
- <version>2.2</version>
- </dependency>
-
- <dependency>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- <version>3.1</version>
- </dependency>
-
- </dependencies>
-
-</project>
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
deleted file mode 100644
index 8c84a9e399..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-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.DefaultAssemblyFactory;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentReferenceImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentServiceImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointReferenceImpl;
-
-
-/**
- * The runtime version of assembly factory
- * @version $Rev$ $Date$
- */
-public class RuntimeAssemblyFactory extends DefaultAssemblyFactory implements AssemblyFactory {
-
- public RuntimeAssemblyFactory(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- @Override
- public Component createComponent() {
- return new RuntimeComponentImpl();
- }
-
- @Override
- public ComponentReference createComponentReference() {
- return new RuntimeComponentReferenceImpl();
- }
-
- @Override
- public ComponentService createComponentService() {
- return new RuntimeComponentServiceImpl();
- }
-
- @Override
- public Endpoint createEndpoint() {
- // Create an instance of EndpointImpl that can be serialized/deserialized using the Tuscany
- // runtime extension points and extensions
- return new RuntimeEndpointImpl(registry);
- }
-
- @Override
- public EndpointReference createEndpointReference() {
- return new RuntimeEndpointReferenceImpl(registry);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
deleted file mode 100644
index 58ffb0f9b9..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-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.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeRegistry;
-import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.provider.PolicyProviderFactory;
-import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.ActivationException;
-import org.apache.tuscany.sca.runtime.CompositeActivator;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-
-/**
- * @version $Rev$ $Date$
- */
-public class CompositeActivatorImpl implements CompositeActivator {
- final Logger logger = Logger.getLogger(CompositeActivatorImpl.class.getName());
-
- private final AssemblyFactory assemblyFactory;
- private final ScopeRegistry scopeRegistry;
- private final ProviderFactoryExtensionPoint providerFactories;
-
- public CompositeActivatorImpl(ExtensionPointRegistry extensionPoints) {
- UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
- this.scopeRegistry = utilities.getUtility(ScopeRegistry.class);
- this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
- }
-
- //=========================================================================
- // Activation
- //=========================================================================
-
- // Composite activation/deactivation
-
- public void activate(CompositeContext compositeContext, Composite composite) throws ActivationException {
- try {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Activating composite: " + composite.getName());
- }
- for (Component component : composite.getComponents()) {
- activateComponent(compositeContext, component);
- }
- } catch (Exception e) {
- throw new ActivationException(e);
- }
- }
-
- public void deactivate(Composite composite) throws ActivationException {
- try {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Deactivating composite: " + composite.getName());
- }
- for (Component component : composite.getComponents()) {
- deactivateComponent(component);
- }
- } catch (Exception e) {
- throw new ActivationException(e);
- }
- }
-
- // Component activation/deactivation
-
- public void activateComponent(CompositeContext compositeContext, Component component)
- throws ActivationException {
- try {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Activating component: " + component.getURI());
- }
-
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- activate(compositeContext, (Composite) implementation);
- } else if (implementation != null) {
- addImplementationProvider((RuntimeComponent) component,
- implementation);
- addScopeContainer(component);
- }
-
- for (ComponentService service : component.getServices()) {
- activate(compositeContext,
- (RuntimeComponent) component, (RuntimeComponentService) service);
- }
-
- for (ComponentReference reference : component.getReferences()) {
- activate(compositeContext,
- (RuntimeComponent) component, (RuntimeComponentReference) reference);
- }
- } catch (Exception e) {
- throw new ActivationException(e);
- }
- }
-
- public void deactivateComponent(Component component)
- throws ActivationException {
- try {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Deactivating component: " + component.getURI());
- }
- for (ComponentService service : component.getServices()) {
- deactivate((RuntimeComponent) component,
- (RuntimeComponentService) service);
- }
-
- for (ComponentReference reference : component.getReferences()) {
- deactivate((RuntimeComponent) component,
- (RuntimeComponentReference) reference);
- }
-
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- deactivate((Composite) implementation);
- } else if (implementation != null) {
- removeImplementationProvider((RuntimeComponent) component);
- removeScopeContainer(component);
- }
- } catch (Exception e) {
- throw new ActivationException(e);
- }
- }
-
- // add/remove artifacts required to get the implementation going
-
- private void addImplementationProvider(RuntimeComponent component, Implementation implementation) {
- ImplementationProviderFactory providerFactory =
- (ImplementationProviderFactory)providerFactories.getProviderFactory(implementation.getClass());
- if (providerFactory != null) {
- @SuppressWarnings("unchecked")
- ImplementationProvider implementationProvider =
- providerFactory.createImplementationProvider(component, implementation);
- if (implementationProvider != null) {
- component.setImplementationProvider(implementationProvider);
- }
- } else {
- throw new IllegalStateException("Provider factory not found for class: " + implementation.getClass()
- .getName());
- }
- for (PolicyProviderFactory f : providerFactories.getPolicyProviderFactories()) {
- PolicyProvider policyProvider = f.createImplementationPolicyProvider(component);
- if (policyProvider != null) {
- component.addPolicyProvider(policyProvider);
- }
- }
-
- }
-
- private void removeImplementationProvider(RuntimeComponent component) {
- component.setImplementationProvider(null);
- component.getPolicyProviders().clear();
- }
-
- private void addScopeContainer(Component component) {
- if (!(component instanceof ScopedRuntimeComponent)) {
- return;
- }
- ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
- ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(runtimeComponent);
- runtimeComponent.setScopeContainer(scopeContainer);
- }
-
- private void removeScopeContainer(Component component) {
- if (!(component instanceof ScopedRuntimeComponent)) {
- return;
- }
- ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
- ScopeContainer scopeContainer = runtimeComponent.getScopeContainer();
- runtimeComponent.setScopeContainer(null);
- }
-
-
- // Service activation/deactivation
-
- public void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentService service) {
- if (service.getService() == null) {
- if (logger.isLoggable(Level.WARNING)) {
- logger.warning("Skipping component service not defined in the component type: " + component.getURI()
- + "#"
- + service.getName());
- }
- return;
- }
-
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Activating component service: " + component.getURI() + "#" + service.getName());
- }
-
- // Add a wire for each service Endpoint
- for ( Endpoint endpoint : service.getEndpoints()){
- RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
- ep.bind(compositeContext);
-
- // create the interface contract for the binding and service ends of the wire
- // that are created as forward only contracts
- // FIXME: [rfeng] We might need a better way to get the impl interface contract
- Service targetService = service.getService();
- if (targetService == null) {
- targetService = service;
- }
- // endpoint.setInterfaceContract(targetService.getInterfaceContract().makeUnidirectional(false));
- }
- }
-
- public void deactivate(RuntimeComponent component, RuntimeComponentService service) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Deactivating component service: " + component.getURI() + "#" + service.getName());
- }
- for(Endpoint ep: service.getEndpoints()) {
- if(ep instanceof RuntimeEndpoint) {
- ((RuntimeEndpoint) ep).unbind();
- }
- }
- }
-
- // Reference activation/deactivation
-
- public void activate(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference reference) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Activating component reference: " + component.getURI() + "#" + reference.getName());
- }
-
- // set the parent component onto the reference. It's used at start time when the
- // reference is asked to return it's runtime wires. If there are none the reference
- // asks the component context to start the reference which creates the wires
- reference.setComponent(component);
- for(EndpointReference epr: reference.getEndpointReferences()) {
- addReferenceWire(compositeContext, epr);
- }
-
- // TODO reference wires are added at component start for some reason
- }
-
- public void deactivate(RuntimeComponent component, RuntimeComponentReference reference) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Deactivating component reference: " + component.getURI() + "#" + reference.getName());
- }
- for(EndpointReference endpointReference: reference.getEndpointReferences()) {
- ((RuntimeEndpointReference) endpointReference).unbind();
- }
- }
-
- //=========================================================================
- // Start
- //=========================================================================
-
- // Composite start/stop
-
- public void start(CompositeContext compositeContext, Composite composite) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Starting composite: " + composite.getName());
- }
- for (Component component : composite.getComponents()) {
- start(compositeContext, component);
- }
- }
-
- public void stop(CompositeContext compositeContext, Composite composite) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Stopping composite: " + composite.getName());
- }
- for (final Component component : composite.getComponents()) {
- stop(compositeContext, component);
- }
- }
-
- // Component start/stop
-
- public void start(CompositeContext compositeContext, Component component) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Starting component: " + component.getURI());
- }
- RuntimeComponent runtimeComponent = ((RuntimeComponent)component);
- if(runtimeComponent.isStarted()) {
- return;
- }
-
- compositeContext.bindComponent(runtimeComponent);
- Implementation implementation = component.getImplementation();
-
- if (implementation instanceof Composite) {
- start(compositeContext, (Composite)implementation);
- } else {
- for (PolicyProvider policyProvider : runtimeComponent.getPolicyProviders()) {
- policyProvider.start();
- }
- ImplementationProvider implementationProvider = runtimeComponent.getImplementationProvider();
- if (implementationProvider != null) {
- implementationProvider.start();
- }
- }
-
- if (component instanceof ScopedRuntimeComponent) {
- ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)component;
- if (scopedRuntimeComponent.getScopeContainer() != null) {
- scopedRuntimeComponent.getScopeContainer().start();
- }
- }
- // Reference bindings aren't started until the wire is first used
-
- for (ComponentService service : component.getServices()) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
- }
- for (Endpoint endpoint : service.getEndpoints()) {
- RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
- // FIXME: Should the policy providers be started before the endpoint is started?
- for (PolicyProvider policyProvider : ep.getPolicyProviders()) {
- policyProvider.start();
- }
-
- final ServiceBindingProvider bindingProvider = ep.getBindingProvider();
- if (bindingProvider != null) {
- // bindingProvider.start();
- // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- bindingProvider.start();
- return null;
- }
- });
- compositeContext.getEndpointRegistry().addEndpoint(endpoint);
- }
- }
- }
-
- runtimeComponent.setStarted(true);
- }
-
- public void stop(CompositeContext compositeContext, Component component) {
- if (!((RuntimeComponent)component).isStarted()) {
- return;
- }
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Stopping component: " + component.getURI());
- }
- for (ComponentService service : component.getServices()) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Stopping component service: " + component.getURI() + "#" + service.getName());
- }
- for (Endpoint endpoint : service.getEndpoints()) {
- RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
- compositeContext.getEndpointRegistry().removeEndpoint(endpoint);
- final ServiceBindingProvider bindingProvider = ep.getBindingProvider();
- if (bindingProvider != null) {
- // Allow bindings to read properties. Requires PropertyPermission read in security policy.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- bindingProvider.stop();
- return null;
- }
- });
- }
- for (PolicyProvider policyProvider : ep.getPolicyProviders()) {
- policyProvider.stop();
- }
- }
- }
- for (ComponentReference reference : component.getReferences()) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
- }
-
- for (EndpointReference endpointReference : reference.getEndpointReferences()) {
- RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
- compositeContext.getEndpointRegistry().removeEndpointReference(endpointReference);
- final ReferenceBindingProvider bindingProvider = epr.getBindingProvider();
- if (bindingProvider != null) {
- // Allow bindings to read properties. Requires PropertyPermission read in security policy.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- bindingProvider.stop();
- return null;
- }
- });
- }
- for (PolicyProvider policyProvider : epr.getPolicyProviders()) {
- policyProvider.stop();
- }
-
- }
- }
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- stop(compositeContext, (Composite)implementation);
- } else {
- final ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider();
- if (implementationProvider != null) {
- // Allow bindings to read properties. Requires PropertyPermission read in security policy.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- implementationProvider.stop();
- return null;
- }
- });
- }
- for (PolicyProvider policyProvider : ((RuntimeComponent)component).getPolicyProviders()) {
- policyProvider.stop();
- }
- }
-
- if (component instanceof ScopedRuntimeComponent) {
- ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
- if (runtimeComponent.getScopeContainer() != null &&
- runtimeComponent.getScopeContainer().getLifecycleState() != ScopeContainer.STOPPED) {
- runtimeComponent.getScopeContainer().stop();
- }
- }
-
- ((RuntimeComponent)component).setStarted(false);
- }
-
- // Service start/stop
-
- // done as part of the component start above
-
- // Reference start/stop
- // Used by component context start
-
- public void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference componentReference) {
- synchronized (componentReference) {
-
- if (!(componentReference instanceof RuntimeComponentReference)) {
- return;
- }
-
- // create a wire for each endpoint reference. An endpoint reference says either that
- // - a target has been specified and hence the reference has been wired in some way.
- // - an unwired binding ha been specified
- // and endpoint reference representing a wired reference may not at this point
- // be resolved (the service to which it points may not be present in the
- // current composite). Endpoint reference resolution takes place when the wire
- // is first used (when the chains are created)
- for (EndpointReference endpointReference : componentReference.getEndpointReferences()){
- // addReferenceWire(compositeContext, endpointReference);
- compositeContext.getEndpointRegistry().addEndpointReference(endpointReference);
- }
-
- }
- }
-
- public void stop(Component component, ComponentReference reference) {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
- }
- RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
- RuntimeComponent runtimeComponent = (RuntimeComponent) component;
- EndpointRegistry endpointRegistry = runtimeComponent.getComponentContext().getCompositeContext().getEndpointRegistry();
- for ( EndpointReference endpointReference : runtimeRef.getEndpointReferences()){
- RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
- endpointRegistry.removeEndpointReference(endpointReference);
- ReferenceBindingProvider bindingProvider = epr.getBindingProvider();
- if (bindingProvider != null) {
- bindingProvider.stop();
- }
- for (PolicyProvider policyProvider : epr.getPolicyProviders()) {
- policyProvider.stop();
- }
- }
- }
-
- private void addReferenceWire(CompositeContext compositeContext, EndpointReference endpointReference) {
- RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
- // create the wire
- // null endpoint passed in here as the endpoint reference may
- // not be resolved yet
- epr.bind(compositeContext);
-
- ComponentReference reference = endpointReference.getReference();
- InterfaceContract sourceContract = epr.getComponentTypeReferenceInterfaceContract();
-
- // TODO - EPR - interface contract seems to be null in the implementation.web
- // case. Not introspecting the CT properly?
- if (sourceContract == null){
- // TODO - Can't do this with move of matching to wire
- // take the contract from the service to which the reference is connected
- sourceContract = ((RuntimeEndpoint) endpointReference.getTargetEndpoint()).getComponentTypeServiceInterfaceContract();
- reference.setInterfaceContract(sourceContract);
- }
-
- // endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
- }
-
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
deleted file mode 100644
index 2ad61963e0..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.runtime.EndpointListener;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-
-/**
- * A EndpointRegistry implementation that sees registrations from the same JVM
- */
-public class EndpointRegistryImpl implements EndpointRegistry, LifeCycleListener {
- private final Logger logger = Logger.getLogger(EndpointRegistryImpl.class.getName());
-
- private List<Endpoint> endpoints = new ArrayList<Endpoint>();
- private List<EndpointReference> endpointreferences = new ArrayList<EndpointReference>();
- private List<EndpointListener> listeners = new ArrayList<EndpointListener>();
-
- public EndpointRegistryImpl(ExtensionPointRegistry extensionPoints, String endpointRegistryURI, String domainURI) {
- }
-
- public synchronized void addEndpoint(Endpoint endpoint) {
- endpoints.add(endpoint);
- for (EndpointListener listener : listeners) {
- listener.endpointAdded(endpoint);
- }
- logger.info("Add endpoint - " + endpoint.toString());
- }
-
- public synchronized void addEndpointReference(EndpointReference endpointReference) {
- endpointreferences.add(endpointReference);
- logger.fine("Add endpoint reference - " + endpointReference.toString());
- }
-
- /**
- * Parse the component/service/binding URI into an array of parts (componentURI, serviceName, bindingName)
- * @param uri
- * @return
- */
- private String[] parse(String uri) {
- String[] names = new String[3];
- int index = uri.lastIndexOf('#');
- if (index == -1) {
- names[0] = uri;
- } else {
- names[0] = uri.substring(0, index);
- String str = uri.substring(index + 1);
- if (str.startsWith("service-binding(") && str.endsWith(")")) {
- str = str.substring("service-binding(".length(), str.length() - 1);
- String[] parts = str.split("/");
- if (parts.length != 2) {
- throw new IllegalArgumentException("Invalid service-binding URI: " + uri);
- }
- names[1] = parts[0];
- names[2] = parts[1];
- } else if (str.startsWith("service(") && str.endsWith(")")) {
- str = str.substring("service(".length(), str.length() - 1);
- names[1] = str;
- } else {
- throw new IllegalArgumentException("Invalid component/service/binding URI: " + uri);
- }
- }
- return names;
- }
-
- private boolean matches(String target, String uri) {
- String[] parts1 = parse(target);
- String[] parts2 = parse(uri);
- for (int i = 0; i < parts1.length; i++) {
- if (parts1[i] == null || parts1[i].equals(parts2[i])) {
- continue;
- } else {
- return false;
- }
- }
- return true;
- }
-
- public synchronized List<Endpoint> findEndpoint(EndpointReference endpointReference) {
- List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
-
- logger.fine("Find endpoint for reference - " + endpointReference.toString());
-
- if (endpointReference.getReference() != null) {
- Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
- for (Endpoint endpoint : endpoints) {
- // TODO: implement more complete matching
- if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
- foundEndpoints.add(endpoint);
- logger.fine("Found endpoint with matching service - " + endpoint);
- }
- // else the service name doesn't match
- }
- }
-
- return foundEndpoints;
- }
-
- public synchronized List<EndpointReference> findEndpointReference(Endpoint endpoint) {
- return null;
- }
-
- public synchronized void removeEndpoint(Endpoint endpoint) {
- endpoints.remove(endpoint);
- endpointRemoved(endpoint);
- }
-
- private void endpointRemoved(Endpoint endpoint) {
- for (EndpointListener listener : listeners) {
- listener.endpointRemoved(endpoint);
- }
- logger.info("Remove endpoint - " + endpoint.toString());
- }
-
- public synchronized void removeEndpointReference(EndpointReference endpointReference) {
- endpointreferences.remove(endpointReference);
- logger.fine("Remove endpoint reference - " + endpointReference.toString());
- }
-
- public synchronized List<EndpointReference> getEndpointRefereneces() {
- return endpointreferences;
- }
-
- public synchronized List<Endpoint> getEndpoints() {
- return endpoints;
- }
-
- public synchronized void addListener(EndpointListener listener) {
- listeners.add(listener);
- }
-
- public synchronized List<EndpointListener> getListeners() {
- return listeners;
- }
-
- public synchronized void removeListener(EndpointListener listener) {
- listeners.remove(listener);
- }
-
- public synchronized Endpoint getEndpoint(String uri) {
- for (Endpoint ep : endpoints) {
- String epURI =
- ep.getComponent().getURI() + "#" + ep.getService().getName() + "/" + ep.getBinding().getName();
- if (epURI.equals(uri)) {
- return ep;
- }
- if (ep.getBinding().getName() == null || ep.getBinding().getName().equals(ep.getService().getName())) {
- epURI = ep.getComponent().getURI() + "#" + ep.getService().getName();
- if (epURI.equals(uri)) {
- return ep;
- }
- }
- }
- return null;
-
- }
-
- public synchronized void updateEndpoint(String uri, Endpoint endpoint) {
- Endpoint oldEndpoint = getEndpoint(uri);
- if (oldEndpoint == null) {
- throw new IllegalArgumentException("Endpoint is not found: " + uri);
- }
- endpoints.remove(oldEndpoint);
- endpoints.add(endpoint);
- for (EndpointListener listener : listeners) {
- listener.endpointUpdated(oldEndpoint, endpoint);
- }
- }
-
- public synchronized void start() {
- }
-
- public synchronized void stop() {
- for (Iterator<Endpoint> i = endpoints.iterator(); i.hasNext();) {
- Endpoint ep = i.next();
- i.remove();
- endpointRemoved(ep);
- }
- endpointreferences.clear();
- listeners.clear();
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
deleted file mode 100644
index abe0fdd78b..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.runtime.EndpointSerializer;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-public class EndpointSerializerImpl implements EndpointSerializer {
- private ExtensionPointRegistry registry;
- private XMLInputFactory inputFactory;
- private XMLOutputFactory outputFactory;
- private StAXArtifactProcessor<Endpoint> processor;
- private StAXArtifactProcessor<EndpointReference> refProcessor;
-
- public EndpointSerializerImpl(ExtensionPointRegistry registry) {
- this.registry = registry;
- FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- inputFactory = factories.getFactory(XMLInputFactory.class);
- outputFactory = factories.getFactory(XMLOutputFactory.class);
- StAXArtifactProcessorExtensionPoint processors =
- registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
- processor = processors.getProcessor(Endpoint.class);
- refProcessor = processors.getProcessor(EndpointReference.class);
- }
-
- public Endpoint readEndpoint(String xml) {
- try {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
- Endpoint result = processor.read(reader, new ProcessorContext(registry));
- reader.close();
- return result;
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public String write(Endpoint endpoint) {
- StringWriter sw = new StringWriter();
- try {
- XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
- processor.write(endpoint, writer, new ProcessorContext(registry));
- writer.flush();
- writer.close();
- return sw.toString();
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public EndpointReference readEndpointReference(String xml) {
- try {
- XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
- EndpointReference result = refProcessor.read(reader, new ProcessorContext(registry));
- reader.close();
- return result;
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public String write(EndpointReference endpointReference) {
- StringWriter sw = new StringWriter();
- try {
- XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
- refProcessor.write(endpointReference, writer, new ProcessorContext(registry));
- writer.flush();
- writer.close();
- return sw.toString();
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java
deleted file mode 100644
index 4d6a98ca5f..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-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.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
-
-/**
- * Artifact processor for reference parameters.
- *
- * @version $Rev$ $Date$
- */
-public class ReferenceParameterProcessor implements StAXArtifactProcessor<ReferenceParameters> {
- private static final QName REFERENCE_PARAMETERS =
- new QName("http://tuscany.apache.org/xmlns/sca/1.1", "referenceParameters", "tuscany");
-
- /**
- * Constructs a new processor.
- *
- * @param modelFactories
- */
- public ReferenceParameterProcessor(FactoryExtensionPoint modelFactories) {
- }
-
- /**
- * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#getArtifactType()
- */
- public QName getArtifactType() {
- return REFERENCE_PARAMETERS;
- }
-
- /**
- * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#read(javax.xml.stream.XMLStreamReader, ProcessorContext)
- */
- public ReferenceParameters read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
- ReferenceParameters parameters = new ReferenceParametersImpl();
- parameters.setCallbackID(reader.getAttributeValue(null, "callbackID"));
- return parameters;
- }
-
- /**
- * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#write(java.lang.Object, javax.xml.stream.XMLStreamWriter, ProcessorContext)
- */
- public void write(ReferenceParameters model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
- XMLStreamException {
- writer.writeStartElement(REFERENCE_PARAMETERS.getPrefix(),
- REFERENCE_PARAMETERS.getLocalPart(),
- REFERENCE_PARAMETERS.getNamespaceURI());
- writer.writeNamespace(REFERENCE_PARAMETERS.getPrefix(), REFERENCE_PARAMETERS.getNamespaceURI());
-
- if (model.getCallbackID() != null) {
- writer.writeAttribute("callbackID", model.getCallbackID().toString());
- }
- writer.writeEndElement();
- }
-
- /**
- * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#getModelType()
- */
- public Class<ReferenceParameters> getModelType() {
- return ReferenceParameters.class;
- }
-
- /**
- * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#resolve(java.lang.Object, org.apache.tuscany.sca.contribution.resolver.ModelResolver, ProcessorContext)
- */
- public void resolve(ReferenceParameters model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java
deleted file mode 100644
index 7bd56271a5..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ReferenceParametersImpl implements ReferenceParameters {
- private Object callbackID;
- private EndpointReference callbackReference;
- private Object callbackObjectID;
-
- /**
- * @return the callbackID
- */
- public Object getCallbackID() {
- return callbackID;
- }
- /**
- * @param callbackID the callbackID to set
- */
- public void setCallbackID(Object callbackID) {
- this.callbackID = callbackID;
- }
-
- /**
- * @see org.apache.tuscany.sca.runtime.ReferenceParameters#getCallbackReference()
- */
- public EndpointReference getCallbackReference() {
- return callbackReference;
- }
- /**
- * @see org.apache.tuscany.sca.runtime.ReferenceParameters#setCallback(java.lang.Object)
- */
- public void setCallbackReference(EndpointReference callback) {
- this.callbackReference = callback;
- }
-
- /**
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- /**
- * @return the callbackObjectID
- */
- public Object getCallbackObjectID() {
- return callbackObjectID;
- }
- /**
- * @param callbackObjectID the callbackObjectID to set
- */
- public void setCallbackObjectID(Object callbackObjectID) {
- this.callbackObjectID = callbackObjectID;
- }
- /**
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((callbackID == null) ? 0 : callbackID.hashCode());
- result = prime * result + ((callbackObjectID == null) ? 0 : callbackObjectID.hashCode());
- result = prime * result + ((callbackReference == null) ? 0 : callbackReference.hashCode());
- return result;
- }
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof ReferenceParametersImpl))
- return false;
- final ReferenceParametersImpl other = (ReferenceParametersImpl)obj;
- if (callbackID == null) {
- if (other.callbackID != null)
- return false;
- } else if (!callbackID.equals(other.callbackID))
- return false;
- if (callbackObjectID == null) {
- if (other.callbackObjectID != null)
- return false;
- } else if (!callbackObjectID.equals(other.callbackObjectID))
- return false;
- if (callbackReference == null) {
- if (other.callbackReference != null)
- return false;
- } else if (!callbackReference.equals(other.callbackReference))
- return false;
-
- return true;
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
deleted file mode 100644
index 6032005b9a..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.impl.ComponentImpl;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ResolverExtension;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
-
-/**
- * @version $Rev$ $Date$
- */
-public class RuntimeComponentImpl extends ComponentImpl implements RuntimeComponent,
- ScopedRuntimeComponent, ResolverExtension {
- protected RuntimeComponentContext componentContext;
- protected ImplementationProvider implementationProvider;
- protected List<PolicyProvider> policyProviders = new ArrayList<PolicyProvider>();
- protected ScopeContainer scopeContainer;
- protected boolean started;
- protected ModelResolver modelResolver;
-
- /**
- */
- public RuntimeComponentImpl() {
- super();
- }
-
- public ImplementationProvider getImplementationProvider() {
- return implementationProvider;
- }
-
- public void setImplementationProvider(ImplementationProvider provider) {
- this.implementationProvider = provider;
- }
-
- public ScopeContainer getScopeContainer() {
- return scopeContainer;
- }
-
- public void setScopeContainer(ScopeContainer scopeContainer) {
- this.scopeContainer = scopeContainer;
- }
-
- public boolean isStarted() {
- return started;
- }
-
- public void setStarted(boolean started) {
- this.started = started;
- }
-
- /**
- * @return the componentContext
- */
- public RuntimeComponentContext getComponentContext() {
- return componentContext;
- }
-
- /**
- * @param componentContext the componentContext to set
- */
- public void setComponentContext(RuntimeComponentContext componentContext) {
- this.componentContext = componentContext;
- }
-
- public void addPolicyProvider(PolicyProvider policyProvider) {
- policyProviders.add(policyProvider);
- }
-
- public List<PolicyProvider> getPolicyProviders() {
- return policyProviders;
- }
-
- public ModelResolver getModelResolver() {
- return modelResolver;
- }
-
- public void setModelResolver(ModelResolver modelResolver) {
- this.modelResolver = modelResolver;
- }
-
- @Override
- public String toString() {
- return getName();
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
deleted file mode 100644
index 2eea60ccea..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-
-/**
- * Implementation of a Component Reference.
- *
- * @version $Rev$ $Date$
- */
-public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implements RuntimeComponentReference {
-
- private RuntimeComponent component;
-
- public RuntimeComponentReferenceImpl() {
- super();
- }
-
- /**
- * @return the component
- */
- public RuntimeComponent getComponent() {
- return component;
- }
-
- /**
- * @param component the component to set
- */
- public void setComponent(RuntimeComponent component) {
- this.component = component;
- }
-
- /**
- * @see org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl#clone()
- */
- @Override
- public Object clone() throws CloneNotSupportedException {
- RuntimeComponentReferenceImpl ref = (RuntimeComponentReferenceImpl)super.clone();
- return ref;
- }
-
- @Override
- public String toString() {
- return getName();
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java
deleted file mode 100644
index bc7e6df878..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-
-/**
- * Implementation of a Component Service.
- *
- * @version $Rev$ $Date$
- */
-public class RuntimeComponentServiceImpl extends ComponentServiceImpl implements RuntimeComponentService {
-
- public RuntimeComponentServiceImpl() {
- super();
- }
-
- @Override
- public String toString() {
- return getName();
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
deleted file mode 100644
index 3dafaedf35..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-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.CompositeReference;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.Contract;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
-import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
-import org.apache.tuscany.sca.core.invocation.RuntimeInvoker;
-import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
-import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.apache.tuscany.sca.provider.BindingPolicyProvider;
-import org.apache.tuscany.sca.provider.BindingProviderFactory;
-import org.apache.tuscany.sca.provider.EndpointProvider;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.provider.PolicyProviderFactory;
-import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.EndpointSerializer;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
-import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
-import org.apache.tuscany.sca.work.WorkScheduler;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * Runtime model for Endpoint that supports java serialization
- */
-public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint, Externalizable {
- private transient CompositeContext compositeContext;
- private transient EndpointRegistry endpointRegistry;
- private transient RuntimeWireProcessor wireProcessor;
- private transient ProviderFactoryExtensionPoint providerFactories;
- private transient InterfaceContractMapper interfaceContractMapper;
- private transient WorkScheduler workScheduler;
- private transient PhaseManager phaseManager;
- private transient MessageFactory messageFactory;
- private transient RuntimeInvoker invoker;
- private transient EndpointSerializer serializer;
-
- private transient List<InvocationChain> chains;
- private transient Map<Operation, InvocationChain> invocationChainMap =
- new ConcurrentHashMap<Operation, InvocationChain>();
- private transient InvocationChain bindingInvocationChain;
-
- private transient ServiceBindingProvider bindingProvider;
- private transient List<PolicyProvider> policyProviders;
- private String xml;
-
- protected InterfaceContract bindingInterfaceContract;
- protected InterfaceContract serviceInterfaceContract;
-
- /**
- * No-arg constructor for Java serilization
- */
- public RuntimeEndpointImpl() {
- super(null);
- }
-
- public RuntimeEndpointImpl(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- protected void copyFrom(RuntimeEndpointImpl copy) {
- this.xml = copy.xml;
-
- this.component = copy.component;
- this.service = copy.service;
- this.interfaceContract = copy.interfaceContract;
- this.serviceInterfaceContract = copy.serviceInterfaceContract;
-
- this.binding = copy.binding;
- this.bindingInterfaceContract = copy.interfaceContract;
- this.bindingInvocationChain = copy.bindingInvocationChain;
-
- this.callbackEndpointReferences = copy.callbackEndpointReferences;
-
- this.requiredIntents = copy.requiredIntents;
- this.policySets = copy.policySets;
-
- this.uri = copy.uri;
- this.remote = copy.remote;
- this.unresolved = copy.unresolved;
-
- this.chains = copy.chains;
- this.invocationChainMap = copy.invocationChainMap;
- this.bindingProvider = copy.bindingProvider;
- this.policyProviders = copy.policyProviders;
-
- if (this.compositeContext == null && copy.compositeContext != null) {
- bind(copy.compositeContext);
- }
- }
-
- public void bind(CompositeContext compositeContext) {
- this.compositeContext = compositeContext;
- bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
- }
-
- public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
- if (compositeContext == null) {
- compositeContext = new CompositeContext(registry, endpointRegistry);
- }
- this.registry = registry;
- this.endpointRegistry = endpointRegistry;
- UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
- this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
- this.workScheduler = utilities.getUtility(WorkScheduler.class);
- this.wireProcessor =
- new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
-
- this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
- this.invoker = new RuntimeInvoker(this.messageFactory, this);
-
- this.phaseManager = utilities.getUtility(PhaseManager.class);
- this.serializer = utilities.getUtility(EndpointSerializer.class);
- this.providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
- }
-
- public void unbind() {
- compositeContext = null;
- bindingInvocationChain = null;
- chains = null;
- bindingProvider = null;
- policyProviders = null;
- invocationChainMap.clear();
- }
-
- public synchronized List<InvocationChain> getInvocationChains() {
- if (chains == null) {
- initInvocationChains();
- }
- return chains;
- }
-
- public synchronized InvocationChain getBindingInvocationChain() {
- if (bindingInvocationChain == null) {
- bindingInvocationChain = new InvocationChainImpl(null, null, false, phaseManager);
- initServiceBindingInvocationChains();
- }
- return bindingInvocationChain;
- }
-
- public InvocationChain getInvocationChain(Operation operation) {
- InvocationChain cached = invocationChainMap.get(operation);
- if (cached == null) {
- for (InvocationChain chain : getInvocationChains()) {
- Operation op = chain.getTargetOperation();
-
- if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) {
- invocationChainMap.put(operation, chain);
- return chain;
- }
- }
- invocationChainMap.put(operation, null);
- return null;
- } else {
- return cached;
- }
- }
-
- public Message invoke(Message msg) {
- return invoker.invokeBinding(msg);
- }
-
- public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
- return invoker.invoke(operation, args);
- }
-
- public Message invoke(Operation operation, Message msg) {
- return invoker.invoke(operation, msg);
- }
-
- /**
- * Navigate the component/componentType inheritence chain to find the leaf contract
- * @param contract
- * @return
- */
- private Contract getLeafContract(Contract contract) {
- Contract prev = null;
- Contract current = contract;
- while (current != null) {
- prev = current;
- if (current instanceof ComponentReference) {
- current = ((ComponentReference)current).getReference();
- } else if (current instanceof CompositeReference) {
- current = ((CompositeReference)current).getPromotedReferences().get(0);
- } else if (current instanceof ComponentService) {
- current = ((ComponentService)current).getService();
- } else if (current instanceof CompositeService) {
- current = ((CompositeService)current).getPromotedService();
- } else {
- break;
- }
- if (current == null) {
- return prev;
- }
- }
- return current;
- }
-
- /**
- * Initialize the invocation chains
- */
- private void initInvocationChains() {
- chains = new ArrayList<InvocationChain>();
- InterfaceContract sourceContract = getBindingInterfaceContract();
-
- // It's the service wire
- RuntimeComponentService service = (RuntimeComponentService)getService();
- RuntimeComponent serviceComponent = (RuntimeComponent)getComponent();
-
- //InterfaceContract targetContract = getInterfaceContract();
- // TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time
- InterfaceContract targetContract = getComponentTypeServiceInterfaceContract();
- // setInterfaceContract(targetContract);
- for (Operation operation : sourceContract.getInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
- if (targetOperation == null) {
- throw new ServiceRuntimeException("No matching operation for " + operation.getName()
- + " is found in service "
- + serviceComponent.getURI()
- + "#"
- + service.getName());
- }
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false, phaseManager);
- if (operation.isNonBlocking()) {
- addNonBlockingInterceptor(chain);
- }
- addServiceBindingInterceptor(chain, operation);
- addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
- chains.add(chain);
- }
-
- wireProcessor.process(this);
- }
-
- private void initServiceBindingInvocationChains() {
-
- // add the binding interceptors to the service binding wire
- ServiceBindingProvider provider = getBindingProvider();
- if ((provider != null) && (provider instanceof EndpointProvider)) {
- ((EndpointProvider)provider).configure();
- }
-
- // add the policy interceptors to the service binding wire
- List<PolicyProvider> pps = getPolicyProviders();
- if (pps != null) {
- for (PolicyProvider p : pps) {
- if (p instanceof BindingPolicyProvider) {
- Interceptor interceptor = ((BindingPolicyProvider)p).createBindingInterceptor();
- if (interceptor != null) {
- bindingInvocationChain.addInterceptor(interceptor);
- }
- }
- }
- }
-
- // TODO - add something on the end of the wire to invoke the
- // invocation chain. Need to split out the runtime
- // wire invoker into conversation, callback interceptors etc
- bindingInvocationChain.addInvoker(invoker);
-
- }
-
- /**
- * Add the interceptor for a binding
- *
- * @param reference
- * @param binding
- * @param chain
- * @param operation
- */
- private void addServiceBindingInterceptor(InvocationChain chain, Operation operation) {
- List<PolicyProvider> pps = getPolicyProviders();
- if (pps != null) {
- for (PolicyProvider p : pps) {
- Interceptor interceptor = p.createInterceptor(operation);
- if (interceptor != null) {
- chain.addInterceptor(p.createInterceptor(operation));
- }
- }
- }
- }
-
- /**
- * Add a non-blocking interceptor if the service binding needs it
- *
- * @param service
- * @param binding
- * @param chain
- */
- private void addNonBlockingInterceptor(InvocationChain chain) {
- ServiceBindingProvider provider = getBindingProvider();
- if (provider != null) {
- if (!provider.supportsOneWayInvocation()) {
- chain.addInterceptor(Phase.SERVICE, new NonBlockingInterceptor(workScheduler));
- }
- }
- }
-
- /**
- * Add the interceptor for a component implementation
- *
- * @param component
- * @param service
- * @param chain
- * @param operation
- */
- private void addImplementationInterceptor(Component component,
- ComponentService service,
- InvocationChain chain,
- Operation operation) {
-
- if (service.getService() instanceof CompositeService) {
- CompositeService compositeService = (CompositeService)service.getService();
- component = getPromotedComponent(compositeService);
- service = getPromotedComponentService(compositeService);
- }
-
- ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider();
-
- if (provider != null) {
- Invoker invoker = null;
- invoker = provider.createInvoker((RuntimeComponentService)service, operation);
- chain.addInvoker(invoker);
- }
- // TODO - EPR - don't we need to get the policy from the right level in the
- // model rather than the leafmost level
- List<PolicyProvider> pps = ((RuntimeComponent)component).getPolicyProviders();
- if (pps != null) {
- for (PolicyProvider p : pps) {
- Interceptor interceptor = p.createInterceptor(operation);
- if (interceptor != null) {
- chain.addInterceptor(p.createInterceptor(operation));
- }
- }
- }
- }
-
- /**
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() throws CloneNotSupportedException {
- RuntimeEndpointImpl copy = (RuntimeEndpointImpl)super.clone();
- copy.invoker = new RuntimeInvoker(copy.messageFactory, copy);
- return copy;
- }
-
- /**
- * Follow a service promotion chain down to the inner most (non composite)
- * component service.
- *
- * @param topCompositeService
- * @return
- */
- private ComponentService getPromotedComponentService(CompositeService compositeService) {
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- Service service = componentService.getService();
- if (componentService.getName() != null && service instanceof CompositeService) {
-
- // Continue to follow the service promotion chain
- return getPromotedComponentService((CompositeService)service);
-
- } else {
-
- // Found a non-composite service
- return componentService;
- }
- } else {
-
- // No promoted service
- return null;
- }
- }
-
- /**
- * Follow a service promotion chain down to the innermost (non-composite) component.
- *
- * @param compositeService
- * @return
- */
- private Component getPromotedComponent(CompositeService compositeService) {
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- Service service = componentService.getService();
- if (componentService.getName() != null && service instanceof CompositeService) {
-
- // Continue to follow the service promotion chain
- return getPromotedComponent((CompositeService)service);
-
- } else {
-
- // Found a non-composite service
- return compositeService.getPromotedComponent();
- }
- } else {
-
- // No promoted service
- return null;
- }
- }
-
- public synchronized ServiceBindingProvider getBindingProvider() {
- resolve();
- if (bindingProvider == null) {
- BindingProviderFactory factory =
- (BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass());
- if (factory == null) {
- throw new ServiceRuntimeException("No provider factory is registered for binding " + getBinding()
- .getType());
- }
- this.bindingProvider = factory.createServiceBindingProvider(this);
- }
- return bindingProvider;
- }
-
- public synchronized List<PolicyProvider> getPolicyProviders() {
- resolve();
- if (policyProviders == null) {
- policyProviders = new ArrayList<PolicyProvider>();
- for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) {
- PolicyProvider provider = factory.createServicePolicyProvider(this);
- if (provider != null) {
- policyProviders.add(provider);
- }
- }
- }
- return policyProviders;
- }
-
- public void setBindingProvider(ServiceBindingProvider provider) {
- this.bindingProvider = provider;
- }
-
- public Contract getContract() {
- return getService();
- }
-
- public CompositeContext getCompositeContext() {
- return compositeContext;
- }
-
- @Override
- protected void reset() {
- super.reset();
- this.xml = null;
- }
-
- @Override
- protected synchronized void resolve() {
- if (xml != null && component == null) {
- if (compositeContext == null) {
- compositeContext = CompositeContext.getCurrentCompositeContext();
- if (compositeContext != null) {
- bind(compositeContext);
- }
- }
- RuntimeEndpointImpl ep = (RuntimeEndpointImpl)serializer.readEndpoint(xml);
- copyFrom(ep);
- }
- super.resolve();
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- resolve();
- if (bindingInterfaceContract != null) {
- return bindingInterfaceContract;
- }
- bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract();
- if (bindingInterfaceContract == null) {
- bindingInterfaceContract = getComponentServiceInterfaceContract();
- }
- if (bindingInterfaceContract == null) {
- bindingInterfaceContract = getComponentTypeServiceInterfaceContract();
- }
- return bindingInterfaceContract;
- }
-
- public InterfaceContract getComponentTypeServiceInterfaceContract() {
- resolve();
- if (serviceInterfaceContract != null) {
- return serviceInterfaceContract;
- }
- if (service == null) {
- return getComponentServiceInterfaceContract();
- }
- serviceInterfaceContract = getLeafContract(service).getInterfaceContract();
- if (serviceInterfaceContract == null) {
- serviceInterfaceContract = getComponentServiceInterfaceContract();
- }
- return serviceInterfaceContract;
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.uri = in.readUTF();
- this.xml = in.readUTF();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF(getURI());
- if (serializer == null && xml != null) {
- out.writeUTF(xml);
- } else {
- if (serializer != null) {
- out.writeUTF(serializer.write(this));
- } else {
- throw new IllegalStateException("No serializer is configured");
- }
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
deleted file mode 100644
index fa61ff8721..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.assembly.impl;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.InvocationTargetException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.assembly.ComponentReference;
-import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.CompositeReference;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.Contract;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
-import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
-import org.apache.tuscany.sca.core.invocation.RuntimeInvoker;
-import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
-import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.apache.tuscany.sca.provider.BindingPolicyProvider;
-import org.apache.tuscany.sca.provider.BindingProviderFactory;
-import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.provider.PolicyProviderFactory;
-import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-import org.apache.tuscany.sca.runtime.EndpointSerializer;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
-import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
-import org.apache.tuscany.sca.work.WorkScheduler;
-import org.oasisopen.sca.SCARuntimeException;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * Runtime model for Endpoint that supports java serialization
- */
-public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements RuntimeEndpointReference, Externalizable {
- private transient CompositeContext compositeContext;
- private transient RuntimeWireProcessor wireProcessor;
- private transient InterfaceContractMapper interfaceContractMapper;
- private transient WorkScheduler workScheduler;
- private transient PhaseManager phaseManager;
- private transient MessageFactory messageFactory;
- private transient RuntimeInvoker invoker;
- private transient EndpointRegistry endpointRegistry;
-
- private transient List<InvocationChain> chains;
- private transient Map<Operation, InvocationChain> invocationChainMap =
- new ConcurrentHashMap<Operation, InvocationChain>();
- private transient InvocationChain bindingInvocationChain;
-
- private transient EndpointReferenceBinder eprBinder;
- private transient ReferenceBindingProvider bindingProvider;
- private transient ProviderFactoryExtensionPoint providerFactories;
- private transient List<PolicyProvider> policyProviders;
- private transient EndpointSerializer serializer;
-
- protected InterfaceContract bindingInterfaceContract;
- protected InterfaceContract referenceInterfaceContract;
-
- private String xml;
-
- /**
- * No-arg constructor for Java serilization
- */
- public RuntimeEndpointReferenceImpl() {
- super(null);
- }
-
- public RuntimeEndpointReferenceImpl(ExtensionPointRegistry registry) {
- super(registry);
- }
-
- protected void copyFrom(RuntimeEndpointReferenceImpl copy) {
- this.xml = copy.xml;
-
- this.component = copy.component;
- this.reference = copy.reference;
- this.interfaceContract = copy.interfaceContract;
- this.referenceInterfaceContract = copy.referenceInterfaceContract;
- this.callbackEndpoint = copy.callbackEndpoint;
- this.targetEndpoint = copy.targetEndpoint;
-
- this.binding = copy.binding;
- this.bindingInterfaceContract = copy.interfaceContract;
- this.bindingInvocationChain = copy.bindingInvocationChain;
-
- this.requiredIntents = copy.requiredIntents;
- this.policySets = copy.policySets;
-
- this.uri = copy.uri;
- this.remote = copy.remote;
- this.unresolved = copy.unresolved;
- this.status = copy.status;
-
- this.chains = copy.chains;
- this.invocationChainMap = copy.invocationChainMap;
- this.bindingProvider = copy.bindingProvider;
- this.policyProviders = copy.policyProviders;
-
- if (this.compositeContext == null && copy.compositeContext != null) {
- bind(copy.compositeContext);
- }
- }
-
- public void bind(CompositeContext compositeContext) {
- this.compositeContext = compositeContext;
- bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
- }
-
- public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) {
- if (compositeContext == null) {
- compositeContext = new CompositeContext(registry, endpointRegistry);
- }
- this.registry = registry;
- this.endpointRegistry = endpointRegistry;
- UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
- this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
- this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
- this.workScheduler = utilities.getUtility(WorkScheduler.class);
- this.wireProcessor =
- new ExtensibleWireProcessor(registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
-
- this.messageFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(MessageFactory.class);
- this.invoker = new RuntimeInvoker(this.messageFactory, this);
-
- this.phaseManager = utilities.getUtility(PhaseManager.class);
- this.serializer = utilities.getUtility(EndpointSerializer.class);
- this.providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
- }
-
- public synchronized List<InvocationChain> getInvocationChains() {
- if (chains == null) {
- initInvocationChains();
- }
- return chains;
- }
-
- public synchronized InvocationChain getBindingInvocationChain() {
- if (bindingInvocationChain == null) {
- bindingInvocationChain = new InvocationChainImpl(null, null, true, phaseManager);
- initReferenceBindingInvocationChains();
- }
- return bindingInvocationChain;
- }
-
- public InvocationChain getInvocationChain(Operation operation) {
- InvocationChain cached = invocationChainMap.get(operation);
- if (cached == null) {
- for (InvocationChain chain : getInvocationChains()) {
- Operation op = chain.getSourceOperation();
- if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) {
- invocationChainMap.put(operation, chain);
- return chain;
- }
- }
- invocationChainMap.put(operation, null);
- return null;
- } else {
- return cached;
- }
- }
-
- public Message invoke(Message msg) {
- return invoker.invoke(msg);
- }
-
- public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
- return invoker.invoke(operation, args);
- }
-
- public Message invoke(Operation operation, Message msg) {
- return invoker.invoke(operation, msg);
- }
-
- /**
- * Navigate the component/componentType inheritence chain to find the leaf contract
- * @param contract
- * @return
- */
- private Contract getLeafContract(Contract contract) {
- Contract prev = null;
- Contract current = contract;
- while (current != null) {
- prev = current;
- if (current instanceof ComponentReference) {
- current = ((ComponentReference)current).getReference();
- } else if (current instanceof CompositeReference) {
- current = ((CompositeReference)current).getPromotedReferences().get(0);
- } else if (current instanceof ComponentService) {
- current = ((ComponentService)current).getService();
- } else if (current instanceof CompositeService) {
- current = ((CompositeService)current).getPromotedService();
- } else {
- break;
- }
- if (current == null) {
- return prev;
- }
- }
- return current;
- }
-
- /**
- * Initialize the invocation chains
- */
- private void initInvocationChains() {
- chains = new ArrayList<InvocationChain>();
- InterfaceContract sourceContract = getComponentTypeReferenceInterfaceContract();
- // TODO - EPR why is this looking at the component types. The endpoint reference should have the right interface contract by this time
- //InterfaceContract sourceContract = getLeafInterfaceContract(endpointReference);
-
- // It's the reference wire
- resolveEndpointReference();
-
- InterfaceContract targetContract = getBindingInterfaceContract();
- // TODO - EPR why is this looking at the component types. The endpoint should have the right interface contract by this time
- //InterfaceContract targetContract = getLeafInterfaceContract(endpoint);
-
- RuntimeComponentReference reference = (RuntimeComponentReference)getReference();
- for (Operation operation : sourceContract.getInterface().getOperations()) {
- Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
- if (targetOperation == null) {
- throw new ServiceRuntimeException("No matching operation for " + operation.getName()
- + " is found in reference "
- + getComponent().getURI()
- + "#"
- + reference.getName());
- }
- InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager);
- if (operation.isNonBlocking()) {
- addNonBlockingInterceptor(chain);
- }
- chains.add(chain);
- addReferenceBindingInterceptor(chain, operation);
- }
-
- wireProcessor.process(this);
- }
-
- /**
- * This code used to be in the activator but has moved here as
- * the endpoint reference may not now be resolved until the wire
- * is first used
- */
- private void resolveEndpointReference() {
- resolve();
-
- boolean ok = eprBinder.bind(endpointRegistry, this);
- if (!ok) {
- throw new SCARuntimeException("Unable to bind " + this);
- }
-
- // start the binding provider
- final ReferenceBindingProvider bindingProvider = getBindingProvider();
-
- if (bindingProvider != null) {
- // Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- bindingProvider.start();
- return null;
- }
- });
- }
- for (PolicyProvider policyProvider : getPolicyProviders()) {
- policyProvider.start();
- }
-
- // InterfaceContract bindingContract = getBindingInterfaceContract();
- // endpoint.setInterfaceContract(bindingContract);
- }
-
- private void initReferenceBindingInvocationChains() {
-
- // add the binding interceptors to the reference binding wire
- ReferenceBindingProvider provider = getBindingProvider();
- if ((provider != null) && (provider instanceof EndpointReferenceProvider)) {
- ((EndpointReferenceProvider)provider).configure();
- }
-
- // add the policy interceptors to the service binding wire
- // find out which policies are active
- for (PolicyProvider p : getPolicyProviders()) {
- if (p instanceof BindingPolicyProvider) {
- Interceptor interceptor = ((BindingPolicyProvider)p).createBindingInterceptor();
- if (interceptor != null) {
- bindingInvocationChain.addInterceptor(interceptor);
- }
- }
- }
- }
-
- public void rebuild() {
- // TODO - can we use the idea of setTarget to rebuild the wire?
- // used at the moment by binding.sca when it resets the
- // source interface contract for local wires
- this.chains = null;
-
- setStatus(EndpointReference.NOT_CONFIGURED);
-
- // TODO - cheating here as I fixed the RuntimeComponentService code
- // to call this when it resets the interface contract
- //endpointReference.setInterfaceContract(epr.getInterfaceContract());
- }
-
- /**
- * Add the interceptor for a reference binding
- *
- * @param reference
- * @param binding
- * @param chain
- * @param operation
- */
- private void addReferenceBindingInterceptor(InvocationChain chain, Operation operation) {
- ReferenceBindingProvider provider = getBindingProvider();
- if (provider != null) {
- Invoker invoker = provider.createInvoker(operation);
- if (invoker != null) {
- chain.addInvoker(invoker);
- }
- }
- List<PolicyProvider> pps = getPolicyProviders();
- if (pps != null) {
- for (PolicyProvider p : pps) {
- Interceptor interceptor = p.createInterceptor(operation);
- if (interceptor != null) {
- chain.addInterceptor(p.createInterceptor(operation));
- }
- }
- }
- }
-
- /**
- * Add a non-blocking interceptor if the reference binding needs it
- *
- * @param reference
- * @param binding
- * @param chain
- */
- private void addNonBlockingInterceptor(InvocationChain chain) {
- ReferenceBindingProvider provider = getBindingProvider();
- if (provider != null) {
- boolean supportsOneWayInvocation = provider.supportsOneWayInvocation();
- if (!supportsOneWayInvocation) {
- chain.addInterceptor(Phase.REFERENCE, new NonBlockingInterceptor(workScheduler));
- }
- }
- }
-
- /**
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() throws CloneNotSupportedException {
- RuntimeEndpointReferenceImpl copy = (RuntimeEndpointReferenceImpl)super.clone();
- copy.invoker = new RuntimeInvoker(copy.messageFactory, copy);
- return copy;
- }
-
- public boolean isOutOfDate() {
- resolve();
- return eprBinder.isOutOfDate(endpointRegistry, this);
- }
-
- public synchronized ReferenceBindingProvider getBindingProvider() {
- resolve();
- // For the case that binding.sca is implemented by another binding
- if (binding == null) {
- return null;
- }
- if (bindingProvider == null) {
- BindingProviderFactory factory =
- (BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass());
- if (factory == null) {
- throw new ServiceRuntimeException("No provider factory is registered for binding " + getBinding()
- .getType());
- }
- this.bindingProvider = factory.createReferenceBindingProvider(this);
- }
- return bindingProvider;
- }
-
- public void setBindingProvider(ReferenceBindingProvider bindingProvider) {
- this.bindingProvider = bindingProvider;
- }
-
- public synchronized List<PolicyProvider> getPolicyProviders() {
- resolve();
- if (policyProviders == null) {
- policyProviders = new ArrayList<PolicyProvider>();
- for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) {
- PolicyProvider provider = factory.createReferencePolicyProvider(this);
- if (provider != null) {
- policyProviders.add(provider);
- }
- }
- }
- return policyProviders;
- }
-
- public void unbind() {
- bindingInvocationChain = null;
- chains = null;
- bindingProvider = null;
- policyProviders = null;
- invocationChainMap.clear();
- }
-
- public Contract getContract() {
- return getReference();
- }
-
- public CompositeContext getCompositeContext() {
- return compositeContext;
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- resolve();
- if (bindingInterfaceContract != null) {
- return bindingInterfaceContract;
- }
- bindingInterfaceContract = getBindingProvider().getBindingInterfaceContract();
- if (bindingInterfaceContract == null) {
- bindingInterfaceContract = getComponentReferenceInterfaceContract();
- }
- if (bindingInterfaceContract == null) {
- bindingInterfaceContract = getComponentTypeReferenceInterfaceContract();
- }
- return bindingInterfaceContract;
- }
-
- public InterfaceContract getComponentTypeReferenceInterfaceContract() {
- resolve();
- if (referenceInterfaceContract != null) {
- return referenceInterfaceContract;
- }
- if (reference == null) {
- return getComponentReferenceInterfaceContract();
- }
- referenceInterfaceContract = getLeafContract(reference).getInterfaceContract();
- if (referenceInterfaceContract == null) {
- referenceInterfaceContract = getComponentReferenceInterfaceContract();
- }
- return referenceInterfaceContract;
- }
-
- @Override
- protected synchronized void resolve() {
- if (xml != null && component == null) {
- if (compositeContext == null) {
- compositeContext = CompositeContext.getCurrentCompositeContext();
- if (compositeContext != null) {
- bind(compositeContext);
- }
- }
- RuntimeEndpointReferenceImpl epr = (RuntimeEndpointReferenceImpl)serializer.readEndpointReference(xml);
- copyFrom(epr);
- }
- super.resolve();
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.uri = in.readUTF();
- this.xml = in.readUTF();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF(getURI());
- if (serializer == null && xml != null) {
- out.writeUTF(xml);
- } else {
- if (serializer != null) {
- out.writeUTF(serializer.write(this));
- } else {
- throw new IllegalStateException("No serializer is configured");
- }
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java
deleted file mode 100644
index 2de52bebb2..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.context;
-
-import org.apache.tuscany.sca.context.ComponentContextFactory;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.context.impl.ComponentContextImpl;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.oasisopen.sca.ComponentContext;
-
-/**
- * @version $Rev$ $Date$
- */
-public class DefaultComponentContextFactory implements ComponentContextFactory {
- private final ExtensionPointRegistry registry;
-
- public DefaultComponentContextFactory(ExtensionPointRegistry registry) {
- this.registry = registry;
- }
-
- public ComponentContext createComponentContext(CompositeContext compositeContext, RuntimeComponent component) {
- return new ComponentContextImpl(registry, compositeContext, component);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java
deleted file mode 100644
index ace4dc48e1..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.context;
-
-import org.apache.tuscany.sca.context.RequestContextFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.context.impl.RequestContextImpl;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.oasisopen.sca.RequestContext;
-
-/**
- * Default implementation of RequestContextFactory
- */
-public class DefaultRequestContextFactory implements RequestContextFactory {
-
- public DefaultRequestContextFactory(ExtensionPointRegistry registry) {
- }
-
- public RequestContext createRequestContext(RuntimeComponent component) {
- return new RequestContextImpl(component);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java
deleted file mode 100644
index 5206f0945e..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.context;
-
-import java.io.Externalizable;
-
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * Extended ServiceReference
- */
-public interface ServiceReferenceExt<B> extends ServiceReference<B>, Externalizable {
-
- /**
- * Return the EndpointReference that sits behind this service reference
- * @return endpoint reference
- */
- RuntimeEndpointReference getEndpointReference();
-
- B getProxy();
- void setProxy(B proxy);
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
deleted file mode 100644
index 542a80f926..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.context.impl;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.context.ThreadMessageContext;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> {
- private RuntimeEndpointReference callbackEPR;
- private List<? extends EndpointReference> callbackEPRs;
- private Endpoint resolvedEndpoint;
-
- /*
- * Public constructor for Externalizable serialization/deserialization
- */
- public CallbackServiceReferenceImpl() {
- super();
- }
-
- public CallbackServiceReferenceImpl(Class<B> interfaze,
- List<? extends EndpointReference> callbackEPRs) {
- super(interfaze, null, getCompositeContext(callbackEPRs));
- this.callbackEPRs = callbackEPRs;
- init();
- }
-
- private static CompositeContext getCompositeContext(List<? extends EndpointReference> callbackEPRs) {
- if(!callbackEPRs.isEmpty()) {
- RuntimeEndpointReference epr = (RuntimeEndpointReference) callbackEPRs.get(0);
- return epr.getCompositeContext();
- }
- return null;
- }
-
- public void init() {
- Message msgContext = ThreadMessageContext.getMessageContext();
- callbackEPR = selectCallbackEPR(msgContext);
- if (callbackEPR == null) {
- throw new ServiceRuntimeException("No callback binding found for " + msgContext.getTo().toString());
- }
- resolvedEndpoint = msgContext.getFrom().getCallbackEndpoint();
- }
-
- @Override
- protected B createProxy() throws Exception {
- return proxyFactory.createCallbackProxy(this);
- }
-
- public RuntimeEndpointReference getCallbackEPR() {
- if (resolvedEndpoint == null) {
- return null;
- } else {
- return cloneAndBind(callbackEPR);
- }
- }
-
- public Endpoint getResolvedEndpoint() {
- return resolvedEndpoint;
- }
-
- private RuntimeEndpointReference selectCallbackEPR(Message msgContext) {
- // look for callback binding with same name as service binding
- Endpoint to = msgContext.getTo();
- if (to == null) {
- //FIXME: need better exception
- throw new ServiceRuntimeException("Destination for forward call is not available");
- }
- for (EndpointReference epr : callbackEPRs) {
- if (epr.getBinding().getName().equals(to.getBinding().getName())) {
- return (RuntimeEndpointReference) epr;
- }
- }
-
- // if no match, look for callback binding with same type as service binding
- for (EndpointReference epr : callbackEPRs) {
- if (epr.getBinding().getType().equals(to.getBinding().getType())) {
- return (RuntimeEndpointReference) epr;
- }
- }
-
- // no suitable callback wire was found
- return null;
- }
-
- private RuntimeEndpointReference cloneAndBind(RuntimeEndpointReference endpointReference) {
- if (resolvedEndpoint != null) {
-
- try {
- RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference.clone();
- epr.setTargetEndpoint(resolvedEndpoint);
- return epr;
- } catch (CloneNotSupportedException e) {
- // will not happen
- throw new ServiceRuntimeException(e);
- }
- } else {
- return null;
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
deleted file mode 100644
index 3a4ff89357..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.context.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ComponentProperty;
-import org.apache.tuscany.sca.assembly.ComponentReference;
-import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.Multiplicity;
-import org.apache.tuscany.sca.assembly.Reference;
-import org.apache.tuscany.sca.assembly.SCABinding;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
-import org.apache.tuscany.sca.context.PropertyValueFactory;
-import org.apache.tuscany.sca.context.RequestContextFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.runtime.CompositeActivator;
-import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.RequestContext;
-import org.oasisopen.sca.ServiceReference;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * Implementation of ComponentContext that delegates to a ComponentContextProvider.
- *
- * @version $Rev$ $Date$
- */
-public class ComponentContextImpl implements RuntimeComponentContext {
- private final RuntimeComponent component;
-
- private final CompositeContext compositeContext;
- private final CompositeActivator compositeActivator;
- private final RequestContextFactory requestContextFactory;
- private final ProxyFactory proxyFactory;
- private final AssemblyFactory assemblyFactory;
- private final JavaInterfaceFactory javaInterfaceFactory;
- private final PropertyValueFactory propertyFactory;
- private final EndpointReferenceBinder eprBinder;
-
- public ComponentContextImpl(ExtensionPointRegistry registry,
- CompositeContext compositeContext,
- RuntimeComponent component) {
- this.component = component;
- FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
- this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
-
- UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
- this.compositeContext = compositeContext;
-
- this.compositeActivator = utilities.getUtility(CompositeActivator.class);
-
- this.requestContextFactory =
- registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class);
- this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
- this.propertyFactory = factories.getFactory(PropertyValueFactory.class);
-
- this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
-
- }
-
- public String getURI() {
- return component.getURI();
- }
-
- public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
- return (R)proxyFactory.cast(target);
- }
-
- public <B> B getService(Class<B> businessInterface, String referenceName) {
- ServiceReference<B> serviceRef = getServiceReference(businessInterface, referenceName);
- return serviceRef.getService();
- }
-
- public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
-
- for (ComponentReference ref : component.getReferences()) {
- if (referenceName.equals(ref.getName())) {
- Multiplicity multiplicity = ref.getMultiplicity();
- if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
- throw new ServiceRuntimeException("Reference " + referenceName
- + " has multiplicity "
- + multiplicity);
- }
- return getServiceReference(businessInterface, (RuntimeEndpointReference)getEndpointReference(ref));
- }
- }
- throw new ServiceRuntimeException("Reference not found: " + referenceName);
-
- }
-
- /**
- * Select an endpoint reference from the component reference
- * @param ref
- * @return
- */
- private EndpointReference getEndpointReference(ComponentReference ref) {
- List<EndpointReference> eprs = ref.getEndpointReferences();
- if (eprs.size() == 1) {
- // Return 1st one
- return eprs.get(0);
- } else {
- for (EndpointReference epr : eprs) {
- // Try to see if there is an EPR using binding.sca
- if (epr.getBinding().getType().equals(SCABinding.TYPE)) {
- return epr;
- }
- }
- return eprs.get(0);
- }
- }
-
- /**
- * Select an endpoint reference from the component reference
- * @param ref
- * @return
- */
- private Endpoint getEndpoint(ComponentService service, String bindingName) {
- if (bindingName == null) {
- // The default binding name is the name of the promoted service
- bindingName = getPromotedService(service).getName();
- }
- List<Endpoint> eps = service.getEndpoints();
- for (Endpoint ep : eps) {
- Binding binding = ep.getBinding();
- if (bindingName.equals(binding.getName()) || binding.getName() == null) {
- return ep;
- }
- }
- return null;
- }
-
- private ComponentService getPromotedService(ComponentService componentService) {
- Service service = componentService.getService();
- if (service instanceof CompositeService) {
- return getPromotedService(((CompositeService)service).getPromotedService());
- } else {
- return componentService;
- }
-
- }
-
- /**
- * Gets the value for the specified property with the specified type.
- *
- * @param type The type of the property value we are getting
- * @param propertyName The name of the property we are getting
- * @param B The class of the property value we are getting
- *
- * @throws ServiceRuntimeException If a Property for the specified propertyName
- * is not found
- *
- * @see #setPropertyValueFactory(PropertyValueFactory)
- */
- public <B> B getProperty(Class<B> type, String propertyName) {
- for (ComponentProperty p : component.getProperties()) {
- if (propertyName.equals(p.getName())) {
- return propertyFactory.createPropertyValue(p, type);
- }
- }
- throw new ServiceRuntimeException("Property not found: " + propertyName);
- }
-
- /**
- * @param component
- */
- public static ComponentService getSingleService(Component component) {
- ComponentService targetService;
- List<ComponentService> services = component.getServices();
- List<ComponentService> regularServices = new ArrayList<ComponentService>();
- for (ComponentService service : services) {
- if (service.isForCallback()) {
- continue;
- }
- String name = service.getName();
- if (!name.startsWith("$") || name.startsWith("$dynamic$")) {
- regularServices.add(service);
- }
- }
- if (regularServices.size() == 0) {
- throw new ServiceRuntimeException("No service is declared on component " + component.getURI());
- }
- if (regularServices.size() != 1) {
- throw new ServiceRuntimeException("More than one service is declared on component " + component.getURI()
- + ". Service name is required to get the service.");
- }
- targetService = regularServices.get(0);
- return targetService;
- }
-
- public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
- ComponentService service = getSingleService(component);
- try {
- return createSelfReference(businessInterface, service);
- } catch (Exception e) {
- throw new ServiceRuntimeException(e.getMessage(), e);
- }
- }
-
- public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
- if (serviceName == null) {
- return createSelfReference(businessInterface);
- }
- try {
- String bindingName = null;
- int index = serviceName.indexOf('/');
- if (index != -1) {
- serviceName = serviceName.substring(0, index);
- bindingName = serviceName.substring(index + 1);
- }
- for (ComponentService service : component.getServices()) {
- if (serviceName.equals(service.getName())) {
- Endpoint endpoint = getEndpoint(service, bindingName);
- if (endpoint == null) {
- break;
- }
- return getServiceReference(businessInterface, (RuntimeEndpoint)endpoint);
- }
- }
- throw new ServiceRuntimeException("Service not found: " + serviceName);
- } catch (ServiceRuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new ServiceRuntimeException(e.getMessage(), e);
- }
- }
-
- /**
- * @param <B>
- * @param businessInterface
- * @param service
- * @return
- */
- public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service) {
- try {
- RuntimeEndpointReference ref =
- (RuntimeEndpointReference)createEndpointReference(component, service, null, businessInterface);
- ref.setComponent(component);
- return getServiceReference(businessInterface, ref);
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public RequestContext getRequestContext() {
- if (requestContextFactory != null) {
- return requestContextFactory.createRequestContext(component);
- } else {
- return new RequestContextImpl(component);
- }
- }
-
- /**
- * @param businessInterface
- * @param reference
- * @return
- * @throws CloneNotSupportedException
- * @throws InvalidInterfaceException
- */
- public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
- RuntimeEndpointReference endpointReference) {
- try {
- RuntimeComponentReference ref = (RuntimeComponentReference)endpointReference.getReference();
- InterfaceContract interfaceContract = ref.getInterfaceContract();
- Reference componentTypeReference = ref.getReference();
- if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) {
- interfaceContract = componentTypeReference.getInterfaceContract();
- }
- InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
- if (refInterfaceContract != interfaceContract) {
- ref = (RuntimeComponentReference)ref.clone();
- if (interfaceContract != null) {
- ref.setInterfaceContract(interfaceContract);
- } else {
- ref.setInterfaceContract(refInterfaceContract);
- }
- }
- ref.setComponent(component);
- return new ServiceReferenceImpl<B>(businessInterface, endpointReference, component.getComponentContext()
- .getCompositeContext());
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, RuntimeEndpoint endpoint) {
- try {
- if (businessInterface == null) {
- InterfaceContract contract = endpoint.getComponentTypeServiceInterfaceContract();
- businessInterface = (Class<B>)((JavaInterface)contract.getInterface()).getJavaClass();
- }
- RuntimeEndpointReference ref =
- (RuntimeEndpointReference)createEndpointReference(endpoint, businessInterface);
- ref.setComponent(component);
- return new ServiceReferenceImpl<B>(businessInterface, ref, compositeContext);
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- /**
- * Create a self-reference for a component service
- * @param component
- * @param service
- * @throws CloneNotSupportedException
- * @throws InvalidInterfaceException
- */
- private EndpointReference createEndpointReference(Component component,
- ComponentService service,
- String bindingName,
- Class<?> businessInterface) throws CloneNotSupportedException,
- InvalidInterfaceException {
-
- Endpoint endpoint = getEndpoint(service, bindingName);
- return createEndpointReference(endpoint, businessInterface);
- }
-
- private EndpointReference createEndpointReference(Endpoint endpoint, Class<?> businessInterface)
- throws CloneNotSupportedException, InvalidInterfaceException {
- Component component = endpoint.getComponent();
- ComponentService service = endpoint.getService();
- ComponentReference componentReference = assemblyFactory.createComponentReference();
- componentReference.setName("$self$." + service.getName());
-
- componentReference.setCallback(service.getCallback());
- componentReference.getTargets().add(service);
- componentReference.getPolicySets().addAll(service.getPolicySets());
- componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
- componentReference.getBindings().add(endpoint.getBinding());
-
- InterfaceContract interfaceContract = service.getInterfaceContract();
- Service componentTypeService = service.getService();
- if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
- interfaceContract = componentTypeService.getInterfaceContract();
- }
- interfaceContract = getInterfaceContract(interfaceContract, businessInterface);
- componentReference.setInterfaceContract(interfaceContract);
- componentReference.setMultiplicity(Multiplicity.ONE_ONE);
- // component.getReferences().add(componentReference);
-
- // create endpoint reference
- EndpointReference endpointReference = assemblyFactory.createEndpointReference();
- endpointReference.setComponent(component);
- endpointReference.setReference(componentReference);
- endpointReference.setBinding(endpoint.getBinding());
- endpointReference.setUnresolved(false);
- endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
-
- endpointReference.setTargetEndpoint(endpoint);
-
- componentReference.getEndpointReferences().add(endpointReference);
- ((RuntimeComponentReference)componentReference).setComponent((RuntimeComponent)component);
- ((RuntimeEndpointReference)endpointReference).bind(compositeContext);
-
- return endpointReference;
- }
-
- /**
- * @param interfaceContract
- * @param businessInterface
- * @return
- * @throws CloneNotSupportedException
- * @throws InvalidInterfaceException
- */
- private InterfaceContract getInterfaceContract(InterfaceContract interfaceContract, Class<?> businessInterface)
- throws CloneNotSupportedException, InvalidInterfaceException {
- boolean compatible = false;
- if (interfaceContract != null && interfaceContract.getInterface() != null) {
- Interface interfaze = interfaceContract.getInterface();
- if (interfaze instanceof JavaInterface) {
- Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
- if (businessInterface.isAssignableFrom(cls)) {
- compatible = true;
- }
- }
- }
-
- if (!compatible) {
- // The interface is not assignable from the interface contract
- interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
- JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(businessInterface);
- interfaceContract.setInterface(callInterface);
- if (callInterface.getCallbackClass() != null) {
- interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(callInterface
- .getCallbackClass()));
- }
- }
-
- return interfaceContract;
- }
-
- /**
- * @see org.apache.tuscany.sca.runtime.RuntimeComponentContext#start(org.apache.tuscany.sca.runtime.RuntimeComponentReference)
- */
- public void start(RuntimeComponentReference reference) {
- compositeActivator.start(compositeContext, component, reference);
- }
-
- /* ******************** Contribution for issue TUSCANY-2281 ******************** */
-
- /**
- * @see ComponentContext#getServices(Class<B>, String)
- */
- public <B> Collection<B> getServices(Class<B> businessInterface, String referenceName) {
- ArrayList<B> services = new ArrayList<B>();
- Collection<ServiceReference<B>> serviceRefs = getServiceReferences(businessInterface, referenceName);
- for (ServiceReference<B> serviceRef : serviceRefs) {
- services.add(serviceRef.getService());
- }
- return services;
- }
-
- /**
- * @see ComponentContext#getServiceReferences(Class<B>, String)
- */
- public <B> Collection<ServiceReference<B>> getServiceReferences(Class<B> businessInterface, String referenceName) {
- try {
- for (ComponentReference ref : component.getReferences()) {
- if (referenceName.equals(ref.getName())) {
- ArrayList<ServiceReference<B>> serviceRefs = new ArrayList<ServiceReference<B>>();
- for (EndpointReference endpointReference : ref.getEndpointReferences()) {
- RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference;
- serviceRefs.add(getServiceReference(businessInterface, epr));
- }
- return serviceRefs;
- }
- }
- throw new ServiceRuntimeException("Reference not found: " + referenceName);
- } catch (ServiceRuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new ServiceRuntimeException(e.getMessage(), e);
- }
- }
-
- /* ******************** Contribution for issue TUSCANY-2281 ******************** */
-
- public CompositeContext getCompositeContext() {
- return compositeContext;
- }
-
- public ExtensionPointRegistry getExtensionPointRegistry() {
- return getCompositeContext().getExtensionPointRegistry();
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
deleted file mode 100644
index c6a6ecd9c0..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.context.impl;
-
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.context.ThreadMessageContext;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.oasisopen.sca.RequestContext;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * @version $Rev$ $Date$
- */
-public class RequestContextImpl implements RequestContext {
-
- private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint;
-
- public RequestContextImpl(RuntimeComponent component) {
- ExtensionPointRegistry registry = component.getComponentContext().getExtensionPointRegistry();
- proxyFactoryExtensionPoint = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
- }
-
- public Subject getSecuritySubject() {
- Subject subject = null;
-
- for (Object header : ThreadMessageContext.getMessageContext().getHeaders()){
- if (header instanceof Subject){
- subject = (Subject)header;
- break;
- }
- }
- return subject;
- }
-
- public String getServiceName() {
- return ThreadMessageContext.getMessageContext().getTo().getService().getName();
- }
-
- public <B> ServiceReference<B> getServiceReference() {
- Message msgContext = ThreadMessageContext.getMessageContext();
- // FIXME: [rfeng] Is this the service reference matching the caller side?
- RuntimeEndpoint to = (RuntimeEndpoint) msgContext.getTo();
- RuntimeComponent component = (RuntimeComponent) to.getComponent();
-
- ServiceReference<B> callableReference = component.getComponentContext().getServiceReference(null, to);
-
- return callableReference;
- }
-
- public <CB> CB getCallback() {
- ServiceReference<CB> cb = getCallbackReference();
- if (cb == null) {
- return null;
- }
- return cb.getService();
- }
-
- @SuppressWarnings("unchecked")
- public <CB> ServiceReference<CB> getCallbackReference() {
- Message msgContext = ThreadMessageContext.getMessageContext();
- Endpoint to = msgContext.getTo();
- RuntimeComponentService service = (RuntimeComponentService) to.getService();
- RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
- if (callbackReference == null) {
- return null;
- }
- JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
- Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
- List<EndpointReference> wires = callbackReference.getEndpointReferences();
- ProxyFactory proxyFactory = new ExtensibleProxyFactory(proxyFactoryExtensionPoint);
- ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires);
-
- return ref;
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
deleted file mode 100644
index 5edf357e60..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.context.impl;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.StringWriter;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-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.ComponentService;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
-import org.apache.tuscany.sca.assembly.builder.BuilderContext;
-import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
-import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
-import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * Default implementation of a ServiceReference.
- *
- * @version $Rev$ $Date$
- * @param <B> the type of the business interface
- */
-public class ServiceReferenceImpl<B> implements ServiceReferenceExt<B> {
- private static final long serialVersionUID = 6763709434194361540L;
-
- protected transient ProxyFactory proxyFactory;
- protected transient Class<B> businessInterface;
- protected transient B proxy;
-
- protected Object callbackID; // The callbackID should be serializable
-
- protected transient RuntimeEndpointReference endpointReference;
-
-// protected String scdl;
-//
-// private transient XMLStreamReader xmlReader;
-
- protected transient CompositeContext compositeContext;
- protected ExtensionPointRegistry registry;
- protected FactoryExtensionPoint modelFactories;
- protected RuntimeAssemblyFactory assemblyFactory;
- protected StAXArtifactProcessorExtensionPoint staxProcessors;
- protected StAXArtifactProcessor<EndpointReference> staxProcessor;
- protected XMLInputFactory xmlInputFactory;
- protected XMLOutputFactory xmlOutputFactory;
- protected BuilderExtensionPoint builders;
-
- /*
- * Public constructor for Externalizable serialization/deserialization
- */
- public ServiceReferenceImpl() {
- super();
- }
-
- public ServiceReferenceImpl(Class<B> businessInterface,
- Invocable endpointReference,
- CompositeContext compositeContext) {
- this.businessInterface = businessInterface;
- this.endpointReference = (RuntimeEndpointReference) endpointReference;
- if (compositeContext == null) {
- compositeContext = endpointReference.getCompositeContext();
- }
- bind(compositeContext);
- }
-
- public ServiceReferenceImpl(Class<B> businessInterface,
- Invocable endpointReference) {
- this(businessInterface, endpointReference, null);
- }
-
- protected void bind(CompositeContext context) {
- this.compositeContext = context;
- this.registry = compositeContext.getExtensionPointRegistry();
- this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
- this.xmlInputFactory = modelFactories.getFactory(XMLInputFactory.class);
- this.xmlOutputFactory = modelFactories.getFactory(XMLOutputFactory.class);
- this.staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
- this.staxProcessor = staxProcessors.getProcessor(EndpointReference.class);
- this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
- this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
- }
-
- public RuntimeEndpointReference getEndpointReference() {
- return endpointReference;
- }
-
- public B getProxy() throws ObjectCreationException {
- try {
- if (proxy == null) {
- proxy = createProxy();
- }
- return proxy;
- } catch (Exception e) {
- throw new ObjectCreationException(e);
- }
- }
-
- public void setProxy(B proxy) {
- this.proxy = proxy;
- }
-
- protected B createProxy() throws Exception {
- return proxyFactory.createProxy(this);
- }
-
- public B getService() {
- try {
- resolve();
- return getProxy();
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public Class<B> getBusinessInterface() {
- try {
- resolve();
- return businessInterface;
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- /**
- * Follow a service promotion chain down to the inner most (non composite)
- * component service.
- *
- * @param topCompositeService
- * @return
- */
- private ComponentService getPromotedComponentService(CompositeService compositeService) {
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- Service service = componentService.getService();
- if (componentService.getName() != null && service instanceof CompositeService) {
-
- // Continue to follow the service promotion chain
- return getPromotedComponentService((CompositeService)service);
-
- } else {
-
- // Found a non-composite service
- return componentService;
- }
- } else {
-
- // No promoted service
- return null;
- }
- }
-
- // ============ WRITE AND READ THE REFERENCE TO EXTERNAL XML ========================
-
- /**
- * write the reference to a stream
- *
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(endpointReference);
- /*
- try {
- String xml = null;
- if (scdl == null) {
- xml = toXMLString();
- } else {
- xml = scdl;
- }
-
- if (xml == null) {
- out.writeBoolean(false);
- } else {
- out.writeBoolean(true);
- out.writeUTF(xml);
- }
- } catch (Exception e) {
- // e.printStackTrace();
- throw new IOException(e.toString());
- }
- */
- }
-
- /**
- * write the endpoint reference into an xml string
- */
- public String toXMLString() throws IOException, XMLStreamException, ContributionWriteException {
- StringWriter writer = new StringWriter();
- XMLStreamWriter streamWriter = xmlOutputFactory.createXMLStreamWriter(writer);
- staxProcessor.write(endpointReference, streamWriter, new ProcessorContext(registry));
- return writer.toString();
- }
-
- /**
- * Read the reference from a stream
- *
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.endpointReference = (RuntimeEndpointReference) in.readObject();
- // Force resolve
- endpointReference.getComponent();
- bind(endpointReference.getCompositeContext());
-
- RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
- reference.setComponent((RuntimeComponent)endpointReference.getComponent());
-
- Interface i = reference.getInterfaceContract().getInterface();
- if (i instanceof JavaInterface) {
- JavaInterface javaInterface = (JavaInterface)i;
- if (javaInterface.isUnresolved()) {
- // Allow privileged access to get ClassLoader. Requires RuntimePermission in
- // security policy.
- ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- return Thread.currentThread().getContextClassLoader();
- }
- });
-
- javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName()));
- JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext);
-
- try {
- javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass());
- } catch (InvalidInterfaceException e) {
- throw new ServiceRuntimeException(e);
- }
- //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO),
- // this needs to be done here. We usually search for XSDs in the current
- // contribution at resolve time. Is it possible to locate the current
- // contribution at runtime?
- }
- this.businessInterface = (Class<B>)javaInterface.getJavaClass();
- }
-
- Binding binding = endpointReference.getBinding();
- if (binding != null) {
- BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType());
- if (bindingBuilder != null) {
- org.apache.tuscany.sca.assembly.builder.BuilderContext context = new BuilderContext(registry);
- bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context);
- }
- }
-
- this.proxyFactory = getProxyFactory(this.compositeContext);
-
- /*
- endpointReference.bind(CompositeContext.getCurrentCompositeContext());
- endpointReference.rebuild();
- */
- /*
- final boolean hasSCDL = in.readBoolean();
- if (hasSCDL) {
- this.scdl = in.readUTF();
- } else {
- this.scdl = null;
- }
- */
- }
-
- /**
- * Read xml string into the endpoint reference
- */
- /*
- public void fromXMLString() throws IOException, XMLStreamException, ContributionReadException {
-
- XMLStreamReader streamReader = xmlReader;
-
- if (scdl != null) {
- Reader reader = new StringReader(scdl);
-
- if (xmlInputFactory == null) {
- // this is a reference being read from a external stream
- // so set up enough of the reference in order to resolved the
- // xml being read
- bind(CompositeContext.getCurrentCompositeContext());
- }
-
- streamReader = xmlInputFactory.createXMLStreamReader(reader);
- }
-
- endpointReference = (RuntimeEndpointReference) staxProcessor.read(streamReader, new ProcessorContext(registry));
-
- // ok to GC
- xmlReader = null;
- scdl = null;
- }
- */
-
- /**
- * @throws IOException
- */
- private synchronized void resolve() throws Exception {
- /*
- if ((scdl != null || xmlReader != null) && endpointReference == null) {
- fromXMLString();
-
- compositeContext.bindComponent((RuntimeComponent) endpointReference.getComponent());
-
- RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
- reference.setComponent((RuntimeComponent)endpointReference.getComponent());
-
- ReferenceParameters parameters = null;
- for (Object ext : reference.getExtensions()) {
- if (ext instanceof ReferenceParameters) {
- parameters = (ReferenceParameters)ext;
- break;
- }
- }
-
- if (parameters != null) {
- this.callbackID = parameters.getCallbackID();
- }
-
- Interface i = reference.getInterfaceContract().getInterface();
- if (i instanceof JavaInterface) {
- JavaInterface javaInterface = (JavaInterface)i;
- if (javaInterface.isUnresolved()) {
- // Allow privileged access to get ClassLoader. Requires RuntimePermission in
- // security policy.
- ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- return Thread.currentThread().getContextClassLoader();
- }
- });
-
- javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName()));
- JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext);
-
- javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass());
- //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO),
- // this needs to be done here. We usually search for XSDs in the current
- // contribution at resolve time. Is it possible to locate the current
- // contribution at runtime?
- }
- this.businessInterface = (Class<B>)javaInterface.getJavaClass();
- }
-
- Binding binding = endpointReference.getBinding();
- if (binding != null) {
- BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType());
- if (bindingBuilder != null) {
- BuilderContext context = new BuilderContext(registry);
- bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context);
- }
- }
-
- this.proxyFactory = getProxyFactory(this.compositeContext);
- } else if (compositeContext == null) {
- this.compositeContext = CompositeContext.getCurrentCompositeContext();
- if (this.compositeContext != null) {
- this.proxyFactory = getProxyFactory(this.compositeContext);
- }
- }
- */
- }
-
- private JavaInterfaceFactory getJavaInterfaceFactory(CompositeContext compositeContext) {
- ExtensionPointRegistry extensionPointRegistry = compositeContext.getExtensionPointRegistry();
- FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
- JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
- return javaInterfaceFactory;
- }
-
- private ProxyFactory getProxyFactory(CompositeContext compositeContext) {
- ExtensionPointRegistry extensionPointRegistry = compositeContext.getExtensionPointRegistry();
- ProxyFactoryExtensionPoint proxyFactories =
- extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
- return new ExtensibleProxyFactory(proxyFactories);
- }
-
- // ==================================================================================
-
- /*
- public XMLStreamReader getXMLReader() {
- return xmlReader;
- }
- */
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java
deleted file mode 100644
index 2371897dce..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.factory;
-
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
-import org.apache.tuscany.sca.core.scope.TargetInitializationException;
-
-
-/**
- * Provides lifecycle management for an implementation instance associated with
- * a component for use by the component's associated {@link org.apache.tuscany.sca.core.scope.ScopeContainer}
- *
- * @version $Rev$ $Date$
- */
-public interface InstanceWrapper<T> {
-
- /**
- * @return
- */
- T getInstance();
-
- /**
- * @throws TargetInitializationException
- */
- void start() throws TargetInitializationException;
-
- /**
- * @throws TargetDestructionException
- */
- void stop() throws TargetDestructionException;
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java
deleted file mode 100644
index d35b27fd24..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.factory;
-
-
-/**
- * Denotes an error creating a new object instance
- *
- * @version $Rev$ $Date$
- */
-public class ObjectCreationException extends RuntimeException {
- private static final long serialVersionUID = -6423113430265944499L;
-
- public ObjectCreationException() {
- super();
- }
-
- public ObjectCreationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ObjectCreationException(String message) {
- super(message);
- }
-
- public ObjectCreationException(Throwable cause) {
- super(cause);
- }
-
-}
-
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java
deleted file mode 100644
index 3f64d2405b..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.factory;
-
-/**
- * Implementations create new instances of a particular type
- *
- * @version $Rev$ $Date$
- */
-public interface ObjectFactory<T> {
-
- /**
- * Return a instance of the type that this factory creates.
- *
- * @return a instance from this factory
- */
- T getInstance() throws ObjectCreationException;
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java
deleted file mode 100644
index 2323973938..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * Uses a wire to return a CallableReference
- *
- * @version $Rev$ $Date$
- */
-public class CallableReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
- private Class<?> businessInterface;
- private RuntimeEndpointReference endpointReference;
-
- /**
- * Constructor.
- *
- * To support the @Reference protected CallableReference<MyService> ref;
- *
- * @param businessInterface the interface to inject
- * @param component the component defining the reference to be injected
- * @param reference the reference to be injected
- * @param binding the binding for the reference
- */
- public CallableReferenceObjectFactory(Class<?> businessInterface,
- RuntimeEndpointReference endpointReference) {
- this.businessInterface = businessInterface;
- this.endpointReference = endpointReference;
- }
-
- public ServiceReference<?> getInstance() throws ObjectCreationException {
- RuntimeComponent component = (RuntimeComponent) endpointReference.getComponent();
- return component.getComponentContext().getServiceReference(businessInterface, endpointReference);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java
deleted file mode 100644
index 588eaa2d15..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-
-/**
- * An interceptor applied to the forward direction of a wire that ensures the callback target implements the required
- * service contract. This is required as callback targets may be set dynamically by service implementations.
- *
- * @version $Rev$ $Date$
- */
-public class CallbackInterfaceInterceptor implements Interceptor {
- private Invoker next;
-
- public CallbackInterfaceInterceptor() {
- }
-
- public Message invoke(Message msg) {
-
- /* TODO - EPR - not required for OASIS
- ReferenceParameters parameters = msg.getFrom().getReferenceParameters();
- if (parameters.getCallbackObjectID() != null || parameters.getCallbackReference() != msg.getFrom()
- .getCallbackEndpoint()) {
- */
- return next.invoke(msg);
- /*
- } else {
- throw new NoRegisteredCallbackException("Callback target does not implement the callback interface");
- }
- */
- }
-
- public void setNext(Invoker next) {
- this.next = next;
- }
-
- public Invoker getNext() {
- return next;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java
deleted file mode 100644
index 0c77ee75f6..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * Uses a wire to return a CallableReference
- *
- * @version $Rev$ $Date$
- */
-public class CallbackReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
- private Class<?> businessInterface;
- private ProxyFactory proxyFactory;
- private List<EndpointReference> wires;
-
- public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<EndpointReference> wires) {
- this.businessInterface = interfaze;
- this.proxyFactory = proxyFactory;
- this.wires = wires;
- }
-
- public ServiceReference<?> getInstance() throws ObjectCreationException {
- return new CallbackServiceReferenceImpl(businessInterface, wires);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
deleted file mode 100644
index 90d7374145..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-
-/**
- * Returns proxy instance for a wire callback
- *
- * @version $Rev$ $Date$
- */
-public class CallbackWireObjectFactory<B> implements ObjectFactory<B> {
- private Class<B> businessInterface;
- private ProxyFactory proxyFactory;
- private List<Invocable> wires;
-
- public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<Invocable> wires) {
- this.businessInterface = interfaze;
- this.proxyFactory = proxyFactory;
- this.wires = wires;
- }
-
- public B getInstance() throws ObjectCreationException {
- return proxyFactory.createCallbackProxy(businessInterface, wires);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
deleted file mode 100644
index f04573dd71..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import net.sf.cglib.proxy.Callback;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.Factory;
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
-import org.apache.tuscany.sca.core.invocation.impl.JDKCallbackInvocationHandler;
-import org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * The implementation of a wire service that uses cglib dynamic proxies
- *
- * @version $Rev$ $Date$
- */
-public class CglibProxyFactory implements ProxyFactory {
- private MessageFactory messageFactory;
-
- public CglibProxyFactory(MessageFactory messageFactory, InterfaceContractMapper mapper) {
- this.messageFactory = messageFactory;
-
- }
-
- public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
- ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, null);
- return createProxy(serviceReference);
- }
-
- /**
- * create the proxy with cglib. use the same JDKInvocationHandler as
- * JDKProxyService.
- */
- public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
- Enhancer enhancer = new Enhancer();
- Class<T> interfaze = callableReference.getBusinessInterface();
- enhancer.setSuperclass(interfaze);
- enhancer.setCallback(new CglibMethodInterceptor<T>(callableReference));
- Object proxy = enhancer.create();
- ((ServiceReferenceImpl)callableReference).setProxy(proxy);
- return interfaze.cast(proxy);
- }
-
- /**
- * create the callback proxy with cglib. use the same
- * JDKCallbackInvocationHandler as JDKProxyService.
- */
- public <T> T createCallbackProxy(Class<T> interfaze, final List<? extends Invocable> wires) throws ProxyCreationException {
- ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), null);
- return callbackReference != null ? createCallbackProxy(callbackReference) : null;
- }
-
- /**
- * create the callback proxy with cglib. use the same
- * JDKCallbackInvocationHandler as JDKProxyService.
- */
- public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
- Enhancer enhancer = new Enhancer();
- Class<T> interfaze = callbackReference.getBusinessInterface();
- enhancer.setSuperclass(interfaze);
- enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference));
- Object object = enhancer.create();
- T proxy = interfaze.cast(object);
- ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy);
- return proxy;
- }
-
- @SuppressWarnings("unchecked")
- public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
- if (isProxyClass(target.getClass())) {
- Factory factory = (Factory)target;
- Callback[] callbacks = factory.getCallbacks();
- if (callbacks.length != 1 || !(callbacks[0] instanceof CglibMethodInterceptor)) {
- throw new IllegalArgumentException("The object is not a known proxy.");
- }
- CglibMethodInterceptor interceptor = (CglibMethodInterceptor)callbacks[0];
- return (R)interceptor.invocationHandler.getCallableReference();
- } else {
- throw new IllegalArgumentException("The object is not a known proxy.");
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
- */
- public boolean isProxyClass(Class<?> clazz) {
- return Factory.class.isAssignableFrom(clazz);
- }
-
- private class CglibMethodInterceptor<T> implements MethodInterceptor {
- private JDKInvocationHandler invocationHandler;
-
- public CglibMethodInterceptor(ServiceReference<T> callableReference) {
- invocationHandler = new JDKInvocationHandler(messageFactory, callableReference);
- }
-
- public CglibMethodInterceptor(ServiceReferenceImpl<T> callbackReference) {
- invocationHandler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
- }
-
- /**
- * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], net.sf.cglib.proxy.MethodProxy)
- */
- public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
- Object result = invocationHandler.invoke(proxy, method, args);
- return result;
- }
-
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java
deleted file mode 100644
index af6f039775..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.invocation.impl.JDKProxyFactory;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-
-/**
- * Default implementation of a ProxyFactoryExtensionPoint.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultProxyFactoryExtensionPoint implements ProxyFactoryExtensionPoint, LifeCycleListener {
- private InterfaceContractMapper interfaceContractMapper;
- private MessageFactory messageFactory;
-
- private ProxyFactory interfaceFactory;
- private ProxyFactory classFactory;
-
- public DefaultProxyFactoryExtensionPoint(ExtensionPointRegistry extensionPoints) {
- UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
-
- FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- this.messageFactory = modelFactories.getFactory(MessageFactory.class);
-
- interfaceFactory = new JDKProxyFactory(messageFactory, interfaceContractMapper);
- }
-
- public DefaultProxyFactoryExtensionPoint(MessageFactory messageFactory, InterfaceContractMapper mapper) {
- this.interfaceContractMapper = mapper;
- this.messageFactory = messageFactory;
- interfaceFactory = new JDKProxyFactory(messageFactory, mapper);
- }
-
- public ProxyFactory getClassProxyFactory() {
- return classFactory;
- }
-
- public ProxyFactory getInterfaceProxyFactory() {
- return interfaceFactory;
- }
-
- public void setClassProxyFactory(ProxyFactory factory) {
- this.classFactory = factory;
-
- }
-
- public void setInterfaceProxyFactory(ProxyFactory factory) {
- this.interfaceFactory = factory;
-
- }
-
- public void start() {
- if (interfaceFactory instanceof LifeCycleListener) {
- ((LifeCycleListener)interfaceFactory).start();
- }
- if (classFactory instanceof LifeCycleListener) {
- ((LifeCycleListener)classFactory).start();
- }
- }
-
- public void stop() {
- if (interfaceFactory instanceof LifeCycleListener) {
- ((LifeCycleListener)interfaceFactory).stop();
- }
- if (classFactory instanceof LifeCycleListener) {
- ((LifeCycleListener)classFactory).stop();
- }
-
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java
deleted file mode 100644
index 7f476b2fa5..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * An extensible proxy factory.
- *
- * @version $Rev$ $Date$
- */
-public class ExtensibleProxyFactory implements ProxyFactory {
-
- private ProxyFactoryExtensionPoint proxyFactories;
-
- public ExtensibleProxyFactory(ProxyFactoryExtensionPoint proxyFactories) {
- this.proxyFactories = proxyFactories;
- }
-
- /**
- * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#cast(java.lang.Object)
- */
- @SuppressWarnings("unchecked")
- public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
- ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
- ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
- if (interfaceFactory.isProxyClass(target.getClass())) {
- return (R)interfaceFactory.cast(target);
- } else if (classFactory != null && classFactory.isProxyClass(target.getClass())) {
- return (R)classFactory.cast(target);
- } else {
- throw new IllegalArgumentException("The target is not a callable proxy");
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createCallbackProxy(java.lang.Class,
- * java.util.List)
- */
- public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException {
- ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
- ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
- if (interfaze.isInterface()) {
- return interfaceFactory.createCallbackProxy(interfaze, wires);
- } else {
- return classFactory.createCallbackProxy(interfaze, wires);
- }
- }
-
- public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
- ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
- ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
- if (callableReference.getBusinessInterface().isInterface()) {
- return interfaceFactory.createProxy(callableReference);
- } else {
- return classFactory.createProxy(callableReference);
- }
- }
-
- public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
- ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
- ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
- if (callbackReference.getBusinessInterface().isInterface()) {
- return interfaceFactory.createCallbackProxy(callbackReference);
- } else {
- return classFactory.createCallbackProxy(callbackReference);
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createProxy(java.lang.Class,
- * org.apache.tuscany.sca.runtime.Invocable)
- */
- public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
- ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
- ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
- if (interfaze.isInterface()) {
- return interfaceFactory.createProxy(interfaze, wire);
- } else {
- return classFactory.createProxy(interfaze, wire);
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
- */
- public boolean isProxyClass(Class<?> clazz) {
- ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
- ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
- return interfaceFactory.isProxyClass(clazz) || (classFactory != null && classFactory.isProxyClass(clazz));
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java
deleted file mode 100644
index 08019ec3e2..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
-import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
-
-/**
- * The default implementation of an extensible <code>WireProcessor</code>
- *
- * @version $Rev$ $Date$
- */
-public class ExtensibleWireProcessor implements RuntimeWireProcessor {
-
- private RuntimeWireProcessorExtensionPoint processors;
-
- public ExtensibleWireProcessor(RuntimeWireProcessorExtensionPoint processors) {
- this.processors = processors;
- }
-
- public void process(RuntimeEndpoint endpoint) {
- for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
- processor.process(endpoint);
- }
- }
-
- public void process(RuntimeEndpointReference endpointReference) {
- for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
- processor.process(endpointReference);
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
deleted file mode 100644
index 6435efe4d6..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.context.ThreadMessageContext;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.work.WorkScheduler;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * Adds non-blocking behavior to an invocation chain
- *
- * @version $Rev$ $Date$
- */
-public class NonBlockingInterceptor implements Interceptor {
-
- private static final Message RESPONSE = new ImmutableMessage();
-
- /**
- * The JDK logger that will be used to log messages.
- */
- private static final Logger LOGGER = Logger.getLogger(NonBlockingInterceptor.class.getName());
-
- private WorkScheduler workScheduler;
- private Invoker next;
-
- public NonBlockingInterceptor(WorkScheduler workScheduler) {
- this.workScheduler = workScheduler;
- }
-
- public NonBlockingInterceptor(WorkScheduler workScheduler, Interceptor next) {
- this.workScheduler = workScheduler;
- this.next = next;
- }
-
- /**
- * Sets desired workScheduler to NonBlockingInterceptor. This is a useful function for the extension framework
- * to set desired workmanager on the InvocationChain, other than default workmanager which is set per Tuscany runtime.
- * Using this function, extension framework can set desired workmanager on InvocationChain during post wire processing.
- * @param workScheduler workScheduler which contains workmanager
- */
- public void setWorkScheduler(WorkScheduler workScheduler){
- this.workScheduler = workScheduler;
- }
-
- public Message invoke(final Message msg) {
- // Schedule the invocation of the next interceptor in a new Work instance
- try {
- workScheduler.scheduleWork(new Runnable() {
- public void run() {
- Message context = ThreadMessageContext.setMessageContext(msg);
- try {
- Message response = null;
-
- Throwable ex = null;
- try {
- response = next.invoke(msg);
- } catch (Throwable t) {
- ex = t;
- }
-
- // Tuscany-2225 - Did the @OneWay method complete successfully?
- // (i.e. no exceptions)
- if (response != null && response.isFault()) {
- // The @OneWay method threw an Exception. Lets log it and
- // then pass it on to the WorkScheduler so it can notify any
- // listeners
- ex = (Throwable)response.getBody();
- }
- if (ex != null) {
- LOGGER.log(Level.SEVERE, "Exception from @OneWay invocation", ex);
- throw new ServiceRuntimeException("Exception from @OneWay invocation", ex);
- }
- } finally {
- ThreadMessageContext.setMessageContext(context);
- }
- }
- });
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- return RESPONSE;
- }
-
- public Invoker getNext() {
- return next;
- }
-
- public void setNext(Invoker next) {
- this.next = next;
- }
-
- /**
- * A dummy message passed back on an invocation
- */
- private static class ImmutableMessage implements Message {
-
- public <T> T getBody() {
- return null;
- }
-
- public void setBody(Object body) {
- if (body != null) {
- throw new UnsupportedOperationException();
- }
- }
-
- public Object getMessageID() {
- return null;
- }
-
- public void setMessageID(Object messageId) {
- throw new UnsupportedOperationException();
- }
-
- public boolean isFault() {
- return false;
- }
-
- public void setFaultBody(Object fault) {
- throw new UnsupportedOperationException();
- }
-
- public EndpointReference getFrom() {
- return null;
- }
-
- public Endpoint getTo() {
- return null;
- }
-
- public void setFrom(EndpointReference from) {
- throw new UnsupportedOperationException();
- }
-
- public void setTo(Endpoint to) {
- throw new UnsupportedOperationException();
- }
-
- public Operation getOperation() {
- return null;
- }
-
- public void setOperation(Operation op) {
- throw new UnsupportedOperationException();
- }
-
- public List<Object> getHeaders() {
- return null;
- }
- public <T> T getBindingContext() {
- return null;
- }
-
- public <T> void setBindingContext(T bindingContext) {
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java
deleted file mode 100644
index 0b36b178f3..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-
-
-/**
- * Denotes an error creating a proxy
- *
- * @version $Rev$ $Date$
- */
-public class ProxyCreationException extends ObjectCreationException {
- private static final long serialVersionUID = 8002454344828513781L;
-
- public ProxyCreationException() {
- super();
- }
-
- public ProxyCreationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ProxyCreationException(String message) {
- super(message);
- }
-
- public ProxyCreationException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
deleted file mode 100644
index fbf703bad0..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * Creates proxies that implement Java interfaces and invocation handlers for fronting wires
- *
- * @version $Rev$ $Date$
- */
-
-public interface ProxyFactory {
-
- /**
- * Creates a Java proxy for the given wire
- *
- * @param interfaze the interface the proxy implements
- * @param invocable the wire to proxy
- * @return the proxy
- * @throws ProxyCreationException
- */
- <T> T createProxy(Class<T> interfaze, Invocable invocable) throws ProxyCreationException;
-
- /**
- * Creates a Java proxy for the given CallableReference
- *
- * @param callableReference The CallableReference
- * @return the proxy
- * @throws ProxyCreationException
- */
- <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException;
-
- /**
- * Creates a Java proxy for the service contract callback
- *
- * @param interfaze the interface the proxy should implement
- * @return the proxy
- * @throws ProxyCreationException
- */
- <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> invocables) throws ProxyCreationException;
-
- /**
- * Creates a Java proxy for the given callback reference
- *
- * @param callableReference The CallableReference
- * @return the proxy
- * @throws ProxyCreationException
- */
- <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException;
-
- /**
- * Cast a proxy to a CallableReference.
- *
- * @param target a proxy generated by this implementation
- * @return a CallableReference (or subclass) equivalent to this proxy
- * @throws IllegalArgumentException if the object supplied is not a proxy
- */
- <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException;
-
- /**
- * Test if a given class is a generated proxy class by this factory
- * @param clazz A java class or interface
- * @return true if the class is a generated proxy class by this factory
- */
- boolean isProxyClass(Class<?> clazz);
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java
deleted file mode 100644
index 875a252798..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation;
-
-
-/**
- * The extension point to plug in proxy factories
- * @version $Rev$ $Date$
- */
-public interface ProxyFactoryExtensionPoint {
-
- /**
- * Get the proxy factory for java interfaces
- * @return
- */
- ProxyFactory getInterfaceProxyFactory();
-
- /**
- * Get the proxy factory for java classes
- * @return
- */
- ProxyFactory getClassProxyFactory();
-
- /**
- * Set the proxy factory for java interfaces
- * @param factory
- */
- void setInterfaceProxyFactory(ProxyFactory factory);
-
- /**
- * Set the proxy factory for java classes
- * @param factory
- */
- void setClassProxyFactory(ProxyFactory factory);
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
deleted file mode 100644
index 0751fd631b..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.context.ThreadMessageContext;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-
-/**
- * Invoker for a endpoint or endpoint reference
- * @version $Rev$ $Date$
- */
-public class RuntimeInvoker implements Invoker {
- protected MessageFactory messageFactory;
- protected Invocable invocable;
-
- public RuntimeInvoker(MessageFactory messageFactory, Invocable invocable) {
- this.messageFactory = messageFactory;
- this.invocable = invocable;
- }
-
- public Message invokeBinding(Message msg) {
- Message context = ThreadMessageContext.setMessageContext(msg);
- try {
- return invocable.getBindingInvocationChain().getHeadInvoker().invoke(msg);
- } finally {
- ThreadMessageContext.setMessageContext(context);
- }
- }
-
- public Message invoke(Message msg) {
- return invoke(msg.getOperation(), msg);
- }
-
- public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
- Message msg = messageFactory.createMessage();
- msg.setBody(args);
- Message resp = invoke(operation, msg);
- Object body = resp.getBody();
- if (resp.isFault()) {
- throw new InvocationTargetException((Throwable)body);
- }
- return body;
- }
-
-
- public Message invoke(Operation operation, Message msg) {
- InvocationChain chain = invocable.getInvocationChain(operation);
- return invoke(chain, msg);
- }
-
- public Message invoke(InvocationChain chain, Message msg) {
-
- if (invocable instanceof Endpoint) {
- msg.setTo((Endpoint)invocable);
- } else if (invocable instanceof EndpointReference) {
- msg.setFrom((EndpointReference)invocable);
- }
-
- Invoker headInvoker = chain.getHeadInvoker();
- Operation operation = chain.getTargetOperation();
- msg.setOperation(operation);
-
- Message msgContext = ThreadMessageContext.setMessageContext(msg);
- try {
- return headInvoker.invoke(msg);
- } finally {
- ThreadMessageContext.setMessageContext(msgContext);
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java
deleted file mode 100644
index 26b3590d14..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation;
-
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.core.invocation.impl.NoMethodForOperationException;
-import org.apache.tuscany.sca.runtime.Invocable;
-
-/**
- * Uses a wire to return an object instance
- *
- * @version $Rev$ $Date$
- */
-public class WireObjectFactory<T> implements ObjectFactory<T> {
- private Class<T> interfaze;
- private Invocable wire;
- private ProxyFactory proxyService;
-
- /**
- * Constructor.
- *
- * @param interfaze the interface to inject on the client
- * @param wire the backing wire
- * @param proxyService the wire service to create the proxy
- * @throws NoMethodForOperationException
- */
- public WireObjectFactory(Class<T> interfaze, Invocable wire, ProxyFactory proxyService) {
- this.interfaze = interfaze;
- this.wire = wire;
- this.proxyService = proxyService;
- }
-
- public T getInstance() throws ObjectCreationException {
- return new ServiceReferenceImpl<T>(interfaze, wire, null).getProxy();
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
deleted file mode 100644
index aeccfa8b05..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.concurrent.Future;
-
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.oasisopen.sca.ServiceReference;
-
-public class AsyncJDKInvocationHandler extends JDKInvocationHandler {
- private static final long serialVersionUID = 1L;
-
- public AsyncJDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
- super(messageFactory, callableReference);
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (isAsyncCallback(method)) {
- return doInvokeAsyncCallback(proxy, method, args);
- } else if (isAsyncPoll(method)) {
- return doInvokeAsyncPoll(proxy, method, args);
- } else {
- return super.invoke(proxy, method, args);
- }
- }
-
- protected boolean isAsyncCallback(Method method) {
- if (method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Future.class))) {
- if (method.getParameterTypes().length > 0) {
- return method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class);
- }
- }
- return false;
- }
-
- protected boolean isAsyncPoll(Method method) {
- return method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Response.class));
- }
-
- protected AsyncResponse doInvokeAsyncPoll(Object proxy, Method asyncMethod, Object[] args) {
- Object response;
- boolean isException;
- try {
- response = super.invoke(proxy, getNonAsyncMethod(asyncMethod), args);
- isException = false;
- } catch (Throwable e) {
- response = e;
- isException = true;
- }
- return new AsyncResponse(response, isException);
- }
-
- private Object doInvokeAsyncCallback(Object proxy, Method asyncMethod, Object[] args) {
- AsyncHandler handler = (AsyncHandler)args[args.length-1];
- Response response = doInvokeAsyncPoll(proxy,asyncMethod,Arrays.copyOf(args, args.length-1));
- handler.handleResponse(response);
-
- return null;
- }
-
- protected Method getNonAsyncMethod(Method asyncMethod) {
- String methodName = asyncMethod.getName().substring(0, asyncMethod.getName().length()-5);
- for (Method m : businessInterface.getMethods()) {
- if (methodName.equals(m.getName())) {
- return m;
- }
- }
- throw new IllegalStateException("No non-async method matching async method " + asyncMethod.getName());
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
deleted file mode 100644
index 07086dfae3..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import javax.xml.ws.Response;
-
-public class AsyncResponse implements Response {
-
- private Object response;
- private boolean isException;
-
- public AsyncResponse(Object response, boolean isException) {
- this.response = response;
- this.isException = isException;
- }
-
- public Map getContext() {
- return new HashMap();
- }
-
- public boolean cancel(boolean mayInterruptIfRunning) {
- return false;
- }
-
- public Object get() throws InterruptedException, ExecutionException {
- if (isException) {
- throw new ExecutionException((Throwable)response);
- } else {
- return response;
- }
- }
-
- public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
- return get();
- }
-
- public boolean isCancelled() {
- return false;
- }
-
- public boolean isDone() {
- return true;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
deleted file mode 100644
index 60914f799b..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.apache.tuscany.sca.invocation.PhasedInterceptor;
-
-/**
- * Default implementation of an invocation chain
- *
- * @version $Rev$ $Date$
- */
-public class InvocationChainImpl implements InvocationChain {
- private Operation sourceOperation;
- private Operation targetOperation;
- private List<Node> nodes = new ArrayList<Node>();
-
- private final PhaseManager phaseManager;
- private boolean forReference;
- private boolean allowsPassByReference;
-
- public InvocationChainImpl(Operation sourceOperation, Operation targetOperation, boolean forReference, PhaseManager phaseManager) {
- this.targetOperation = targetOperation;
- this.sourceOperation = sourceOperation;
- this.forReference = forReference;
- this.phaseManager = phaseManager;
- }
-
- public Operation getTargetOperation() {
- return targetOperation;
- }
-
- public void setTargetOperation(Operation operation) {
- this.targetOperation = operation;
- }
-
- public void addInterceptor(Interceptor interceptor) {
- if (interceptor instanceof PhasedInterceptor) {
- PhasedInterceptor pi = (PhasedInterceptor)interceptor;
- if (pi.getPhase() != null) {
- addInvoker(pi.getPhase(), pi);
- return;
- }
- }
- String phase = forReference ? Phase.REFERENCE : Phase.SERVICE;
- addInterceptor(phase, interceptor);
- }
-
- public void addInvoker(Invoker invoker) {
- if (invoker instanceof PhasedInterceptor) {
- PhasedInterceptor pi = (PhasedInterceptor)invoker;
- if (pi.getPhase() != null) {
- addInvoker(pi.getPhase(), pi);
- return;
- }
- }
- String phase = forReference ? Phase.REFERENCE_BINDING : Phase.IMPLEMENTATION;
- addInvoker(phase, invoker);
- }
-
- public Invoker getHeadInvoker() {
- return nodes.isEmpty() ? null : nodes.get(0).getInvoker();
- }
-
- /**
- * @return the sourceOperation
- */
- public Operation getSourceOperation() {
- return sourceOperation;
- }
-
- /**
- * @param sourceOperation the sourceOperation to set
- */
- public void setSourceOperation(Operation sourceOperation) {
- this.sourceOperation = sourceOperation;
- }
-
- public void addInterceptor(String phase, Interceptor interceptor) {
- addInvoker(phase, interceptor);
- }
-
- private void addInvoker(String phase, Invoker invoker) {
- int index = phaseManager.getAllPhases().indexOf(phase);
- if (index == -1) {
- throw new IllegalArgumentException("Invalid phase name: " + phase);
- }
- Node node = new Node(index, invoker);
- ListIterator<Node> li = nodes.listIterator();
- Node before = null, after = null;
- boolean found = false;
- while (li.hasNext()) {
- before = after;
- after = li.next();
- if (after.getPhaseIndex() > index) {
- // Move back
- li.previous();
- li.add(node);
- found = true;
- break;
- }
- }
- if (!found) {
- // Add to the end
- nodes.add(node);
- before = after;
- after = null;
- }
-
- // Relink the interceptors
- if (before != null) {
- if (before.getInvoker() instanceof Interceptor) {
- ((Interceptor)before.getInvoker()).setNext(invoker);
- }
- }
- if (after != null) {
- if (invoker instanceof Interceptor) {
- ((Interceptor)invoker).setNext(after.getInvoker());
- }
- }
-
- }
-
- public boolean allowsPassByReference() {
- if (allowsPassByReference) {
- // No need to check the invokers
- return true;
- }
- // Check if any of the invokers allows pass-by-reference
- boolean allowsPBR = false;
- for (Node i : nodes) {
- if (i.getInvoker() instanceof DataExchangeSemantics) {
- if (((DataExchangeSemantics)i.getInvoker()).allowsPassByReference()) {
- allowsPBR = true;
- break;
- }
- }
- }
- return allowsPBR;
- }
-
- public void setAllowsPassByReference(boolean allowsPBR) {
- this.allowsPassByReference = allowsPBR;
- }
-
- private static class Node {
- private int phaseIndex;
- private Invoker invoker;
-
- public Node(int phaseIndex, Invoker invoker) {
- super();
- this.phaseIndex = phaseIndex;
- this.invoker = invoker;
- }
-
- public int getPhaseIndex() {
- return phaseIndex;
- }
-
- public Invoker getInvoker() {
- return invoker;
- }
-
- @Override
- public String toString() {
- return "(" + phaseIndex + ")" + invoker;
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
deleted file mode 100644
index 168af952db..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.ServiceReference;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * Responsible for dispatching to a callback through a wire. <p/> TODO cache
- * target invoker
- *
- * @version $Rev$ $Date$
- */
-public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
- private static final long serialVersionUID = -3350283555825935609L;
-
- public JDKCallbackInvocationHandler(MessageFactory messageFactory, ServiceReference<?> ref) {
- super(messageFactory, ref);
- this.fixedWire = false;
- }
-
- @Override
- @SuppressWarnings( {"unchecked"})
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-
- if (Object.class == method.getDeclaringClass()) {
- return invokeObjectMethod(method, args);
- }
-
- // obtain a dedicated wire to be used for this callback invocation
- RuntimeEndpointReference wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackEPR();
- if (wire == null) {
- //FIXME: need better exception
- throw new ServiceRuntimeException("No callback wire found");
- }
-
- setEndpoint(((CallbackServiceReferenceImpl)callableReference).getResolvedEndpoint());
-
- InvocationChain chain = getInvocationChain(method, wire);
- if (chain == null) {
- throw new IllegalArgumentException("No matching operation is found: " + method);
- }
-
- try {
- return invoke(chain, args, wire);
- } catch (InvocationTargetException e) {
- Throwable t = e.getCause();
- throw t;
- } finally {
- // allow the cloned wire to be reused by subsequent callbacks
- }
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
deleted file mode 100644
index 77b72ed1d1..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.IdentityHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.context.ThreadMessageContext;
-import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
-import org.oasisopen.sca.ServiceReference;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class JDKInvocationHandler implements InvocationHandler, Serializable {
- private static final long serialVersionUID = -3366410500152201371L;
-
- protected boolean conversational;
- protected MessageFactory messageFactory;
- protected Endpoint target;
- protected RuntimeEndpointReference source;
- protected ServiceReferenceExt<?> callableReference;
- protected Class<?> businessInterface;
-
- protected boolean fixedWire = true;
-
- protected transient Map<Method, InvocationChain> chains = new IdentityHashMap<Method, InvocationChain>();
-
- public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, RuntimeEndpointReference source) {
- this.messageFactory = messageFactory;
- this.source = source;
- this.businessInterface = businessInterface;
- }
-
- public JDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
- this.messageFactory = messageFactory;
- this.callableReference = (ServiceReferenceExt<?>)callableReference;
- if (callableReference != null) {
- this.businessInterface = callableReference.getBusinessInterface();
- this.source = (RuntimeEndpointReference) this.callableReference.getEndpointReference();
- }
- }
-
-
- public Class<?> getBusinessInterface() {
- return businessInterface;
- }
-
- protected Object getCallbackID() {
- return null;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (Object.class == method.getDeclaringClass()) {
- return invokeObjectMethod(method, args);
- }
- if (source == null) {
- throw new ServiceRuntimeException("No runtime source is available");
- }
-
- if (source.isOutOfDate()) {
- source.rebuild();
- chains.clear();
- }
-
- InvocationChain chain = getInvocationChain(method, source);
-
- if (chain == null) {
- throw new IllegalArgumentException("No matching operation is found: " + method);
- }
-
- // send the invocation down the source
- Object result = invoke(chain, args, source);
-
- return result;
- }
-
- /**
- * Handle the methods on the Object.class
- * @param method
- * @param args
- */
- protected Object invokeObjectMethod(Method method, Object[] args) throws Throwable {
- String name = method.getName();
- if ("toString".equals(name)) {
- return "[Proxy - " + toString() + "]";
- } else if ("equals".equals(name)) {
- Object obj = args[0];
- if (obj == null) {
- return false;
- }
- if (!Proxy.isProxyClass(obj.getClass())) {
- return false;
- }
- return equals(Proxy.getInvocationHandler(obj));
- } else if ("hashCode".equals(name)) {
- return hashCode();
- } else {
- return method.invoke(this);
- }
- }
-
- /**
- * Determines if the given operation matches the given method
- *
- * @return true if the operation matches, false if does not
- */
- // FIXME: Should it be in the InterfaceContractMapper?
- @SuppressWarnings("unchecked")
- private static boolean match(Operation operation, Method method) {
- if (operation instanceof JavaOperation) {
- JavaOperation javaOp = (JavaOperation)operation;
- Method m = javaOp.getJavaMethod();
- if (!method.getName().equals(m.getName())) {
- return false;
- }
- if (method.equals(m)) {
- return true;
- }
- } else {
- if (!method.getName().equals(operation.getName())) {
- return false;
- }
- }
-
- // For remotable interface, operation is not overloaded.
- if (operation.getInterface().isRemotable()) {
- return true;
- }
-
- Class<?>[] params = method.getParameterTypes();
-
- DataType<List<DataType>> inputType = null;
- if (operation.isWrapperStyle()) {
- inputType = operation.getWrapper().getUnwrappedInputType();
- } else {
- inputType = operation.getInputType();
- }
- List<DataType> types = inputType.getLogical();
- boolean matched = true;
- if (types.size() == params.length && method.getName().equals(operation.getName())) {
- for (int i = 0; i < params.length; i++) {
- Class<?> clazz = params[i];
- Class<?> type = types.get(i).getPhysical();
- // Object.class.isAssignableFrom(int.class) returns false
- if (type != Object.class && (!type.isAssignableFrom(clazz))) {
- matched = false;
- }
- }
- } else {
- matched = false;
- }
- return matched;
-
- }
-
- protected synchronized InvocationChain getInvocationChain(Method method, Invocable source) {
- if (fixedWire && chains.containsKey(method)) {
- return chains.get(method);
- }
- InvocationChain found = null;
- for (InvocationChain chain : source.getInvocationChains()) {
- Operation operation = chain.getSourceOperation();
- if (operation.isDynamic()) {
- operation.setName(method.getName());
- found = chain;
- break;
- } else if (match(operation, method)) {
- found = chain;
- break;
- }
- }
- if (fixedWire) {
- chains.put(method, found);
- }
- return found;
- }
-
- protected void setEndpoint(Endpoint endpoint) {
- this.target = endpoint;
- }
-
- protected Object invoke(InvocationChain chain, Object[] args, RuntimeEndpointReference source)
- throws Throwable {
- Message msg = messageFactory.createMessage();
- msg.setFrom(source);
- if (target != null) {
- msg.setTo(target);
- } else {
- msg.setTo(source.getTargetEndpoint());
- }
- Invoker headInvoker = chain.getHeadInvoker();
- Operation operation = chain.getTargetOperation();
- msg.setOperation(operation);
- msg.setBody(args);
-
- Message msgContext = ThreadMessageContext.getMessageContext();
-
- ThreadMessageContext.setMessageContext(msg);
-
- try {
- // dispatch the source down the chain and get the response
- Message resp = headInvoker.invoke(msg);
- Object body = resp.getBody();
- if (resp.isFault()) {
- throw (Throwable)body;
- }
- return body;
- } finally {
- ThreadMessageContext.setMessageContext(msgContext);
- }
- }
-
- /**
- * @return the callableReference
- */
- public ServiceReference<?> getCallableReference() {
- return callableReference;
- }
-
- /**
- * @param callableReference the callableReference to set
- */
- public void setCallableReference(ServiceReference<?> callableReference) {
- this.callableReference = (ServiceReferenceExt<?>)callableReference;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java
deleted file mode 100644
index 13d4040b8e..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.List;
-import java.util.concurrent.Future;
-
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-
-import org.apache.tuscany.sca.common.java.collection.LRUCache;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
-import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
-import org.apache.tuscany.sca.core.invocation.ProxyCreationException;
-import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.Invocable;
-import org.oasisopen.sca.ServiceReference;
-
-
-/**
- * the default implementation of a wire service that uses JDK dynamic proxies
- *
- * @version $Rev$ $Date$
- */
-public class JDKProxyFactory implements ProxyFactory, LifeCycleListener {
- protected InterfaceContractMapper contractMapper;
- private MessageFactory messageFactory;
-
- public JDKProxyFactory(MessageFactory messageFactory, InterfaceContractMapper mapper) {
- this.contractMapper = mapper;
- this.messageFactory = messageFactory;
- }
-
- /**
- * The original createProxy method assumes that the proxy doesn't want to
- * share conversation state so sets the conversation object to null
- */
- public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
- ServiceReference<T> serviceReference = new ServiceReferenceImpl<T>(interfaze, wire, null);
- return createProxy(serviceReference);
- }
-
- public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
- assert callableReference != null;
- final Class<T> interfaze = callableReference.getBusinessInterface();
- InvocationHandler handler;
- if (isAsync(interfaze)) {
- handler = new AsyncJDKInvocationHandler(messageFactory, callableReference);
- } else {
- handler = new JDKInvocationHandler(messageFactory, callableReference);
- }
- // Allow privileged access to class loader. Requires RuntimePermission in security policy.
- ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- return interfaze.getClassLoader();
- }
- });
- T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
- ((ServiceReferenceExt<T>)callableReference).setProxy(proxy);
- return proxy;
- }
-
- private boolean isAsync(Class<?> interfaze) {
- for (Method method : interfaze.getMethods()) {
- if (method.getName().endsWith("Async")) {
- if (method.getReturnType().isAssignableFrom(Future.class)) {
- if (method.getParameterTypes().length > 0) {
- if (method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class)) {
- return true;
- }
- }
- }
- if (method.getReturnType().isAssignableFrom(Response.class)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException {
- ServiceReferenceImpl<T> callbackReference = new CallbackServiceReferenceImpl(interfaze, wires);
- return callbackReference != null ? createCallbackProxy(callbackReference) : null;
- }
-
- public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
- assert callbackReference != null;
- Class<T> interfaze = callbackReference.getBusinessInterface();
- InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
- ClassLoader cl = interfaze.getClassLoader();
- T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
- ((ServiceReferenceExt<T>) callbackReference).setProxy(proxy);
- return proxy;
- }
-
- public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
- InvocationHandler handler = Proxy.getInvocationHandler(target);
- if (handler instanceof JDKInvocationHandler) {
- return (R)((JDKInvocationHandler)handler).getCallableReference();
- } else {
- throw new IllegalArgumentException("The object is not a known proxy.");
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
- */
- public boolean isProxyClass(Class<?> clazz) {
- return Proxy.isProxyClass(clazz);
- }
-
- // This is a cache containing the proxy class constructor for each business interface.
- // This improves performance compared to calling Proxy.newProxyInstance()
- // every time that a proxy is needed.
- private final LRUCache<Class<?>, Constructor<?>> cache = new LRUCache<Class<?>, Constructor<?>>(512);
-
- public Object newProxyInstance(ClassLoader classloader,
- Class<?> interfaces[],
- InvocationHandler invocationhandler) throws IllegalArgumentException {
- if (interfaces.length > 1) {
- // We only cache the proxy constructors with one single interface which the case in SCA where
- // one reference can have one interface
- return Proxy.newProxyInstance(classloader, interfaces, invocationhandler);
- }
- try {
- if (invocationhandler == null)
- throw new NullPointerException("InvocationHandler is null");
- // Lookup cached constructor. aclass[0] is the reference's business interface.
- Constructor<?> proxyCTOR;
- synchronized (cache) {
- proxyCTOR = cache.get(interfaces[0]);
- }
- if (proxyCTOR == null) {
- Class<?> proxyClass = Proxy.getProxyClass(classloader, interfaces);
- proxyCTOR = proxyClass.getConstructor(InvocationHandler.class);
- synchronized (cache) {
- cache.put(interfaces[0], proxyCTOR);
- }
- }
- return proxyCTOR.newInstance(invocationhandler);
- } catch (Throwable e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public void start() {
- }
-
- public void stop() {
- cache.clear();
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java
deleted file mode 100644
index 6ce2ffca21..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-
-/**
- * Implementation of MessageFactory.
- *
- * @version $Rev$ $Date$
- */
-public class MessageFactoryImpl implements MessageFactory {
-
- public Message createMessage() {
- return new MessageImpl();
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java
deleted file mode 100644
index e66fb0567a..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Message;
-
-/**
- * The default implementation of a message flowed through a wire during an invocation
- *
- * @version $Rev $Date$
- */
-public class MessageImpl implements Message {
- private List<Object> headers = new ArrayList<Object>();
- private Object body;
- private Object messageID;
- private boolean isFault;
- private Operation operation;
-
- private EndpointReference from;
- private Endpoint to;
-
- private Object bindingContext;
-
- public MessageImpl() {
- this.from = null;
- this.to = null;
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getBody() {
- return (T)body;
- }
-
- public <T> void setBody(T body) {
- this.isFault = false;
- this.body = body;
- }
-
- public Object getMessageID() {
- return messageID;
- }
-
- public void setMessageID(Object messageId) {
- this.messageID = messageId;
- }
-
- public boolean isFault() {
- return isFault;
- }
-
- public void setFaultBody(Object fault) {
- this.isFault = true;
- this.body = fault;
- }
-
- public EndpointReference getFrom() {
- return from;
- }
-
- public void setFrom(EndpointReference from) {
- this.from = from;
- }
-
- public Endpoint getTo() {
- return to;
- }
-
- public void setTo(Endpoint to) {
- this.to = to;
- }
-
- public Operation getOperation() {
- return operation;
- }
-
- public void setOperation(Operation op) {
- this.operation = op;
- }
-
- public List<Object> getHeaders() {
- return headers;
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getBindingContext() {
- return (T)bindingContext;
- }
-
- public <T> void setBindingContext(T bindingContext) {
- this.bindingContext = bindingContext;
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java
deleted file mode 100644
index 45f4bf52bf..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import org.apache.tuscany.sca.core.invocation.ProxyCreationException;
-
-
-/**
- * Thrown when an {@link org.apache.tuscany.sca.core.factory.model.Operation} cannot be mapped to a method on an interface
- * @version $Rev$ $Date$
- */
-public class NoMethodForOperationException extends ProxyCreationException {
- private static final long serialVersionUID = 5116536602309483679L;
-
- public NoMethodForOperationException() {
- }
-
- public NoMethodForOperationException(String message) {
- super(message);
- }
-
- public NoMethodForOperationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public NoMethodForOperationException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
deleted file mode 100644
index 1649eade87..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION;
-import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION_POLICY;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_POLICY;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_TRANSPORT;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_WIREFORMAT;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_INTERFACE;
-import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_POLICY;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_OPERATION_SELECTOR;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_POLICY;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_TRANSPORT;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_WIREFORMAT;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_INTERFACE;
-import static org.apache.tuscany.sca.invocation.Phase.SERVICE_POLICY;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class PhaseManager {
- private static final Logger log = Logger.getLogger(PhaseManager.class.getName());
-
- public static final String STAGE_REFERENCE = "reference";
- public static final String STAGE_REFERENCE_BINDING = "reference.binding";
- public static final String STAGE_SERVICE_BINDING = "service.binding";
- public static final String STAGE_SERVICE = "service";
- public static final String STAGE_IMPLEMENTATION = "implementation";
-
- private static final String[] SYSTEM_REFERENCE_PHASES =
- {REFERENCE, REFERENCE_INTERFACE, REFERENCE_POLICY, REFERENCE_BINDING};
-
- private static final String[] SYSTEM_REFERENCE_BINDING_PHASES =
- {REFERENCE_BINDING_WIREFORMAT, REFERENCE_BINDING_POLICY, REFERENCE_BINDING_TRANSPORT};
-
- private static final String[] SYSTEM_SERVICE_BINDING_PHASES =
- {SERVICE_BINDING_TRANSPORT, SERVICE_BINDING_OPERATION_SELECTOR, SERVICE_BINDING_WIREFORMAT, SERVICE_BINDING_POLICY};
-
- private static final String[] SYSTEM_SERVICE_PHASES =
- {SERVICE_BINDING, SERVICE_POLICY, SERVICE_INTERFACE, SERVICE};
-
- private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
-
- private ExtensionPointRegistry registry;
- private String pattern = Phase.class.getName();
- private Map<String, Stage> stages;
- private List<String> phases;
-
- public class Stage {
- private String name;
- private PhaseSorter<String> sorter = new PhaseSorter<String>();
- private Set<String> firstSet = new HashSet<String>();
- private Set<String> lastSet = new HashSet<String>();
- private List<String> phases = new ArrayList<String>();
-
- public Stage(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public PhaseSorter<String> getSorter() {
- return sorter;
- }
-
- public Set<String> getFirstSet() {
- return firstSet;
- }
-
- public Set<String> getLastSet() {
- return lastSet;
- }
-
- public List<String> getPhases() {
- return phases;
- }
-
- @Override
- public String toString() {
- return name + phases;
- }
- }
-
- /**
- * @param registry
- */
- public PhaseManager(ExtensionPointRegistry registry) {
- super();
- this.registry = registry;
- }
-
- public static PhaseManager getInstance(ExtensionPointRegistry registry) {
- UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
- return utilityExtensionPoint.getUtility(PhaseManager.class);
- }
-
- // For unit test purpose
- PhaseManager(String pattern) {
- super();
- this.pattern = pattern;
- this.registry = new DefaultExtensionPointRegistry();
- }
-
- private List<String> getPhases(String stage) {
- Stage s = getStages().get(stage);
- return s == null ? null : s.getPhases();
- }
-
- public List<String> getReferencePhases() {
- return getPhases(STAGE_REFERENCE);
- }
-
- public List<String> getServicePhases() {
- return getPhases(STAGE_SERVICE);
- }
-
- public List<String> getReferenceBindingPhases() {
- return getPhases(STAGE_REFERENCE_BINDING);
- }
-
- public List<String> getServiceBindingPhases() {
- return getPhases(STAGE_SERVICE_BINDING);
- }
-
- public List<String> getImplementationPhases() {
- return getPhases(STAGE_IMPLEMENTATION);
- }
-
- public synchronized List<String> getAllPhases() {
- if (phases == null) {
- phases = new ArrayList<String>();
- phases.addAll(getReferencePhases());
- phases.addAll(getReferenceBindingPhases());
- phases.addAll(getServiceBindingPhases());
- phases.addAll(getServicePhases());
- phases.addAll(getImplementationPhases());
- }
- return phases;
- }
-
- public synchronized Map<String, Stage> getStages() {
- if (stages != null) {
- return stages;
- }
- init();
-
- Collection<ServiceDeclaration> services;
- try {
- services = registry.getServiceDiscovery().getServiceDeclarations(pattern);
- } catch (IOException e) {
- throw new ServiceRuntimeException(e);
- }
-
- for (ServiceDeclaration d : services) {
- if (log.isLoggable(Level.FINE)) {
- log.fine(d.getLocation() + ": " + d.getAttributes());
- }
- String name = d.getAttributes().get("name");
- if (name == null) {
- throw new ServiceRuntimeException("Required attribute 'name' is missing.");
- }
- String stageName = d.getAttributes().get("stage");
- if (stageName == null) {
- throw new ServiceRuntimeException("Required attribute 'stage' is missing.");
- }
- Stage stage = stages.get(stageName);
- if (stage == null) {
- throw new ServiceRuntimeException("Invalid stage: " + stageName);
- }
- PhaseSorter<String> graph = stage.getSorter();
- Set<String> firstSet = stage.getFirstSet(), lastSet = stage.getLastSet();
-
- String before = d.getAttributes().get("before");
- String after = d.getAttributes().get("after");
- if (before != null) {
- StringTokenizer tokenizer = new StringTokenizer(before);
- while (tokenizer.hasMoreTokens()) {
- String p = tokenizer.nextToken();
- if (!"*".equals(p)) {
- graph.addEdge(name, p);
- } else {
- firstSet.add(name);
- }
- }
- }
- if (after != null) {
- StringTokenizer tokenizer = new StringTokenizer(after);
- while (tokenizer.hasMoreTokens()) {
- String p = tokenizer.nextToken();
- if (!"*".equals(p)) {
- graph.addEdge(p, name);
- } else {
- lastSet.add(name);
- }
- }
- }
- graph.addVertext(name);
- if(firstSet.size()>1) {
- log.warning("More than one phases are declared to be first: "+firstSet);
- }
- for (String s : firstSet) {
- for (String v : new HashSet<String>(graph.getVertices().keySet())) {
- if (!firstSet.contains(v)) {
- graph.addEdge(s, v);
- }
- }
- }
- if(lastSet.size()>1) {
- log.warning("More than one phases are declared to be the last: "+lastSet);
- }
- for (String s : lastSet) {
- for (String v : new HashSet<String>(graph.getVertices().keySet())) {
- if (!lastSet.contains(v)) {
- graph.addEdge(v, s);
- }
- }
- }
-
- }
-
- for (Stage s : stages.values()) {
- List<String> phases = s.getSorter().topologicalSort(false);
- s.getPhases().clear();
- s.getPhases().addAll(phases);
- }
- if (log.isLoggable(Level.FINE)) {
- log.fine("Stages: " + stages);
- }
- return stages;
- }
-
- private void init() {
- stages = new HashMap<String, Stage>();
-
- Stage referenceStage = new Stage(STAGE_REFERENCE);
- for (int i = 1; i < SYSTEM_REFERENCE_PHASES.length; i++) {
- referenceStage.getSorter().addEdge(SYSTEM_REFERENCE_PHASES[i - 1], SYSTEM_REFERENCE_PHASES[i]);
- }
- referenceStage.getLastSet().add(REFERENCE_BINDING);
- stages.put(referenceStage.getName(), referenceStage);
-
- Stage referenceBindingStage = new Stage(STAGE_REFERENCE_BINDING);
- for (int i = 1; i < SYSTEM_REFERENCE_BINDING_PHASES.length; i++) {
- referenceBindingStage.getSorter().addEdge(SYSTEM_REFERENCE_BINDING_PHASES[i - 1], SYSTEM_REFERENCE_BINDING_PHASES[i]);
- }
- stages.put(referenceBindingStage.getName(), referenceBindingStage);
-
- Stage serviceBindingStage = new Stage(STAGE_SERVICE_BINDING);
- for (int i = 1; i < SYSTEM_SERVICE_BINDING_PHASES.length; i++) {
- serviceBindingStage.getSorter().addEdge(SYSTEM_SERVICE_BINDING_PHASES[i - 1], SYSTEM_SERVICE_BINDING_PHASES[i]);
- }
- stages.put(serviceBindingStage.getName(), serviceBindingStage);
-
-
- Stage serviceStage = new Stage(STAGE_SERVICE);
- for (int i = 1; i < SYSTEM_SERVICE_PHASES.length; i++) {
- serviceStage.getSorter().addEdge(SYSTEM_SERVICE_PHASES[i - 1], SYSTEM_SERVICE_PHASES[i]);
- }
- stages.put(serviceStage.getName(), serviceStage);
-
- Stage implementationStage = new Stage(STAGE_IMPLEMENTATION);
- for (int i = 1; i < SYSTEM_IMPLEMENTATION_PHASES.length; i++) {
- implementationStage.getSorter().addEdge(SYSTEM_IMPLEMENTATION_PHASES[i - 1],
- SYSTEM_IMPLEMENTATION_PHASES[i]);
- }
- implementationStage.getLastSet().add(IMPLEMENTATION);
- stages.put(implementationStage.getName(), implementationStage);
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java
deleted file mode 100644
index 175f3463ad..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Directed, weighted graph
- *
- * @param <V> The type of vertex object
- * @param <E> The type of edge object
- *
- * @version $Rev$ $Date$
- */
-public class PhaseSorter<V> implements Cloneable {
- private final Map<V, Vertex> vertices = new HashMap<V, Vertex>();
-
- /**
- * Vertex of a graph
- */
- public final class Vertex {
- private V value;
-
- // TODO: Do we want to support multiple edges for a vertex pair? If so,
- // we should use a List instead of Map
- private Map<Vertex, Edge> outEdges = new HashMap<Vertex, Edge>();
- private Map<Vertex, Edge> inEdges = new HashMap<Vertex, Edge>();
-
- private Vertex(V value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return "(" + value + ")";
- }
-
- public V getValue() {
- return value;
- }
-
- public Map<Vertex, Edge> getOutEdges() {
- return outEdges;
- }
-
- public Map<Vertex, Edge> getInEdges() {
- return inEdges;
- }
-
- }
-
- /**
- * An Edge connects two vertices in one direction
- */
- public final class Edge {
- private Vertex sourceVertex;
-
- private Vertex targetVertex;
-
- public Edge(Vertex source, Vertex target) {
- this.sourceVertex = source;
- this.targetVertex = target;
- }
-
- @Override
- public String toString() {
- return sourceVertex + "->" + targetVertex;
- }
-
- public Vertex getTargetVertex() {
- return targetVertex;
- }
-
- public void setTargetVertex(Vertex vertex) {
- this.targetVertex = vertex;
- }
-
- public Vertex getSourceVertex() {
- return sourceVertex;
- }
-
- public void setSourceVertex(Vertex sourceVertex) {
- this.sourceVertex = sourceVertex;
- }
- }
-
- public void addEdge(V source, V target) {
- Vertex s = getVertex(source);
- if (s == null) {
- s = new Vertex(source);
- vertices.put(source, s);
- }
- Vertex t = getVertex(target);
- if (t == null) {
- t = new Vertex(target);
- vertices.put(target, t);
- }
- Edge edge = new Edge(s, t);
- s.outEdges.put(t, edge);
- t.inEdges.put(s, edge);
- }
-
- public void addVertext(V source) {
- Vertex s = getVertex(source);
- if (s == null) {
- s = new Vertex(source);
- vertices.put(source, s);
- }
- }
-
- public Vertex getVertex(V source) {
- Vertex s = vertices.get(source);
- return s;
- }
-
- public boolean removeEdge(V source, V target) {
- Vertex s = getVertex(source);
- if (s == null) {
- return false;
- }
-
- Vertex t = getVertex(target);
- if (t == null) {
- return false;
- }
-
- return s.outEdges.remove(t) != null && t.inEdges.remove(s) != null;
-
- }
-
- public void removeEdge(Edge edge) {
- edge.sourceVertex.outEdges.remove(edge.targetVertex);
- edge.targetVertex.inEdges.remove(edge.sourceVertex);
- }
-
- public void removeVertex(Vertex vertex) {
- vertices.remove(vertex.getValue());
- for (Edge e : new ArrayList<Edge>(vertex.outEdges.values())) {
- removeEdge(e);
- }
- for (Edge e : new ArrayList<Edge>(vertex.inEdges.values())) {
- removeEdge(e);
- }
- }
-
- public Edge getEdge(Vertex source, Vertex target) {
- return source.outEdges.get(target);
- }
-
- public Edge getEdge(V source, V target) {
- Vertex sv = getVertex(source);
- if (sv == null) {
- return null;
- }
- Vertex tv = getVertex(target);
- if (tv == null) {
- return null;
- }
- return getEdge(getVertex(source), getVertex(target));
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- for (Vertex v : vertices.values()) {
- sb.append(v.outEdges.values()).append("\n");
- }
- return sb.toString();
- }
-
- public Map<V, Vertex> getVertices() {
- return vertices;
- }
-
- public void addGraph(PhaseSorter<V> otherGraph) {
- for (Vertex v : otherGraph.vertices.values()) {
- for (Edge e : v.outEdges.values()) {
- addEdge(e.sourceVertex.value, e.targetVertex.value);
- }
- }
- }
-
- private Vertex getFirst() {
- for (Vertex v : vertices.values()) {
- if (v.inEdges.isEmpty()) {
- return v;
- }
- }
- if (!vertices.isEmpty()) {
- throw new IllegalArgumentException("Circular ordering has been detected: " + toString());
- } else {
- return null;
- }
- }
-
- public List<V> topologicalSort(boolean readOnly) {
- PhaseSorter<V> graph = (!readOnly) ? this : (PhaseSorter<V>)clone();
- List<V> list = new ArrayList<V>();
- while (true) {
- Vertex v = graph.getFirst();
- if (v == null) {
- break;
- }
- list.add(v.getValue());
- graph.removeVertex(v);
- }
-
- return list;
- }
-
- @Override
- public Object clone() {
- PhaseSorter<V> copy = new PhaseSorter<V>();
- copy.addGraph(this);
- return copy;
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
deleted file mode 100644
index 3240b4e50d..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.runtime;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
-import org.apache.tuscany.sca.runtime.EndpointListener;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-
-/**
- * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the
- * given domain
- */
-public class DefaultDomainRegistryFactory implements DomainRegistryFactory, LifeCycleListener {
- private ExtensionPointRegistry extensionRegistry;
- private Map<String, ServiceDeclaration> declarations = new HashMap<String, ServiceDeclaration>();
- private Map<String, EndpointRegistry> endpointRegistries = new ConcurrentHashMap<String, EndpointRegistry>();
- private List<EndpointListener> listeners = new ArrayList<EndpointListener>();
-
- /**
- * @param extensionRegistry
- */
- public DefaultDomainRegistryFactory(ExtensionPointRegistry extensionRegistry) {
- super();
- this.extensionRegistry = extensionRegistry;
- }
-
- public void start() {
- Collection<ServiceDeclaration> sds = null;
- try {
- sds = extensionRegistry.getServiceDiscovery().getServiceDeclarations(EndpointRegistry.class);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- for (ServiceDeclaration sd : sds) {
- String scheme = sd.getAttributes().get("scheme");
- if (scheme != null) {
- scheme = scheme.toLowerCase();
- }
- declarations.put(scheme, sd);
- }
- }
-
- public synchronized EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) {
- if (endpointRegistryURI == null) {
- endpointRegistryURI = "vm://localhost";
- }
-
- String key = endpointRegistryURI + "," + domainURI;
-
- EndpointRegistry endpointRegistry = endpointRegistries.get(key);
- if (endpointRegistry != null) {
- return endpointRegistry;
- }
-
- URI uri = URI.create(endpointRegistryURI);
- String scheme = uri.getScheme();
- if (scheme != null) {
- scheme = scheme.toLowerCase();
- }
-
- ServiceDeclaration sd = declarations.get(scheme);
-
- try {
- Class<?> implClass = sd.loadClass();
- Constructor<?> constructor = null;
- try {
- constructor = implClass.getConstructor(ExtensionPointRegistry.class, String.class, String.class);
- endpointRegistry =
- (EndpointRegistry)constructor.newInstance(extensionRegistry, endpointRegistryURI, domainURI);
- } catch (NoSuchMethodException e) {
- constructor =
- implClass.getConstructor(ExtensionPointRegistry.class, Map.class, String.class, String.class);
- endpointRegistry =
- (EndpointRegistry)constructor.newInstance(extensionRegistry,
- sd.getAttributes(),
- endpointRegistryURI,
- domainURI);
- }
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
-
- if (endpointRegistry instanceof LifeCycleListener) {
- ((LifeCycleListener)endpointRegistry).start();
- }
-
- for (EndpointListener listener : listeners) {
- endpointRegistry.addListener(listener);
- }
- endpointRegistries.put(key, endpointRegistry);
- return endpointRegistry;
- }
-
- public void stop() {
- declarations.clear();
- for (EndpointRegistry endpointRegistry : endpointRegistries.values()) {
- if (endpointRegistry instanceof LifeCycleListener) {
- ((LifeCycleListener)endpointRegistry).stop();
- }
- }
- endpointRegistries.clear();
- listeners.clear();
- }
-
- public synchronized Collection<EndpointRegistry> getEndpointRegistries() {
- return new ArrayList<EndpointRegistry>(endpointRegistries.values());
- }
-
- public synchronized void addListener(EndpointListener listener) {
- listeners.add(listener);
- for(EndpointRegistry registry: endpointRegistries.values()) {
- registry.addListener(listener);
- }
- }
-
- public synchronized List<EndpointListener> getListeners() {
- return listeners;
- }
-
- public synchronized void removeListener(EndpointListener listener) {
- listeners.remove(listener);
- for(EndpointRegistry registry: endpointRegistries.values()) {
- registry.removeListener(listener);
- }
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
deleted file mode 100644
index da5abeb728..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.runtime.impl;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.MonitorFactory;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
-import org.apache.tuscany.sca.runtime.EndpointRegistry;
-
-/**
- * An builder that takes endpoint references and resolves them. It either finds local
- * service endpoints if they are available or asks the domain. The main function here
- * is to perform binding and policy matching.
- * This is a separate builder in case it is required by undresolved endpoints
- * once the runtime has started.
- *
- * @version $Rev$ $Date$
- */
-public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
-
- protected ExtensionPointRegistry extensionPoints;
- protected AssemblyFactory assemblyFactory;
- protected InterfaceContractMapper interfaceContractMapper;
- private Monitor monitor;
-
-
- public EndpointReferenceBinderImpl(ExtensionPointRegistry extensionPoints) {
- this.extensionPoints = extensionPoints;
-
- FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
-
- UtilityExtensionPoint utils = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- this.interfaceContractMapper = utils.getUtility(InterfaceContractMapper.class);
- MonitorFactory monitorFactory = utils.getUtility(MonitorFactory.class);
- monitor = monitorFactory.createMonitor();
- }
-
-
-
- /**
- * Build a single endpoint reference
- *
- * @param invocable
- * @param monitor
- */
- public boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
- Problem problem = null;
- if ( endpointReference.getStatus() == EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED ||
- endpointReference.getStatus() == EndpointReference.RESOLVED_BINDING ) {
- // The endpoint reference is already resolved to either
- // a service endpoint local to this composite or it has
- // a remote binding
-
- // still need to check that the callback endpoint is set correctly
- if (hasCallback(endpointReference) &&
- endpointReference.getCallbackEndpoint() != null &&
- endpointReference.getCallbackEndpoint().isUnresolved() == true ){
- problem = selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService().getEndpoints());
- }
- } else if (endpointReference.getStatus() == EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING ){
- // The endpoint reference is already resolved to either
- // a service endpoint but no binding was specified in the
- // target URL and/or the policies have yet to be matched.
-
- problem = selectForwardEndpoint(endpointReference,
- endpointReference.getTargetEndpoint().getService().getEndpoints());
-
- if (problem == null && hasCallback(endpointReference)){
- problem = selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService().getEndpoints());
- }
-
- } else if (endpointReference.getStatus() == EndpointReference.WIRED_TARGET_NOT_FOUND ||
- endpointReference.getStatus() == EndpointReference.NOT_CONFIGURED){
- // The service is in a remote composite somewhere else in the domain
-
- // find the service in the endpoint registry
- List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
-
- if (endpoints.size() == 0) {
- problem = monitor.createProblem(this.getClass().getName(),
- "endpoint-validation-messages",
- Problem.Severity.ERROR,
- this,
- "NoEndpointsFound",
- endpointReference.toString());
- }
-
- problem = selectForwardEndpoint(endpointReference,
- endpoints);
-
- if (problem == null && hasCallback(endpointReference)){
- problem = selectCallbackEndpoint(endpointReference,
- endpointReference.getReference().getCallbackService().getEndpoints());
- }
- }
-
- if (problem != null){
- monitor.problem(problem);
- return false;
- }
-
- if (endpointReference.getStatus() != EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED &&
- endpointReference.getStatus() != EndpointReference.RESOLVED_BINDING){
- problem = monitor.createProblem(this.getClass().getName(),
- "endpoint-validation-messages",
- Problem.Severity.ERROR,
- this,
- "EndpointReferenceCantBeMatched",
- endpointReference.toString());
- monitor.problem(problem);
- return false;
- }
-
- return true;
-
- }
-
- private Problem selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints) {
-
- Endpoint matchedEndpoint = null;
-
- if (endpointReference.getReference().getName().startsWith("$self$.")){
- // just select the first one and don't do any policy matching
- matchedEndpoint = endpoints.get(0);
- } else {
- // find the first endpoint that matches this endpoint reference
- for (Endpoint endpoint : endpoints){
- if (haveMatchingPolicy(endpointReference, endpoint)){
- matchedEndpoint = endpoint;
- break;
- }
- }
- }
-
- if (matchedEndpoint == null){
- return null;
- }
-
- endpointReference.setTargetEndpoint(matchedEndpoint);
- endpointReference.setBinding(endpointReference.getTargetEndpoint().getBinding());
- endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED);
- endpointReference.setUnresolved(false);
-
- return null;
- }
-
- private boolean hasCallback(EndpointReference endpointReference){
- if (endpointReference.getReference().getInterfaceContract() == null ||
- endpointReference.getReference().getInterfaceContract().getCallbackInterface() == null ||
- endpointReference.getReference().getName().startsWith("$self$.")){
- return false;
- } else {
- return true;
- }
- }
-
- private Problem selectCallbackEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints) {
-
- Problem problem = null;
-
- // find the first callback endpoint that matches a callback endpoint reference
- // at the service
- Endpoint matchedEndpoint = null;
- match:
- for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
- for (Endpoint endpoint : endpoints){
- if (haveMatchingPolicy(callbackEndpointReference, endpoint)){
- matchedEndpoint = endpoint;
- break match;
- }
- }
- }
-
- if (matchedEndpoint == null){
- return null;
- }
-
- endpointReference.setCallbackEndpoint(matchedEndpoint);
-
- return problem;
- }
-
- // FIXME: [rfeng] This implementation is wrong. It is the responsibility of the policy language
- // to compare the reference and service side setting to determine if they are compatible. Some of
- // policies apply to the reference side only, some of the policies apply to the service side only,
- // while others apply to both sides. Even for those policies that apply to both side, they can be
- // independent or related.
- private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint){
-
- /*
- // if no policy sets or intents are present then they match
- if ((endpointReference.getRequiredIntents().size() == 0) &&
- (endpoint.getRequiredIntents().size() == 0) &&
- (endpointReference.getPolicySets().size() == 0) &&
- (endpoint.getPolicySets().size() == 0)) {
- return true;
- }
-
- // if there are different numbers of intents
- // then they don't match
- if (endpointReference.getRequiredIntents().size() !=
- endpoint.getRequiredIntents().size()) {
- return false;
- }
-
- // if there are different numbers of policy sets
- // then they don't match
- if (endpointReference.getPolicySets().size() !=
- endpoint.getPolicySets().size()) {
- return false;
- }
-
- // check intents for compatibility
- for(Intent intentEPR : endpointReference.getRequiredIntents()){
- boolean matched = false;
- for (Intent intentEP : endpoint.getRequiredIntents()){
- if (intentEPR.getName().equals(intentEP.getName())){
- matched = true;
- break;
- }
- }
- if (matched == false){
- return false;
- }
- }
-
- // check policy sets for compatibility. The list of policy sets
- // may be a subset of the list of intents as some of the intents
- // may be directly provided. We can't just rely on intent compatibility
- // as different policy sets might have been attached at each end to
- // satisfy the listed intents
-
- // if all of the policy sets on the endpoint reference match a
- // policy set on the endpoint then they match
- for(PolicySet policySetEPR : endpointReference.getPolicySets()){
- boolean matched = false;
- for (PolicySet policySetEP : endpoint.getPolicySets()){
- // find if there is a policy set with the same name
- if (policySetEPR.getName().equals(policySetEP.getName())){
- matched = true;
- break;
- }
- // find if the policies inside the policy set match the
- // policies inside a policy set on the endpoint
-
- // TODO - need a policy specific matcher to do this
- // so need a new extension point
-
- }
-
- if (matched == false){
- return false;
- }
- }
- */
-
- return true;
- }
-
- public boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
- Endpoint te = endpointReference.getTargetEndpoint();
- if (!te.isUnresolved() && te.getURI()!= null) {
- List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
- return ! endpoints.contains(endpointReference.getTargetEndpoint());
- }
- return false;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java
deleted file mode 100644
index 4674456925..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * Implements functionality common to scope contexts.
- *
- * @version $Rev$ $Date$
- */
-public abstract class AbstractScopeContainer<KEY> implements ScopeContainer<KEY> {
- protected Map<KEY, InstanceWrapper<?>> wrappers = new ConcurrentHashMap<KEY, InstanceWrapper<?>>();
- protected final Scope scope;
-
- protected RuntimeComponent component;
- protected volatile int lifecycleState = UNINITIALIZED;
-
-
- public AbstractScopeContainer(Scope scope, RuntimeComponent component) {
- this.scope = scope;
- this.component = component;
- }
-
- protected void checkInit() {
- if (getLifecycleState() != RUNNING) {
- throw new IllegalStateException("Scope container not running [" + getLifecycleState() + "]");
- }
- }
-
- /**
- * Creates a new physical instance of a component, wrapped in an
- * InstanceWrapper.
- *
- * @param component the component whose instance should be created
- * @return a wrapped instance that has been injected but not yet started
- * @throws TargetResolutionException if there was a problem creating the
- * instance
- */
- protected InstanceWrapper createInstanceWrapper() throws TargetResolutionException {
- ImplementationProvider implementationProvider = component.getImplementationProvider();
- if (implementationProvider instanceof ScopedImplementationProvider) {
- return ((ScopedImplementationProvider)implementationProvider).createInstanceWrapper();
- }
- return null;
- }
-
- public InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException {
- return getWrapper(contextId); // TODO: what is this method supposed to do diff than getWrapper?
- }
-
- public Scope getScope() {
- return scope;
- }
-
- public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException {
- return wrappers.get(contextId);
- }
-
- public void addWrapperReference(KEY existingContextId, KEY newContextId)
- throws TargetResolutionException {
- // do nothing here. the conversational scope container implements this
- }
-
- public void registerWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetResolutionException {
- // do nothing here. the conversational scope container implements this
- }
-
- protected boolean isEagerInit() {
- ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider();
- if (implementationProvider instanceof ScopedImplementationProvider) {
- return ((ScopedImplementationProvider)implementationProvider).isEagerInit();
- }
- return false;
- }
-
- public void returnWrapper(InstanceWrapper wrapper, KEY contextId) throws TargetDestructionException {
- }
-
- /**
- * Default implementation of remove which does nothing
- *
- * @param contextId the identifier of the context to remove.
- */
- public void remove(KEY contextId)
- throws TargetDestructionException {
- }
-
- public synchronized void start() {
- int lifecycleState = getLifecycleState();
- if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
- throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
- }
- setLifecycleState(RUNNING);
- }
-
- public void startContext(KEY contextId) {
- if(isEagerInit()) {
- try {
- getWrapper(contextId);
- } catch (TargetResolutionException e) {
- //
- }
- }
- }
-
- public synchronized void stop() {
- int lifecycleState = getLifecycleState();
- if (lifecycleState != RUNNING) {
- throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
- }
- setLifecycleState(STOPPED);
- }
-
- public void stopContext(KEY contextId) {
- wrappers.remove(contextId);
- }
-
- @Override
- public String toString() {
- String s;
- switch (lifecycleState) {
- case ScopeContainer.CONFIG_ERROR:
- s = "CONFIG_ERROR";
- break;
- case ScopeContainer.ERROR:
- s = "ERROR";
- break;
- case ScopeContainer.INITIALIZING:
- s = "INITIALIZING";
- break;
- case ScopeContainer.INITIALIZED:
- s = "INITIALIZED";
- break;
- case ScopeContainer.RUNNING:
- s = "RUNNING";
- break;
- case ScopeContainer.STOPPING:
- s = "STOPPING";
- break;
- case ScopeContainer.STOPPED:
- s = "STOPPED";
- break;
- case ScopeContainer.UNINITIALIZED:
- s = "UNINITIALIZED";
- break;
- default:
- s = "UNKNOWN";
- break;
- }
- return "In state [" + s + ']';
- }
-
- public RuntimeComponent getComponent() {
- return component;
- }
-
- public void setComponent(RuntimeComponent component) {
- this.component = component;
- }
-
- public int getLifecycleState() {
- return lifecycleState;
- }
-
- /**
- * Set the current state of the Lifecycle.
- *
- * @param lifecycleState the new state
- */
- protected void setLifecycleState(int lifecycleState) {
- this.lifecycleState = lifecycleState;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
deleted file mode 100644
index 2ea724ccf6..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.scope;
-
-import org.apache.tuscany.sca.core.scope.impl.CompositeScopeContainerFactory;
-import org.apache.tuscany.sca.core.scope.impl.ScopeRegistryImpl;
-import org.apache.tuscany.sca.core.scope.impl.StatelessScopeContainerFactory;
-
-/**
- * A default scope registry implementation.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultScopeRegistry extends ScopeRegistryImpl implements ScopeRegistry {
-
- public DefaultScopeRegistry() {
- ScopeContainerFactory[] factories =
- new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory()};
- for (ScopeContainerFactory f : factories) {
- register(f);
- }
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
deleted file mode 100644
index 0a7f2ef64f..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-/**
- * The default implementation scopes supported by assemblies.
- *
- * @version $Rev$ $Date$
- */
-public class Scope {
- public static final Scope STATELESS = new Scope("STATELESS");
- public static final Scope COMPOSITE = new Scope("COMPOSITE");
- public static final Scope INVALID = new Scope("INVALID");
-
- private String scope;
-
- public Scope(String scope) {
- this.scope = scope.toUpperCase().intern();
- }
-
- public String getScope() {
- return scope;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- final Scope scope1 = (Scope) o;
- return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null);
- }
-
- @Override
- public int hashCode() {
- return scope != null ? scope.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return scope;
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java
deleted file mode 100644
index 2398ecea3e..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-
-/**
- * Manages the lifecycle and visibility of instances associated with a an {@link RuntimeComponent}.
- *
- * @version $Rev$ $Date$
- * @param <KEY> the type of IDs that this container uses to identify its contexts.
- * For example, for COMPOSITE scope this could be the URI of the composite component,
- * or for HTTP Session scope it might be the HTTP session ID.
- */
-public interface ScopeContainer<KEY> {
-
- /**
- * Returns the Scope that this container supports.
- *
- * @return the Scope that this container supports
- */
- Scope getScope();
-
- /**
- * Start a new context with the supplied ID.
- *
- * @param contextId an ID that uniquely identifies the context.
- */
- void startContext(KEY contextId);
-
- /**
- * Stop the context with the supplied ID.
- *
- * @param contextId an ID that uniquely identifies the context.
- */
- void stopContext(KEY contextId);
-
- /**
- * Returns an instance wrapper associated with the current scope context, creating one if necessary
- * @param contextId the id for the scope context
- *
- * @return the wrapper for the target instance
- * @throws TargetResolutionException if there was a problem instantiating the target instance
- */
- InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException;
-
- /**
- * Allows a component to be registered against more than one context id. This is required in the
- * case of stateful callbacks where we want to identify the originating client component instance
- * as the callback target but we don't want to reuse the clients original conversation id
- *
- * @param existingContextId an id that identifies an existing component instance
- * @param newContextId a new id against which this component will also be registered
- * @throws TargetResolutionException
- */
- void addWrapperReference(KEY existingContextId, KEY newContextId)
- throws TargetResolutionException;
-
- /**
- * Register an existing instance against a context id. This is needed
- * for a stateful callback where the service reference for the forward call
- * contains a callback object that is not a service reference.
- *
- * @param wrapper the instance wrapper for the instance to be registered
- * @param contextId the id for the scope context
- * @throws TargetResolutionException
- */
- void registerWrapper(InstanceWrapper wrapper, KEY contextId)
- throws TargetResolutionException;
-
- /**
- * Returns an implementation instance associated with the current scope context.
- * If no instance is found, a {@link TargetNotFoundException} is thrown.
- * @param contextId the id for the scope context
- *
- * @return the wrapper for the target instance
- * @throws TargetResolutionException if there was a problem instantiating the target instance
- */
- InstanceWrapper getAssociatedWrapper(KEY contextId)
- throws TargetResolutionException;
-
- /**
- * Return a wrapper after use (for example, after invoking the instance).
- * @param wrapper the wrapper for the target instance being returned
- * @param contextId the id for the scope context
- *
- * @throws TargetDestructionException if there was a problem returning the target instance
- */
- void returnWrapper(InstanceWrapper wrapper, KEY contextId)
- throws TargetDestructionException;
-
- /**
- * Removes an identified component implementation instance associated with the current
- * context from persistent storage
- *
- * @param contextId the identifier of the context to remove.
- */
- void remove(KEY contextId)
- throws TargetDestructionException;
-
- /* A configuration error state */
- int CONFIG_ERROR = -1;
- /* Has not been initialized */
- int UNINITIALIZED = 0;
- /* In the process of being configured and initialized */
- int INITIALIZING = 1;
- /* Instantiated and configured */
- int INITIALIZED = 2;
- /* Configured and initialized */
- int RUNNING = 4;
- /* In the process of being shutdown */
- int STOPPING = 5;
- /* Has been shutdown and removed from the composite */
- int STOPPED = 6;
- /* In an error state */
- int ERROR = 7;
-
- /**
- * Returns the lifecycle state
- *
- * @see #UNINITIALIZED
- * @see #INITIALIZING
- * @see #INITIALIZED
- * @see #RUNNING
- * @see #STOPPING
- * @see #STOPPED
- */
- int getLifecycleState();
-
- /**
- * Starts the Lifecycle.
- */
- void start();
-
- /**
- * Stops the Lifecycle.
- */
- void stop();
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java
deleted file mode 100644
index b19c14b3e0..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.scope;
-
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * Factory to create ScopeContainer for components
- *
- * @version $Rev$ $Date$
- */
-public interface ScopeContainerFactory {
- ScopeContainer createScopeContainer(RuntimeComponent component);
- Scope getScope();
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java
deleted file mode 100644
index 842ed4c547..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-
-/**
- * Manages {@link ScopeContainer}s in the runtime
- *
- * @version $Rev$ $Date$
- */
-public interface ScopeRegistry {
-
- /**
- * Returns the scope container for the given scope or null if one not found
- *
- * @param scope the scope
- * @return the scope container for the given scope or null if one not found
- */
- ScopeContainer getScopeContainer(RuntimeComponent component);
-
- /**
- * @param factory
- */
- void register(ScopeContainerFactory factory);
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java
deleted file mode 100644
index 30d5c77181..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.scope;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-
-/**
- * A component implementation can implement this interface to provide scope
- * management for the components
- *
- * @version $Rev$ $Date$
- */
-public interface ScopedImplementationProvider extends ImplementationProvider {
- /**
- * Get the scope for the component implementation
- *
- * @return The scope for the component implementation, if null is returned,
- * STATELESS will be used
- */
- Scope getScope();
-
- /**
- * Indicate if the component needs to be eagerly initialized
- *
- * @return true if the component is marked to be eagerly initialized, false
- * otherwise
- */
- boolean isEagerInit();
-
- /**
- * @return the maxAge
- */
- long getMaxAge();
-
- /**
- * @return the maxIdleTime
- */
- long getMaxIdleTime();
-
- /**
- * Create a wrapper for the component instance for the scope management
- *
- * @return A wrapper for the component instance
- */
- InstanceWrapper createInstanceWrapper();
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java
deleted file mode 100644
index c27b112f8a..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.scope;
-
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * Scoped runtime component
- *
- * @version $Rev$ $Date$
- */
-public interface ScopedRuntimeComponent extends RuntimeComponent {
- /**
- * Set the associated scope container
- * @param scopeContainer
- */
- void setScopeContainer(ScopeContainer scopeContainer);
- /**
- * Get the assoicated scope container
- * @return
- */
- ScopeContainer getScopeContainer();
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java
deleted file mode 100644
index 0f83dad97d..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-/**
- * Denotes an error destroying a target
- *
- * @version $Rev$ $Date$
- */
-public class TargetDestructionException extends TargetResolutionException {
- private static final long serialVersionUID = -6126684147851674709L;
-
- public TargetDestructionException() {
- super();
- }
-
- public TargetDestructionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public TargetDestructionException(String message) {
- super(message);
- }
-
- public TargetDestructionException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java
deleted file mode 100644
index 15959c0608..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-/**
- * Denotes an error initializing a target
- *
- * @version $Rev$ $Date$
- */
-public class TargetInitializationException extends TargetResolutionException {
- private static final long serialVersionUID = -6228778208649752698L;
-
- public TargetInitializationException() {
- super();
- }
-
- public TargetInitializationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public TargetInitializationException(String message) {
- super(message);
- }
-
- public TargetInitializationException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java
deleted file mode 100644
index bb46a2499b..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-/**
- * Thrown when a target of an operation cannot be found
- *
- * @version $Rev$ $Date$
- */
-public class TargetNotFoundException extends TargetResolutionException {
- private static final long serialVersionUID = 5541830480658471186L;
-
- public TargetNotFoundException() {
- super();
- }
-
- public TargetNotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public TargetNotFoundException(String message) {
- super(message);
- }
-
- public TargetNotFoundException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java
deleted file mode 100644
index ea8d0e876c..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope;
-
-/**
- * Denotes an error retrieving a target instance
- *
- * @version $Rev$ $Date$
- */
-public class TargetResolutionException extends Exception {
- private static final long serialVersionUID = 2912513650522019405L;
-
- public TargetResolutionException() {
- super();
- }
-
- public TargetResolutionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public TargetResolutionException(String message) {
- super(message);
- }
-
- public TargetResolutionException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java
deleted file mode 100644
index 730f92e0f9..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope.impl;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
-import org.apache.tuscany.sca.core.scope.TargetNotFoundException;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.oasisopen.sca.ServiceUnavailableException;
-
-/**
- * A scope context which manages atomic component instances keyed by composite
- *
- * @version $Rev$ $Date$
- */
-public class CompositeScopeContainer<KEY> extends AbstractScopeContainer<KEY> {
- private InstanceWrapper<?> wrapper;
-
- public CompositeScopeContainer(RuntimeComponent component) {
- super(Scope.COMPOSITE, component);
- }
-
- @Override
- public synchronized void stop() {
- super.stop();
- if (wrapper != null) {
- try {
- wrapper.stop();
- } catch (TargetDestructionException e) {
- throw new IllegalStateException(e);
- }
- }
- wrapper = null;
- }
-
- @Override
- public synchronized InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException {
- if (wrapper == null) {
- try {
- wrapper = createInstanceWrapper();
- wrapper.start();
- } catch (Exception e) {
- throw new ServiceUnavailableException(e);
- }
- }
- return wrapper;
- }
-
- @Override
- public InstanceWrapper getAssociatedWrapper(KEY contextId) throws TargetResolutionException {
- if (wrapper == null) {
- throw new TargetNotFoundException(component.getURI());
- }
- return wrapper;
- }
-
- @Override
- public synchronized void start() {
- super.start();
- if (isEagerInit()) {
- try {
- getWrapper(null);
- } catch (TargetResolutionException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java
deleted file mode 100644
index f61e70a598..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.scope.impl;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class CompositeScopeContainerFactory implements ScopeContainerFactory {
-
- public ScopeContainer createScopeContainer(RuntimeComponent component) {
- return new CompositeScopeContainer(component);
- }
-
- public Scope getScope() {
- return Scope.COMPOSITE;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
deleted file mode 100644
index 9884c5f053..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
-import org.apache.tuscany.sca.core.scope.ScopeRegistry;
-import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
-import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * The default implementation of a scope registry
- *
- * @version $Rev$ $Date$
- */
-public class ScopeRegistryImpl implements ScopeRegistry {
- private final Map<Scope, ScopeContainerFactory> scopeCache = new ConcurrentHashMap<Scope, ScopeContainerFactory>();
-
- public void register(ScopeContainerFactory factory) {
- scopeCache.put(factory.getScope(), factory);
- }
-
- public ScopeContainer getScopeContainer(RuntimeComponent runtimeComponent) {
- if (!(runtimeComponent instanceof ScopedRuntimeComponent)) {
- return null;
- }
- ScopedRuntimeComponent component = (ScopedRuntimeComponent)runtimeComponent;
- if (component.getScopeContainer() != null) {
- return component.getScopeContainer();
- }
- ImplementationProvider implementationProvider = component.getImplementationProvider();
- if (implementationProvider instanceof ScopedImplementationProvider) {
- ScopedImplementationProvider provider = (ScopedImplementationProvider)implementationProvider;
- Scope scope = provider.getScope();
- if (scope == null) {
- scope = Scope.STATELESS;
- } else if (scope.equals(Scope.INVALID)) {
- return null;
- }
- ScopeContainerFactory factory = scopeCache.get(scope);
- ScopeContainer container = factory.createScopeContainer(component);
- component.setScopeContainer(container);
- return container;
- }
- return null;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java
deleted file mode 100644
index 1235fd2a67..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.scope.impl;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * A scope context which manages stateless atomic component instances in a non-pooled fashion.
- *
- * @version $Rev$ $Date$
- */
-public class StatelessScopeContainer<KEY> extends AbstractScopeContainer<KEY> {
-
- public StatelessScopeContainer(RuntimeComponent component) {
- super(Scope.STATELESS, component);
- }
-
- @Override
- public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException {
- if (lifecycleState != RUNNING) {
- throw new TargetResolutionException("scope container not running, lifecycleState=" + lifecycleState);
- }
- InstanceWrapper ctx = createInstanceWrapper();
- ctx.start();
- return ctx;
- }
-
- @Override
- public InstanceWrapper getAssociatedWrapper(KEY contextId)
- throws TargetResolutionException {
- return getWrapper(contextId);
- }
-
- @Override
- public void returnWrapper(InstanceWrapper wrapper, KEY contextId)
- throws TargetDestructionException {
- wrapper.stop();
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java
deleted file mode 100644
index 5bf20a6a5f..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.scope.impl;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class StatelessScopeContainerFactory implements ScopeContainerFactory {
-
- public ScopeContainer createScopeContainer(RuntimeComponent component) {
- return new StatelessScopeContainer(component);
- }
-
- public Scope getScope() {
- return Scope.STATELESS;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
deleted file mode 100644
index 9e6f3b3087..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.work.NotificationListener;
-import org.apache.tuscany.sca.work.WorkScheduler;
-import org.apache.tuscany.sca.work.WorkSchedulerException;
-
-/**
- * A work scheduler implementation based on a JSR 237 work manager.
- * <p/>
- * <p/>
- * This needs a JSR 237 work manager implementation available for scheduling work. Instances can be configured with a
- * work manager implementation that is injected in. It is the responsibility of the runtime environment to make a work
- * manager implementation available. For example, if the managed environment supports work manager the runtime can use
- * the appropriate lookup mechanism to inject the work manager implementation. </p>
- *
- * @version $Rev$ $Date$
- */
-public class DefaultWorkScheduler implements WorkScheduler, LifeCycleListener {
-
- /**
- * Underlying JSR-237 work manager
- */
- private ThreadPoolWorkManager jsr237WorkManager;
-
- /**
- * Initializes the JSR 237 work manager.
- *
- * @param jsr237WorkManager JSR 237 work manager.
- */
- public DefaultWorkScheduler() {
- }
-
- private synchronized ThreadPoolWorkManager getWorkManager() {
- if (jsr237WorkManager != null) {
- return jsr237WorkManager;
- }
-// try {
-// InitialContext ctx = new InitialContext();
-// jsr237WorkManager = (ThreadPoolWorkManager)ctx.lookup("java:comp/env/wm/TuscanyWorkManager");
-// } catch (Throwable e) {
-// // ignore
-// }
- if (jsr237WorkManager == null) {
- jsr237WorkManager = new ThreadPoolWorkManager(0);
- }
- return jsr237WorkManager;
- }
-
- /**
- * Schedules a unit of work for future execution. The notification listener is used to register interest in
- * callbacks regarding the status of the work.
- *
- * @param work The unit of work that needs to be asynchronously executed.
- */
- public <T extends Runnable> void scheduleWork(T work) {
- scheduleWork(work, null);
- }
-
- /**
- * Schedules a unit of work for future execution. The notification listener is used to register interest in
- * callbacks regarding the status of the work.
- *
- * @param work The unit of work that needs to be asynchronously executed.
- * @param listener Notification listener for callbacks.
- */
- public <T extends Runnable> void scheduleWork(T work, NotificationListener<T> listener) {
-
- if (work == null) {
- throw new IllegalArgumentException("Work cannot be null");
- }
-
- Work<T> jsr237Work = new Work<T>(work);
- try {
- if (listener == null) {
- getWorkManager().schedule(jsr237Work);
- } else {
- Jsr237WorkListener<T> jsr237WorkListener = new Jsr237WorkListener<T>(listener, work);
- getWorkManager().schedule(jsr237Work, jsr237WorkListener);
- }
- } catch (IllegalArgumentException ex) {
- if (listener != null) {
- listener.workRejected(work);
- } else {
- throw new WorkSchedulerException(ex);
- }
- } catch (Exception ex) {
- throw new WorkSchedulerException(ex);
- }
-
- }
-
- public void start() {
- }
-
- public void stop() {
- if (jsr237WorkManager instanceof ThreadPoolWorkManager) {
- // Allow privileged access to modify threads. Requires RuntimePermission in security
- // policy.
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- ((ThreadPoolWorkManager)jsr237WorkManager).destroy();
- return null;
- }
- });
- }
- }
-
- /*
- * WorkListener for keeping track of work status callbacks.
- *
- */
- private class Jsr237WorkListener<T extends Runnable> implements WorkListener {
-
- // Notification listener
- private NotificationListener<T> listener;
-
- // Work
- private T work;
-
- /*
- * Initializes the notification listener.
- */
- public Jsr237WorkListener(NotificationListener<T> listener, T work) {
- this.listener = listener;
- this.work = work;
- }
-
- /*
- * Callback when the work is accepted.
- */
- public void workAccepted(WorkEvent workEvent) {
- T work = getWork();
- listener.workAccepted(work);
- }
-
- /*
- * Callback when the work is rejected.
- */
- public void workRejected(WorkEvent workEvent) {
- T work = getWork();
- listener.workRejected(work);
- }
-
- /*
- * Callback when the work is started.
- */
- public void workStarted(WorkEvent workEvent) {
- T work = getWork();
- listener.workStarted(work);
- }
-
- /*
- * Callback when the work is completed.
- */
- public void workCompleted(WorkEvent workEvent) {
- T work = getWork();
- Exception exception = workEvent.getException();
- if (exception != null) {
- listener.workFailed(work, exception);
- } else {
- listener.workCompleted(work);
- }
- }
-
- /*
- * Gets the underlying work from the work event.
- */
- private T getWork() {
- return work;
- }
-
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
deleted file mode 100644
index e7728ca9a9..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ThreadFactory;
-
-import org.apache.tuscany.sca.work.WorkSchedulerException;
-
-/**
- * A thread-pool based implementation for the JSR-237 work manager.
- * <p/>
- * <p/>
- * This implementation supports only local work.
- * <p/>
- * TODO Elaborate the implementation. </p>
- *
- * @version $Rev$ $Date$
- */
-public class ThreadPoolWorkManager {
-
- // Map of work items currently handled by the work manager
- private Map<WorkItem, WorkListener> workItems = new ConcurrentHashMap<WorkItem, WorkListener>();
-
- // Thread-pool
- private ExecutorService executor;
-
- /**
- * Initializes the thread-pool.
- *
- * @param threadPoolSize Thread-pool size. If the size <1, then a cached pool is created
- */
- public ThreadPoolWorkManager(int threadPoolSize) {
- ThreadFactory factory = new ThreadFactory() {
- public Thread newThread(Runnable r) {
- Thread thread = new Thread(r);
- thread.setDaemon(true);
- return thread;
- }
- };
- if (threadPoolSize <= 0) {
-
- // Creates a new Executor, use a custom ThreadFactory that
- // creates daemon threads.
- executor = Executors.newCachedThreadPool(factory);
- } else {
- executor = Executors.newFixedThreadPool(threadPoolSize);
- }
- }
-
- /**
- * Schedules a unit of work asynchronously.
- *
- * @param work Work that needs to be scheduled.
- * @return Work Work item representing the asynchronous work
- */
- public WorkItem schedule(Work work) throws IllegalArgumentException {
- return schedule(work, null);
- }
-
- /**
- * Schedules a unit of work asynchronously.
- *
- * @param work Work that needs to be scheduled.
- * @param workListener Work listener for callbacks.
- * @return Work Work item representing the asynchronous work
- */
- public WorkItem schedule(Work work, WorkListener workListener) throws IllegalArgumentException {
-
- WorkItem workItem = new WorkItem(UUID.randomUUID().toString(), work);
- if (workListener != null) {
- workItems.put(workItem, workListener);
- }
- workAccepted(workItem, work);
- if (scheduleWork(work, workItem)) {
- return workItem;
- } else {
- workItem.setStatus(WorkEvent.WORK_REJECTED);
- if (workListener != null) {
- workListener.workRejected(new WorkEvent(workItem));
- }
- throw new IllegalArgumentException("Unable to schedule work");
- }
- }
-
- /**
- * Wait for all the specified units of work to finish.
- *
- * @param works Units of the work that need to finish.
- * @param timeout Timeout for waiting for the units of work to finish.
- */
- public boolean waitForAll(Collection works, long timeout) {
- throw new UnsupportedOperationException("waitForAll not supported");
- }
-
- /**
- * Wait for any of the specified units of work to finish.
- *
- * @param works Units of the work that need to finish.
- * @param timeout Timeout for waiting for the units of work to finish.
- */
- public Collection waitForAny(Collection works, long timeout) {
- throw new UnsupportedOperationException("waitForAny not supported");
- }
-
- /**
- * Method provided for subclasses to indicate a work acceptance.
- *
- * @param workItem Work item representing the work that was accepted.
- * @param work Work that was accepted.
- */
- private void workAccepted(final WorkItem workItem, final Work work) {
- WorkListener listener = workItems.get(workItem);
- if (listener != null) {
- workItem.setStatus(WorkEvent.WORK_ACCEPTED);
- WorkEvent event = new WorkEvent(workItem);
- listener.workAccepted(event);
- }
- }
-
- /*
- * Method to indicate a work start.
- */
- private void workStarted(final WorkItem workItem, final Work work) {
- WorkListener listener = workItems.get(workItem);
- if (listener != null) {
- workItem.setStatus(WorkEvent.WORK_STARTED);
- WorkEvent event = new WorkEvent(workItem);
- listener.workStarted(event);
- }
- }
-
- /*
- * Method to indicate a work completion.
- */
- private void workCompleted(final WorkItem workItem, final Work work) {
- workCompleted(workItem, work, null);
- }
-
- /*
- * Method to indicate a work completion.
- */
- private void workCompleted(final WorkItem workItem, final Work work, final WorkSchedulerException exception) {
- WorkListener listener = workItems.get(workItem);
- if (listener != null) {
- workItem.setStatus(WorkEvent.WORK_COMPLETED);
- workItem.setResult(work);
- workItem.setException(exception);
- WorkEvent event = new WorkEvent(workItem);
- listener.workCompleted(event);
- workItems.remove(workItem);
- }
- }
-
- /*
- * Schedules the work using the ThreadPool.
- */
- private boolean scheduleWork(final Work work, final WorkItem workItem) {
- try {
- executor.execute(new DecoratingWork(workItem, work));
- return true;
- } catch (RejectedExecutionException ex) {
- return false;
- }
- }
-
- /*
- * Class that decorates the original worker so that it can get callbacks when work is done.
- */
- private final class DecoratingWork implements Runnable {
-
- // Work item for this work.
- private WorkItem workItem;
-
- // The original work.
- private Work decoratedWork;
-
- /*
- * Initializes the work item and underlying work.
- */
- private DecoratingWork(final WorkItem workItem, final Work decoratedWork) {
- this.workItem = workItem;
- this.decoratedWork = decoratedWork;
- }
-
- /*
- * Overrides the run method.
- */
- public void run() {
- workStarted(workItem, decoratedWork);
- try {
- decoratedWork.run();
- workCompleted(workItem, decoratedWork);
- } catch (Throwable th) {
- workCompleted(workItem, decoratedWork, new WorkSchedulerException(th.getMessage(), th));
- }
- }
-
- }
-
- public void destroy() {
- executor.shutdown();
- }
-
-}
-
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java
deleted file mode 100644
index ca06d0e854..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.work.impl;
-
-/**
- * JCA work wrapper.
- *
- * @version $Rev$ $Date$
- */
-public class Work<T extends Runnable> {
-
- // Work that is being executed.
- private T work;
-
- /*
- * Initializes the work instance.
- */
- public Work(T work) {
- this.work = work;
- }
-
- /*
- * Returns the completed work.
- */
- public T getWork() {
- return work;
- }
-
- /*
- * Release the work.
- */
- public void release() {
- }
-
- /*
- * Work attributes are not daemon.
- */
- public boolean isDaemon() {
- return false;
- }
-
- /*
- * Runs the work.
- */
- public void run() {
- work.run();
- }
-} \ No newline at end of file
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java
deleted file mode 100644
index 4580011806..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import org.apache.tuscany.sca.work.WorkSchedulerException;
-
-
-
-/**
- * Default immutable implementation of the <code>WorkEvent</code> class.
- *
- * @version $Rev$ $Date$
- */
-class WorkEvent {
-
- public static final int WORK_ACCEPTED = 1;
- public static final int WORK_REJECTED = 2;
- public static final int WORK_STARTED = 3;
- public static final int WORK_COMPLETED = 4;
-
- // Work item for this event
- private WorkItem workItem;
-
- // Exception if something has gone wrong
- private WorkSchedulerException exception;
-
- /**
- * Instantiates the event.
- *
- * @param workItem Work item for this event.
- */
- public WorkEvent(final WorkItem workItem) {
- this.workItem = workItem;
- this.exception = workItem.getException();
- }
-
- /**
- * Returns the work type based on whether the work was accepted, started,
- * rejected or completed.
- *
- * @return Work type.
- */
- public int getType() {
- return workItem.getStatus();
- }
-
- /**
- * Returns the work item associated with this work type.
- *
- * @return Work item.
- */
- public WorkItem getWorkItem() {
- return workItem;
- }
-
- /**
- * Returns the exception if the work completed with an exception.
- *
- * @return Work exception.
- */
- public WorkSchedulerException getException() {
- return exception;
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java
deleted file mode 100644
index 0fc104d0fc..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import org.apache.tuscany.sca.work.WorkSchedulerException;
-
-/**
- * An identity based immutable implementation of the <code>WorkItem</code>
- * interface.
- *
- * @version $Rev$ $Date$
- */
-class WorkItem {
-
- // Id scoped for the VM
- private String id;
-
- // Status
- private int status = -1;
-
- // Result
- private Work<?> result;
-
- // Original work
- private Work<?> originalWork;
-
- // Exception
- private WorkSchedulerException exception;
-
- /**
- * Instantiates an id for this item.
- *
- * @param id of this work event.
- */
- protected WorkItem(final String id, final Work<?> orginalWork) {
- this.id = id;
- this.originalWork = orginalWork;
- }
-
- /**
- * Returns the id.
- *
- * @return Id of this item.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Returns the original work.
- *
- * @return Original work.
- */
- public Work<?> getOriginalWork() {
- return originalWork;
- }
-
- /**
- * Returns the work result if the work completed.
- *
- * @return Work.
- * @throws WorkException If the work completed with an exception.
- */
- public Work<?> getResult() {
- return result;
- }
-
- /**
- * Sets the result.
- *
- * @param result Result.
- */
- protected void setResult(final Work<?> result) {
- this.result = result;
- }
-
- /**
- * Returns the exception if work completed with an exception.
- *
- * @return Work exception.
- */
- protected WorkSchedulerException getException() {
- return exception;
- }
-
- /**
- * Sets the exception.
- *
- * @param exception Exception.
- */
- protected void setException(final WorkSchedulerException exception) {
- this.exception = exception;
- }
-
- /**
- * Returns the work type based on whether the work was accepted, started,
- * rejected or completed.
- *
- * @return Work status.
- */
- public int getStatus() {
- return status;
- }
-
- /**
- * Sets the status.
- *
- * @param status Status.
- */
- protected void setStatus(final int status) {
- this.status = status;
- }
-
- /**
- * @see Object#hashCode()
- */
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * @param obj Object to be compared.
- * @return true if this object is the same as the obj argument; false
- * otherwise..
- */
- @Override
- public boolean equals(final Object obj) {
- return (obj != null) && (obj.getClass() == WorkItem.class) && ((WorkItem) obj).id.equals(id);
- }
-
- /**
- * Compares this object with the specified object for order. Returns a
- * negative integer, zero, or a positive integer as this object is less
- * than, equal to, or greater than the specified object.
- *
- * @param o Object to be compared.
- * @return A negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object.
- * @throws ClassCastException needs better documentation.
- */
- public int compareTo(final Object o) {
- if (o.getClass() != WorkItem.class) {
- throw new ClassCastException(o.getClass().getName());
- } else {
- return ((WorkItem) o).getId().compareTo(getId());
- }
- }
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java
deleted file mode 100644
index 38bbaeebe0..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.work.impl;
-
-public interface WorkListener {
-
- long IMMEDIATE = 0;
- long INDEFINITE = java.lang.Long.MAX_VALUE;
-
- void workAccepted(WorkEvent event);
- void workCompleted(WorkEvent event);
- void workRejected(WorkEvent event);
- void workStarted(WorkEvent event);
-
-}
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
deleted file mode 100644
index e8ee318b6c..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-# Set the ranking to be greater than the DefaultAssemblyFactory
-org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;ranking=100
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory
deleted file mode 100644
index 51ed2449fb..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-org.apache.tuscany.sca.core.context.DefaultComponentContextFactory
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory
deleted file mode 100644
index 70b17a2f00..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-org.apache.tuscany.sca.core.context.DefaultRequestContextFactory
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
deleted file mode 100644
index 94c83ceeab..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.core.assembly.impl.ReferenceParameterProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#referenceParameters,model=org.apache.tuscany.sca.runtime.ReferenceParameters
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint
deleted file mode 100644
index c6567aa904..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.core.invocation.DefaultProxyFactoryExtensionPoint
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry
deleted file mode 100644
index 2aa000efc0..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.core.scope.DefaultScopeRegistry
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory
deleted file mode 100644
index a21b75b570..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.core.invocation.impl.MessageFactoryImpl
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator
deleted file mode 100644
index 0182f52086..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
deleted file mode 100644
index c5c7e543ac..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-org.apache.tuscany.sca.core.runtime.DefaultDomainRegistryFactory
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
deleted file mode 100644
index 61edf5111e..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-org.apache.tuscany.sca.core.runtime.impl.EndpointReferenceBinderImpl
-
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
deleted file mode 100644
index 9ca8971396..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.core.assembly.impl.EndpointRegistryImpl;ranking=100,scheme=vm
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer
deleted file mode 100644
index fb951e75d5..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-org.apache.tuscany.sca.core.assembly.impl.EndpointSerializerImpl
diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
deleted file mode 100644
index 576e52d8ea..0000000000
--- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.core.work.impl.DefaultWorkScheduler
-
diff --git a/java/sca/modules/core/src/main/resources/endpoint-validation-messages.properties b/java/sca/modules/core/src/main/resources/endpoint-validation-messages.properties
deleted file mode 100644
index 7be0f2b4a2..0000000000
--- a/java/sca/modules/core/src/main/resources/endpoint-validation-messages.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#
-NoEndpointsFound = No endpoints found in the domain that match the reference {0}
-EndpointReferenceCantBeMatched = = Unable to match the endpoint reference {0} with the policy of the service to which it refers.
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
deleted file mode 100644
index 1302bed681..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.junit.Test;
-
-/**
- * @version $Rev$ $Date$
- */
-public class InvocationChainImplTestCase {
-
- @Test
- public void testInsertAtEnd() throws Exception {
- Operation op = newOperation("foo");
- InvocationChain chain = new InvocationChainImpl(op, op, true, new PhaseManager(new DefaultExtensionPointRegistry()));
- Interceptor inter2 = new MockInterceptor();
- Interceptor inter1 = new MockInterceptor();
- chain.addInterceptor(inter1);
- chain.addInterceptor(inter2);
- Interceptor head = (Interceptor)chain.getHeadInvoker();
- assertEquals(inter1, head);
- assertEquals(inter2, head.getNext());
- }
-
- @Test
- public void testAddByPhase() throws Exception {
- Operation op = newOperation("foo");
- InvocationChain chain = new InvocationChainImpl(op, op, false, new PhaseManager(new DefaultExtensionPointRegistry()));
- Interceptor inter1 = new MockInterceptor();
- Interceptor inter2 = new MockInterceptor();
- Interceptor inter3 = new MockInterceptor();
- Interceptor inter4 = new MockInterceptor();
- chain.addInterceptor(inter3); // SERVICE
- chain.addInterceptor(Phase.IMPLEMENTATION_POLICY, inter4);
- chain.addInterceptor(Phase.SERVICE_POLICY, inter2);
- chain.addInterceptor(Phase.SERVICE_BINDING, inter1);
- Interceptor head = (Interceptor)chain.getHeadInvoker();
- assertEquals(inter1, head);
- assertEquals(inter2, inter1.getNext());
- assertEquals(inter3, inter2.getNext());
- assertEquals(inter4, inter3.getNext());
- }
-
- private class MockInterceptor implements Interceptor {
-
- private Invoker next;
-
- public Message invoke(Message msg) {
- return null;
- }
-
- public void setNext(Invoker next) {
- this.next = next;
- }
-
- public Invoker getNext() {
- return next;
- }
-
- }
-
- private static Operation newOperation(String name) {
- Operation operation = new OperationImpl();
- operation.setName(name);
- return operation;
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java
deleted file mode 100644
index 8fcead004d..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * @version $Rev$ $Date$
- */
-public class PhaseManagerTestCase {
-
- @Test
- public void testDiscovery() {
- PhaseManager pm = new PhaseManager("org.apache.tuscany.sca.invocation.PhaseTest");
- List<String> phases = pm.getAllPhases();
- System.out.println(phases.size());
- System.out.println(phases);
- // Assert.assertEquals(15, phases.size());
- Assert.assertEquals("reference.first", phases.get(0));
-
- int rt = phases.indexOf("reference.transaction");
- Assert.assertTrue(rt > phases.indexOf("reference.interface"));
-
- int st = phases.indexOf("service.transaction");
- Assert.assertTrue(st > phases.indexOf("service.binding"));
-
- int it = phases.indexOf("implementation.transaction");
- Assert.assertTrue(it < phases.indexOf("implementation.policy"));
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java
deleted file mode 100644
index c268e133e4..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.invocation.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class PhaseSorterTestCase {
- private PhaseSorter<String> graph;
-
- @Before
- public void setUp() throws Exception {
- graph = new PhaseSorter<String>();
- }
-
- @Test
- public void testSort() {
- graph.addEdge("a", "b");
- graph.addEdge("a", "c");
- graph.addEdge("c", "d");
- graph.addEdge("b", "c");
- List<String> order = graph.topologicalSort(true);
- assertEquals(Arrays.asList("a", "b", "c", "d"), order);
- assertTrue(!graph.getVertices().isEmpty());
-
- graph.addEdge("d", "a");
- try {
- order = graph.topologicalSort(true);
- assertTrue("Should have failed", false);
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- graph.removeEdge("d", "a");
- order = graph.topologicalSort(false);
- assertEquals(Arrays.asList("a", "b", "c", "d"), order);
- assertTrue(graph.getVertices().isEmpty());
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java
deleted file mode 100644
index 16ca5fd00e..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-
-
-/**
- * Simple Work item that will throw an exception
- *
- * @version $Rev$ $Date$
- */
-public class FailingWork extends Work {
-
- public FailingWork() {
- super(null);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDaemon() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void release() {
- }
-
- /**
- * Throws an IllegalArgumentException
- */
- public void run() {
- System.out.println("Starting " + this + " and throwing an Exception");
- throw new IllegalArgumentException("Sample exception from " + this);
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java
deleted file mode 100644
index 2d791e5012..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-/**
- * Simple Runnable that throws an IllegalArgumentException
- *
- * @version $Rev$ $Date$
- */
-public class JSR237MyFailingRunnable extends JSR237MyRunnable {
-
- /**
- * Constructor
- */
- public JSR237MyFailingRunnable() {
- super(-1);
- }
-
- /**
- * Sleeps for a period of time defined by sleepTime
- */
- @Override
- public void run() {
- System.out.println("Starting " + this + " and throwing an Exception");
- throw new IllegalArgumentException("Sample exception from " + this);
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java
deleted file mode 100644
index c0183b6f9b..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Simple Runnable that is used for testing Jsr237WorkScheduler
- *
- * @version $Rev$ $Date$
- */
-public class JSR237MyRunnable implements Runnable {
-
- /**
- * Count of workAccepted() method calls
- */
- private AtomicInteger runCompletedCount = new AtomicInteger();
-
- /**
- * The amount of time to sleep in the Run loop
- */
- private final long sleepTime;
-
- /**
- * Constructor
- *
- * @param sleepTime The amount of time to sleep (in milliseconds) in the run() method
- */
- public JSR237MyRunnable(long sleepTime) {
- this.sleepTime = sleepTime;
- }
-
- /**
- * Sleeps for a period of time defined by sleepTime
- */
- public void run() {
- System.out.println("Starting " + this);
- try {
- Thread.sleep(sleepTime);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("Done " + this);
- runCompletedCount.incrementAndGet();
- }
-
- /**
- * Returns the number of completed calls to run()
- *
- * @return The number of completed calls to run()
- */
- public int getRunCompletedCount() {
- return runCompletedCount.get();
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java
deleted file mode 100644
index 307f24aca7..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.tuscany.sca.work.NotificationListener;
-
-/**
- * Simple NotificationListener that is used for testing Jsr237WorkScheduler
- *
- * @version $Rev$ $Date$
- */
-public class JSR237MyRunnerListener implements NotificationListener<JSR237MyRunnable> {
-
- /**
- * Count of workAccepted() method calls
- */
- private AtomicInteger workAcceptedCallCount = new AtomicInteger();
-
- /**
- * Count of workStarted() method calls
- */
- private AtomicInteger workStartedCallCount = new AtomicInteger();
-
- /**
- * Count of workCompleted() method calls
- */
- private AtomicInteger workCompletedCallCount = new AtomicInteger();
-
- /**
- * Count of workFailed() method calls
- */
- private AtomicInteger workFailedCallCount = new AtomicInteger();
-
- /**
- * Count of workRejected() method calls
- */
- private AtomicInteger workRejectedCallCount = new AtomicInteger();
-
- /**
- * List of all exceptions thrown by Work items
- */
- private List<Throwable> workExceptions = Collections.synchronizedList(new ArrayList<Throwable>());
-
- /**
- * {@inheritDoc}
- */
- public void workAccepted(JSR237MyRunnable work) {
- workAcceptedCallCount.incrementAndGet();
- }
-
- /**
- * {@inheritDoc}
- */
- public void workCompleted(JSR237MyRunnable work) {
- workCompletedCallCount.incrementAndGet();
- }
-
- /**
- * {@inheritDoc}
- */
- public void workFailed(JSR237MyRunnable work, Throwable error) {
- workExceptions.add(error);
- workFailedCallCount.incrementAndGet();
- }
-
- /**
- * {@inheritDoc}
- */
- public void workRejected(JSR237MyRunnable work) {
- workRejectedCallCount.incrementAndGet();
- }
-
- /**
- * {@inheritDoc}
- */
- public void workStarted(JSR237MyRunnable work) {
- workStartedCallCount.incrementAndGet();
- }
-
- /**
- * Returns the number of calls to workAccepted()
- *
- * @return The number of calls to workAccepted()
- */
- public int getWorkAcceptedCallCount() {
- return workAcceptedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workStarted()
- *
- * @return The number of calls to workStarted()
- */
- public int getWorkStartedCallCount() {
- return workStartedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workCompleted()
- *
- * @return The number of calls to workCompleted()
- */
- public int getWorkCompletedCallCount() {
- return workCompletedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workFailed()
- *
- * @return The number of calls to workFailed()
- */
- public int getWorkFailedCallCount() {
- return workFailedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workRejected()
- *
- * @return The number of calls to workRejected()
- */
- public int getWorkRejectedCallCount() {
- return workRejectedCallCount.get();
- }
-
- /**
- * Returns a List of all exceptions that are thrown by the Work items
- *
- * @return A List of all exceptions that are thrown by the Work items
- */
- public List<Throwable> getWorkExceptions() {
- return Collections.unmodifiableList(workExceptions);
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
deleted file mode 100644
index c0f35d427c..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Test case for Jsr237WorkScheduler
- *
- * @version $Rev$ $Date$
- */
-public class Jsr237WorkSchedulerTestCase {
-
- /**
- * Wait up to 20 seconds for the Work units to complete
- */
- private static final long WAIT_TIMEOUT = 20000;
-
- /**
- * This is the shared instance of the ThreadPoolWorkManager used by the tests
- */
- private static DefaultWorkScheduler workSchedular = null;
-
- /**
- * Setup the Jsr237WorkScheduler
- */
- @BeforeClass
- public static void setup() {
- workSchedular = new DefaultWorkScheduler();
- }
-
- /**
- * Make sure that the Jsr237WorkScheduler is stopped after running the tests
- */
- @AfterClass
- public static void destroy() {
- if (workSchedular != null) {
- workSchedular.stop();
- }
- }
-
- /**
- * Tests running a single fast job on the Jsr237WorkScheduler
- */
- @Test
- public void testSingleFastJob() {
- // Create the work and register it
- JSR237MyRunnable fast = new JSR237MyRunnable(10);
- JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
- workSchedular.scheduleWork(fast, listener);
-
- // Wait for the 1 job to complete
- waitForWorkToComplete(listener, 1);
-
- // Test that the job completed successfully.
- Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(1, listener.getWorkStartedCallCount());
- Assert.assertEquals(1, listener.getWorkCompletedCallCount());
- Assert.assertEquals(0, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a single job that fails on the Jsr237WorkScheduler
- */
- @Test
- public void testSingleFailingJob() {
- // Create the work and register it
- JSR237MyFailingRunnable fail = new JSR237MyFailingRunnable();
- JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
- workSchedular.scheduleWork(fail, listener);
-
- // Wait for the 1 job to complete
- waitForWorkToComplete(listener, 1);
-
- // Test that the job completed successfully.
- Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(1, listener.getWorkStartedCallCount());
- Assert.assertEquals(0, listener.getWorkCompletedCallCount());
- Assert.assertEquals(1, listener.getWorkFailedCallCount());
- Assert.assertEquals(1, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a mixture of fast and slow jobs on the Jsr237WorkScheduler
- */
- @Test
- public void testMultipleJobs() {
- // Create the work and register it
- JSR237MyRunnable fast1 = new JSR237MyRunnable(5);
- JSR237MyRunnable fast2 = new JSR237MyRunnable(10);
- JSR237MyRunnable fast3 = new JSR237MyRunnable(20);
- JSR237MyRunnable slow1= new JSR237MyRunnable(200);
- JSR237MyRunnable slow2 = new JSR237MyRunnable(200);
- JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
- workSchedular.scheduleWork(fast1, listener);
- workSchedular.scheduleWork(fast2, listener);
- workSchedular.scheduleWork(fast3, listener);
- workSchedular.scheduleWork(slow1, listener);
- workSchedular.scheduleWork(slow2, listener);
-
- // Wait for the 5 jobs to complete
- waitForWorkToComplete(listener, 5);
-
- // Test that the job completed successfully.
- Assert.assertEquals(5, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(5, listener.getWorkStartedCallCount());
- Assert.assertEquals(5, listener.getWorkCompletedCallCount());
- Assert.assertEquals(0, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a mixture of fast and slow jobs some of which fail on the
- * Jsr237WorkScheduler
- */
- @Test
- public void testMultipleJobsSomeFail() {
- // Create the work and register it
- JSR237MyRunnable fast1 = new JSR237MyRunnable(5);
- JSR237MyRunnable fast2 = new JSR237MyRunnable(10);
- JSR237MyRunnable fast3 = new JSR237MyRunnable(20);
- JSR237MyRunnable slow1= new JSR237MyRunnable(200);
- JSR237MyRunnable slow2 = new JSR237MyRunnable(200);
- JSR237MyFailingRunnable fail1 = new JSR237MyFailingRunnable();
- JSR237MyFailingRunnable fail2 = new JSR237MyFailingRunnable();
- JSR237MyRunnerListener listener = new JSR237MyRunnerListener();
- workSchedular.scheduleWork(fast1, listener);
- workSchedular.scheduleWork(fast2, listener);
- workSchedular.scheduleWork(fail1, listener);
- workSchedular.scheduleWork(fast3, listener);
- workSchedular.scheduleWork(slow1, listener);
- workSchedular.scheduleWork(fail2, listener);
- workSchedular.scheduleWork(slow2, listener);
-
- // Wait for the 7 jobs to complete
- waitForWorkToComplete(listener, 7);
-
- // Test that the job completed successfully.
- Assert.assertEquals(7, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(7, listener.getWorkStartedCallCount());
- Assert.assertEquals(5, listener.getWorkCompletedCallCount());
- Assert.assertEquals(2, listener.getWorkFailedCallCount());
- Assert.assertEquals(2, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a single job that has no listener
- */
- @Test
- public void testSingleFastJobWithNoListener() {
- // Create the work and register it
- JSR237MyRunnable fast = new JSR237MyRunnable(10);
- workSchedular.scheduleWork(fast);
-
- // Wait for the job to complete
- long startTime = System.currentTimeMillis();
- while (true) {
- int completedCount = fast.getRunCompletedCount();
- if (completedCount == 1) {
- break;
- }
-
- if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
- Assert.fail("Only " + completedCount + " work items completed before timeout");
- return;
- }
-
- // Lets wait for the job to complete
- try {
- Thread.sleep(25);
- } catch (InterruptedException ex) {
- Assert.fail("Unexpected exception: " + ex);
- }
- }
- }
-
- /**
- * Tests scheduling a null as the work item
- */
- @Test
- public void testNullWork() {
- try {
- workSchedular.scheduleWork(null);
- Assert.fail("Should have thrown IllegalArgumentException ");
- } catch (IllegalArgumentException ex) {
- // As expected
- Assert.assertTrue(ex.toString().indexOf("null") != -1);
- }
- }
-
- /**
- * Waits for the specified number of jobs to complete or the timeout to fire.
- *
- * @param listener The listener to use to track Work unit completion
- * @param completedWorkItemsToWaitFor The number of Work items to complete
- */
- private void waitForWorkToComplete(JSR237MyRunnerListener listener, int completedWorkItemsToWaitFor) {
- long startTime = System.currentTimeMillis();
- while (true) {
- int completedCount = listener.getWorkCompletedCallCount() + listener.getWorkFailedCallCount();
- if (completedCount == completedWorkItemsToWaitFor) {
- return;
- }
-
- if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
- Assert.fail("Only " + completedCount + " work items completed before timeout");
- return;
- }
-
- // Lets wait for more jobs to complete
- try {
- Thread.sleep(25);
- } catch (InterruptedException ex) {
- Assert.fail("Unexpected exception: " + ex);
- }
- }
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java
deleted file mode 100644
index a452d6f371..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.tuscany.sca.work.WorkSchedulerException;
-import org.junit.Assert;
-
-/**
- * A simple WorkListener that tracks invocations to it.
- *
- * @version $Rev$ $Date$
- */
-public class TestWorkListener implements WorkListener {
-
- /**
- * Count of workAccepted() method calls
- */
- private AtomicInteger workAcceptedCallCount = new AtomicInteger();
-
- /**
- * Count of workStarted() method calls
- */
- private AtomicInteger workStartedCallCount = new AtomicInteger();
-
- /**
- * Count of workCompleted() method calls
- */
- private AtomicInteger workCompletedCallCount = new AtomicInteger();
-
- /**
- * Count of workRejected() method calls
- */
- private AtomicInteger workRejectedCallCount = new AtomicInteger();
-
- /**
- * List of all exceptions thrown by Work items
- */
- private List<WorkSchedulerException> workExceptions = Collections.synchronizedList(new ArrayList<WorkSchedulerException>());
-
- /**
- * {@inheritDoc}
- */
- public void workAccepted(WorkEvent work) {
- workAcceptedCallCount.incrementAndGet();
-
- // Validate the WorkEvent
- Assert.assertNotNull(work.getWorkItem());
- Assert.assertEquals(WorkEvent.WORK_ACCEPTED, work.getType());
- }
-
- /**
- * {@inheritDoc}
- */
- public void workStarted(WorkEvent work) {
- workStartedCallCount.incrementAndGet();
-
- // Validate the WorkEvent
- Assert.assertNotNull(work.getWorkItem());
- Assert.assertEquals(WorkEvent.WORK_STARTED, work.getType());
- }
-
- /**
- * {@inheritDoc}
- */
- public void workCompleted(WorkEvent work) {
- if (work.getException() != null) {
- workExceptions.add(work.getException());
- }
-
- // Validate the WorkEvent
- Assert.assertNotNull(work.getWorkItem());
- Assert.assertEquals(WorkEvent.WORK_COMPLETED, work.getType());
-
- workCompletedCallCount.incrementAndGet();
- }
-
- /**
- * {@inheritDoc}
- */
- public void workRejected(WorkEvent work) {
- workRejectedCallCount.incrementAndGet();
-
- // Validate the WorkEvent
- Assert.assertNotNull(work.getWorkItem());
- Assert.assertEquals(WorkEvent.WORK_REJECTED, work.getType());
- }
-
- /**
- * Returns the number of calls to workAccepted()
- *
- * @return The number of calls to workAccepted()
- */
- public int getWorkAcceptedCallCount() {
- return workAcceptedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workStarted()
- *
- * @return The number of calls to workStarted()
- */
- public int getWorkStartedCallCount() {
- return workStartedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workCompleted()
- *
- * @return The number of calls to workCompleted()
- */
- public int getWorkCompletedCallCount() {
- return workCompletedCallCount.get();
- }
-
- /**
- * Returns the number of calls to workRejected()
- *
- * @return The number of calls to workRejected()
- */
- public int getWorkRejectedCallCount() {
- return workRejectedCallCount.get();
- }
-
- /**
- * Returns a List of all exceptions that are thrown by the Work items
- *
- * @return A List of all exceptions that are thrown by the Work items
- */
- public List<WorkSchedulerException> getWorkExceptions() {
- return Collections.unmodifiableList(workExceptions);
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java
deleted file mode 100644
index 122609d7e6..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * This test case will test the ThreadPoolWorkManager
- *
- * @version $Rev$ $Date$
- */
-public class ThreadPoolWorkManagerTestCase {
-
- /**
- * Wait up to 20 seconds for the Work units to complete
- */
- private static final long WAIT_TIMEOUT = 20000;
-
- /**
- * This is the shared instance of the ThreadPoolWorkManager used by the tests
- */
- private static ThreadPoolWorkManager workManager = null;
-
- /**
- * Setup the ThreadPoolWorkManager
- */
- @BeforeClass
- public static void setup() {
- workManager = new ThreadPoolWorkManager(10);
- }
-
- /**
- * Make sure that the ThreadPoolWorkManager is stopped after running the tests
- */
- @AfterClass
- public static void destroy() {
- if (workManager != null) {
- workManager.destroy();
- }
- }
-
- /**
- * Tests running a single fast job on the ThreadPoolWorkManager
- */
- @Test
- public void testSingleFastJob() {
- // Create the work and register it
- TimeDelayWork fast = new TimeDelayWork(10);
- TestWorkListener listener = new TestWorkListener();
- workManager.schedule(fast, listener);
-
- // Wait for the 1 job to complete
- waitForWorkToComplete(listener, 1);
-
- // Test that the job completed successfully.
- Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(1, listener.getWorkStartedCallCount());
- Assert.assertEquals(1, listener.getWorkCompletedCallCount());
- Assert.assertEquals(0, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a single job that fails on the ThreadPoolWorkManager
- */
- @Test
- public void testSingleFailingJob() {
- // Create the work and register it
- FailingWork fail = new FailingWork();
- TestWorkListener listener = new TestWorkListener();
- workManager.schedule(fail, listener);
-
- // Wait for the 1 job to complete
- waitForWorkToComplete(listener, 1);
-
- // Test that the job completed successfully.
- Assert.assertEquals(1, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(1, listener.getWorkStartedCallCount());
- Assert.assertEquals(1, listener.getWorkCompletedCallCount());
- Assert.assertEquals(1, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a mixture of fast and slow jobs on the ThreadPoolWorkManager
- */
- @Test
- public void testMultipleJobs() {
- // Create the work and register it
- TimeDelayWork fast1 = new TimeDelayWork(5);
- TimeDelayWork fast2 = new TimeDelayWork(10);
- TimeDelayWork fast3 = new TimeDelayWork(20);
- TimeDelayWork slow1= new TimeDelayWork(200);
- TimeDelayWork slow2 = new TimeDelayWork(200);
- TestWorkListener listener = new TestWorkListener();
- workManager.schedule(fast1, listener);
- workManager.schedule(fast2, listener);
- workManager.schedule(fast3, listener);
- workManager.schedule(slow1, listener);
- workManager.schedule(slow2, listener);
-
- // Wait for the 5 jobs to complete
- waitForWorkToComplete(listener, 5);
-
- // Test that the job completed successfully.
- Assert.assertEquals(5, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(5, listener.getWorkStartedCallCount());
- Assert.assertEquals(5, listener.getWorkCompletedCallCount());
- Assert.assertEquals(0, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a mixture of fast and slow jobs some of which fail on the
- * ThreadPoolWorkManager
- */
- @Test
- public void testMultipleJobsSomeFail() {
- // Create the work and register it
- TimeDelayWork fast1 = new TimeDelayWork(5);
- TimeDelayWork fast2 = new TimeDelayWork(10);
- TimeDelayWork fast3 = new TimeDelayWork(20);
- TimeDelayWork slow1= new TimeDelayWork(200);
- TimeDelayWork slow2 = new TimeDelayWork(200);
- FailingWork fail1 = new FailingWork();
- FailingWork fail2 = new FailingWork();
- TestWorkListener listener = new TestWorkListener();
- workManager.schedule(fast1, listener);
- workManager.schedule(fast2, listener);
- workManager.schedule(fail1, listener);
- workManager.schedule(fast3, listener);
- workManager.schedule(slow1, listener);
- workManager.schedule(fail2, listener);
- workManager.schedule(slow2, listener);
-
- // Wait for the 7 jobs to complete
- waitForWorkToComplete(listener, 7);
-
- // Test that the job completed successfully.
- Assert.assertEquals(7, listener.getWorkAcceptedCallCount());
- Assert.assertEquals(0, listener.getWorkRejectedCallCount());
- Assert.assertEquals(7, listener.getWorkStartedCallCount());
- Assert.assertEquals(7, listener.getWorkCompletedCallCount());
- Assert.assertEquals(2, listener.getWorkExceptions().size());
- }
-
- /**
- * Tests running a single job that has no listener
- */
- @Test
- public void testSingleFastJobWithNoListener() {
- // Create the work and register it
- TimeDelayWork fast = new TimeDelayWork(10);
- workManager.schedule(fast);
-
- // Wait for the job to complete
- long startTime = System.currentTimeMillis();
- while (true) {
- int completedCount = fast.getRunCompletedCount();
- if (completedCount == 1) {
- break;
- }
-
- if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
- Assert.fail("Only " + completedCount + " work items completed before timeout");
- return;
- }
-
- // Lets wait for the job to complete
- try {
- Thread.sleep(25);
- } catch (InterruptedException ex) {
- Assert.fail("Unexpected exception: " + ex);
- }
- }
-
- // Make sure we have got one completed run
- Assert.assertEquals(1, fast.getRunCompletedCount());
- }
-
- /**
- * Waits for the specified number of jobs to complete or the timeout to fire.
- *
- * @param listener The listener to use to track Work unit completion
- * @param completedWorkItemsToWaitFor The number of Work items to complete
- */
- private void waitForWorkToComplete(TestWorkListener listener, int completedWorkItemsToWaitFor) {
- long startTime = System.currentTimeMillis();
- while (true) {
- int completedCount = listener.getWorkCompletedCallCount();
- if (completedCount == completedWorkItemsToWaitFor) {
- return;
- }
-
- if (System.currentTimeMillis() - startTime > WAIT_TIMEOUT) {
- Assert.fail("Only " + completedCount + " work items completed before timeout");
- return;
- }
-
- // Lets wait for more jobs to complete
- try {
- Thread.sleep(25);
- } catch (InterruptedException ex) {
- Assert.fail("Unexpected exception: " + ex);
- }
- }
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java
deleted file mode 100644
index f6435659ef..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.core.work.impl;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Simple Work item that will sleep in the run() method for the specified
- * period of time
- *
- * @version $Rev$ $Date$
- */
-public class TimeDelayWork extends Work {
-
- /**
- * Count of completed run() method calls
- */
- private AtomicInteger runCompletedCount = new AtomicInteger();
-
- /**
- * The amount of time to sleep in the Run loop
- */
- private final long sleepTime;
-
- /**
- * Constructor
- *
- * @param sleepTime The amount of time to sleep (in milliseconds) in the run() method
- */
- public TimeDelayWork(long sleepTime) {
- super(null);
- this.sleepTime = sleepTime;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDaemon() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void release() {
- }
-
- /**
- * Sleeps for a period of time defined by sleepTime
- */
- public void run() {
- System.out.println("Starting " + this);
- try {
- Thread.sleep(sleepTime);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("Done " + this);
- runCompletedCount.incrementAndGet();
- }
-
- /**
- * Returns the number of completed calls to run()
- *
- * @return The number of completed calls to run()
- */
- public int getRunCompletedCount() {
- return runCompletedCount.get();
- }
-}
diff --git a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java b/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java
deleted file mode 100644
index ca7bf9b3d7..0000000000
--- a/java/sca/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.scope;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.junit.Test;
-/**
- * @version $Rev$ $Date$
- */
-public class ScopeTestCase {
-
- @Test
- public void testEquals() throws Exception {
- Scope scope = new Scope("COMPOSITE");
- assertTrue(scope.equals(Scope.COMPOSITE));
- }
-
- @Test
- public void testEqualsNew() throws Exception {
- Scope foo = new Scope("foo");
- Scope foo2 = new Scope("FOO");
- assertTrue(foo.equals(foo2));
- }
-
- @Test
- public void testNotEquals() throws Exception {
- Scope foo = new Scope("BAR");
- Scope foo2 = new Scope("FOO");
- assertFalse(foo.equals(foo2));
- }
-
- @Test
- public void testNotEqualsDifferent() throws Exception {
- Scope foo = new Scope("FOO");
- assertFalse(foo.equals(new Bar("FOO")));
- }
-
- public class Bar {
- String scope;
-
- public Bar(String scope) {
- this.scope = scope;
- }
- }
-
-
-}
diff --git a/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest b/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
deleted file mode 100644
index ad23df3761..0000000000
--- a/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-name=implementation.last, stage=implementation, after=*
-name=reference.first, stage=reference, before=*
-name=reference.transaction, stage=reference, after=reference.interface
-name=reference.binding.header, stage=reference.binding, after=reference.binding.transport
-name=service.binding.header, stage=service.binding, after=service.binding.transport
-name=service.transaction, stage=service, after=service.binding, before=component.service
-name=implementation.transaction, stage=implementation, before=implementation.policy