diff options
Diffstat (limited to '')
20 files changed, 1338 insertions, 0 deletions
diff --git a/java/sca/modules/host-corba/LICENSE b/java/sca/modules/host-corba/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/java/sca/modules/host-corba/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/java/sca/modules/host-corba/NOTICE b/java/sca/modules/host-corba/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/java/sca/modules/host-corba/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/java/sca/modules/host-corba/pom.xml b/java/sca/modules/host-corba/pom.xml new file mode 100644 index 0000000000..499063719d --- /dev/null +++ b/java/sca/modules/host-corba/pom.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>1.4-SNAPSHOT</version> + </parent> + <artifactId>tuscany-host-corba</artifactId> + <name>Apache Tuscany SCA CORBA Host Extension Point</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core-spi</artifactId> + <version>1.4-SNAPSHOT</version> + </dependency> + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + + <configuration> + <instructions> + <Bundle-Version>${tuscany.version}</Bundle-Version> + <Bundle-SymbolicName>org.apache.tuscany.sca.host.http</Bundle-SymbolicName> + <Bundle-Description>${pom.name}</Bundle-Description> + <Export-Package>org.apache.tuscany.sca.host.http*</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java new file mode 100644 index 0000000000..7d9a3db587 --- /dev/null +++ b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba; + +import org.omg.CORBA.Object; + +/** + * CORBA Service hosting interface + */ +public interface CorbaHost { + + /** + * Registers servant in name server. + * + * @param name binding name + * @param host name server host + * @param port name server port + * @param serviceObject + * @throws CorbaHostException + */ + void registerServant(String name, String host, int port, Object serviceObject) throws CorbaHostException; + + /** + * Removes servant from name server + * + * @param name binding name + * @param host name server host + * @param port name server port + * @throws CorbaHostException + */ + void unregisterServant(String name, String host, int port) throws CorbaHostException; + + /** + * Gets reference to object + * + * @param name binding name + * @param host name server host + * @param port name server port + * @return objects reference + * @throws CorbaHostException + */ + Object getReference(String name, String host, int port) throws CorbaHostException; + +} diff --git a/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java new file mode 100644 index 0000000000..47037a01fc --- /dev/null +++ b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba; + +/** + * General exception for corba hosts operations + */ +public class CorbaHostException extends Exception { + + private static final long serialVersionUID = 1L; + + public static final String BINDING_IN_USE = "Binding name is already in use"; + public static final String NO_SUCH_OBJECT = "There is no object under given binding name"; + public static final String NO_SUCH_HOST = "Couldn't find specified host"; + public static final String NO_SUCH_PORT = "Couldn't connect to specified port"; + public static final String WRONG_NAME = "Characters used in binding name are illegal"; + + public CorbaHostException(String message) { + super(message); + } + + public CorbaHostException(Exception cause) { + super(cause); + } + + public CorbaHostException(String message, Exception cause) { + super(message, cause); + } +} diff --git a/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java new file mode 100644 index 0000000000..1488e4f80b --- /dev/null +++ b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba; + +import java.util.List; + +/** + * An extension point for CORBA hostst + */ +public interface CorbaHostExtensionPoint { + + /** + * Removes CORBA host extension + * + * @param corbaHost + */ + void addCorbaHost(CorbaHost corbaHost); + + /** + * Removes CORBA host extension + * + * @param corbaHost + */ + void removeCorbaHost(CorbaHost corbaHost); + + /** + * Gets all CORBA host extensions + * + * @return + */ + List<CorbaHost> getCorbaHosts(); + +} diff --git a/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHost.java b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHost.java new file mode 100644 index 0000000000..c8b485466e --- /dev/null +++ b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHost.java @@ -0,0 +1,128 @@ +/* + * 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.host.corba; + +import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextHelper; +import org.omg.CosNaming.NamingContextPackage.InvalidName; +import org.omg.CosNaming.NamingContextPackage.NotFound; + +/** + * Default implementation of CORBA host + */ +public class DefaultCorbaHost implements CorbaHost { + + private void validatePort(int port) throws IllegalArgumentException { + if (port < 1) { + throw new IllegalArgumentException("Port value should be > 0"); + } + } + + private void validateName(String name) throws IllegalArgumentException { + if (name == null || name.length() == 0) { + throw new IllegalArgumentException("Object name shouldn't be null"); + } + } + + private String[] getArgs(String host, int port) { + String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port}; + return args; + } + + private NamingContext getNamingContext(String host, int port) throws Exception { + ORB orb = ORB.init(getArgs(host, port), null); + org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); + return NamingContextHelper.narrow(objRef); + } + + private void handleException(Exception e) throws CorbaHostException { + // The cause of the Exception is JDK specific + if (e instanceof NotFound) { + throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT, e); + } else if (e instanceof InvalidName) { + throw new CorbaHostException(e); + } else { + throw new CorbaHostException(e); + } + } + + public void registerServant(String name, String host, int port, Object servantObject) throws CorbaHostException { + validatePort(port); + validateName(name); + if (host == null || host.length() == 0) { + host = "localhost"; + } + try { + NamingContext ncRef = getNamingContext(host, port); + NameComponent nc = new NameComponent(name, ""); + NameComponent[] path = {nc}; + try { + ncRef.resolve(path); + // no exception means that some object is already registered + // under this name, we need to crash here + throw new CorbaHostException(CorbaHostException.BINDING_IN_USE); + } catch (NotFound e) { + ncRef.bind(path, servantObject); + } + } catch (CorbaHostException e) { + throw e; + } catch (Exception e) { + handleException(e); + } + } + + public void unregisterServant(String name, String host, int port) throws CorbaHostException { + validatePort(port); + validateName(name); + if (host == null || host.length() == 0) { + host = "localhost"; + } + try { + NamingContext ncRef = getNamingContext(host, port); + NameComponent nc = new NameComponent(name, ""); + NameComponent[] path = {nc}; + ncRef.unbind(path); + } catch (Exception e) { + handleException(e); + } + } + + public Object getReference(String name, String host, int port) throws CorbaHostException { + validatePort(port); + validateName(name); + if (host == null || host.length() == 0) { + host = "localhost"; + } + Object result = null; + try { + NamingContext ncRef = getNamingContext(host, port); + NameComponent nc = new NameComponent(name, ""); + NameComponent path[] = {nc}; + result = ncRef.resolve(path); + } catch (Exception e) { + handleException(e); + } + return result; + } + +} diff --git a/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java new file mode 100644 index 0000000000..f9150f137c --- /dev/null +++ b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java @@ -0,0 +1,49 @@ +/* + * 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.host.corba; + +import java.util.ArrayList; +import java.util.List; + +/** + * Default implementation of CorbaHostExtensionPoint + */ +public class DefaultCorbaHostExtensionPoint implements CorbaHostExtensionPoint { + + private List<CorbaHost> corbaHosts = new ArrayList<CorbaHost>(); + + public DefaultCorbaHostExtensionPoint() { + CorbaHost defaultHost = new DefaultCorbaHost(); + addCorbaHost(defaultHost); + } + + public void addCorbaHost(CorbaHost host) { + corbaHosts.add(host); + } + + public void removeCorbaHost(CorbaHost host) { + corbaHosts.remove(host); + } + + public List<CorbaHost> getCorbaHosts() { + return corbaHosts; + } + +} diff --git a/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java new file mode 100644 index 0000000000..eab7af57a7 --- /dev/null +++ b/java/sca/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba; + +import org.omg.CORBA.Object; + +/** + * Default implementation of extensible CORBA host + */ +public class ExtensibleCorbaHost implements CorbaHost { + + private CorbaHostExtensionPoint chep; + + public ExtensibleCorbaHost(CorbaHostExtensionPoint chep) { + this.chep = chep; + } + + public Object getReference(String name, String host, int port) throws CorbaHostException { + if (chep.getCorbaHosts().isEmpty()) { + throw new CorbaHostException("No registered CORBA hosts"); + } + return chep.getCorbaHosts().get(0).getReference(name, host, port); + } + + public void registerServant(String name, String host, int port, Object serviceObject) throws CorbaHostException { + if (chep.getCorbaHosts().isEmpty()) { + throw new CorbaHostException("No registered CORBA hosts"); + } + registerServant(name, host, port, serviceObject); + } + + public void unregisterServant(String name, String host, int port) throws CorbaHostException { + if (chep.getCorbaHosts().isEmpty()) { + throw new CorbaHostException("No registered CORBA hosts"); + } + unregisterServant(name, host, port); + } + +} diff --git a/java/sca/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint b/java/sca/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint new file mode 100644 index 0000000000..a72bed4ea8 --- /dev/null +++ b/java/sca/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.host.corba.DefaultCorbaHostExtensionPoint
diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java new file mode 100644 index 0000000000..5b9167122f --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java @@ -0,0 +1,226 @@ +/* + * 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.host.corba.testing; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.DefaultCorbaHost; +import org.apache.tuscany.sca.host.corba.testing.general.TestInterface; +import org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper; +import org.apache.tuscany.sca.host.corba.testing.servants.TestInterfaceServant; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.omg.CORBA.ORB; + +/** + * General tests + */ +public class DefaultCorbaHostTestCase { + + private static final String LOCALHOST = "localhost"; + private static final int DEFAULT_PORT = 11100; //1050; + private static final long INTERVAL = 500; + + private static Process tn; + private static CorbaHost host; + + /** + * Spawn tnameserv under given port + * + * @param port + * @return + * @throws IOException + */ + private static Process spawnTnameserv(int port) throws IOException { + Process process = Runtime.getRuntime().exec("tnameserv -ORBInitialPort " + port); + for (int i = 0; i < 3; i++) { + try { + // Thread.sleep(SPAWN_TIME); + String[] args = {"-ORBInitialHost", LOCALHOST, "-ORBInitialPort", "" + port}; + ORB orb = ORB.init(args, null); + orb.resolve_initial_references("NameService"); + break; + } catch (Throwable e) { + try { + Thread.sleep(INTERVAL); + } catch (InterruptedException e1) { + // Ignore + } + } + } + return process; + } + + /** + * Kill previously spawned tnameserv + * + * @param p + */ + private static void killProcess(Process p) { + if (p != null) { + p.destroy(); + } + } + + @BeforeClass + public static void start() { + try { + tn = spawnTnameserv(DEFAULT_PORT); + host = new DefaultCorbaHost(); + } catch (Throwable e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @AfterClass + public static void stop() { + killProcess(tn); + } + + /** + * Tests registering, getting and unregistering CORBA object + */ + @Test + public void test_registerServant() { + try { + TestInterface servant = new TestInterfaceServant(); + host.registerServant("Test", LOCALHOST, DEFAULT_PORT, servant); + + TestInterface ref = TestInterfaceHelper.narrow(host.getReference("Test", null, DEFAULT_PORT)); + assertEquals(2, ref.getInt(2)); + + host.unregisterServant("Test", LOCALHOST, DEFAULT_PORT); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests situation when name is already registered + */ + @Test + public void test_nameAlreadyRegistered() { + try { + TestInterface servant = new TestInterfaceServant(); + host.registerServant("Test", LOCALHOST, DEFAULT_PORT, servant); + host.registerServant("Test", LOCALHOST, DEFAULT_PORT, servant); + fail(); + } catch (CorbaHostException e) { + assertTrue(e.getMessage().equals(CorbaHostException.BINDING_IN_USE)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests getting non existing reference + */ + @Test + public void test_getNonExistingObject() { + try { + host.getReference("NonExistingReference", LOCALHOST, DEFAULT_PORT); + fail(); + } catch (CorbaHostException e) { + assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests unregistering non existing reference + */ + @Test + public void test_unregisterNonExistentObject() { + try { + host.unregisterServant("NonExistingReference2", LOCALHOST, DEFAULT_PORT); + fail(); + } catch (CorbaHostException e) { + assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests registering under invalid host + */ + @Test + public void test_invalidHost() { + try { + TestInterface servant = new TestInterfaceServant(); + host.registerServant("Test", "nosuchhost", DEFAULT_PORT, servant); + fail(); + } catch (CorbaHostException e) { + // Expected + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + /** + * Tests registering under invalid port + */ + @Test + public void test_invalidPort() { + try { + TestInterface servant = new TestInterfaceServant(); + host.registerServant("Test", LOCALHOST, 9991, servant); + fail(); + } catch (CorbaHostException e) { + // Expected + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + /** + * Tests registering under invalid name + */ + @Test + @Ignore("SUN JDK 6 is happy with all kind of names") + public void test_invalidBindingName() { + try { + TestInterface servant = new TestInterfaceServant(); + host.registerServant("---", LOCALHOST, DEFAULT_PORT, servant); + fail(); + } catch (CorbaHostException e) { + assertTrue(e.getMessage().equals(CorbaHostException.WRONG_NAME)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } +} diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java new file mode 100644 index 0000000000..8d1a9db9e9 --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba.testing.general; + +/** +* org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* środa, 25 czerwiec 2008 16:19:44 CEST +*/ + +public interface TestInterface extends TestInterfaceOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface TestInterface diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java new file mode 100644 index 0000000000..fe85dc7743 --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java @@ -0,0 +1,98 @@ +/* + * 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.host.corba.testing.general; + +/** +* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* środa, 25 czerwiec 2008 16:19:44 CEST +*/ + +abstract public class TestInterfaceHelper { + private static String _id = "IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"; + + public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.host.corba.testing.general.TestInterface that) { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream(); + a.type(type()); + write(out, that); + a.read_value(out.create_input_stream(), type()); + } + + public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface extract(org.omg.CORBA.Any a) { + return read(a.create_input_stream()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + + synchronized public static org.omg.CORBA.TypeCode type() { + if (__typeCode == null) { + __typeCode = + org.omg.CORBA.ORB.init() + .create_interface_tc(org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.id(), + "TestInterface"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_TestInterfaceStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.host.corba.testing.general.TestInterface value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.host.corba.testing.general.TestInterface) + return (org.apache.tuscany.sca.host.corba.testing.general.TestInterface)obj; + else if (!obj._is_a(id())) + throw new org.omg.CORBA.BAD_PARAM(); + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub stub = + new org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.host.corba.testing.general.TestInterface unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.host.corba.testing.general.TestInterface) + return (org.apache.tuscany.sca.host.corba.testing.general.TestInterface)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub stub = + new org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java new file mode 100644 index 0000000000..305a4d7b97 --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java @@ -0,0 +1,51 @@ +/* + * 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.host.corba.testing.general; + +/** +* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* środa, 25 czerwiec 2008 16:19:44 CEST +*/ + +public final class TestInterfaceHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.host.corba.testing.general.TestInterface value = null; + + public TestInterfaceHolder() { + } + + public TestInterfaceHolder(org.apache.tuscany.sca.host.corba.testing.general.TestInterface initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.host.corba.testing.general.TestInterfaceHelper.type(); + } + +} diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java new file mode 100644 index 0000000000..f557d3e020 --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java @@ -0,0 +1,31 @@ +/* + * 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.host.corba.testing.general; + +/** +* org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* środa, 25 czerwiec 2008 16:19:44 CEST +*/ + +public interface TestInterfaceOperations { + int getInt(int arg); +} // interface TestInterfaceOperations diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java new file mode 100644 index 0000000000..f993066dab --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba.testing.general; + +/** +* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* środa, 25 czerwiec 2008 16:19:44 CEST +*/ + +public abstract class _TestInterfaceImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.host.corba.testing.general.TestInterface, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _TestInterfaceImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("getInt", new java.lang.Integer(0)); + } + + public org.omg.CORBA.portable.OutputStream _invoke(String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue()) { + case 0: // org/apache/tuscany/sca/host/corba/testing/general/TestInterface/getInt + { + int arg = in.read_long(); + int $result = (int)0; + $result = this.getInt(arg); + out = $rh.createReply(); + out.write_long($result); + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"}; + + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _TestInterfaceImplBase diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java new file mode 100644 index 0000000000..30a77deaf5 --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba.testing.general; + +/** +* org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* środa, 25 czerwiec 2008 16:19:44 CEST +*/ + +public class _TestInterfaceStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.host.corba.testing.general.TestInterface { + + public int getInt(int arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("getInt", true); + $out.write_long(arg); + $in = _invoke($out); + int $result = $in.read_long(); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream(); + String _id = $ex.getId(); + throw new org.omg.CORBA.MARSHAL(_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return getInt(arg); + } finally { + _releaseReply($in); + } + } // getInt + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/host/corba/testing/general/TestInterface:1.0"}; + + public String[] _ids() { + return (String[])__ids.clone(); + } + + private void readObject(java.io.ObjectInputStream s) throws java.io.IOException { + String str = s.readUTF(); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init(args, props).string_to_object(str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + _set_delegate(delegate); + } + + private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { + String[] args = null; + java.util.Properties props = null; + String str = org.omg.CORBA.ORB.init(args, props).object_to_string(this); + s.writeUTF(str); + } +} // class _TestInterfaceStub diff --git a/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java new file mode 100644 index 0000000000..0ebde8ef0d --- /dev/null +++ b/java/sca/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba.testing.servants; + +import org.apache.tuscany.sca.host.corba.testing.general._TestInterfaceImplBase; + +/** + * Testing servant + */ +public class TestInterfaceServant extends _TestInterfaceImplBase { + + private static final long serialVersionUID = 1L; + + public int getInt(int arg) { + return arg; + } + +} diff --git a/java/sca/modules/host-corba/src/test/resources/general.idl b/java/sca/modules/host-corba/src/test/resources/general.idl new file mode 100644 index 0000000000..f67566deb8 --- /dev/null +++ b/java/sca/modules/host-corba/src/test/resources/general.idl @@ -0,0 +1,43 @@ +/*
+ * 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.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase genera.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module host {
+ module corba {
+ module testing {
+ module general {
+ interface TestInterface {
+ long getInt(in long arg);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/java/sca/modules/pom.xml b/java/sca/modules/pom.xml index d9ec2d52d9..699f5e1aab 100644 --- a/java/sca/modules/pom.xml +++ b/java/sca/modules/pom.xml @@ -104,6 +104,7 @@ <module>endpoint</module> <module>extensibility</module> <module>extension-helper</module> + <module>host-corba</module> <module>host-ejb</module> <module>host-embedded</module> <module>host-http</module> |