From 3a569a2f00bf172cddfd567149774ee808a2a242 Mon Sep 17 00:00:00 2001 From: nash Date: Wed, 30 Mar 2011 19:50:51 +0000 Subject: Create branch for 1.6.2 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1087059 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca-java-1.6.2/modules/core-spi/LICENSE | 205 +++++++ .../sca-java-1.6.2/modules/core-spi/NOTICE | 6 + .../sca-java-1.6.2/modules/core-spi/pom.xml | 122 ++++ .../modules/core-spi/src/doc/Context Model.emx | 673 +++++++++++++++++++++ .../sca/context/ComponentContextFactory.java | 38 ++ .../sca/context/ContextFactoryExtensionPoint.java | 50 ++ .../DefaultContextFactoryExtensionPoint.java | 114 ++++ .../tuscany/sca/context/PropertyValueFactory.java | 40 ++ .../tuscany/sca/context/RequestContextFactory.java | 33 + ...faultEndpointResolverFactoryExtensionPoint.java | 180 ++++++ .../sca/endpointresolver/EndpointResolver.java | 55 ++ .../endpointresolver/EndpointResolverFactory.java | 44 ++ .../EndpointResolverFactoryExtensionPoint.java | 57 ++ .../java/org/apache/tuscany/sca/event/Event.java | 33 + .../org/apache/tuscany/sca/event/EventFilter.java | 35 ++ .../apache/tuscany/sca/event/EventPublisher.java | 55 ++ .../tuscany/sca/event/RuntimeEventListener.java | 35 ++ .../org/apache/tuscany/sca/event/TrueFilter.java | 37 ++ .../sca/invocation/DataExchangeSemantics.java | 34 ++ .../apache/tuscany/sca/invocation/Interceptor.java | 40 ++ .../tuscany/sca/invocation/InvocationChain.java | 112 ++++ .../org/apache/tuscany/sca/invocation/Invoker.java | 36 ++ .../org/apache/tuscany/sca/invocation/Message.java | 127 ++++ .../tuscany/sca/invocation/MessageFactory.java | 36 ++ .../org/apache/tuscany/sca/invocation/Phase.java | 69 +++ .../tuscany/sca/management/ManagementService.java | 39 ++ .../sca/provider/BindingProviderFactory.java | 60 ++ .../DefaultProviderFactoryExtensionPoint.java | 509 ++++++++++++++++ ...efaultSCADefinitionsProviderExtensionPoint.java | 91 +++ .../sca/provider/ImplementationProvider.java | 68 +++ .../provider/ImplementationProviderFactory.java | 42 ++ .../sca/provider/OperationSelectorProvider.java | 39 ++ .../provider/OperationSelectorProviderFactory.java | 53 ++ .../tuscany/sca/provider/PolicyImplementor.java | 38 ++ .../tuscany/sca/provider/PolicyProvider.java | 41 ++ .../sca/provider/PolicyProviderFactory.java | 63 ++ .../tuscany/sca/provider/ProviderFactory.java | 36 ++ .../provider/ProviderFactoryExtensionPoint.java | 63 ++ .../sca/provider/ReferenceBindingProvider.java | 76 +++ .../sca/provider/ReferenceBindingProviderRRB.java | 35 ++ .../sca/provider/SCADefinitionsProvider.java | 33 + .../provider/SCADefinitionsProviderException.java | 30 + .../SCADefinitionsProviderExtensionPoint.java | 35 ++ .../sca/provider/ServiceBindingProvider.java | 63 ++ .../sca/provider/ServiceBindingProviderRRB.java | 39 ++ .../tuscany/sca/provider/WireFormatProvider.java | 54 ++ .../sca/provider/WireFormatProviderFactory.java | 53 ++ .../DefaultWireProcessorExtensionPoint.java | 63 ++ .../tuscany/sca/runtime/EndpointReference.java | 93 +++ .../tuscany/sca/runtime/ReferenceParameters.java | 69 +++ .../tuscany/sca/runtime/RuntimeComponent.java | 83 +++ .../sca/runtime/RuntimeComponentContext.java | 105 ++++ .../sca/runtime/RuntimeComponentReference.java | 119 ++++ .../sca/runtime/RuntimeComponentService.java | 138 +++++ .../apache/tuscany/sca/runtime/RuntimeWire.java | 117 ++++ .../tuscany/sca/runtime/RuntimeWireProcessor.java | 35 ++ .../RuntimeWireProcessorExtensionPoint.java | 53 ++ .../sca/store/DuplicateRecordException.java | 56 ++ .../apache/tuscany/sca/store/RecoveryListener.java | 46 ++ .../java/org/apache/tuscany/sca/store/Store.java | 96 +++ .../apache/tuscany/sca/store/StoreException.java | 57 ++ .../tuscany/sca/store/StoreExpirationEvent.java | 71 +++ .../org/apache/tuscany/sca/store/StoreMonitor.java | 71 +++ .../tuscany/sca/store/StoreReadException.java | 56 ++ .../tuscany/sca/store/StoreWriteException.java | 56 ++ .../tuscany/sca/work/NotificationListener.java | 67 ++ .../org/apache/tuscany/sca/work/WorkScheduler.java | 58 ++ .../tuscany/sca/work/WorkSchedulerException.java | 59 ++ ...uscany.sca.context.ContextFactoryExtensionPoint | 18 + ...tresolver.EndpointResolverFactoryExtensionPoint | 18 + ...cany.sca.provider.ProviderFactoryExtensionPoint | 18 + ...a.provider.SCADefinitionsProviderExtensionPoint | 19 + ....sca.runtime.RuntimeWireProcessorExtensionPoint | 18 + ...efaultContextFactoryExtensionPointTestCase.java | 208 +++++++ .../tuscany/sca/event/TrueFilterTestCase.java | 63 ++ 75 files changed, 5756 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/doc/Context Model.emx create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolver.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactoryExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/Event.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventFilter.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventPublisher.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/RuntimeEventListener.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/TrueFilter.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReference.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/DuplicateRecordException.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/RecoveryListener.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/Store.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreException.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreExpirationEvent.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreMonitor.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreReadException.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreWriteException.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProviderExtensionPoint create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/event/TrueFilterTestCase.java (limited to 'sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi') diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/LICENSE b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/NOTICE b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/NOTICE new file mode 100644 index 0000000000..ad2ba40961 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2010 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/pom.xml b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/pom.xml new file mode 100644 index 0000000000..501f0c4169 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/pom.xml @@ -0,0 +1,122 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.6.1-SNAPSHOT + ../pom.xml + + tuscany-core-spi + Apache Tuscany SCA Core SPI + + + + org.apache.tuscany.sca + tuscany-extensibility + 1.6.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.6.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-sca-api-extension + 1.6.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly + 1.6.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-definitions + 1.6.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-policy + 1.6.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface + 1.6.1-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-contribution + 1.6.1-SNAPSHOT + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + runtime + + + stax + stax-api + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + + + + ${tuscany.version} + org.apache.tuscany.sca.core.spi + ${pom.name} + org.apache.tuscany.sca* + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/doc/Context Model.emx b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/doc/Context Model.emx new file mode 100644 index 0000000000..0445ea5a6b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/doc/Context Model.emx @@ -0,0 +1,673 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java new file mode 100644 index 0000000000..ed4b57639c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.context; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.osoa.sca.ComponentContext; + +/** + * Interface implemented by the provider of the ComponentContext. + * + * @version $Rev$ $Date$ + */ +public interface ComponentContextFactory { + /** + * Create an instance of ComponentContext + * + * @param component The runtime component + * @param requestContextFactory The factory to create RequestContext + * @return An instance of ComponentContext for the component + */ + ComponentContext createComponentContext(RuntimeComponent component, RequestContextFactory requestContextFactory); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java new file mode 100644 index 0000000000..e92a8f2844 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.context; + +/** + * An extension point for context factories. + * + * @version $Rev$ $Date$ + */ +public interface ContextFactoryExtensionPoint { + + /** + * Add a context factory extension. + * + * @param factory The factory to add + */ + void addFactory(Object factory); + + /** + * Remove a context factory extension. + * + * @param factory The factory to remove + */ + void removeFactory(Object factory); + + /** + * Get a factory implementing the given interface. + * @param factoryInterface the lookup key (factory interface) + * @return The factory + */ + T getFactory(Class factoryInterface); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java new file mode 100644 index 0000000000..5a0aefe55d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.context; + +import java.lang.reflect.Constructor; +import java.util.HashMap; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; + +/** + * Default implementation of a model factory extension point. + * + * @version $Rev$ $Date$ + */ +public class DefaultContextFactoryExtensionPoint implements ContextFactoryExtensionPoint { + + /** + * The Map of Factories that have been registered. + */ + private HashMap, Object> factories = new HashMap, Object>(); + + private ExtensionPointRegistry registry; + + public DefaultContextFactoryExtensionPoint(ExtensionPointRegistry registry) { + this.registry = registry; + } + + /** + * Add a model factory extension. + * + * @param factory The factory to add. + * @throws IllegalArgumentException if factory is null + */ + public void addFactory(Object factory) throws IllegalArgumentException { + if (factory == null) { + throw new IllegalArgumentException("Cannot add null as a factory"); + } + + Class[] interfaces = factory.getClass().getInterfaces(); + for (int i = 0; i[] interfaces = factory.getClass().getInterfaces(); + for (int i = 0; i T getFactory(Class factoryInterface) throws IllegalArgumentException { + if (factoryInterface == null) { + throw new IllegalArgumentException("Cannot get null as a factory"); + } + + Object factory = factories.get(factoryInterface); + if (factory == null) { + + // Dynamically load a factory class declared under META-INF/services + try { + Class factoryClass = ServiceDiscovery.getInstance().loadFirstServiceClass(factoryInterface); + if (factoryClass != null) { + + // Default empty constructor + Constructor constructor = factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + + // Cache the loaded factory + addFactory(factory); + } + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + + } + + return factoryInterface.cast(factory); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java new file mode 100644 index 0000000000..9766e164b8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.context; + +import org.apache.tuscany.sca.assembly.ComponentProperty; + +/** + * Interface implemented by the provider of the property values + * + * @version $Rev$ $Date$ + */ +public interface PropertyValueFactory { + + /** + * This method will create an instance of the value for the specified Property. + * + * @param property The Property from which to retrieve the property value + * @param type The type of the property value being retrieved from the Property + * @param Type type of the property value being looked up + * + * @return the value for the Property + */ + B createPropertyValue(ComponentProperty property, Class type); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java new file mode 100644 index 0000000000..546757c766 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.context; + +import org.osoa.sca.RequestContext; + +/** + * Interface implemented by the provider of the RequestContext. + * + * @version $Rev$ $Date$ + */ +public interface RequestContextFactory { + /** + * @return An instance of RequestContext for the current invocation + */ + RequestContext createRequestContext(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java new file mode 100644 index 0000000000..04ac4ee20c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.endpointresolver; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.extensibility.ServiceDeclaration; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; + +/** + * Default implementation of a provider factory extension point. + * + * @version $Rev$ $Date$ + */ +public class DefaultEndpointResolverFactoryExtensionPoint implements EndpointResolverFactoryExtensionPoint { + + private ExtensionPointRegistry registry; + private final Map, EndpointResolverFactory> endpointResolverFactories = new HashMap, EndpointResolverFactory>(); + private boolean loaded; + + /** + * The default constructor. Does nothing. + * + */ + public DefaultEndpointResolverFactoryExtensionPoint(ExtensionPointRegistry registry) { + this.registry = registry; + } + + /** + * Add an endpoint resolver factory. + * + * @param endpointResolverFactory The resolver factory + */ + public void addEndpointResolverFactory(EndpointResolverFactory endpointResolverFactory){ + endpointResolverFactories.put(endpointResolverFactory.getModelType(), endpointResolverFactory); + } + + /** + * Remove a endpoint resolver factory. + * + * @param endpointResolverFactory The endpoint resolver factory + */ + public void removeEndpointResolverFactory(EndpointResolverFactory endpointResolverFactory){ + endpointResolverFactories.remove(endpointResolverFactory.getModelType()); + } + + /** + * Returns the provider factory associated with the given model type. + * @param modelType A model type + * @return The provider factory associated with the given model type + */ + public EndpointResolverFactory getEndpointResolverFactory(Class modelType) { + loadProviderFactories(); + + Class[] classes = modelType.getInterfaces(); + for (Class c : classes) { + EndpointResolverFactory factory = endpointResolverFactories.get(c); + if (factory != null) { + return factory; + } + } + return endpointResolverFactories.get(modelType); + } + + + /** + * Load provider factories declared under META-INF/services. + * @param registry + */ + private synchronized void loadProviderFactories() { + if (loaded) + return; + + // Get the provider factory service declarations + Set factoryDeclarations; + ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance(); + try { + factoryDeclarations = serviceDiscovery.getServiceDeclarations(EndpointResolverFactory.class); + } catch (Exception e) { + throw new IllegalStateException(e); + } + + // Get the extension point + EndpointResolverFactoryExtensionPoint factoryExtensionPoint = + registry.getExtensionPoint(EndpointResolverFactoryExtensionPoint.class); + List factories = new ArrayList(); + + for (ServiceDeclaration factoryDeclaration : factoryDeclarations) { + Map attributes = factoryDeclaration.getAttributes(); + + // Find the model type that identifies this resolver + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + EndpointResolverFactory factory = + new LazyEndpointResolverFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addEndpointResolverFactory(factory); + factories.add(factory); + } + + loaded = true; + } + + /** + * A wrapper around an endpoint provider factory allowing lazy + * loading and initialization of endpoint providers. + */ + private class LazyEndpointResolverFactory implements EndpointResolverFactory { + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private EndpointResolverFactory factory; + private Class modelType; + + private LazyEndpointResolverFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private EndpointResolverFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + public EndpointResolver createEndpointResolver(Endpoint endpoint, Binding binding) { + return getFactory().createEndpointResolver(endpoint, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolver.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolver.java new file mode 100644 index 0000000000..79a10f6d84 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolver.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.endpointresolver; + + +/** + * A reference binding implementation can options implement this + * interface to tie into the Tuscany SCA runtime + * + * @version $Rev$ $Date$ + */ +public interface EndpointResolver { + + /** + * This method will be invoked when the endpoint is + * activated. It gives the resolver the opportunity + * to do any set up ready for when it is asked to + * resolve the endpoint when a message arrives + */ + void start(); + + /** + * This method will be invoked when the endpoint is + * to be resolved. The resolver will attempt to resolve the + * endpoint against available services. The resolvers extending + * this interface will provide environment or binding specific + * resolution processing + */ + void resolve(); + + /** + * This method will be invoked when the endpont is + * deactivated. It gives the resolver the opportunity + * to take and required resolver shutdown actions + */ + void stop(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactory.java new file mode 100644 index 0000000000..fdd304a9c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactory.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.endpointresolver; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Endpoint; + +/** + * A factory for creating the runtime artifacts that resolve endpoints. + * + * @version $Rev$ $Date$ + */ +public interface EndpointResolverFactory { + + /** + * Creates a new endpoint resolver for the given component, + * reference and binding. + * + * @param component The runtime component + * @param reference The reference on the runtime component + * @param enpoint The endpoint assembly model object + * @return The endpoint provider + */ + EndpointResolver createEndpointResolver(Endpoint endpoint, Binding binding); + + Class getModelType(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactoryExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactoryExtensionPoint.java new file mode 100644 index 0000000000..be55981131 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/EndpointResolverFactoryExtensionPoint.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.endpointresolver; + +import java.util.List; + + +/** + * An extension point for resolver factories. Holds all of the resolver + * factories from loaded extension points. Allows a resolver factory + * to be located based on a given model type. Hence the runtime can + * generate endpoint resolvers from the in memory assembly model. + * + * @version $Rev$ $Date$ + */ +public interface EndpointResolverFactoryExtensionPoint { + + + /** + * Add an endpoint resolver factory. + * + * @param endpointResolverFactory The resolver factory + */ + void addEndpointResolverFactory(EndpointResolverFactory endpointResolverFactory); + + /** + * Remove a endpoint resolver factory. + * + * @param endpointResolverFactory The endpoint resolver factory + */ + void removeEndpointResolverFactory(EndpointResolverFactory endpointResolverFactory); + + /** + * Returns the endpoint resolver factory associated with the given binding type. + * @param bindingType A binding type + * @return The endpoint resolver factory associated with the given binding type + */ + EndpointResolverFactory getEndpointResolverFactory(Class bindingType); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/Event.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/Event.java new file mode 100644 index 0000000000..992c1188f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/Event.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.event; + +/** + * The base interface for events that are propagated in the runtime + * + * @version $Rev$ $Date$ + */ +public interface Event { + + /** + * Returns the source of the event + */ + Object getSource(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventFilter.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventFilter.java new file mode 100644 index 0000000000..d17aebd7e8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventFilter.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.event; + +/** + * Evaluates whether a {@link RuntimeEventListener} is applicable to a given runtime event + * + * @version $Rev$ $Date$ + */ +public interface EventFilter { + + /** + * Performs the actual evaluation on an event + * @param event Returns true if the event matches implemented criteria + * @return Match result + */ + boolean match(Event event); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventPublisher.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventPublisher.java new file mode 100644 index 0000000000..f209eb8936 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/EventPublisher.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.event; + +/** + * Publishes events in the runtime by accepting {@link Event} objects and + * forwarding them to all registered {@link RuntimeEventListener} objects. + * + * @version $Rev$ $Date$ + */ +public interface EventPublisher { + + /** + * Publish an event to all registered listeners + * @param object The event to publish + */ + void publish(Event object); + + /** + * Registers a listener to receive notifications for the context + * @param listener The listener to add + */ + void addListener(RuntimeEventListener listener); + + /** + * Registers a listener to receive notifications for the context + * @param filter The filter that will be applied before the lister is called + * @param listener The lister to add + */ + void addListener(EventFilter filter, RuntimeEventListener listener); + + + /** + * Removes a previously registered listener + * @param listener The listener to remove + */ + void removeListener(RuntimeEventListener listener); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/RuntimeEventListener.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/RuntimeEventListener.java new file mode 100644 index 0000000000..b34dceee62 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/RuntimeEventListener.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.event; + +import java.util.EventListener; + +/** + * Listeners observe events fired in the SCA runtime. + * + * @version $Rev$ $Date$ + */ +public interface RuntimeEventListener extends EventListener { + + /** + * Accepts and event and acts on it + * @param event The event to act on + */ + void onEvent(Event event); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/TrueFilter.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/TrueFilter.java new file mode 100644 index 0000000000..f888908340 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/event/TrueFilter.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.event; + +/** + * An event filter that always returns a true condition + * + * @version $Rev$ $Date$ + */ +public class TrueFilter implements EventFilter { + + /** + * Performs the actual evaluation on an event. Always returns true + * in this case + * @param event The incoming event which is ignored + * @return true + */ + public boolean match(Event event) { + return true; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java new file mode 100644 index 0000000000..957a15ce8a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.invocation; + +/** + * An invoker or interceptor can optionally implement this interface to indicate if they can + * enforce the pass-by-value semantics for an operation on remotable interfaces. + * + * @version $Rev$ $Date$ + */ +public interface DataExchangeSemantics { + /** + * Indicate if the data can be passed in by reference as they won't be mutated. + * @return true if pass-by-reference is allowed + */ + boolean allowsPassByReference(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java new file mode 100644 index 0000000000..a5f221fc11 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.invocation; + +/** + * Synchronous mediation associated with a client- or target- side wire. + * + * @version $Rev$ $Date$ + */ +public interface Interceptor extends Invoker { + + /** + * Sets the next invoker + * @param next The next invoker + */ + void setNext(Invoker next); + + /** + * Returns the next invoker or null + * @return The next Invoker + */ + Invoker getNext(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java new file mode 100644 index 0000000000..75719bb0cc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.invocation; + +import org.apache.tuscany.sca.interfacedef.Operation; + +/** + * A wire consists of 1..n invocation chains associated with the operations of its source service contract. + *

+ * Invocation chains may contain Interceptors that process invocations. + *

+ * A Message is used to pass data associated with an invocation through the chain. + * + * @version $Rev$ $Date$ + */ +public interface InvocationChain { + /** + * Returns the target operation for this invocation chain. + * + * @return The target operation for this invocation chain + */ + Operation getTargetOperation(); + + /** + * Updates the target operation for this invocation chain. + * + * @param operation The new target operation for this invocation chain + */ + void setTargetOperation(Operation operation); + + /** + * Returns the source operation for this invocation chain. + * + * @return The source operation for this invocation chain + */ + Operation getSourceOperation(); + + /** + * Adds an interceptor to the chain. For reference side, it will be added to + * Phase.REFERENCE. For service side, it will be added to Phase.SERVICE + * + * @param interceptor The interceptor to add + */ + void addInterceptor(Interceptor interceptor); + + /** + * Adds an invoker to the chain + * + * @param invoker The invoker to add + */ + void addInvoker(Invoker invoker); + + /** + * Returns the first invoker in the chain. + * + * @return The first invoker in the chain + */ + Invoker getHeadInvoker(); + + /** + * @deprecated This method is not used + * Returns the last invoker in the chain. + * + * @return The last invoker in the chain + */ + @Deprecated + Invoker getTailInvoker(); + + /** + * @deprecated Please use void addInterceptor(String phase, Interceptor interceptor); + * Adds an interceptor at the given position in the interceptor stack + * + * @param index The position in the interceptor stack to add the interceptor + * @param interceptor The interceptor to add + */ + @Deprecated + void addInterceptor(int index, Interceptor interceptor); + + /** + * Add an interceptor to the given phase + * @param phase + * @param interceptor + */ + void addInterceptor(String phase, Interceptor interceptor); + + /** + * Indicate if the data can be passed in by reference as they won't be mutated. + * @return true if pass-by-reference is allowed + */ + boolean allowsPassByReference(); + /** + * Force the invocation to allow pass-by-reference + * @param allowsPBR + */ + void setAllowsPassByReference(boolean allowsPBR); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java new file mode 100644 index 0000000000..2748bbed9a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.invocation; + +/** + * Synchronous mediation associated with a client- or target- side wire. + * + * @version $Rev$ $Date$ + */ +public interface Invoker { + + /** + * Process a synchronous wire + * + * @param msg The request Message for the wire + * @return The response Message from the wire + */ + Message invoke(Message msg); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java new file mode 100644 index 0000000000..16cb4132e4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.invocation; + +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.runtime.EndpointReference; + +/** + * Represents a request, response, or exception flowing through a wire + * + * @version $Rev $Date$ + */ +public interface Message { + + /** + * Returns the body of the message, which will be the payload or parameters associated with the wire + * @return The body of the message + */ + T getBody(); + + /** + * Sets the body of the message. + * @param body The body of the message + */ + void setBody(T body); + + /** + * Get the end point reference of the source reference + * @return The end point reference of the reference originating the message + */ + EndpointReference getFrom(); + + /** + * Set the end point reference of the reference originating the message + * @param from The end point reference of the reference originating the message + */ + void setFrom(EndpointReference from); + + /** + * Get the end point reference of target service + * @return The end point reference of the service that the message targets + */ + EndpointReference getTo(); + + /** + * Set the end point reference of target service + * @param to The end point reference of the service that the message targets + */ + void setTo(EndpointReference to); + + /** + * Returns the id of the message + * @return The message Id + */ + Object getMessageID(); + + /** + * Sets the id of the message + * @param messageId The message ID + */ + void setMessageID(Object messageId); + + /** + * Determines if the message represents a fault/exception + * + * @return true If the message body is a fault object, false if the body is a normal payload + */ + boolean isFault(); + + /** + * Set the message body with a fault object. After this method is called, isFault() returns true. + * + * @param fault The fault object represents an exception + */ + void setFaultBody(T fault); + + /** + * Returns the operation that created the message. + * + * @return The operation that created the message + */ + Operation getOperation(); + + /** + * Sets the operation that created the message. + * + * @param op The operation that created the message + */ + void setOperation(Operation op); + + /** + * Returns a list of objects that are contained in the message header + * + * @return + */ + List getHeaders(); + + /** + * Returns the binding context in force for this message + */ + T getBindingContext(); + + /** + * Set the binding context that is in force for this message + * @param bindingContext + */ + void setBindingContext(T bindingContext); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java new file mode 100644 index 0000000000..38c900e36a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.invocation; + + +/** + * A factory for messages + * + * @version $Rev $Date$ + */ +public interface MessageFactory { + + /** + * Creates a new message. + * + * @return The new message + */ + Message createMessage(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java new file mode 100644 index 0000000000..af8ad6e582 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.invocation; + +/** + * Tuscany built-in phases for the invocation chain + * + * @version $Rev$ $Date$ + */ +public interface Phase { + // The first phase for outgoing invocations via a reference + String REFERENCE = "component.reference"; + + // data transformation and validation + String REFERENCE_INTERFACE = "reference.interface"; + + // reference policy handling + String REFERENCE_POLICY = "reference.policy"; + + // reference binding invoker + String REFERENCE_BINDING = "reference.binding"; + + String REFERENCE_BINDING_WIREFORMAT = "reference.binding.wireformat"; + String REFERENCE_BINDING_POLICY = "reference.binding.policy"; + String REFERENCE_BINDING_TRANSPORT = "reference.binding.transport"; + + String SERVICE_BINDING_TRANSPORT = "service.binding.transport"; + String SERVICE_BINDING_OPERATION_SELECTOR = "service.binding.operationselector"; + String SERVICE_BINDING_WIREFORMAT = "service.binding.wireformat"; + String SERVICE_BINDING_POLICY = "service.binding.policy"; + + + // The first phase for incoming invocations via a service + String SERVICE_BINDING = "service.binding"; + + // service policy handling + String SERVICE_POLICY = "service.policy"; + + // data validation and transformation + String SERVICE_INTERFACE = "service.interface"; + + // TODO: not sure if we need to have this face + String SERVICE = "component.service"; + + // implementation policy handling + String IMPLEMENTATION_POLICY = "implementation.policy"; + + // implementation invoker + String IMPLEMENTATION = "component.implementation"; + + // String getName(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java new file mode 100644 index 0000000000..3887db4873 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.management; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Interface for the management service abstraction. The implementation + * could be based on a variety of technologies including JMX, WSDM, + * SNMP etc. + * + * @version $Revision$ $Date$ + */ +public interface ManagementService { + + /** + * Registers a component for management. + * + * @param name Name of the component. + * @param component Component to be registered. + */ + void registerComponent(String name, RuntimeComponent component); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java new file mode 100644 index 0000000000..0f6a932c51 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * A factory for creating the runtime artifacts that represent bindings. + * + * @version $Rev$ $Date$ + */ +public interface BindingProviderFactory extends ProviderFactory { + + /** + * Creates a new reference binding provider for the given component and + * reference. + * + * @param component The runtime component + * @param reference The reference on the runtime component + * @param binding The binding assembly model object + * @return The binding provider + */ + ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + M binding); + + /** + * Creates a new service binding provider for the given component and + * service. + * + * @param component The runtime component + * @param service The service on the runtime component + * @param binding The binding assembly model object + * @return The binding provider + */ + ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + M binding); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java new file mode 100644 index 0000000000..df46af121c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java @@ -0,0 +1,509 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.extensibility.ServiceDeclaration; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * Default implementation of a provider factory extension point. + * + * @version $Rev$ $Date$ + */ +public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExtensionPoint { + + private ExtensionPointRegistry registry; + private final Map, ProviderFactory> providerFactories = new HashMap, ProviderFactory>(); + private final List policyProviderFactories = new ArrayList(); + private boolean loaded; + + /** + * The default constructor. Does nothing. + * + */ + public DefaultProviderFactoryExtensionPoint(ExtensionPointRegistry registry) { + this.registry = registry; + } + + /** + * Add a provider factory. + * + * @param providerFactory The provider factory + */ + public void addProviderFactory(ProviderFactory providerFactory) { + if(providerFactory instanceof PolicyProviderFactory) { + policyProviderFactories.add((PolicyProviderFactory)providerFactory); + } + providerFactories.put(providerFactory.getModelType(), providerFactory); + } + + /** + * Remove a provider factory. + * + * @param providerFactory The provider factory + */ + public void removeProviderFactory(ProviderFactory providerFactory) { + if(providerFactory instanceof PolicyProviderFactory) { + policyProviderFactories.remove((PolicyProviderFactory)providerFactory); + } + providerFactories.remove(providerFactory.getModelType()); + } + + /** + * Returns the provider factory associated with the given model type. + * @param modelType A model type + * @return The provider factory associated with the given model type + */ + public ProviderFactory getProviderFactory(Class modelType) { + loadProviderFactories(); + + Class[] classes = modelType.getInterfaces(); + for (Class c : classes) { + ProviderFactory factory = providerFactories.get(c); + if (factory != null) { + return factory; + } + } + return providerFactories.get(modelType); + } + + public List getPolicyProviderFactories() { + loadProviderFactories(); + return policyProviderFactories; + } + + /** + * Load provider factories declared under META-INF/services. + * @param registry + */ + private synchronized void loadProviderFactories() { + if (loaded) + return; + + loadProviderFactories(BindingProviderFactory.class); + loadProviderFactories(ImplementationProviderFactory.class); + loadProviderFactories(PolicyProviderFactory.class); + loadProviderFactories(WireFormatProviderFactory.class); + loadProviderFactories(OperationSelectorProviderFactory.class); + + loaded = true; + } + + /** + * Load provider factories declared under META-INF/services. + * @param registry + * @param factoryClass + * @return + */ + private List loadProviderFactories(Class factoryClass) { + + // Get the provider factory service declarations + Set factoryDeclarations; + ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance(); + try { + factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass); + } catch (Exception e) { + throw new IllegalStateException(e); + } + + // Get the target extension point + ProviderFactoryExtensionPoint factoryExtensionPoint = + registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); + List factories = new ArrayList(); + + for (ServiceDeclaration factoryDeclaration : factoryDeclarations) { + Map attributes = factoryDeclaration.getAttributes(); + + // Load an implementation provider factory + if (factoryClass == ImplementationProviderFactory.class) { + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + ImplementationProviderFactory factory = + new LazyImplementationProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); + + } else if (factoryClass == BindingProviderFactory.class) { + + // Load a binding provider factory + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + BindingProviderFactory factory = + new LazyBindingProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); + } else if (factoryClass == PolicyProviderFactory.class) { + // Load a policy provider factory + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + PolicyProviderFactory factory = + new LazyPolicyProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); + } else if (factoryClass == WireFormatProviderFactory.class) { + + // Load a wire format provider factory + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + WireFormatProviderFactory factory = + new LazyWireFormatProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); + } else if (factoryClass == OperationSelectorProviderFactory.class) { + + // Load a wire format provider factory + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + OperationSelectorProviderFactory factory = + new LazyOperationSelectorProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); + } + } + return factories; + } + + /** + * A wrapper around an implementation provider factory allowing lazy + * loading and initialization of implementation providers. + */ + private static class LazyBindingProviderFactory implements BindingProviderFactory { + + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration factoryDeclaration; + private BindingProviderFactory factory; + private Class modelType; + + private LazyBindingProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration factoryDeclaration) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.factoryDeclaration = factoryDeclaration; + } + + @SuppressWarnings("unchecked") + private BindingProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = + (Class)factoryDeclaration.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + @SuppressWarnings("unchecked") + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return getFactory().createReferenceBindingProvider(component, reference, binding); + } + + @SuppressWarnings("unchecked") + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return getFactory().createServiceBindingProvider(component, service, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + modelType = factoryDeclaration.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + + } + + /** + * A wrapper around an implementation provider factory allowing lazy + * loading and initialization of implementation providers. + */ + private class LazyImplementationProviderFactory implements ImplementationProviderFactory { + + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private ImplementationProviderFactory factory; + private Class modelType; + + private LazyImplementationProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private ImplementationProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = + (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + @SuppressWarnings("unchecked") + public ImplementationProvider createImplementationProvider(RuntimeComponent component, + Implementation Implementation) { + return getFactory().createImplementationProvider(component, Implementation); + } + + public Class getModelType() { + if (modelType == null) { + try { + + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + + } + + /** + * A wrapper around an policy provider factory allowing lazy + * loading and initialization of policy providers. + */ + private class LazyPolicyProviderFactory implements PolicyProviderFactory { + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private PolicyProviderFactory factory; + private Class modelType; + + private LazyPolicyProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private PolicyProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, + Implementation implementation) { + return getFactory().createImplementationPolicyProvider(component, implementation); + } + + public PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return getFactory().createReferencePolicyProvider(component, reference, binding); + } + + public PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return getFactory().createServicePolicyProvider(component, service, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + } + + /** + * A wrapper around a wire format provider factory allowing lazy + * loading and initialization of wire format providers. + */ + private class LazyWireFormatProviderFactory implements WireFormatProviderFactory { + + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private WireFormatProviderFactory factory; + private Class modelType; + + private LazyWireFormatProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private WireFormatProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = + (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + @SuppressWarnings("unchecked") + public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding){ + return getFactory().createReferenceWireFormatProvider(component, reference, binding); + } + + @SuppressWarnings("unchecked") + public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding){ + return getFactory().createServiceWireFormatProvider(component, service, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + } + + /** + * A wrapper around a operation selector provider factory allowing lazy + * loading and initialization of operation selector providers. + */ + private class LazyOperationSelectorProviderFactory implements OperationSelectorProviderFactory { + + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private OperationSelectorProviderFactory factory; + private Class modelType; + + private LazyOperationSelectorProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private OperationSelectorProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = + (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + @SuppressWarnings("unchecked") + public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding){ + return getFactory().createReferenceOperationSelectorProvider(component, reference, binding); + } + + @SuppressWarnings("unchecked") + public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding){ + return getFactory().createServiceOperationSelectorProvider(component, service, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java new file mode 100644 index 0000000000..76ca061bab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.extensibility.ServiceDeclaration; +import org.apache.tuscany.sca.extensibility.ServiceDiscovery; + +/** + * Concrete Implementation for the SCADefinitionsProviderExtensionPoint + * + * @version $Rev$ $Date$ + */ +public class DefaultSCADefinitionsProviderExtensionPoint implements + SCADefinitionsProviderExtensionPoint { + + private ExtensionPointRegistry extensionPointRegistry = null; + + private List scaDefnsProviders = new ArrayList(); + + public DefaultSCADefinitionsProviderExtensionPoint(ExtensionPointRegistry extnPtReg) { + this.extensionPointRegistry = extnPtReg; + } + + public void addSCADefinitionsProvider(SCADefinitionsProvider provider) { + scaDefnsProviders.add(provider); + } + + public void removeSCADefinitionsProvider(SCADefinitionsProvider provider) { + scaDefnsProviders.remove(provider); + } + + public List getSCADefinitionsProviders() { + if (scaDefnsProviders.isEmpty()) { + loadProviders(); + } + return scaDefnsProviders; + } + + private synchronized void loadProviders() { + // Get the provider service declarations + Set defnProviderDecls; + SCADefinitionsProvider aProvider = null; + Class providerClass = null; + Constructor constructor = null; + + try { + defnProviderDecls = + ServiceDiscovery.getInstance().getServiceDeclarations(SCADefinitionsProvider.class); + + for (ServiceDeclaration aDefnProviderDecl : defnProviderDecls) { + providerClass = aDefnProviderDecl.loadClass(); + + try { + constructor = providerClass.getConstructor(); + aProvider = (SCADefinitionsProvider)constructor.newInstance(); + } catch (NoSuchMethodException e1) { + constructor = providerClass.getConstructor(ExtensionPointRegistry.class); + aProvider = (SCADefinitionsProvider)constructor.newInstance(extensionPointRegistry); + } + + scaDefnsProviders.add(aProvider); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java new file mode 100644 index 0000000000..015c673d66 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * A component implementation can implement this interface in order to tie + * into the Tuscany runtime + * + * @version $Rev$ $Date$ + */ +public interface ImplementationProvider { + + /** + * This method will be invoked when the component implementation + * is activated. + */ + void start(); + + /** + * This method will be invoked when the component implementation + * is deactivated. + */ + void stop(); + + /** + * Create an invoker for the component implementation in the invocation + * chain. The invoker will be responsible for calling the implementation + * logic for the given component. + * + * @param service The component service + * @param operation The operation that the interceptor will handle + * @return An invoker that handles the invocation logic, null should be + * returned if no invoker is required + */ + Invoker createInvoker(RuntimeComponentService service, Operation operation); + + /** + * For bindings that invoke one-way callback operations asynchronously, + * there is no need to perform a thread switch before calling the invoker. + * This method indicates whether the binding has this capability. + * + * @return true if the callback invoker is able to invoke one-way operations + * asynchronously, false if all invocations are synchronous + */ + boolean supportsOneWayInvocation(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java new file mode 100644 index 0000000000..6a37d1e951 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * An interface for factories that create implementation providers. + * + * @version $Rev$ $Date$ + */ +public interface ImplementationProviderFactory extends ProviderFactory { + + /** + * Creates a new implementation provider for the given + * component. + * + * @param component The runtime component + * @param Implementation The implementation type + * @return The implementation provider + */ + ImplementationProvider createImplementationProvider(RuntimeComponent component, M Implementation); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java new file mode 100644 index 0000000000..f385c7dfba --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import org.apache.tuscany.sca.invocation.Interceptor; + +/** + * @version $Rev$ $Date$ + */ +public interface OperationSelectorProvider { + /** + * Create an interceptor for the operation selector + * @return An interceptor that realize the policySet + */ + Interceptor createInterceptor(); + + /** + * Get the phase that the interceptor should be added + * @return The phase that this interceptor belongs to + */ + String getPhase(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java new file mode 100644 index 0000000000..183b38cb33 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.OperationSelector; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public interface OperationSelectorProviderFactory extends ProviderFactory { + /** + * Create wire format provider for a given reference binding + * @param component + * @param reference + * @param binding + * @return + */ + OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding); + + /** + * Create policy provider for a given service binding + * @param component + * @param service + * @param binding + * @return + */ + OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java new file mode 100644 index 0000000000..f2b59a7c54 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import java.util.List; + +import javax.xml.namespace.QName; + +/** + * This interface can be optionally implemented by the Binding or Implementation providers to + * indicate if they implement the policies in the binding/implementation provider. + * + * @version $Rev$ $Date$ + */ +public interface PolicyImplementor { + /** + * Get a list of policy names that are implemented by this policy implementor + * @return A list of policy names + */ + List getImplementedPolicies(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java new file mode 100644 index 0000000000..644283dea1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; + +/** + * @version $Rev$ $Date$ + */ +public interface PolicyProvider { + /** + * Create an interceptor for a given operation + * @param operation + * @return An interceptor that realize the policySet + */ + Interceptor createInterceptor(Operation operation); + + /** + * Get the phase that the interceptor should be added + * @return The phase that this interceptor belongs to + */ + String getPhase(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java new file mode 100644 index 0000000000..b60a14d2da --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.policy.Policy; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public interface PolicyProviderFactory extends ProviderFactory { + /** + * Create policy provider for a given reference binding + * @param component + * @param reference + * @param binding + * @return + */ + PolicyProvider createReferencePolicyProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding); + + /** + * Create policy provider for a given service binding + * @param component + * @param service + * @param binding + * @return + */ + PolicyProvider createServicePolicyProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding); + + /** + * Create policy provider for a given component implementation + * @param component + * @param implementation + * @return + */ + PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java new file mode 100644 index 0000000000..2102806881 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +/** + * A factory for runtime providers. + * + * @version $Rev$ $Date$ + */ +public interface ProviderFactory { + + /** + * The model type that this factory creates providers for. + * + * @return the model type + */ + Class getModelType(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java new file mode 100644 index 0000000000..d8f9973338 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import java.util.List; + + +/** + * An extension point for provider factories. Holds all of the provider + * factories from loaded extension points. Allows a provider factory + * to be located based on a given model type. Hence the runtime can + * generate runtime artifacts from the in memory assembly model. + * + * @version $Rev$ $Date$ + */ +public interface ProviderFactoryExtensionPoint { + + + /** + * Add a provider factory. + * + * @param providerFactory The provider factory + */ + void addProviderFactory(ProviderFactory providerFactory); + + /** + * Remove a provider factory. + * + * @param providerFactory The provider factory + */ + void removeProviderFactory(ProviderFactory providerFactory); + + /** + * Returns the provider factory associated with the given model type. + * @param modelType A model type + * @return The provider factory associated with the given model type + */ + ProviderFactory getProviderFactory(Class modelType); + + /** + * Get a list of registered PolicyProviderFactory + * @return a list of registered PolicyProviderFactory + */ + List getPolicyProviderFactories(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java new file mode 100644 index 0000000000..b3ab1d8b87 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; + +/** + * A reference binding implementation can options implement this + * interface to tie into the Tuscany SCA runtime + * + * @version $Rev$ $Date$ + */ +public interface ReferenceBindingProvider { + + /** + * This method will be invoked when the component reference binding is + * activated. + */ + void start(); + + /** + * This method will be invoked when the component reference binding is + * deactivated. + */ + void stop(); + + /** + * Create an invoker for the reference binding in the invocation chain. The + * invoker is responsible for making the outbound invocation over the + * binding protocol. + * + * @param operation The operation that the interceptor will handle + * @return An invoker that handles the invocation logic, null should be + * returned if no invoker is required + */ + Invoker createInvoker(Operation operation); + + /** + * Get the effective interface contract imposed by the binding. For example, + * it will be interface contract introspected from the WSDL portType used by + * the endpoint for a WebService binding. + * + * @return The effective interface contract, if null is returned, the + * interface contract for the component reference will be used + */ + InterfaceContract getBindingInterfaceContract(); + + /** + * For bindings that invoke one-way operations asynchronously, there is no + * need to perform a thread switch before calling the invoker. This method + * indicates whether the binding has this capability. + * + * @return true if the binding invoker is able to invoke one-way operations + * asynchronously, false if all invocations are synchronous + */ + boolean supportsOneWayInvocation(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java new file mode 100644 index 0000000000..3ea9d0ac3c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * TODO RRB experiment + * This is an experiment extension to try out the request response + * binding function + * + * @version $Rev$ $Date$ + */ +public interface ReferenceBindingProviderRRB extends ReferenceBindingProvider { + + void configureBindingChain(RuntimeWire runtimeWire); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java new file mode 100644 index 0000000000..bd0f4d4b75 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import org.apache.tuscany.sca.definitions.SCADefinitions; + +/** + * Models a provider of SCA Definitions. Typically SCA Definitions providers + * may either load a definitions.xml file or create the SCA Definitions model + * programmatically. + * + * @version $Rev$ $Date$ + */ +public interface SCADefinitionsProvider { + SCADefinitions getSCADefinition() throws SCADefinitionsProviderException ; +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java new file mode 100644 index 0000000000..b05130d6c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +/** + * @version $Rev$ $Date$ + */ +public class SCADefinitionsProviderException extends Exception { + + public SCADefinitionsProviderException(Throwable e) { + super(e); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java new file mode 100644 index 0000000000..a5d60cc6eb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import java.util.List; + +/** + * An extension point for SCA Definitions Providers. SCA Definition providers, load SCA Definitions + * items that are being specifically contributed by the module that hosts the provider in question. + * + * @version $Rev$ $Date$ + */ +public interface SCADefinitionsProviderExtensionPoint { + + void addSCADefinitionsProvider(SCADefinitionsProvider provider); + void removeSCADefinitionsProvider(SCADefinitionsProvider provider); + List getSCADefinitionsProviders(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java new file mode 100644 index 0000000000..e15234a549 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.provider; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; + +/** + * A service binding can optionally implement this interface to tie + * into the Tuscany SCA runtime + * + * @version $Rev$ $Date$ + */ +public interface ServiceBindingProvider { + /** + * This method will be invoked when the component service binding is + * activated. + */ + void start(); + + /** + * This method will be invoked when the component service binding is + * deactivated. + */ + void stop(); + + /** + * Get the effective interface contract imposed by the binding. For example, + * it will be interface contract introspected from the WSDL portType used by + * the endpoint for a WebService binding. + * + * @return The effective interface contract, if null is returned, the + * interface contract for the component service will be used + */ + InterfaceContract getBindingInterfaceContract(); + + /** + * For bindings that invoke one-way callback operations asynchronously, + * there is no need to perform a thread switch before calling the invoker. + * This method indicates whether the binding has this capability. + * + * @return true if the callback invoker is able to invoke one-way operations + * asynchronously, false if all invocations are synchronous + */ + boolean supportsOneWayInvocation(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java new file mode 100644 index 0000000000..e23a37360a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * TODO RRB experiment + * This is an experiment extension to try out the request response + * binding function + * + * @version $Rev$ $Date$ + */ +public interface ServiceBindingProviderRRB extends ServiceBindingProvider { + + void configureBindingChain(RuntimeWire runtimeWire); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java new file mode 100644 index 0000000000..35526cb251 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.Interceptor; + +/** + * @version $Rev$ $Date$ + */ +public interface WireFormatProvider { + + /** + * Set up the contract that describes the interface that + * is providing data to or accepting data from the + * wire format interceptor. The wire format's job + * is to translate between this interface contract and the + * format on the wire. The interface contract may be + * configured separately for request and response + * wire formats + * + * @return the wire format interface contract + */ + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract); + + /** + * Create an interceptor for the wire format + * @return An interceptor that realize the policySet + */ + Interceptor createInterceptor(); + + /** + * Get the phase that the interceptor should be added + * @return The phase that this interceptor belongs to + */ + String getPhase(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java new file mode 100644 index 0000000000..fd748df6ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.provider; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.WireFormat; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public interface WireFormatProviderFactory extends ProviderFactory { + /** + * Create wire format provider for a given reference binding + * @param component + * @param reference + * @param binding + * @return + */ + WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding); + + /** + * Create policy provider for a given service binding + * @param component + * @param service + * @param binding + * @return + */ + WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java new file mode 100644 index 0000000000..851afee3c1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.runtime; + +import java.util.ArrayList; +import java.util.List; + + +/** + * The default implementation of a WireProcessorExtensionPoint + * + * @version $Rev$ $Date$ + */ +public class DefaultWireProcessorExtensionPoint implements RuntimeWireProcessorExtensionPoint { + + /** + * The list of WireProcessors available to the runtime + */ + private final List processors = new ArrayList(); + + /** + * Registers a wire-processor in the runtime + * + * @param processor The processor to register + */ + public void addWireProcessor(RuntimeWireProcessor processor) { + processors.add(processor); + } + + /** + * De-registers a wire-processor in the runtime + * + * @param processor The processor to de-register + */ + public void removeWireProcessor(RuntimeWireProcessor processor) { + processors.remove(processor); + } + + /** + * Returns a list of registered wire-processors. + * + * @return The list of wire processors + */ + public List getWireProcessors() { + return processors; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReference.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReference.java new file mode 100644 index 0000000000..b6fafa5fb6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReference.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; + +/** + * The endpoint reference for a component service or reference + * + * @version $Rev$ $Date$ + */ +public interface EndpointReference extends Cloneable { + /** + * Get the component for the endpoint + * @return The component, null of the EPR is for a non-SCA service + */ + RuntimeComponent getComponent(); + + /** + * Get the component service or reference for the endpoint + * @return The component service or reference, null if the EPR is for a non-SCA service + */ + Contract getContract(); + + /** + * Get the binding for the endpoint + * @return The binding + */ + Binding getBinding(); + + /** + * Get the interface contract for the endpoint + * @return The interface contract + */ + InterfaceContract getInterfaceContract(); + + /** + * Update the interface contract for the endpoint + * @param interfaceContract The updated interface contract + */ + void setInterfaceContract(InterfaceContract interfaceContract); + + /** + * Get the URI for this endpoint + * @return The URI of the endpoint + */ + String getURI(); + + /** + * Set the URI for this endpoint + * @param uri The new URI of the endpoint + */ + void setURI(String uri); + + /** + * Get the callback endpoint for this endpoint + * @return The callback endpoint for this endpoint + */ + EndpointReference getCallbackEndpoint(); + + /** + * Set the callback endpoint for this endpoint + * @param callbackEndpoint The new callback endpoint for this endpoint + */ + void setCallbackEndpoint(EndpointReference callbackEndpoint); + + Object clone() throws CloneNotSupportedException; + + void setReferenceParameters(ReferenceParameters parameters); + ReferenceParameters getReferenceParameters(); + + void mergeEndpoint(EndpointReference epr); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java new file mode 100644 index 0000000000..0e19538aff --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +/** + * Parameters for the EndPointReference + * + * @version $Rev$ $Date$ + */ +public interface ReferenceParameters extends Cloneable { + /** + * Get the callback ID + * @return the callbackID + */ + Object getCallbackID(); + + /** + * Set the callback ID + * @param callbackID the callbackID to set + */ + void setCallbackID(Object callbackID); + + /** + * Get the conversation ID + * @return the conversationID + */ + Object getConversationID(); + + /** + * Set the conversation ID + * @param conversationID the conversationID to set + */ + void setConversationID(Object conversationID); + + /** + * Get the ID for the non-ServiceReference callback object + * @return + */ + Object getCallbackObjectID(); + + /** + * Set the ID for the non-ServiceReference callback object + * @param callbackObjectID + */ + void setCallbackObjectID(Object callbackObjectID); + + EndpointReference getCallbackReference(); + + void setCallbackReference(EndpointReference callback); + + Object clone() throws CloneNotSupportedException; +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java new file mode 100644 index 0000000000..30bba78a40 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.PolicyProvider; + +/** + * The runtime component interface. Provides the bridge between the + * assembly model representation of a component and its runtime + * realization. + * + * @version $Rev$ $Date$ + */ +public interface RuntimeComponent extends Component { + /** + * Set the implementation-specific configuration for this component + * @param implementationProvider The object that manages the component implementation + */ + void setImplementationProvider(ImplementationProvider implementationProvider); + + /** + * Get the implementation-specific configuration for this component + * @return The implementation provider for this component + */ + ImplementationProvider getImplementationProvider(); + + /** + * Get the associated component context + * @return + */ + RuntimeComponentContext getComponentContext(); + + /** + * Set the associated component context + * @param context + */ + void setComponentContext(RuntimeComponentContext context); + + /** + * Tests if the RuntimeComponent is started + * @return true if the RuntimeComponent is started otherwise false + */ + boolean isStarted(); + + /** + * Sets the RuntimeComponent started state + * @param started the state to set + */ + void setStarted(boolean started); + + /** + * Add a policy provider to the component + * @param policyProvider + */ + void addPolicyProvider(PolicyProvider policyProvider); + + /** + * Get a list of policy providers configured for this component + * @return + */ + List getPolicyProviders(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java new file mode 100644 index 0000000000..f61bff9735 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; + +import org.apache.tuscany.sca.api.ComponentContextExtension; +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; + +/** + * @version $Rev$ $Date$ + */ +public interface RuntimeComponentContext extends ComponentContextExtension { + /** + * Activate the reference (creating runtime wires) + * @param reference + */ + void start(RuntimeComponentReference reference); + + /** + * Deserialize the component reference + * @param reader + * @return A component that contains the reference + * @throws IOException + */ + RuntimeComponent read(Reader reader) throws IOException; + + /** + * Serialize the component reference + * @param reference + * @param writer + * @throws IOException + */ + void write(RuntimeComponentReference reference, Writer writer) throws IOException; + + /** + * Get the CallableReference for a given component reference + * @param + * @param businessInterface The business interface + * @param reference The reference to be wired + * @param binding The binding to be used, if it's null, either binding.sca or the 1st binding + * will be selected + * @return A service reference representing the wire + */ + ServiceReference getServiceReference(Class businessInterface, + RuntimeComponentReference reference, + Binding binding); + + /** + * Bind the reference to a target component/componentService + * @param + * @param businessInterface The business interface + * @param reference The reference to be wired + * @param component The target component + * @param service The target component service + * @return A service reference representing the wire + */ + ServiceReference getServiceReference(Class businessInterface, + RuntimeComponentReference reference, + RuntimeComponent component, + RuntimeComponentService service); + + /** + * Create a CallableReference for the given component service + * @param + * @param businessInterface + * @param component + * @param service + * @return + */ + CallableReference getCallableReference(Class businessInterface, + RuntimeComponent component, + RuntimeComponentService service); + + /** + * @param + * @param businessInterface + * @param service + * @return + */ + ServiceReference createSelfReference(Class businessInterface, ComponentService service); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java new file mode 100644 index 0000000000..44ae7f552a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.endpointresolver.EndpointResolver; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; + +/** + * The runtime component reference. Provides the bridge between the + * assembly model representation of a component reference and its runtime + * realization + * + * @version $Rev$ $Date$ + */ +public interface RuntimeComponentReference extends ComponentReference { + + /** + * Get a list of runtime wires to the reference + * + * @return The list of wires + */ + List getRuntimeWires(); + + /** + * Get the runtime wire for the given binding + * @param binding The assembly model binding + * @return The runtime wire + */ + RuntimeWire getRuntimeWire(Binding binding); + + /** + * Returns the reference binding provider associated with this + * component reference and the given binding. + * + * @param binding The assembly model binding + * @return The runtime reference binding provider + */ + ReferenceBindingProvider getBindingProvider(Binding binding); + + /** + * Sets the reference binding provider associated with this + * component reference and the given binding. + * + * @param binding The assembly model binding + * @param bindingProvider The runtime reference binding provider + */ + void setBindingProvider(Binding binding, ReferenceBindingProvider bindingProvider); + + /** + * Returns the endpoint resolver associated with this + * component reference and the given endpoint. + * + * @param endpont The assembly model endpoint + * @return The enpoint resolver + */ + EndpointResolver getEndpointResolver(Endpoint endpoint); + + /** + * Sets the endpoint resolver associated with this + * component reference and the given endpoint. + * + * @param binding The assembly model binding + * @param bindingProvider The runtime reference binding provider + */ + void setEndpointResolver(Endpoint endpoint, EndpointResolver endpointResolver); + + /** + * Add a policy provider for the given binding to the reference + * @param binding The assembly model binding + * @param policyProvider The policy handler + */ + void addPolicyProvider(Binding binding, PolicyProvider policyProvider); + + /** + * Get a list of policy providers for the given binding + * @param binding The assembly model binding + * @return A list of policy providers for the given binding + */ + List getPolicyProviders(Binding binding); + + /** + * Get the invoker for the given binding and operation + * @param binding The assembly model binding + * @param operation The assembly model operation + * @return The runtime Invoker + */ + Invoker getInvoker(Binding binding, Operation operation); + + /** + * Set the owning component + * @param component + */ + void setComponent(RuntimeComponent component); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java new file mode 100644 index 0000000000..982724d798 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +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.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; + +/** + * The runtime component service. Provides the bridge between the + * assembly model representation of a component service and its runtime + * realization + * + * @version $Rev$ $Date$ + */ +public interface RuntimeComponentService extends ComponentService { + + /** + * Get a list of runtime wires to the service + * + * @return The list of wires + */ + List getRuntimeWires(); + /** + * Get the runtime wire for the given binding + * @param binding The assembly model binding + * @return The runtime wire + */ + RuntimeWire getRuntimeWire(Binding binding); + + /** + * Get the callback wires associated with this service + * + * @return The list of runtime callback wires + */ + List getCallbackWires(); + + /** + * Returns the service binding provider associated with this + * component service and the given binding. + * + * @param binding The assembly model binding + * @return The runtime service binding provider + */ + ServiceBindingProvider getBindingProvider(Binding binding); + + /** + * Returns the service binding provider associated with this + * component service and the given binding. + * + * @param binding + * @param interfaceContract + * @return + */ + RuntimeWire getRuntimeWire(Binding binding, InterfaceContract interfaceContract); + + /** + * Sets the service binding provider associated with this + * component service and the given binding. + * + * @param binding The assembly model binding + * @param bindingProvider The runtime service binding provider + */ + void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider); + + /** + * Get the invoker for the given binding and operation + * @param binding The assembly model binding + * @param operation The assembly model operation + * @return The runtime invoker + */ + Invoker getInvoker(Binding binding, Operation operation); + + /** + * Get the invoker for the given binding and operation + * @param binding The assembly model binding + * @param interfaceContract the client interface contract + * @param operation The assembly model operation + * @return The runtime invoker + */ + Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation); + + /** + * Get the invocation chain for the given binding and operation + * @param binding The assembly model binding + * @param operation The assembly model operation + * @return The runtime invocation chain + */ + InvocationChain getInvocationChain(Binding binding, Operation operation); + + /** + * Get the invocation chain for the given binding and operation + * @param binding The assembly model binding + * @param operation The assembly model operation + * @param interfaceContract the client interface contract + * @return The runtime invocation chain + */ + InvocationChain getInvocationChain(Binding binding, InterfaceContract interfaceContract, Operation operation); + + /** + * Add a policy provider for the given binding to the service + * @param binding The assembly model binding + * @param policyProvider The policy handler + */ + void addPolicyProvider(Binding binding, PolicyProvider policyProvider); + + /** + * Get a list of policy providers for the given binding + * @param binding The assembly model binding + * @return A list of policy providers for the given binding + */ + List getPolicyProviders(Binding binding); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java new file mode 100644 index 0000000000..a2e7152202 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.runtime; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Message; + +/** + * The runtime wire interface that connects a component reference to a + * component service (or an external service) over the selected binding + * + * @version $Rev$ $Date$ + */ +public interface RuntimeWire extends Cloneable { + + /** + * Get the source of the wire + * + * @return The end point reference of the source + */ + EndpointReference getSource(); + + /** + * Get the target of the wire + * + * @return The end point reference of the target + */ + EndpointReference getTarget(); + + /** + * Rebind the runtime wire with the given target + * @param target The target endpoint reference + */ + void setTarget(EndpointReference target); + + /** + * Force the invocation chains to be rebuilt + */ + void rebuild(); + + /** + * Returns the invocation chains for service operations associated with the + * wire + * + * @return the invocation chains for service operations associated with the + * wire + */ + List getInvocationChains(); + + /** + * Lookup the invocation chain by operation + * @param operation The operation + * @return The invocation chain for the given operation + */ + InvocationChain getInvocationChain(Operation operation); + + /** + * Get the invocation chain for the binding-specific handling + * @return + */ + InvocationChain getBindingInvocationChain(); + + /** + * This invoke method assumes that the binding invocation chain is in force + * and that there will be an operation selector element there to + * determine which operation to call + * @param msg The message + * @return The result + * @throws InvocationTargetException + */ + Object invoke(Message msg) throws InvocationTargetException; + + /** + * Invoke an operation with given arguments + * @param operation The operation + * @param args The arguments + * @return The result + * @throws InvocationTargetException + */ + Object invoke(Operation operation, Object[] args) throws InvocationTargetException; + + /** + * Invoke an operation with a context message + * @param operation The operation + * @param msg The message + * @return The result + * @throws InvocationTargetException + */ + Object invoke(Operation operation, Message msg) throws InvocationTargetException; + + /** + * @return a clone of the runtime wire + * @throws CloneNotSupportedException + */ + Object clone() throws CloneNotSupportedException; +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java new file mode 100644 index 0000000000..fbb7aae467 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.runtime; + +/** + * Implementations are called after wires are decorated with policy and before they are connected. + * + * @version $Rev$ $Date$ + */ +public interface RuntimeWireProcessor { + + /** + * Process the runtime wire to add interceptors + * + * @param wire + */ + void process(RuntimeWire wire); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java new file mode 100644 index 0000000000..4b2c71b397 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.runtime; + +import java.util.List; + +/** + * Acts as a delegating WireProcessorExtensionPoint, delegating + * processing of wires after policies have been applied and source and targets + * have been connected. + * + * @version $Rev$ $Date$ + */ +public interface RuntimeWireProcessorExtensionPoint { + + /** + * Registers a wire-processor in the runtime + * + * @param processor The processor to register + */ + void addWireProcessor(RuntimeWireProcessor processor); + + /** + * De-registers a wire-processor in the runtime + * + * @param processor The processor to de-register + */ + void removeWireProcessor(RuntimeWireProcessor processor); + + /** + * Returns a list of registered wire-processors. + * + * @return The list of wire processors + */ + List getWireProcessors(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/DuplicateRecordException.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/DuplicateRecordException.java new file mode 100644 index 0000000000..7d5cd6c54b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/DuplicateRecordException.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.store; + +/** + * thrown when a record already exists during an insert operation + * + * @version $Rev$ $Date$ + */ +public class DuplicateRecordException extends StoreWriteException { + private static final long serialVersionUID = 3116253222569378447L; + + /** + * {@inheritDoc} + */ + public DuplicateRecordException() { + super(); + } + + /** + * {@inheritDoc} + */ + public DuplicateRecordException(String message, Throwable cause) { + super(message, cause); + } + + /** + * {@inheritDoc} + */ + public DuplicateRecordException(String message) { + super(message); + } + + /** + * {@inheritDoc} + */ + public DuplicateRecordException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/RecoveryListener.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/RecoveryListener.java new file mode 100644 index 0000000000..9d965a3369 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/RecoveryListener.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.store; + +import java.util.UUID; + +/** + * Implementations receive callback events during a store recovery operation + * + * @version $Rev$ $Date$ + */ +public interface RecoveryListener { + + /** + * Signals the start of a recovery + */ + void onBegin(); + + /** + * Received when a record is recovered + * + * @param id + */ + void onRecord(UUID id); + + /** + * Signals the end of recovery + */ + void onEnd(); +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/Store.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/Store.java new file mode 100644 index 0000000000..b15cde066a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/Store.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.store; + +import org.apache.tuscany.sca.event.EventPublisher; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Implementations provide a persistent store for runtime data such as conversational state. A persistent store could be + * implemented in a durable fashion using JDBC or a journaling system, or using a non-durable mechanism such as an + * in-memory map. + * + * @version $Rev$ $Date$ + */ +public interface Store extends EventPublisher { + + /* Used to indicate an the default expiration offset for records for the store */ + long DEFAULT_EXPIRATION_OFFSET = -1; + + /* Used to indicate an entry should not expire */ + long NEVER = -2; + + /** + * Adds the given record to the store. Implementations may choose different strategies for writing data such as + * write-through or write-behind. + * + * @param owner the instance owner + * @param id the unique id of the record + * @param object the object representing the data to write + * @param expiration the time in milliseconds when the entry expires + * @throws StoreWriteException if an error occurs during the write operation + */ + void insertRecord(RuntimeComponent owner, String id, Object object, long expiration) throws StoreWriteException; + + /** + * Updates a given record in the store, overwriting previous information. + * + * @param owner the instance owner + * @param id the unique id of the record + * @param object the object representing the data to write + * @param expiration the time in milliseconds when the entry expires + * @throws StoreWriteException + */ + void updateRecord(RuntimeComponent owner, String id, Object object, long expiration) throws StoreWriteException; + + /** + * Returns the deserialized object in the store corresponding to the given id + * + * @param owner the instance owner + * @param id the unique id of the record + * @return the deserialized object or null if one is not found + * @throws StoreReadException + */ + Object readRecord(RuntimeComponent owner, String id) throws StoreReadException; + + /** + * Removes a record from the store + * + * @param owner the instance owner + * @param id the unique id of the record + * @throws StoreWriteException + */ + void removeRecord(RuntimeComponent owner, String id) throws StoreWriteException; + + /** + * Removes all records from the store + * + * @throws StoreWriteException + */ + void removeRecords() throws StoreWriteException; + + /** + * Initiates a recovery operation, for example during restart after a crash + * + * @param listener the listener to receive recovery callback events + * @throws StoreReadException + */ + void recover(RecoveryListener listener) throws StoreReadException; + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreException.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreException.java new file mode 100644 index 0000000000..24eaddd3e0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreException.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.store; + + +/** + * Represents a generic exception thrown by a Store + * + * @version $Rev$ $Date$ + */ +public class StoreException extends Exception { + private static final long serialVersionUID = -319152147419962709L; + + /** + * {@inheritDoc} + */ + public StoreException() { + super(); + } + + /** + * {@inheritDoc} + */ + public StoreException(String message, Throwable cause) { + super(message, cause); + } + + /** + * {@inheritDoc} + */ + public StoreException(String message) { + super(message); + } + + /** + * {@inheritDoc} + */ + public StoreException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreExpirationEvent.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreExpirationEvent.java new file mode 100644 index 0000000000..5c1a3ca79d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreExpirationEvent.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.store; + +import org.apache.tuscany.sca.event.Event; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Fired when a store implementation expires a resource + * + * @version $Rev$ $Date$ + */ +public class StoreExpirationEvent implements Event { + private Object source; + private RuntimeComponent owner; + private Object instance; + + /** + * Constructor. + * + * @param source the source of the event + * @param owner the owner of the expiring object + * @param instance the expiring object + */ + public StoreExpirationEvent(Object source, RuntimeComponent owner, Object instance) { + assert source != null; + assert owner != null; + assert instance != null; + this.source = source; + this.owner = owner; + this.instance = instance; + } + + public Object getSource() { + return source; + } + + /** + * Returns the owner of the expiring object. + * + * @return the owner of the expiring object. + */ + public RuntimeComponent getOwner() { + return owner; + } + + /** + * Returns the expiring object. + * + * @return the expiring object. + */ + public Object getInstance() { + return instance; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreMonitor.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreMonitor.java new file mode 100644 index 0000000000..4bc7facf39 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreMonitor.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.store; + + +/** + * A generic monitor interface for services to log events + * + * @version $Rev$ $Date$ + */ +public interface StoreMonitor { + + /** + * Signals the service has started + * + * @param msg + */ + void start(String msg); + + /** + * Signals the service has been shutdown + * + * @param msg + */ + void stop(String msg); + + /** + * Fired when recovery is started + */ + + void beginRecover(); + + /** + * Fired when recovery is completed + */ + + void endRecover(); + + /** + * Fired when a record is processed during recovery + * + * @param recordId the id of the record being recovered + */ + + void recover(Object recordId); + + /** + * Signals an error event + * + * @param e the error + */ + + void error(Throwable e); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreReadException.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreReadException.java new file mode 100644 index 0000000000..c2346bddca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreReadException.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.store; + +/** + * Thrown when an error occurs reading from persistent storage + * + * @version $Rev$ $Date$ + */ +public class StoreReadException extends StoreException { + private static final long serialVersionUID = -8624542082121467271L; + + /** + * {@inheritDoc} + */ + public StoreReadException() { + super(); + } + + /** + * {@inheritDoc} + */ + public StoreReadException(String message, Throwable cause) { + super(message, cause); + } + + /** + * {@inheritDoc} + */ + public StoreReadException(String message) { + super(message); + } + + /** + * {@inheritDoc} + */ + public StoreReadException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreWriteException.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreWriteException.java new file mode 100644 index 0000000000..b37519b31c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/store/StoreWriteException.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.store; + +/** + * Thrown when an error occurs writing to persistent storage + * + * @version $Rev$ $Date$ + */ +public class StoreWriteException extends StoreException { + private static final long serialVersionUID = 5539070473942048555L; + + /** + * {@inheritDoc} + */ + public StoreWriteException() { + super(); + } + + /** + * {@inheritDoc} + */ + public StoreWriteException(String message, Throwable cause) { + super(message, cause); + } + + /** + * {@inheritDoc} + */ + public StoreWriteException(String message) { + super(message); + } + + /** + * {@inheritDoc} + */ + public StoreWriteException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java new file mode 100644 index 0000000000..d32af450ff --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.work; + +/** + * A callback interface that can be optionally used for registering + * interest in status of asynchronously scheduled unit of work. + * + * @version $Rev$ $Date$ + */ +public interface NotificationListener { + + /** + * Callback method when the unit of work is accepted. + * + * @param work Work that was accepted. + */ + void workAccepted(T work); + + /** + * Callback method when the unit of work is successfully completed. + * + * @param work Work that was successfully completed. + */ + void workCompleted(T work); + + /** + * Callback when the unit of work is started. + * + * @param work Unit of work that was started. + */ + void workStarted(T work); + + /** + * Callback when the unit of work is rejected. + * + * @param work Unit of work that was rejected. + */ + void workRejected(T work); + + /** + * Callback when the unit of work fails to complete. + * + * @param work Unit of work that failed to complete. + * @param error Error that caused the unit of work to fail. + */ + void workFailed(T work, Throwable error); + + + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java new file mode 100644 index 0000000000..b1beac78e2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.work; + +/** + * Defines the contract for scheduling asynchronous units of work. + * + *

+ * Units of work can be scheduled with an optional NotificationListener. + * If a notification listener is specified, the caller will be notified regarding the + * status of the work. The unit of work can either be completed, rejected or completed + * with an error. If the work completed with an error, the caller is notified with the + * error details. + *

+ * + * @version $Rev$ $Date$ + */ +public interface WorkScheduler { + + /** + * 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. + */ + void scheduleWork(T work, NotificationListener listener); + + /** + * 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. + */ + void scheduleWork(T work); + + /** + * Destroys the work scheduler + */ + void destroy(); + +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java new file mode 100644 index 0000000000..18ec2dfeaa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.work; + + +/** + * Exception thrown by the work scheduler in case of unexpected exceptions. + * + * @version $Rev$ $Date$ + * + * @version $Rev$ $Date$ + */ +public class WorkSchedulerException extends RuntimeException { + private static final long serialVersionUID = 1L; + + /** + * {@inheritDoc} + */ + public WorkSchedulerException() { + super(); + } + + /** + * {@inheritDoc} + */ + public WorkSchedulerException(String message, Throwable cause) { + super(message, cause); + } + + /** + * {@inheritDoc} + */ + public WorkSchedulerException(String message) { + super(message); + } + + /** + * {@inheritDoc} + */ + public WorkSchedulerException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint new file mode 100644 index 0000000000..ddd91bceac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.context.DefaultContextFactoryExtensionPoint diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint new file mode 100644 index 0000000000..91839e998f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.endpointresolver.DefaultEndpointResolverFactoryExtensionPoint diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint new file mode 100644 index 0000000000..e9de1f135f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.provider.DefaultProviderFactoryExtensionPoint diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProviderExtensionPoint b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProviderExtensionPoint new file mode 100644 index 0000000000..2f700671ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProviderExtensionPoint @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.provider.DefaultSCADefinitionsProviderExtensionPoint + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint new file mode 100644 index 0000000000..95591dca5d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.runtime.DefaultWireProcessorExtensionPoint diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java new file mode 100644 index 0000000000..3a27569a3b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java @@ -0,0 +1,208 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.context; + +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; + +import org.junit.Assert; +import org.junit.Test; + +/** + * This test case will test the class + * org.apache.tuscany.sca.context.DefaultContextFactoryExtensionPoint + * + * $Date$ $Rev$ + */ +public class DefaultContextFactoryExtensionPointTestCase { + + /** + * Tests adding/getting/removing a factory with no interfaces + */ + @Test + public void testFactoryWithNoInterfaces() { + Object factory = new FactoryWithNoInterfaces(); + Class[] ifaces = {}; + addGetRemoveFactory(factory, ifaces); + } + + /** + * Tests adding/getting/removing a factory with one interface + */ + @Test + public void testFactoryWithOneInterface() { + Object factory = new FactoryWithOneInterface(); + Class[] ifaces = { FactoryOneInterface.class }; + addGetRemoveFactory(factory, ifaces); + } + + /** + * Tests adding/getting/removing a factory with two interfaces + */ + @Test + public void testFactoryWithTwoInterfaces() { + Object factory = new FactoryWithTwoInterfaces(); + Class[] ifaces = { FactoryTwoInterfacesA.class, FactoryTwoInterfacesB.class }; + addGetRemoveFactory(factory, ifaces); + } + + /** + * Tests having multiple factories registered + */ + @Test + public void testMultipleFactories() { + // Create new factories + FactoryWithOneInterface factory1 = new FactoryWithOneInterface(); + FactoryWithTwoInterfaces factory2 = new FactoryWithTwoInterfaces(); + + ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); + + // Register the factories + DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry); + ctxFactory.addFactory(factory1); + ctxFactory.addFactory(factory2); + + // Re-get each of the factories + FactoryOneInterface regotFactory1 = ctxFactory.getFactory(FactoryOneInterface.class); + Assert.assertNotNull(regotFactory1); + Assert.assertSame(factory1, regotFactory1); + FactoryTwoInterfacesA regotFactory2A = ctxFactory.getFactory(FactoryTwoInterfacesA.class); + Assert.assertNotNull(regotFactory2A); + Assert.assertSame(factory2, regotFactory2A); + FactoryTwoInterfacesB regotFactory2B = ctxFactory.getFactory(FactoryTwoInterfacesB.class); + Assert.assertNotNull(regotFactory1); + Assert.assertSame(factory2, regotFactory2B); + } + + /** + * Tests passing in null to addFactory() + */ + @Test + public void testAddingNullFactory() { + + ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); + DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry); + try { + ctxFactory.addFactory(null); + Assert.fail("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException ex) { + // As expected + } + } + + /** + * Test passing in null to removeFactory() + */ + @Test + public void testRemovingNullFactory() { + ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); + DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry); + try { + ctxFactory.removeFactory(null); + Assert.fail("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException ex) { + // As expected + } + } + + /** + * Test passing in null to getFactory() + */ + @Test + public void testGetNullFactory() { + ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); + DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry); + try { + ctxFactory.getFactory(null); + Assert.fail("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException ex) { + // As expected + } + } + + /** + * Utility method for testing adding and removing a factory + * + * @param factory The factory class to test + * @param factoryInterfaces The list of interfaces implemented by the factory + */ + private void addGetRemoveFactory(Object factory, Class[] factoryInterfaces) { + ExtensionPointRegistry registry = new DefaultExtensionPointRegistry(); + DefaultContextFactoryExtensionPoint ctxFactory = new DefaultContextFactoryExtensionPoint(registry); + + // Make sure factory not already present + for (Class iface : factoryInterfaces) { + Assert.assertNull(ctxFactory.getFactory(iface)); + } + + // Add the factory + ctxFactory.addFactory(factory); + + // Make sure we can get the factory recently registered factory + for (Class iface : factoryInterfaces) { + Object regot = ctxFactory.getFactory(iface); + Assert.assertNotNull(regot); + Assert.assertSame(factory, regot); + } + + // Remove the factory + ctxFactory.removeFactory(factory); + + // Make sure factory is no longer registered + for (Class iface : factoryInterfaces) { + Assert.assertNull(ctxFactory.getFactory(iface)); + } + } + + /** + * Simple factory with no interfaces + */ + private class FactoryWithNoInterfaces { + } + + /** + * Simple interface for the factory with one interface + */ + private interface FactoryOneInterface { + } + + /** + * Simple factory with one interface + */ + private class FactoryWithOneInterface implements FactoryOneInterface { + } + + /** + * Simple interface for the factory with two interfaces + */ + private interface FactoryTwoInterfacesA { + } + + /** + * Simple interface for the factory with two interfaces + */ + private interface FactoryTwoInterfacesB { + } + + /** + * Simple factory with two interfaces + */ + private class FactoryWithTwoInterfaces implements FactoryTwoInterfacesA, FactoryTwoInterfacesB { + } +} diff --git a/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/event/TrueFilterTestCase.java b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/event/TrueFilterTestCase.java new file mode 100644 index 0000000000..2425133273 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.6.2/modules/core-spi/src/test/java/org/apache/tuscany/sca/event/TrueFilterTestCase.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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.event; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test case for TrueFilter + * + * @version $Rev$ $Date$ + */ +public class TrueFilterTestCase { + + /** + * Test TrueFilter matching an event + */ + @Test + public void testTrueFilterMatch() { + EventFilter filter = new TrueFilter(); + + Assert.assertTrue(filter.match(new DummyEvent())); + } + + /** + * Test TrueFilter matching null + */ + @Test + public void testTrueFilterMatchNull() { + EventFilter filter = new TrueFilter(); + + Assert.assertTrue(filter.match(null)); + } + + /** + * Dummy Event implementation for testing + */ + private class DummyEvent implements Event { + + /** + * {@inheritDoc} + */ + public Object getSource() { + throw new UnsupportedOperationException(); + } + } +} -- cgit v1.2.3