From f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:42 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca-java-0.90/modules/binding-rmi/.ruleset | 190 ++++++++++++++++ .../sca-java-0.90/modules/binding-rmi/DISCLAIMER | 8 + .../sca-java-0.90/modules/binding-rmi/LICENSE | 205 +++++++++++++++++ .../sca-java-0.90/modules/binding-rmi/NOTICE | 6 + .../sca-java-0.90/modules/binding-rmi/pom.xml | 82 +++++++ .../sca/binding/rmi/DefaultRMIBindingFactory.java | 36 +++ .../sca/binding/rmi/NoRemoteMethodException.java | 40 ++++ .../sca/binding/rmi/NoRemoteServiceException.java | 38 ++++ .../apache/tuscany/sca/binding/rmi/RMIBinding.java | 55 +++++ .../sca/binding/rmi/RMIBindingConstants.java | 36 +++ .../tuscany/sca/binding/rmi/RMIBindingFactory.java | 33 +++ .../tuscany/sca/binding/rmi/RMIBindingImpl.java | 129 +++++++++++ .../tuscany/sca/binding/rmi/RMIBindingInvoker.java | 83 +++++++ .../sca/binding/rmi/RMIBindingProvider.java | 244 +++++++++++++++++++++ .../sca/binding/rmi/RMIBindingProviderFactory.java | 57 +++++ .../sca/binding/rmi/RMIModuleActivator.java | 60 +++++ .../sca/binding/rmi/RMIRuntimeException.java | 37 ++++ .../sca/binding/rmi/xml/RMIBindingProcessor.java | 169 ++++++++++++++ .../org.apache.tuscany.sca.core.ModuleActivator | 18 ++ .../src/test/java/helloworld/HelloWorldImpl.java | 37 ++++ .../test/java/helloworld/HelloWorldRmiImpl.java | 48 ++++ .../test/java/helloworld/HelloWorldRmiService.java | 29 +++ .../test/java/helloworld/HelloWorldService.java | 29 +++ .../tuscany/sca/binding/rmi/BindingTestCase.java | 59 +++++ .../rmi/NoRemoteMethodExceptionTestCase.java | 47 ++++ .../rmi/NoRemoteServiceExceptionTestCase.java | 47 ++++ .../test/resources/HelloWorldImpl.componentType | 23 ++ .../test/resources/HelloWorldRmiImpl.componentType | 27 +++ .../src/test/resources/META-INF/LICENSE.txt | 202 +++++++++++++++++ .../binding-rmi/src/test/resources/META-INF/NOTICE | 14 ++ .../src/test/resources/RMIBindingTest.composite | 44 ++++ 31 files changed, 2132 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/.ruleset create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/DISCLAIMER create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/NOTICE create mode 100755 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/DefaultRMIBindingFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingConstants.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIModuleActivator.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIRuntimeException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/xml/RMIBindingProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodExceptionTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceExceptionTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/LICENSE.txt create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/RMIBindingTest.composite (limited to 'sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi') diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/.ruleset b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/.ruleset new file mode 100644 index 0000000000..3886f07f2d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/.ruleset @@ -0,0 +1,190 @@ + + + + PMD Plugin preferences rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/DISCLAIMER b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/DISCLAIMER new file mode 100644 index 0000000000..d68a410903 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/DISCLAIMER @@ -0,0 +1,8 @@ +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/LICENSE b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/LICENSE @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/NOTICE b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/NOTICE new file mode 100644 index 0000000000..94481d6cfa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/NOTICE @@ -0,0 +1,6 @@ +${pom.name} +Copyright (c) 2005 - 2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/pom.xml b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/pom.xml new file mode 100755 index 0000000000..3953552b03 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 0.90-incubating-SNAPSHOT + ../pom.xml + + tuscany-binding-rmi + Apache Tuscany Java RMI Binding + + + + + org.apache.tuscany.sca + tuscany-core + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-rmi + 0.90-incubating-SNAPSHOT + + + + cglib + cglib-nodep + 2.1_3 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.90-incubating-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.90-incubating-SNAPSHOT + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/DefaultRMIBindingFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/DefaultRMIBindingFactory.java new file mode 100644 index 0000000000..bc92dba962 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/DefaultRMIBindingFactory.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + + +/** + * A factory for the WSDL model. + * + * @version $Rev: 526508 $ $Date: 2007-04-08 07:42:42 +0530 (Sun, 08 Apr 2007) $ + */ +public class DefaultRMIBindingFactory implements RMIBindingFactory { + + public DefaultRMIBindingFactory() { + } + + public RMIBinding createRMIBinding() { + return new RMIBindingImpl(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodException.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodException.java new file mode 100644 index 0000000000..874a2ca066 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodException.java @@ -0,0 +1,40 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +/** + * @version $Rev$ $Date$ + */ +public class NoRemoteMethodException extends RuntimeException { + + private static final long serialVersionUID = -4706646034473965972L; + + public NoRemoteMethodException() { + } + + public NoRemoteMethodException(String message) { + super(message); + } + + public NoRemoteMethodException(String message, Throwable cause) { + super(message, cause); + } + + public NoRemoteMethodException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceException.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceException.java new file mode 100644 index 0000000000..81b51c7e53 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceException.java @@ -0,0 +1,38 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +/** + */ +public class NoRemoteServiceException extends RMIRuntimeException { + private static final long serialVersionUID = 4940083022809126473L; + + public NoRemoteServiceException() { + } + + public NoRemoteServiceException(String message) { + super(message); + } + + public NoRemoteServiceException(String message, Throwable cause) { + super(message, cause); + } + + public NoRemoteServiceException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java new file mode 100644 index 0000000000..d01c26f368 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java @@ -0,0 +1,55 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import org.apache.tuscany.sca.assembly.Binding; + +/** + * Represents a binding to an RMI service. + */ +public interface RMIBinding extends Binding { + /** + * @return the host name of the RMI Service + */ + String getRmiHostName(); + + /** + * @param rmiHostName the hostname of the RMI Service + */ + void setRmiHostName(String rmiHostName); + + /** + * @return the port number for the RMI Service + */ + String getRmiPort(); + + /** + * @param rmiPort the port number for the RMI Service + */ + void setRmiPort(String rmiPort); + + /** + * @return returns the RMI Service Name + */ + String getRmiServiceName(); + + /** + * Sets the service name for the RMI Server + * @param rmiServiceName the name of the RMI service + */ + void setRmiServiceName(String rmiServiceName); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingConstants.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingConstants.java new file mode 100644 index 0000000000..e350386ca0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingConstants.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; + +public interface RMIBindingConstants { + + String BINDING_RMI = "binding.rmi"; + QName BINDING_RMI_QNAME = new QName(Constants.SCA10_NS, BINDING_RMI); + String RMI_HOST = "host"; + String RMI_PORT = "port"; + String RMI_SERVICE = "serviceName"; + + String COLON = ":"; + String FWD_SLASH = "/"; + String LOCAL_HOST = "localhost"; +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java new file mode 100644 index 0000000000..199b4053e3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +/** + * Factory for the RMI binding model. + */ +public interface RMIBindingFactory { + + /** + * Creates a new RMI binding. + * + * @return a new RMI binding + */ + RMIBinding createRMIBinding(); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingImpl.java new file mode 100644 index 0000000000..144bc3623a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingImpl.java @@ -0,0 +1,129 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + + +/** + * Represents a binding to an RMI service. + * + * @version $Rev: 490475 $ $Date: 2006-12-27 15:53:42 +0530 (Wed, 27 Dec 2006) $ + */ +public class RMIBindingImpl implements RMIBinding, RMIBindingConstants { + private String name; + private List policySets = new ArrayList(); + private List requiredIntents = new ArrayList(); + private String host; + private String port; + private String serviceName; + private List extensions = new ArrayList(); + + protected RMIBindingImpl() { + } + + public String getURI() { + return host + COLON + port + serviceName; + } + + public String getRmiHostName() { + if (host == null) { + extractFromUri(); + } + return host; + } + + public void setRmiHostName(String host) { + this.host = host; + } + + public String getRmiPort() { + if (port == null) { + extractFromUri(); + } + return port; + } + + public void setRmiPort(String port) { + this.port = port; + } + + public String getRmiServiceName() { + if (serviceName == null) { + extractFromUri(); + } + return serviceName; + } + + public void setRmiServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void setURI(String uri) { + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public List getPolicySets() { + return policySets; + } + + public List getExtensions() { + return extensions; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } + + private void extractFromUri() { + if (getURI() != null && getURI().length() > 0) { + int colonIndex = getURI().indexOf(COLON); + if (colonIndex != -1) { + setRmiHostName(getURI().substring(0, colonIndex)); + setRmiPort(getURI().substring(colonIndex + 1)); + } + + int slashIndex = getURI().indexOf(FWD_SLASH); + if (slashIndex != -1) { + if (colonIndex == -1) { + setRmiHostName(getURI().substring(0, slashIndex)); + } + setRmiServiceName(getURI().substring(slashIndex + 1)); + } else { + setRmiServiceName(getURI()); + } + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingInvoker.java new file mode 100644 index 0000000000..50ff9233ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingInvoker.java @@ -0,0 +1,83 @@ +/** + * * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.rmi.Remote; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.rmi.RMIHost; +import org.apache.tuscany.sca.rmi.RMIHostException; + +public class RMIBindingInvoker implements Invoker { + private RMIHost rmiHost; + private String host; + private String port; + private String svcName; + private Method remoteMethod; + private Remote proxy; + + public RMIBindingInvoker(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) { + this.rmiHost = rmiHost; + this.remoteMethod = remoteMethod; + this.host = host; + this.port = port; + this.svcName = svcName; + } + + public Message invoke(Message msg) { + try { + Object[] args = msg.getBody(); + Object resp = invokeTarget(args); + msg.setBody(resp); + } catch (InvocationTargetException e) { + msg.setFaultBody(e.getCause()); + } catch (Throwable e) { + msg.setFaultBody(e); + } + return msg; + } + + + public Object invokeTarget(final Object payload) throws InvocationTargetException { + try { + if (proxy == null) { + proxy = rmiHost.findService(host, port, svcName); + // proxy = Naming.lookup(serviceURI); + } + remoteMethod = proxy.getClass().getMethod(remoteMethod.getName(), remoteMethod.getParameterTypes()); + + if (payload != null && !payload.getClass().isArray()) { + return remoteMethod.invoke(proxy, payload); + } else { + return remoteMethod.invoke(proxy, (Object[])payload); + + } + } catch (RMIHostException e) { + // the method we are passed must be accessible + throw new AssertionError(e); + } catch (IllegalAccessException e) { + // the method we are passed must be accessible + throw new AssertionError(e); + } catch (NoSuchMethodException e) { + throw new AssertionError(e); + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProvider.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProvider.java new file mode 100644 index 0000000000..b22ddd936a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProvider.java @@ -0,0 +1,244 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tuscany.sca.binding.rmi; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URI; +import java.rmi.Remote; +import java.rmi.server.UnicastRemoteObject; + +import net.sf.cglib.asm.ClassWriter; +import net.sf.cglib.asm.Constants; +import net.sf.cglib.asm.Type; +import net.sf.cglib.proxy.Enhancer; +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; + +import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.rmi.RMIHost; +import org.apache.tuscany.sca.rmi.RMIHostException; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * RMIBindingProvider + */ +public class RMIBindingProvider implements ReferenceBindingProvider, ServiceBindingProvider, MethodInterceptor { + + private RuntimeComponent component; + private RuntimeComponentService service; + private RuntimeComponentReference reference; + private RMIBinding binding; + private MessageFactory messageFactory; + private RMIHost rmiHost; + + // need this member to morph the service interface to extend from Remote if + // it does not + // the base class's member variable interfaze is to be maintained to enable + // the connection + // of the service outbound to the component's inbound wire which requires + // that the service + // and the component match in their service contracts. + private Interface serviceInterface; + + public RMIBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + RMIBinding binding, + MessageFactory messageFactory, + RMIHost rmiHost) { + this.component = component; + this.service = service; + this.binding = binding; + this.rmiHost = rmiHost; + this.messageFactory = messageFactory; + } + + public RMIBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + RMIBinding binding, + RMIHost rmiHost) { + this.component = component; + this.reference = reference; + this.binding = binding; + this.rmiHost = rmiHost; + } + + public InterfaceContract getBindingInterfaceContract() { + if (service != null) + return service.getInterfaceContract(); + else + return reference.getInterfaceContract(); + } + + public void start() { + if (service != null) { + URI uri = URI.create(component.getURI() + "/" + binding.getName()); + binding.setURI(uri.toString()); + + this.serviceInterface = service.getInterfaceContract().getInterface(); + + Remote rmiProxy = createRmiService(); + + try { + rmiHost.registerService(binding.getRmiServiceName(), getPort(binding.getRmiPort()), rmiProxy); + } catch (RMIHostException e) { + throw new NoRemoteServiceException(e); + } + } + } + + public void stop() { + if (service != null) { + try { + rmiHost.unregisterService(binding.getRmiServiceName(), getPort(binding.getRmiPort())); + } catch (RMIHostException e) { + throw new NoRemoteServiceException(e.getMessage()); + } + } + } + + public Invoker createInvoker(Operation operation, boolean isCallback) { + try { + Method remoteMethod = JavaInterfaceUtil.findMethod(((JavaInterface)reference.getInterfaceContract() + .getInterface()).getJavaClass(), operation); + return new RMIBindingInvoker(rmiHost, binding.getRmiHostName(), binding.getRmiPort(), binding + .getRmiServiceName(), remoteMethod); + } catch (NoSuchMethodException e) { + throw new NoRemoteMethodException(operation.toString(), e); + } + } + + protected Remote createRmiService() { + Enhancer enhancer = new Enhancer(); + enhancer.setSuperclass(UnicastRemoteObject.class); + enhancer.setCallback(this); + Class targetJavaInterface = getTargetJavaClass(serviceInterface); + if (!Remote.class.isAssignableFrom(targetJavaInterface)) { + RMIServiceClassLoader classloader = new RMIServiceClassLoader(getClass().getClassLoader()); + final byte[] byteCode = generateRemoteInterface(targetJavaInterface); + targetJavaInterface = classloader.defineClass(byteCode); + enhancer.setClassLoader(classloader); + } + enhancer.setInterfaces(new Class[] {targetJavaInterface}); + return (Remote)enhancer.create(); + } + + // if the interface of the component whose serviceBindings must be exposed + // as RMI Service, does not + // implement java.rmi.Remote, then generate such an interface. This method + // will stop with + // just generating the bytecode. Defining the class from the byte code must + // tbe the responsibility + // of the caller of this method, since it requires a classloader to be + // created to define and load + // this interface. + protected byte[] generateRemoteInterface(Class serviceInterface) { + String interfazeName = serviceInterface.getCanonicalName(); + ClassWriter cw = new ClassWriter(false); + + String simpleName = serviceInterface.getSimpleName(); + cw.visit(Constants.V1_5, Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE, interfazeName + .replace('.', '/'), "java/lang/Object", new String[] {"java/rmi/Remote"}, simpleName + ".java"); + + StringBuffer argsAndReturn = null; + Method[] methods = serviceInterface.getMethods(); + for (Method method : methods) { + argsAndReturn = new StringBuffer("("); + Class[] paramTypes = method.getParameterTypes(); + Class returnType = method.getReturnType(); + + for (Class paramType : paramTypes) { + argsAndReturn.append(Type.getType(paramType)); + } + argsAndReturn.append(")"); + argsAndReturn.append(Type.getType(returnType)); + + cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT, + method.getName(), + argsAndReturn.toString(), + new String[] {"java/rmi/RemoteException"}, + null); + } + cw.visitEnd(); + return cw.toByteArray(); + } + + public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { + // since incoming method signatures have 'remotemethod invocation' it + // will not match with the + // wired component's method signatures. Hence need to pull in the + // corresponding method from the + // component's service contract interface to make this invocation. + + return invokeTarget(JavaInterfaceUtil.findOperation(method, serviceInterface.getOperations()), args); + } + + public Object invokeTarget(Operation op, Object[] args) throws InvocationTargetException { + + Message requestMsg = messageFactory.createMessage(); + ThreadMessageContext.setMessageContext(requestMsg); + requestMsg.setBody(args); + + Message responseMsg = service.getInvoker(binding, op).invoke(requestMsg); + + if (responseMsg.isFault()) { + throw new InvocationTargetException((Throwable)responseMsg.getBody()); + } + return responseMsg.getBody(); + } + + protected int getPort(String port) { + int portNumber = RMIHost.RMI_DEFAULT_PORT; + if (port != null && port.length() > 0) { + portNumber = Integer.decode(port); + } + + return portNumber; + } + + private Class getTargetJavaClass(Interface targetInterface) { + // TODO: right now assume that the target is always a Java + // Implementation. Need to figure out + // how to generate Java Interface in cases where the target is not a + // Java Implementation + return ((JavaInterface)targetInterface).getJavaClass(); + } + + private class RMIServiceClassLoader extends ClassLoader { + public RMIServiceClassLoader(ClassLoader parent) { + super(parent); + } + + public Class defineClass(byte[] byteArray) { + return defineClass(null, byteArray, 0, byteArray.length); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProviderFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProviderFactory.java new file mode 100644 index 0000000000..604eae3ab0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingProviderFactory.java @@ -0,0 +1,57 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tuscany.sca.binding.rmi; + +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.rmi.RMIHost; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + + +/** + * + * RMIBindingProvider + * + * @version $Rev$ $Date$ + */ +public class RMIBindingProviderFactory implements BindingProviderFactory { + + private RMIHost rmiHost; + private MessageFactory messageFactory; + + public RMIBindingProviderFactory(MessageFactory messageFactory, RMIHost rmiHost) { + this.rmiHost = rmiHost; + this.messageFactory = messageFactory; + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, RMIBinding binding) { + return new RMIBindingProvider(component, reference, binding, rmiHost); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, RMIBinding binding) { + return new RMIBindingProvider(component, service, binding, messageFactory, rmiHost); + } + + public Class getModelType() { + return RMIBinding.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIModuleActivator.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIModuleActivator.java new file mode 100644 index 0000000000..aaf77bbf66 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIModuleActivator.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.rmi; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.binding.rmi.xml.RMIBindingProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; +import org.apache.tuscany.sca.rmi.RMIHost; + +public class RMIModuleActivator implements ModuleActivator { + + public void start(ExtensionPointRegistry registry) { + + ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); + PolicyFactory policyFactory = factories.getFactory(PolicyFactory.class); + MessageFactory messageFactory = factories.getFactory(MessageFactory.class); + + StAXArtifactProcessorExtensionPoint processors = + registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + + RMIHost rmiHost = registry.getExtensionPoint(RMIHost.class); + RMIBindingFactory rmiFactory = new DefaultRMIBindingFactory(); + processors.addArtifactProcessor(new RMIBindingProcessor(assemblyFactory, policyFactory, rmiFactory)); + + ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); + providerFactories.addProviderFactory(new RMIBindingProviderFactory(messageFactory, rmiHost)); + } + + public void stop(ExtensionPointRegistry registry) { + } + + public Object[] getExtensionPoints() { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIRuntimeException.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIRuntimeException.java new file mode 100644 index 0000000000..79382c75c6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIRuntimeException.java @@ -0,0 +1,37 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + + +/** + */ +public abstract class RMIRuntimeException extends RuntimeException { + protected RMIRuntimeException() { + } + + protected RMIRuntimeException(String message) { + super(message); + } + + protected RMIRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + protected RMIRuntimeException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/xml/RMIBindingProcessor.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/xml/RMIBindingProcessor.java new file mode 100644 index 0000000000..0a33e00548 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/xml/RMIBindingProcessor.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.rmi.xml; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import java.util.List; +import java.util.StringTokenizer; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.binding.rmi.RMIBinding; +import org.apache.tuscany.sca.binding.rmi.RMIBindingConstants; +import org.apache.tuscany.sca.binding.rmi.RMIBindingFactory; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +public class RMIBindingProcessor implements + StAXArtifactProcessor, RMIBindingConstants { + + private RMIBindingFactory rmiBindingFactory; + private PolicyFactory policyFactory; + + public RMIBindingProcessor(AssemblyFactory assemblyFactory, + PolicyFactory policyFactory, + RMIBindingFactory rmiBindingFactory) { + this.policyFactory = policyFactory; + this.rmiBindingFactory = rmiBindingFactory; + } + + public RMIBinding read(XMLStreamReader reader) throws ContributionReadException { + try { + RMIBinding rmiBinding = rmiBindingFactory.createRMIBinding(); + + //Read policies + readPolicies(rmiBinding, reader); + + //Read host, port and service name + rmiBinding.setRmiHostName(reader.getAttributeValue(null, RMI_HOST)); + rmiBinding.setRmiPort(reader.getAttributeValue(null, RMI_PORT)); + rmiBinding.setRmiServiceName(reader.getAttributeValue(null, RMI_SERVICE)); + + // Skip to end element + while (reader.hasNext()) { + if (reader.next() == END_ELEMENT && BINDING_RMI_QNAME.equals(reader.getName())) { + break; + } + } + return rmiBinding; + + } catch (XMLStreamException e) { + throw new ContributionReadException(e); + } + } + + public void write(RMIBinding rmiBinding, XMLStreamWriter writer) throws ContributionWriteException { + try { + // Write a + writer.writeStartElement(Constants.SCA10_NS, BINDING_RMI); + + if (rmiBinding.getRmiHostName() != null) { + writer.writeAttribute(RMIBindingConstants.RMI_HOST, rmiBinding.getRmiHostName()); + } + + if (rmiBinding.getRmiPort() != null) { + writer.writeAttribute(RMIBindingConstants.RMI_PORT, rmiBinding.getRmiPort()); + } + + if (rmiBinding.getRmiServiceName() != null) { + writer.writeAttribute(RMIBindingConstants.RMI_SERVICE, rmiBinding.getRmiServiceName()); + } + writer.writeEndElement(); + + } catch (XMLStreamException e) { + throw new ContributionWriteException(e); + } + } + + public void resolve(RMIBinding model, ModelResolver resolver) throws ContributionResolveException { + } + + public QName getArtifactType() { + return RMIBindingConstants.BINDING_RMI_QNAME; + } + + public Class getModelType() { + return RMIBinding.class; + } + + /** + * Reads policy intents and policy sets. + * @param attachPoint + * @param reader + */ + private void readPolicies(PolicySetAttachPoint attachPoint, XMLStreamReader reader) { + String value = reader.getAttributeValue(null, Constants.REQUIRES); + if (value != null) { + List requiredIntents = attachPoint.getRequiredIntents(); + for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { + QName qname = getQNameValue(reader, tokens.nextToken()); + Intent intent = policyFactory.createIntent(); + intent.setName(qname); + requiredIntents.add(intent); + } + } + + value = reader.getAttributeValue(null, Constants.POLICY_SETS); + if (value != null) { + List policySets = attachPoint.getPolicySets(); + for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { + QName qname = getQNameValue(reader, tokens.nextToken()); + PolicySet policySet = policyFactory.createPolicySet(); + policySet.setName(qname); + policySets.add(policySet); + } + } + } + + /** + * Returns a qname from a string. + * @param reader + * @param value + * @return + */ + private QName getQNameValue(XMLStreamReader reader, String value) { + if (value != null) { + int index = value.indexOf(':'); + String prefix = index == -1 ? "" : value.substring(0, index); + String localName = index == -1 ? value : value.substring(index + 1); + String ns = reader.getNamespaceContext().getNamespaceURI(prefix); + if (ns == null) { + ns = ""; + } + return new QName(ns, localName, prefix); + } else { + return null; + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator new file mode 100644 index 0000000000..9cc4a2ed7f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# Implementation class for the ExtensionActivator +org.apache.tuscany.sca.binding.rmi.RMIModuleActivator diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..acb81a00f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Service; + + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldImpl implements HelloWorldService { + + public String sayHello(String name) { + return "Hello from the RMI Service to - " + name; + } + + public String sayHi(String name, String greeter) { + return "Hi from " + greeter + " in RMI Service to - " + name; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java new file mode 100644 index 0000000000..73aedc3b6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldRmiService.class) +public class HelloWorldRmiImpl implements HelloWorldRmiService { + private HelloWorldService extService; + + public HelloWorldService getExtService() { + return extService; + } + + @Reference + public void setExtService(HelloWorldService extService) { + this.extService = extService; + } + + public String sayRmiHello(String name) { + return extService.sayHello(name) + " thro the RMI Reference"; + } + + public String sayRmiHi(String name, String greeter) { + return extService.sayHi(name, greeter) + " thro the RMI Reference"; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java new file mode 100644 index 0000000000..f636c8f7d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +public interface HelloWorldRmiService { + + String sayRmiHello(String name); + String sayRmiHi(String name, String greeter); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..d5dc509f3e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/helloworld/HelloWorldService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +public interface HelloWorldService { + + String sayHello(String name); + String sayHi(String name, String greeter); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java new file mode 100644 index 0000000000..e9991185a8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import helloworld.HelloWorldRmiService; +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class BindingTestCase { + private static HelloWorldRmiService helloWorldRmiService; + private static SCADomain domain; + + @Test + public void testRmiService() { + System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!")); + Assert.assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference", + helloWorldRmiService.sayRmiHello("Tuscany World!")); + + System.out.println(helloWorldRmiService.sayRmiHi("Tuscany World!", "Apache World")); + + Assert.assertEquals("Hi from Apache World in RMI Service to - Tuscany World! thro the RMI Reference", + helloWorldRmiService.sayRmiHi("Tuscany World!", "Apache World")); + } + + + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("RMIBindingTest.composite"); + helloWorldRmiService = + domain.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodExceptionTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodExceptionTestCase.java new file mode 100644 index 0000000000..3f9aa9950f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteMethodExceptionTestCase.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import junit.framework.TestCase; + +public class NoRemoteMethodExceptionTestCase extends TestCase { + + public void testNoArgs() { + assertNotNull(new NoRemoteMethodException()); + } + + public void testMsgArg() { + NoRemoteMethodException e = new NoRemoteMethodException("foo"); + assertEquals("foo", e.getMessage()); + } + + public void test2Args() { + Exception cause = new Exception(); + NoRemoteMethodException e = new NoRemoteMethodException("foo", cause); + assertEquals("foo", e.getMessage()); + assertEquals(cause, e.getCause()); + } + + public void testCauseArgs() { + Exception cause = new Exception(); + NoRemoteMethodException e = new NoRemoteMethodException(cause); + assertEquals(cause, e.getCause()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceExceptionTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceExceptionTestCase.java new file mode 100644 index 0000000000..d4de9996de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/java/org/apache/tuscany/sca/binding/rmi/NoRemoteServiceExceptionTestCase.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.rmi; + +import junit.framework.TestCase; + +public class NoRemoteServiceExceptionTestCase extends TestCase { + + public void testNoArgs() { + assertNotNull(new NoRemoteServiceException()); + } + + public void testMsgArg() { + NoRemoteServiceException e = new NoRemoteServiceException("foo"); + assertEquals("foo", e.getMessage()); + } + + public void test2Args() { + Exception cause = new Exception(); + NoRemoteServiceException e = new NoRemoteServiceException("foo", cause); + assertEquals("foo", e.getMessage()); + assertEquals(cause, e.getCause()); + } + + public void testCauseArgs() { + Exception cause = new Exception(); + NoRemoteServiceException e = new NoRemoteServiceException(cause); + assertEquals(cause, e.getCause()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType new file mode 100644 index 0000000000..224a68f88d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType @@ -0,0 +1,23 @@ + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType new file mode 100644 index 0000000000..a83e7e6d1d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..0084319535 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/LICENSE.txt @@ -0,0 +1,202 @@ + + 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, serviceDefinition marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/NOTICE new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/META-INF/NOTICE @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/RMIBindingTest.composite b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/RMIBindingTest.composite new file mode 100644 index 0000000000..9f7b2548bf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/binding-rmi/src/test/resources/RMIBindingTest.composite @@ -0,0 +1,44 @@ + + + + + + + + HelloWorldServiceComponent + + + + + + + + + + + + + + + + + -- cgit v1.2.3