diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2013-09-26 20:33:20 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2013-09-26 20:33:20 +0000 |
commit | e5b7380c874745c989d1816b8f552504f038e1bc (patch) | |
tree | 3084133139737c821ce5384bd27fc2258e795826 /sca-java-2.x/branches/2.0/modules/sca-api | |
parent | 33b786453598495cde754c80f5a9397de68ff60e (diff) |
2.0 branch for possible maintenance release
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1526672 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/2.0/modules/sca-api')
47 files changed, 2503 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/LICENSE b/sca-java-2.x/branches/2.0/modules/sca-api/LICENSE new file mode 100644 index 0000000000..97b8a2303e --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/LICENSE @@ -0,0 +1,261 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=============================================================================== + +Apache Tuscany SCA for Java Subcomponents +=========================================: + +The Tuscany SCA for Java release includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +This module includes Java files under the following OASIS license: + +Copyright (C) OASIS(R) 2005, 2009. All Rights Reserved. +All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual +Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website. +This document and translations of it may be copied and furnished to others, and derivative works that +comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, +and distributed, in whole or in part, without restriction of any kind, provided that the above copyright +notice and this section are included on all such copies and derivative works. However, this document +itself may not be modified in any way, including by removing the copyright notice or references to OASIS, +except as needed for the purpose of developing any document or deliverable produced by an OASIS +Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR +Policy, must be followed) or as required to translate it into languages other than English. +The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors +or assigns. +This document and the information contained herein is provided on an "AS IS" basis and OASIS +DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY +WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP +RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. +OASIS requests that any OASIS Party or any other party that believes it has patent claims that would +necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard, +to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to +such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that +produced this specification. +OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of +any patent claims that would necessarily be infringed by implementations of this specification by a patent +holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR +Mode of the OASIS Technical Committee that produced this specification. OASIS may include such +claims on its website, but disclaims any obligation to do so. +OASIS takes no position regarding the validity or scope of any intellectual property or other rights that +might be claimed to pertain to the implementation or use of the technology described in this document or +the extent to which any license under such rights might or might not be available; neither does it represent +that it has made any effort to identify any such rights. Information on OASIS' procedures with respect to +rights in any document or deliverable produced by an OASIS Technical Committee can be found on the +OASIS website. Copies of claims of rights made available for publication and any assurances of licenses +to be made available, or the result of an attempt made to obtain a general license or permission for the use +of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS +Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any +information or list of intellectual property rights will at any time be complete, or that any claims in such list +are, in fact, Essential Claims. +The names "OASIS", are trademarks of OASIS, the owner and developer of this specification, and should +be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and +implementation and use of, specifications, while reserving the right to enforce its marks against misleading +uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance. + diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/META-INF/MANIFEST.MF b/sca-java-2.x/branches/2.0/modules/sca-api/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..4729aa7bc8 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0
+Export-Package: org.oasisopen.sca;version="2.0.0";uses:="javax.security.auth",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.oasisopen.sca.client;version="2.0.0"
+SCA-Version: 1.1
+Bundle-Name: Apache Tuscany SCA API
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: API classes for the Service Component Architecture
+Import-Package: javax.security.auth,org.oasisopen.sca;version="2.0.0",org.oas
+ isopen.sca.annotation;version="2.0.0",org.oasisopen.sca.client;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.api
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/NOTICE b/sca-java-2.x/branches/2.0/modules/sca-api/NOTICE new file mode 100644 index 0000000000..b01801136b --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2012 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/pom.xml b/sca-java-2.x/branches/2.0/modules/sca-api/pom.xml new file mode 100644 index 0000000000..3c571776a2 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/pom.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0</version> + <relativePath>../pom.xml</relativePath> + </parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <name>Apache Tuscany SCA API</name> + + <description>API classes for the Service Component Architecture</description> + <packaging>jar</packaging> + +</project> diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java new file mode 100644 index 0000000000..09faf1b15e --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java @@ -0,0 +1,194 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +import java.util.Collection; + +/** + * The ComponentContext interface is used to obtain contextual information + * about the SCA component which is executing at the time the API is + * invoked. + * + * <p>Note: An SCA component can obtain a service reference either through + * injection or programmatically through the ComponentContext API. Using + * reference injection is the recommended way to access a service, since it + * results in code with minimal use of middleware APIs. The ComponentContext + * API is provided for use in cases where reference injection is not possible. + */ +public interface ComponentContext { + + /** + * Returns the absolute URI of the component within the SCA domain. + * + * @return the absolute URI of the component within the SCA domain. + */ + String getURI(); + + /** + * Returns a typed service proxy object for a reference defined by the + * current component, where the reference has multiplicity 0..1 or 1..1. + * + * @param <B> the Java type that is implemented by the returned proxy + * object. + * @param businessInterface the Class object for the Java type that + * is implemented by the returned proxy object. + * @param referenceName the name of the service reference. + * @return a proxy for the reference defined by the current component. + * Returns null if the named reference has no target service + * configured. + * @exception IllegalArgumentException if the reference has multiplicity + * greater than one, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> B getService(Class<B> businessInterface, String referenceName) + throws IllegalArgumentException; + + /** + * Returns a ServiceReference object for a reference defined by the current + * component, where the reference has multiplicity 0..1 or 1..1. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param businessInterface the Class object for the Java type that + * is associated with the returned object. + * @param referenceName the name of the service reference. + * @return a ServiceReference object for a reference defined by the current + * component, where the reference has multiplicity 0..1 or 1..1. + * Returns null if the named reference has no target service + * configured. + * @exception IllegalArgumentException if the reference has multiplicity + * greater than one, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, + String referenceName) + throws IllegalArgumentException; + + /** + * Returns a list of typed service proxies for a reference defined by the current + * component, where the reference has multiplicity 0..n or 1..n. + * + * @param <B> the Java type that is implemented by the returned proxy + * objects. + * @param businessInterface the Class object for the Java type that + * is implemented by the returned proxy objects. + * @param referenceName the name of the service reference. + * @return a collection of proxy objects for the reference, one for each target + * service to which the reference is wired, where each proxy object + * implements the interface B contained in the + * <code>businessInterface</code> parameter. The collection is empty if the + * reference is not wired to any target services. + * @exception IllegalArgumentException if the reference has multiplicity + * greater other than 0..1 or 1..1, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> Collection<B> getServices(Class<B> businessInterface, + String referenceName) + throws IllegalArgumentException; + + /** + * Returns a list of typed ServiceReference objects for a reference defined by the current + * component, where the reference has multiplicity 0..n or 1..n. + * + * @param <B> the Java type that is associated with returned proxy + * objects. + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param referenceName the name of the service reference. + * @return a collection of ServiceReference objects for the reference, one for each target + * service to which the reference is wired, where each proxy object implements + * the interface B contained in the <code>businessInterface</code> parameter. + * The collection is empty if the reference is not wired to any target services. + * @exception IllegalArgumentException if the reference has multiplicity + * greater other than 0..1 or 1..1, or the component does not have the reference + * named by <code>referenceName</code>, or the interface of the named + * reference is not compatible with the interface supplied in + * the <code>businessInterface</code> parameter. + */ + <B> Collection<ServiceReference<B>> getServiceReferences( + Class<B> businessInterface, String referenceName) + throws IllegalArgumentException; + + /** + * Returns a ServiceReference that can be used to invoke this component + * over the designated service. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param businessInterface the Class object for the Java type that + * is associated with the returned object. + * @return a ServiceReference that can be used to invoke this + * component over the designated service. + * @exception IllegalArgumentException if the component does not have a service + * which implements the interface identified by the <code> + * businessinterface</code> parameter. + */ + <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) + throws IllegalArgumentException; + + /** + * Returns a ServiceReference that can be used to invoke this component + * over the designated service. The <code>serviceName</code> parameter explicitly names + * the service with which the returned ServiceReference is associated. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param businessInterface the Class object for the Java type that + * is associated with the returned object. + * @param serviceName the service name with which the returned ServiceReference + * is associated. + * @return a ServiceReference that can be used to invoke this component + * over the designated service. + * @exception IllegalArgumentException if the component does not have a service + * with the name identified by the <code>serviceName</code> parameter, or + * if the named service does not implement the interface identified by the + * <code>businessinterface</code> parameter. + */ + <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, + String serviceName) + throws IllegalArgumentException; + + /** + * Returns the value of an SCA property defined by this component. + * + * @param <B> the property type. + * @param type the Class object for the property type. + * @param propertyName the property name. + * @return The value of an SCA property defined by this component, or null if + * the property is not configured. + * @exception IllegalArgumentException if the component does not have a property + * with the name identified by the <code>propertyName</code> parameter, or + * if the named property type is not compatible with the <code>type</code> + * parameter. + */ + <B> B getProperty(Class<B> type, String propertyName) + throws IllegalArgumentException; + + /** + * Casts a type-safe reference to a ServiceReference. + * + * @param <B> the Java type of the reference that is associated with + * the returned object. + * @param target the type-safe reference proxy that implements interface <B>. + * @return a type-safe reference to a ServiceReference. + */ + <B> ServiceReference<B> cast(B target) + throws IllegalArgumentException; + + /** + * Returns the RequestContext for the current SCA service request. + * + * @return the RequestContext for the current SCA service request when + * invoked during the execution of a component service method or + * callback method. Returns null in all other cases. + */ + RequestContext getRequestContext(); +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java new file mode 100644 index 0000000000..294b254229 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java @@ -0,0 +1,90 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * The SCA Constants interface defines a number of constant values + * that are used in the SCA Java APIs and Annotations. + * + * <p> The serialized QNames are used with the @Requires annotation + * to specify a policy intent. The policy intent strings in this + * interface do not have a corresponding Java annotation, so these + * policy intents have to be specified through the use of the + * @Requires annotation. + */ +public interface Constants { + + /** + * The SCA V1.1 namespace. + */ + String SCA_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200912"; + + /** + * The serialized form of the SCA namespace for construction of QNames. + */ + String SCA_PREFIX = "{"+SCA_NS+"}"; + + /** + * The serialized QName of the serverAuthentication policy intent. + */ + String SERVERAUTHENTICATION = SCA_PREFIX + "serverAuthentication"; + /** + * The serialized QName of the clientAuthentication policy intent. + */ + String CLIENTAUTHENTICATION = SCA_PREFIX + "clientAuthentication"; + /** + * The serialized QName of the atleastOnce policy intent. + */ + String ATLEASTONCE = SCA_PREFIX + "atLeastOnce"; + /** + * The serialized QName of the atMostOnce policy intent. + */ + String ATMOSTONCE = SCA_PREFIX + "atMostOnce"; + /** + * The serialized QName of the exactlyOnce policy intent. + */ + String EXACTLYONCE = SCA_PREFIX + "exactlyOnce"; + /** + * The serialized QName of the ordered policy intent. + */ + String ORDERED = SCA_PREFIX + "ordered"; + /** + * The serialized QName of the transactedOneWay policy intent. + */ + String TRANSACTEDONEWAY = SCA_PREFIX + "transactedOneWay"; + /** + * The serialized QName of the immediateOneWay policy intent. + */ + String IMMEDIATEONEWAY = SCA_PREFIX + "immediateOneWay"; + /** + * The serialized QName of the propagatesTransaction policy intent. + */ + String PROPAGATESTRANSACTION = SCA_PREFIX + "propagatesTransaction"; + /** + * The serialized QName of the suspendsTransaction policy intent. + */ + String SUSPENDSTRANSACTION = SCA_PREFIX + "suspendsTransaction"; + /** + * The serialized QName of the asyncInvocation policy intent. + */ + String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation"; + /** + * The serialized QName of the SOAP policy intent. + */ + String SOAP = SCA_PREFIX + "SOAP"; + /** + * The serialized QName of the JMS policy intent. + */ + String JMS = SCA_PREFIX + "JMS"; + /** + * The serialized QName of the noListener policy intent. + */ + String NOLISTENER = SCA_PREFIX + "noListener"; + /** + * The serialized QName of the EJB policy intent. + */ + String EJB = SCA_PREFIX + "EJB"; + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java new file mode 100644 index 0000000000..02c575c05c --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java @@ -0,0 +1,60 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals that the ServiceReference is no longer valid. + * This can happen when the target of the reference is undeployed. + * + * This exception is not transient and therefore is unlikely to be + * resolved by retrying the operation and will most likely require + * human intervention. + */ +public class InvalidServiceException extends ServiceRuntimeException { + /** + * Constructs a InvalidServiceException with no detail message. + */ + public InvalidServiceException() { + super(); + } + + /** + * Constructs a InvalidServiceException with the specified detail + * message. + * + * @param message the detail message + */ + public InvalidServiceException(String message) { + super(message); + } + + /** + * Constructs a InvalidServiceException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public InvalidServiceException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a InvalidServiceException with the specified cause and + * a detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public InvalidServiceException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 7520492728695222145L; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java new file mode 100644 index 0000000000..d0f8a3e24d --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java @@ -0,0 +1,56 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals that the given SCA Domain does not exist. + */ + +public class NoSuchDomainException extends Exception { + /** + * Constructs a NoSuchDomainException with no detail message. + */ + public NoSuchDomainException() { + super(); + } + + /** + * Constructs a NoSuchDomainException with the specified detail + * message. + * + * @param message the detail message + */ + public NoSuchDomainException(String message) { + super(message); + } + + /** + * Constructs a NoSuchDomainException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchDomainException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a NoSuchDomainException with the specified cause and a + * detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchDomainException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 6761623124602414622L; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java new file mode 100644 index 0000000000..189e713e97 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java @@ -0,0 +1,56 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals that the given SCA service does not exist. + */ + +public class NoSuchServiceException extends Exception { + /** + * Constructs a NoSuchServiceException with no detail message. + */ + public NoSuchServiceException() { + super(); + } + + /** + * Constructs a NoSuchServiceException with the specified detail + * message. + * + * @param message the detail message + */ + public NoSuchServiceException(String message) { + super(message); + } + + /** + * Constructs a NoSuchServiceException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchServiceException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a NoSuchServiceException with the specified cause and a + * detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public NoSuchServiceException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 6761623124602414622L; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java new file mode 100644 index 0000000000..162e8e2055 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java @@ -0,0 +1,71 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +import javax.security.auth.Subject; + +/** + * The RequestContext interface is used to obtain information about + * the service invocation which is executing when one of the + * RequestContext methods is called. + */ +public interface RequestContext { + + /** + * Returns the JAAS Subject of the current request. + * + * @return The JAAS (javax.security.auth.Subject) Subject of the + * current request. Returns null if there is no JAAS + * Subject. + */ + Subject getSecuritySubject(); + + /** + * Returns the name of the service under which the current service + * method is executing. + * + * @return the name of the service under which the current service + * operation is executing, or null if called outside of the + * execution of a service method. + */ + String getServiceName(); + + /** + * Returns a service reference for the callback for the invoked service + * operation, as specified by the service caller. + * + * @param <CB> the Java interface type of the callback. + * @return a service reference for the callback as specified by + * the service caller. Returns null when called for a service + * request whose interface is not bidirectional, or when called + * during execution of a callback request, or when called outside + * the execution of a service method. + */ + <CB> ServiceReference<CB> getCallbackReference(); + + /** + * Returns a proxy for the callback for the invoked service as specified + * by the service client. + * + * @param <CB> the type of the callback proxy + * @return a proxy for the callback for the invoked service as specified + * by the service client. Returns null when called during the + * execution of a service method whose interface is not + * bidirectional, or when called during the execution of a + * callback request, or when called outside the execution of a + * service method. + */ + <CB> CB getCallback(); + + /** + * Returns a ServiceReference object for the service that is executing. + * + * @param <B> the Java interface type associated with the service reference. + * @return the ServiceReference representing the service or callback + * that is executing. Returns null if when called outside the + * execution of a service method. + */ + <B> ServiceReference<B> getServiceReference(); +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java new file mode 100644 index 0000000000..1192b16778 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ResponseDispatch.java @@ -0,0 +1,46 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +import java.util.Map; + +/** + * + * The following defines the ResponseDispatch interface, used to return a response + * message asynchronously from a service implementation method. + * + * @param <T> the type of the Response message returned by the service implementation method + */ +public interface ResponseDispatch<T> { + + /** + * Sends the response message from an asynchronous service method. + * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked + * if sendFault has previously been invoked for the same ResponseDispatch object. + * @param res an instance of the response message returned by the service operation + * @exception InvalidStateException if this method is called more than once for the same service + * operation. + */ + void sendResponse(T res); + + /** + * Sends an exception as a fault from an asynchronous service method. + * This method can only be invoked once for a given ResponseDispatch object and cannot be invoked + * if sendResponse has previously been invoked for the same ResponseDispatch object. + * @param e an instance of an exception returned by the service operation + * @exception InvalidStateException if this method is called more than once for the same service + * operation. + */ + void sendFault(Throwable e); + + /** + * Obtains the context object for the ResponseDispatch method + * @return a Map which is is the context object for the ResponseDispatch object. + * The invoker can update the context object with appropriate context information, prior to invoking + * either the sendResponse method or the sendFault method + */ + Map<String, Object> getContext(); +} + diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java new file mode 100644 index 0000000000..d2d62763fa --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java @@ -0,0 +1,36 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * The ServiceReference interface represents a component reference. + * It can be injected using the @Reference annotation + * on a field, a setter method, or constructor parameter taking the + * type ServiceReference. + * + * @param <B> the type of the service reference + */ +public interface ServiceReference<B> extends java.io.Serializable { + + /** + * Returns a type-safe reference to the target of this reference. + * The instance returned is guaranteed to implement the business + * interface for this reference. The value returned is a proxy + * to the target that implements the business interface associated + * with this reference. + * + * @return a type-safe reference to the target of this reference. + */ + B getService(); + + /** + * Returns the Java class for the business interface associated + * with this reference. + * + * @return the Java class for the business interface associated + * with this reference. + */ + Class<B> getBusinessInterface(); +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java new file mode 100644 index 0000000000..8ebaa96500 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java @@ -0,0 +1,55 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals problems in the management of SCA component execution. + */ +public class ServiceRuntimeException extends RuntimeException { + /** + * Constructs a ServiceRuntimeException with no detail message. + */ + public ServiceRuntimeException() { + super(); + } + + /** + * Constructs a ServiceRuntimeException with the specified detail + * message. + * + * @param message the detail message + */ + public ServiceRuntimeException(String message) { + super(message); + } + + /** + * Constructs a ServiceRuntimeException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a ServiceRuntimeException with the specified cause and a + * detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceRuntimeException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 6761623124602414622L; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java new file mode 100644 index 0000000000..355a84a4c3 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java @@ -0,0 +1,62 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca; + +/** + * This exception signals problems in the interaction with remote + * services. + * + * These are exceptions that can be transient, so retrying is + * appropriate. Any exception that is a ServiceRuntimeException + * that is not a ServiceUnavailableException is unlikely to be + * resolved by retrying the operation, since it most likely + * requires human intervention. + */ +public class ServiceUnavailableException extends ServiceRuntimeException { + /** + * Constructs a ServiceUnavailableException with no detail message. + */ + public ServiceUnavailableException() { + super(); + } + + /** + * Constructs a ServiceUnavailableException with the specified detail + * message. + * + * @param message the detail message + */ + public ServiceUnavailableException(String message) { + super(message); + } + + /** + * Constructs a ServiceUnavailableException with the specified detail + * message and cause. + * + * The detail message associated with <code>cause</code> is not + * automatically incorporated in this exception's detail message. + * + * @param message the detail message + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceUnavailableException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a ServiceUnavailableException with the specified cause and + * a detail message of <tt>(cause==null ? null : cause.toString())</tt>. + * + * @param cause the cause, or null if the cause is nonexistent + * or unknown + */ + public ServiceUnavailableException(Throwable cause) { + super(cause); + } + + private static final long serialVersionUID = 5750303470949048271L; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java new file mode 100644 index 0000000000..3350e9413b --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java @@ -0,0 +1,39 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @AllowsPassByReference annotation is used on implementations + * of remotable interfaces to indicate that interactions with the + * service from a client within the same address space are allowed + * to use pass by reference data exchange semantics. + * + * The implementation promises that its by-value semantics will be + * maintained even if the parameters and return values are actually + * passed by-reference. This means that the service will not modify + * any operation input parameter or return value, even after returning + * from the operation. + * + * Either a whole class implementing a remotable service or an individual + * remotable service method implementation can be annotated using the + * {@literal @AllowsPassByReference} annotation. + * + * {@literal @AllowsPassByReference} has no attributes. + */ +@Target({TYPE, METHOD, FIELD, PARAMETER}) +@Retention(RUNTIME) +public @interface AllowsPassByReference { + + boolean value() default true; +} + diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java new file mode 100644 index 0000000000..278e8ead57 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncFault.java @@ -0,0 +1,27 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @AsyncFault annotation is used to indicate the faults/exceptions which are returned by + * the asynchronous service method which it annotates. + * + */ +@Inherited +@Target({METHOD}) +@Retention(RUNTIME) +public @interface AsyncFault { + + Class<?>[] value() default {}; + +} + diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java new file mode 100644 index 0000000000..c6a4147afd --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AsyncInvocation.java @@ -0,0 +1,29 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @AsyncInvocation annotation is used to indicate that the operations of a Java interface + * uses the long-running request-response pattern as described in the SCA Assembly specification. + * + */ +@Inherited +@Target({TYPE, METHOD}) +@Retention(RUNTIME) +@Intent(AsyncInvocation.ASYNCINVOCATION) +public @interface AsyncInvocation { + String ASYNCINVOCATION = SCA_PREFIX + "asyncInvocation"; + + boolean value() default true; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java new file mode 100644 index 0000000000..2b18388c8b --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java @@ -0,0 +1,51 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Authentication annotation is used to indicate that the + * invocation requires authentication. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Authentication.AUTHENTICATION) +public @interface Authentication { + /** + * The serialized QName of the authentication policy intent, + * for use with the SCA @Requires annotation. + */ + String AUTHENTICATION = SCA_PREFIX + "authentication"; + /** + * The serialized QName of the authentication.message policy + * intent, for use with the SCA @Requires annotation. + */ + String AUTHENTICATION_MESSAGE = AUTHENTICATION + ".message"; + /** + * The serialized QName of the authentication.transport policy + * intent, for use with the SCA @Requires annotation. + */ + String AUTHENTICATION_TRANSPORT = AUTHENTICATION + ".transport"; + + /** + * List of authentication qualifiers (such as "message" + * or "transport"). + * + * @return authentication qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java new file mode 100644 index 0000000000..6893f6196a --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Authorization annotation is used to indicate that + * an authorization policy is required. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Authorization.AUTHORIZATION) +public @interface Authorization { + /** + * The serialized QName of the authorization policy intent, + * for use with the SCA @Requires annotation. + */ + String AUTHORIZATION = SCA_PREFIX + "authorization"; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java new file mode 100644 index 0000000000..cc68baaba9 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java @@ -0,0 +1,29 @@ +/* + * Copyright(C) OASIS(R) 2005, 2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Callback annotation is used to annotate a service interface + * with a callback interface, which takes the Java Class object of + * the callback interface as a parameter. + */ +@Target({TYPE, METHOD, FIELD}) +@Retention(RUNTIME) +public @interface Callback { + + /** + * The name of a Java class file containing the callback interface. + * + * @return the callback interface + */ + Class<?> value() default Void.class; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java new file mode 100644 index 0000000000..5ea768a9ca --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java @@ -0,0 +1,21 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @ComponentName annotation is used to denote a Java class field + * or setter method that is used to inject the component name. + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +public @interface ComponentName { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java new file mode 100644 index 0000000000..df5c3c502e --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java @@ -0,0 +1,50 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Confidentiality annotation is used to indicate that the + * invocation requires confidentiality. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Confidentiality.CONFIDENTIALITY) +public @interface Confidentiality { + /** + * The serialized QName of the confidentiality policy intent, + * for use with the SCA @Requires annotation. + */ + String CONFIDENTIALITY = SCA_PREFIX + "confidentiality"; + /** + * The serialized QName of the confidentiality.message policy intent, + * for use with the SCA @Requires annotation. + */ + String CONFIDENTIALITY_MESSAGE = CONFIDENTIALITY + ".message"; + /** + * The serialized QName of the confidentiality.transport policy intent, + * for use with the SCA @Requires annotation. + */ + String CONFIDENTIALITY_TRANSPORT = CONFIDENTIALITY + ".transport"; + + /** + * List of confidentiality qualifiers (such as "message" or "transport"). + * + * @return confidentiality qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java new file mode 100644 index 0000000000..0b068febd3 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java @@ -0,0 +1,23 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Constructor annotation is used to mark a particular + * constructor to use when instantiating a Java component + * implementation. If this constructor has parameters, each + * of these parameters MUST have either a @Property annotation + * or a @Reference annotation. + */ +@Target(CONSTRUCTOR) +@Retention(RUNTIME) +public @interface Constructor { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java new file mode 100644 index 0000000000..90cf9b81ce --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java @@ -0,0 +1,26 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Context annotation is used to denote a Java class field + * or a setter method that is used to inject a composite context + * for the component. The type of context to be injected is defined + * by the type of the Java class field or type of the setter method + * input argument; the type is either ComponentContext or RequestContext. + * + * The @Context annotation has no attributes. + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +public @interface Context { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java new file mode 100644 index 0000000000..b4d3cd4369 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Destroy annotation is used to denote a single Java class method + * that will be called when the scope defined for the implementation + * class ends. The method MAY have any access modifier and MUST have a + * void return type and no arguments. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Destroy { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java new file mode 100644 index 0000000000..e4cd03ea4b --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @EagerInit annotation is used to annotate the Java class of a + * COMPOSITE scoped implementation for eager initialization. When marked + * for eager initialization, the composite scoped instance is created + * when its containing component is started. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface EagerInit { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java new file mode 100644 index 0000000000..b4b420c175 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java @@ -0,0 +1,22 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Init annotation is used to denote a single Java class method + * that is called when the scope defined for the implementation class + * starts. The method MAY have any access modifier and MUST have a + * void return type and no arguments. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Init { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java new file mode 100644 index 0000000000..e9918533d9 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java @@ -0,0 +1,51 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Integrity annotation is used to indicate that the invocation + * requires integrity (ie no tampering of the messages between client + * and service). + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(Integrity.INTEGRITY) +public @interface Integrity { + /** + * The serialized QName of the integrity policy intent, + * for use with the SCA @Requires annotation. + */ + String INTEGRITY = SCA_PREFIX + "integrity"; + /** + * The serialized QName of the integrity.message policy intent, + * for use with the SCA @Requires annotation. + */ + String INTEGRITY_MESSAGE = INTEGRITY + ".message"; + /** + * The serialized QName of the integrity.transport policy intent, + * for use with the SCA @Requires annotation. + */ + String INTEGRITY_TRANSPORT = INTEGRITY + ".transport"; + + /** + * List of integrity qualifiers (such as "message" or "transport"). + * + * @return integrity qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java new file mode 100644 index 0000000000..593ae56e67 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java @@ -0,0 +1,38 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Intent annotation is used for the creation of new annotations + * for specific intents. It is not expected that the @Intent annotation + * will be used in application code. + */ +@Target({ANNOTATION_TYPE}) +@Retention(RUNTIME) +public @interface Intent { + /** + * The qualified name of the intent, in the form defined by + * javax.xml.namespace.QName.toString(). + * @return the qualified name of the intent + */ + String value() default ""; + + /** + * The XML namespace for the intent. + * @return the XML namespace for the intent + */ + String targetNamespace() default ""; + + /** + * The name of the intent within its namespace. + * @return name of the intent within its namespace + */ + String localPart() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java new file mode 100644 index 0000000000..ba6b086756 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @ManagedSharedTransaction annotation is used to indicate that + * a distributed ACID transaction is required. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(ManagedSharedTransaction.MANAGEDSHAREDTRANSACTION) +public @interface ManagedSharedTransaction { + /** + * The serialized QName of the managedSharedTransaction policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDSHAREDTRANSACTION = SCA_PREFIX + "managedSharedTransaction"; +}
\ No newline at end of file diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java new file mode 100644 index 0000000000..db28ea043c --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java @@ -0,0 +1,50 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @ManagedTransaction annotation is used to indicate the + * need for an ACID transaction environment. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(ManagedTransaction.MANAGEDTRANSACTION) +public @interface ManagedTransaction { + /** + * The serialized QName of the managedTransaction policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDTRANSACTION = SCA_PREFIX + "managedTransaction"; + /** + * The serialized QName of the managedTransaction.local policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDTRANSACTION_LOCAL = MANAGEDTRANSACTION + ".local"; + /** + * The serialized QName of the managedTransaction.global policy intent, + * for use with the SCA @Requires annotation. + */ + String MANAGEDTRANSACTION_GLOBAL = MANAGEDTRANSACTION + ".global"; + + /** + * List of managedTransaction qualifiers (such as "global" or "local"). + * + * @return managedTransaction qualifiers + */ + @Qualifier + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java new file mode 100644 index 0000000000..9a4bf86053 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @MutualAuthentication annotation is used to indicate that + * a mutual authentication policy is needed. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(MutualAuthentication.MUTUALAUTHENTICATION) +public @interface MutualAuthentication { + /** + * The serialized QName of the mutualAuthentication policy intent, + * for use with the SCA @Requires annotation. + */ + String MUTUALAUTHENTICATION = SCA_PREFIX + "mutualAuthentication"; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java new file mode 100644 index 0000000000..5c31fbc99f --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static org.oasisopen.sca.Constants.SCA_PREFIX; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @NoManagedTransaction annotation is used to indicate that + * a non-transactional environment is needed. + */ +@Inherited +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +@Intent(NoManagedTransaction.NOMANAGEDTRANSACTION) +public @interface NoManagedTransaction { + /** + * The serialized QName of the noManagedTransaction policy intent, + * for use with the SCA @Requires annotation. + */ + String NOMANAGEDTRANSACTION = SCA_PREFIX + "noManagedTransaction"; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java new file mode 100644 index 0000000000..1fbf83458e --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java @@ -0,0 +1,23 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @OneWay annotation is used on a Java interface or class method + * to indicate that invocations will be dispatched in a non-blocking + * fashion as described in the section on Asynchronous Programming. + * + * The @OneWay annotation has no attributes. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface OneWay { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java new file mode 100644 index 0000000000..2f9fe9a098 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java @@ -0,0 +1,30 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @PolicySets annotation is used to attach one or more + * SCA Policy Sets to a Java implementation class or to one + * of its subelements. + */ +@Target({TYPE, FIELD, METHOD, PARAMETER}) +@Retention(RUNTIME) +public @interface PolicySets { + /** + * Returns the policy sets to be applied. + * + * @return the policy sets to be applied + */ + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java new file mode 100644 index 0000000000..6a8c8a0e04 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java @@ -0,0 +1,58 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Property annotation is used to denote a Java class field, + * a setter method, or a constructor parameter that is used to + * inject an SCA property value. The type of the property injected, + * which can be a simple Java type or a complex Java type, is defined + * by the type of the Java class field or the type of the input + * parameter of the setter method or constructor. + * + * The @Property annotation can be used on fields, on setter methods + * or on a constructor method parameter. However, the @Property annotation + * MUST NOT be used on a class field that is declared as final. + * + * Properties can also be injected via setter methods even when + * the @Property annotation is not present. However, the @Property + * annotation must be used in order to inject a property onto a + * non-public field. In the case where there is no @Property + * annotation, the name of the property is the same as the name of the + * field or setter. + * + * Where there is both a setter method and a field for a property, the + * setter method is used. + */ +@Target({METHOD, FIELD, PARAMETER}) +@Retention(RUNTIME) +public @interface Property { + + /** + * The name of the property. For a field annotation, the default is + * the name of the field of the Java class. For a setter method annotation, + * the default is the JavaBeans property name corresponding to the setter + * method name. For a constructor parameter annotation, there is no + * default and the name attribute MUST be present. + * + * @return the name of the property + */ + String name() default ""; + + /** + * Specifies whether injection is required, defaults to true. For a + * constructor parameter annotation, this attribute MUST have the value true. + * + * @return true if injection is required + */ + boolean required() default true; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java new file mode 100644 index 0000000000..dd002d27c7 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java @@ -0,0 +1,24 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Qualifier annotation is applied to an attribute of a + * specific intent annotation definition, defined using the @Intent + * annotation, to indicate that the attribute provides qualifiers + * for the intent. The @Qualifier annotation MUST be used in a + * specific intent annotation definition where the intent has qualifiers. + */ +@Target(METHOD) +@Retention(RUNTIME) +public @interface Qualifier { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java new file mode 100644 index 0000000000..4dbf9412fc --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java @@ -0,0 +1,56 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Reference annotation type is used to annotate a Java class field, + * a setter method, or a constructor parameter that is used to inject a + * service that resolves the reference. The interface of the service + * injected is defined by the type of the Java class field or the type + * of the input parameter of the setter method or constructor. + * + * The @Reference annotation MUST NOT be used on a class field that is + * declared as final. + * + * References can also be injected via setter methods even when + * the @Reference annotation is not present. However, the @Reference + * annotation must be used in order to inject a reference onto a non-public + * field. In the case where there is no @Reference annotation, the name + * of the reference is the same as the name of the field or setter. + * + * Where there is both a setter method and a field for a reference, the + * setter method is used. + */ +@Target({METHOD, FIELD, PARAMETER}) +@Retention(RUNTIME) +public @interface Reference { + + /** + * The name of the reference. For a field annotation, the default is + * the name of the field of the Java class. For a setter method + * annotation, the default is the JavaBeans property name corresponding + * to the setter method name. For a constructor parameter annotation, + * there is no default and the name attribute MUST be present. + * + * @return the name of the reference + */ + String name() default ""; + + /** + * Specifies whether injection of service or services is required. + * Defaults to true. For a constructor parameter annotation, this + * attribute MUST have the value true. + * + * @return true if injection is required + */ + boolean required() default true; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java new file mode 100644 index 0000000000..e7ddbace7d --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java @@ -0,0 +1,26 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Remotable annotation is used to specify a Java service + * interface as remotable. A remotable service can be published + * externally as a service and must be translatable into a WSDL portType. + * + * The @Remotable annotation has no attributes. + */ +@Target({TYPE,METHOD,FIELD,PARAMETER}) +@Retention(RUNTIME) +public @interface Remotable { + +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java new file mode 100644 index 0000000000..b5d485e016 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java @@ -0,0 +1,32 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Requires annotation supports general purpose intents + * specified as strings. Users can also define specific intent + * annotations using the @Intent annotation. + */ +@Inherited +@Retention(RUNTIME) +@Target({TYPE, METHOD, FIELD, PARAMETER}) +public @interface Requires { + /** + * Returns the attached intents. + * + * @return the attached intents + */ + String[] value() default ""; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java new file mode 100644 index 0000000000..087f589168 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java @@ -0,0 +1,36 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Scope annotation MUST only be used on a service's implementation + * class. It is an error to use this annotation on an interface. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface Scope { + + /** + * The name of the scope. + * + * For 'STATELESS' implementations, a different implementation + * instance can be used to service each request. Implementation + * instances can be newly created or be drawn from a pool of instances. + * + * SCA defines the following scope names, but others can be defined + * by particular Java-based implementation types: + * STATELESS + * COMPOSITE + * The default value is STATELESS. + * + * @return the name of the scope + */ + String value() default "STATELESS"; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java new file mode 100644 index 0000000000..5c2600ff12 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java @@ -0,0 +1,45 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * The @Service annotation is used on a component implementation + * class to specify the SCA services offered by the implementation. + * + * The class need not be declared as implementing all of the + * interfaces implied by the services, but all methods of the service + * interfaces must be present. + * + * A class used as the implementation of a service is not required + * to have a @Service annotation. If a class has no @Service annotation, + * then the rules determining which services are offered and what + * interfaces those services have are determined by the specific + * implementation type. + */ +@Target(TYPE) +@Retention(RUNTIME) +public @interface Service { + + /** + * The value is an array of interface or class objects that should be + * exposed as services by this component. + * + * @return the services of this component + */ + Class<?>[] value(); + + /** + * The value is an array of strings which are used as the service names + * for each of the interfaces declared in the value array. + * + * @return the service names + */ + String[] names() default {}; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html new file mode 100644 index 0000000000..b29df75b5f --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/package.html @@ -0,0 +1,3 @@ +<body>
+Provides SCA common annotation definitions for Java.
+</body>
diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java new file mode 100644 index 0000000000..0922bf3e64 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java @@ -0,0 +1,151 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.client; + +import java.net.URI; +import java.util.Properties; + +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; +import org.oasisopen.sca.client.SCAClientFactoryFinder; +import org.oasisopen.sca.client.impl.SCAClientFactoryFinderImpl; + +/** + * The SCAClientFactory can be used by non-SCA managed code to + * lookup services that exist in a SCA Domain. + * + * @see SCAClientFactoryFinderImpl + * + * @author OASIS Open + */ + +public abstract class SCAClientFactory { + + /** + * The SCAClientFactoryFinder. + * Provides a means by which a provider of an SCAClientFactory + * implementation can inject a factory finder implementation into + * the abstract SCAClientFactory class - once this is done, future + * invocations of the SCAClientFactory use the injected factory + * finder to locate and return an instance of a subclass of + * SCAClientFactory. + */ + protected static SCAClientFactoryFinder factoryFinder; + /** + * The Domain URI of the SCA Domain which is accessed by this + * SCAClientFactory + */ + private URI domainURI; + + /** + * Prevent concrete subclasses from using the no-arg constructor + */ + private SCAClientFactory() { + } + + /** + * Constructor used by concrete subclasses + * @param domainURI - The Domain URI of the Domain accessed via this + * SCAClientFactory + */ + protected SCAClientFactory(URI domainURI) + throws NoSuchDomainException { + this.domainURI = domainURI; + } + + /** + * Gets the Domain URI of the Domain accessed via this SCAClientFactory + * @return - the URI for the Domain + */ + protected URI getDomainURI() { + return domainURI; + } + + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory + */ + public static SCAClientFactory newInstance( URI domainURI ) + throws NoSuchDomainException { + return newInstance(null, null, domainURI); + } + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param properties Properties that may be used when + * creating a new instance of the SCAClientFactory + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory instance + */ + public static SCAClientFactory newInstance(Properties properties, + URI domainURI) + throws NoSuchDomainException { + return newInstance(properties, null, domainURI); + } + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param classLoader ClassLoader that may be used when + * creating a new instance of the SCAClientFactory + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory instance + */ + public static SCAClientFactory newInstance(ClassLoader classLoader, + URI domainURI) + throws NoSuchDomainException { + return newInstance(null, classLoader, domainURI); + } + + /** + * Creates a new instance of the SCAClientFactory that can be + * used to lookup SCA Services. + * + * @param properties Properties that may be used when + * creating a new instance of the SCAClientFactory + * @param classLoader ClassLoader that may be used when + * creating a new instance of the SCAClientFactory + * @param domainURI URI of the target domain for the SCAClientFactory + * @return A new SCAClientFactory instance + */ + public static SCAClientFactory newInstance(Properties properties, + ClassLoader classLoader, + URI domainURI) + throws NoSuchDomainException { + final SCAClientFactoryFinder finder = + factoryFinder != null ? factoryFinder : + new SCAClientFactoryFinderImpl(); + final SCAClientFactory factory + = finder.find(properties, classLoader, domainURI); + return factory; + } + + /** + * Returns a reference proxy that implements the business interface <T> + * of a service in the SCA Domain handled by this SCAClientFactory + * + * @param serviceURI the relative URI of the target service. Takes the + * form componentName/serviceName. + * Can also take the extended form componentName/serviceName/bindingName + * to use a specific binding of the target service + * + * @param interfaze The business interface class of the service in the + * domain + * @param <T> The business interface class of the service in the domain + * + * @return a proxy to the target service, in the specified SCA Domain + * that implements the business interface <B>. + * @throws NoSuchServiceException Service requested was not found + */ + public abstract <T> T getService(Class<T> interfaze, String serviceURI) + throws NoSuchServiceException; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java new file mode 100644 index 0000000000..c6bcfd6c28 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactoryFinder.java @@ -0,0 +1,36 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ + +package org.oasisopen.sca.client; + +import java.net.URI; +import java.util.Properties; + +import org.oasisopen.sca.NoSuchDomainException; + +/** + * A Service Provider Interface representing a SCAClientFactory finder. + * SCA provides a default reference implementation of this interface. + * SCA runtime vendors can create alternative implementations of this + * interface that use different class loading or lookup mechanisms. + */ +public interface SCAClientFactoryFinder { + + /** + * Method for finding the SCAClientFactory for a given Domain URI using + * a specified set of properties and a a specified ClassLoader + * @param properties - properties to use - may be null + * @param classLoader - ClassLoader to use - may be null + * @param domainURI - the Domain URI - must be a valid SCA Domain URI + * @return - the SCAClientFactory or null if the factory could not be + * @throws - NoSuchDomainException if the domainURI does not reference + * a valid SCA Domain + * found + */ + SCAClientFactory find(Properties properties, + ClassLoader classLoader, + URI domainURI ) + throws NoSuchDomainException ; +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java new file mode 100644 index 0000000000..14a02c8b8f --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinderImpl.java @@ -0,0 +1,308 @@ +/* + * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved. + * OASIS trademark, IPR and other policies apply. + */ +package org.oasisopen.sca.client.impl; + +import org.oasisopen.sca.client.SCAClientFactoryFinder; + +import java.io.BufferedReader; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.net.URI; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Properties; + +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.client.SCAClientFactory; + +/** + * This is a default implementation of an SCAClientFactoryFinder which is + * used to find an implementation of the SCAClientFactory interface. + * + * @see SCAClientFactoryFinder + * @see SCAClientFactory + * + * @author OASIS Open + */ +public class SCAClientFactoryFinderImpl implements SCAClientFactoryFinder { + + /** + * The name of the System Property used to determine the SPI + * implementation to use for the SCAClientFactory. + */ + private static final String SCA_CLIENT_FACTORY_PROVIDER_KEY = + SCAClientFactory.class.getName(); + + /** + * The name of the file loaded from the ClassPath to determine + * the SPI implementation to use for the SCAClientFactory. + */ + private static final String SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE + = "META-INF/services/" + SCA_CLIENT_FACTORY_PROVIDER_KEY; + + /** + * Public Constructor + */ + public SCAClientFactoryFinderImpl() { + } + + /** + * Creates an instance of the SCAClientFactorySPI implementation. + * This discovers the SCAClientFactorySPI Implementation and instantiates + * the provider's implementation. + * + * @param properties Properties that may be used when creating a new + * instance of the SCAClient + * @param classLoader ClassLoader that may be used when creating a new + * instance of the SCAClient + * @param domainURI URI for the Domain to which this client instance is connected + * @return new instance of the SCAClientFactory + * @throws ServiceRuntimeException Failed to create SCAClientFactory + * Implementation. + */ + public SCAClientFactory find(Properties properties, + ClassLoader classLoader, + URI domainURI ) + throws NoSuchDomainException, ServiceRuntimeException { + if (classLoader == null) { + classLoader = getThreadContextClassLoader (); + } + final String factoryImplClassName = + discoverProviderFactoryImplClass(properties, classLoader); + final Class<? extends SCAClientFactory> factoryImplClass + = loadProviderFactoryClass(factoryImplClassName, + classLoader); + final SCAClientFactory factory = + instantiateSCAClientFactoryClass(factoryImplClass, + domainURI, properties ); + return factory; + } + + /** + * Gets the Context ClassLoader for the current Thread. + * + * @return The Context ClassLoader for the current Thread. + */ + private static ClassLoader getThreadContextClassLoader () { + return AccessController.doPrivileged( + new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { + return Thread.currentThread().getContextClassLoader(); + } + }); + } + + /** + * Attempts to discover the class name for the SCAClientFactorySPI + * implementation from the specified Properties, the System Properties + * or the specified ClassLoader. + * + * @param properties Properties that may be used when creating a new + * instance of the SCAClient + * @param classLoader ClassLoader that may be used when creating a new + * instance of the SCAClient + * @return The class name of the SCAClientFactorySPI implementation + * @throw ServiceRuntimeException Failed to find implementation for + * SCAClientFactorySPI. + */ + private static String + discoverProviderFactoryImplClass(Properties properties, + ClassLoader classLoader) + throws ServiceRuntimeException { + String providerClassName = + checkPropertiesForSPIClassName(properties); + if (providerClassName != null) { + return providerClassName; + } + + providerClassName = + checkPropertiesForSPIClassName(System.getProperties()); + if (providerClassName != null) { + return providerClassName; + } + + providerClassName = checkMETAINFServicesForSPIClassName(classLoader); + if (providerClassName == null) { + throw new ServiceRuntimeException( + "Failed to find implementation for SCAClientFactory"); + } + + return providerClassName; + } + + /** + * Attempts to find the class name for the SCAClientFactorySPI + * implementation from the specified Properties. + * + * @param properties Properties that may be used when creating a new + * instance of the SCAClient + * @return The class name for the SCAClientFactorySPI implementation + * or <code>null</code> if not found. + */ + private static String + checkPropertiesForSPIClassName(Properties properties) { + if (properties == null) { + return null; + } + + final String providerClassName = + properties.getProperty(SCA_CLIENT_FACTORY_PROVIDER_KEY); + if (providerClassName != null && providerClassName.length() > 0) { + return providerClassName; + } + + return null; + } + + /** + * Attempts to find the class name for the SCAClientFactorySPI + * implementation from the META-INF/services directory + * + * @param cl ClassLoader that may be used when creating a new + * instance of the SCAClient + * @return The class name for the SCAClientFactorySPI implementation or + * <code>null</code> if not found. + */ + private static String checkMETAINFServicesForSPIClassName(ClassLoader cl) + { + final URL url = + cl.getResource(SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE); + if (url == null) { + return null; + } + + InputStream in = null; + try { + in = url.openStream(); + BufferedReader reader = null; + try { + reader = + new BufferedReader(new InputStreamReader(in, "UTF-8")); + + String line; + while ((line = readNextLine(reader)) != null) { + if (!line.startsWith("#") && line.length() > 0) { + return line; + } + } + + return null; + } finally { + closeStream(reader); + } + } catch (IOException ex) { + throw new ServiceRuntimeException( + "Failed to discover SCAClientFactory provider", ex); + } finally { + closeStream(in); + } + } + + /** + * Reads the next line from the reader and returns the trimmed version + * of that line + * + * @param reader The reader from which to read the next line + * @return The trimmed next line or <code>null</code> if the end of the + * stream has been reached + * @throws IOException I/O error occurred while reading from Reader + */ + private static String readNextLine(BufferedReader reader) + throws IOException { + + String line = reader.readLine(); + if (line != null) { + line = line.trim(); + } + return line; + } + + /** + * Loads the specified SCAClientFactory Implementation class. + * + * @param factoryImplClassName The name of the SCAClientFactory + * Implementation class to load + * @param classLoader ClassLoader that may be used when creating a new + * instance of the SCAClient + * @return The specified SCAClientFactory Implementation class + * @throws ServiceRuntimeException Failed to load the SCAClientFactory + * Implementation class + */ + private static Class<? extends SCAClientFactory> + loadProviderFactoryClass(String factoryImplClassName, + ClassLoader classLoader) + throws ServiceRuntimeException { + + try { + final Class<?> providerClass = + classLoader.loadClass(factoryImplClassName); + final Class<? extends SCAClientFactory> providerFactoryClass = + providerClass.asSubclass(SCAClientFactory.class); + return providerFactoryClass; + } catch (ClassNotFoundException ex) { + throw new ServiceRuntimeException( + "Failed to load SCAClientFactory implementation class " + + factoryImplClassName, ex); + } catch (ClassCastException ex) { + throw new ServiceRuntimeException( + "Loaded SCAClientFactory implementation class " + + factoryImplClassName + + " is not a subclass of " + + SCAClientFactory.class.getName() , ex); + } + } + + /** + * Instantiate an instance of the specified SCAClientFactorySPI + * Implementation class. + * + * @param factoryImplClass The SCAClientFactorySPI Implementation + * class to instantiate. + * @param domainURI URI for the Domain to which this client instance is connected + * @param properties Properties that may be used when creating a new + * instance of the SCAClient + * @return An instance of the SCAClientFactorySPI Implementation class + * @throws ServiceRuntimeException Failed to instantiate the specified + * specified SCAClientFactorySPI Implementation class + */ + private static SCAClientFactory instantiateSCAClientFactoryClass( + Class<? extends SCAClientFactory> factoryImplClass, + URI domainURI, Properties properties) + throws NoSuchDomainException, ServiceRuntimeException { + + try { + Constructor<? extends SCAClientFactory> URIConstructor = + factoryImplClass.getConstructor(URI.class, Properties.class); + SCAClientFactory provider = + URIConstructor.newInstance( domainURI, properties ); + return provider; + } catch (Throwable ex) { + throw new ServiceRuntimeException( + "Failed to instantiate SCAClientFactory implementation class " + + factoryImplClass, ex); + } + } + + /** + * Utility method for closing Closeable Object. + * + * @param closeable The Object to close. + */ + private static void closeStream(Closeable closeable) { + if (closeable != null) { + try{ + closeable.close(); + } catch (IOException ex) { + throw new ServiceRuntimeException("Failed to close stream", + ex); + } + } + } +} diff --git a/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/package.html b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/package.html new file mode 100644 index 0000000000..236fc686a0 --- /dev/null +++ b/sca-java-2.x/branches/2.0/modules/sca-api/src/main/java/org/oasisopen/sca/package.html @@ -0,0 +1,3 @@ +<body>
+Provides SCA common API definitions for Java.
+</body>
|