diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-17 05:21:11 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-17 05:21:11 +0000 |
commit | b0499f2d27297d66423a4bc04959f75e884be435 (patch) | |
tree | f669fe9df900cf97a3a06d7360fcd6b3e98767c2 | |
parent | 3ded433af820aae000913fa0305380a0f7988c2c (diff) |
Port binding.corba from 1.x to 2.x
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@924158 13f79535-47bb-0310-9956-ffa450edef68
283 files changed, 23842 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/LICENSE b/sca-java-2.x/trunk/modules/binding-corba-runtime/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/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-2.x/trunk/modules/binding-corba-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-corba-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..395aa218a3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/META-INF/MANIFEST.MF @@ -0,0 +1,35 @@ +Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.corba.provider.meta;ve
+ rsion="1.4",org.apache.tuscany.sca.binding.corba.provider.types.util;
+ version="2.0.0",org.apache.tuscany.sca.binding.corba.provider.util;vers
+ ion="1.4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA CORBA Binding Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397143078
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA CORBA Binding Runtime
+Import-Package: javax.xml.namespace;resolution:=optional,
+ net.sf.cglib.proxy,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.corba;version="2.0.0",
+ org.apache.tuscany.sca.context;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.java;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.invocation;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.provider;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
+ org.omg.CORBA,
+ org.omg.CORBA.portable,
+ org.omg.CosNaming;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.corba.runtime
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/NOTICE b/sca-java-2.x/trunk/modules/binding-corba-runtime/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/pom.xml b/sca-java-2.x/trunk/modules/binding-corba-runtime/pom.xml new file mode 100644 index 0000000000..77b1a02b55 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/pom.xml @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-binding-corba-runtime</artifactId> + <name>Apache Tuscany SCA CORBA Binding Runtime</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-interface-java</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-corba</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba-jse</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>2.2</version> + <scope>compile</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Unfortunately the idlj maven plugin only works with SUN JDK --> + <!-- + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>target/idl-source</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>idlj-maven-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <configuration> + <debug>true</debug> + <compiler>idlj</compiler> + <sources> + <source> + <includes> + <include>tester.idl</include> + </includes> + <emitStubs>true</emitStubs> + <emitSkeletons>true</emitSkeletons> + </source> + </sources> + <sourceDirectory>${basedir}/src/test/resources</sourceDirectory> + <outputDirectory>${project.build.directory}/idl-source</outputDirectory> + </configuration> + <dependencies> + <dependency> + <groupId>com.sun</groupId> + <artifactId>tools</artifactId> + <version>1.5.0</version> + <scope>system</scope> + <systemPath>${java.home}/../lib/tools.jar</systemPath> + </dependency> + </dependencies> + </plugin> + --> + + </plugins> + </build> + +</project> diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.java new file mode 100644 index 0000000000..86cb4afb7c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaBindingProviderFactory.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider; + +import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint; +import org.apache.tuscany.sca.host.corba.ExtensibleCorbaHost; +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.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaBindingProviderFactory implements BindingProviderFactory<CorbaBinding> { + + private CorbaHostExtensionPoint chep; + private ExtensibleCorbaHost host; + + public CorbaBindingProviderFactory(ExtensionPointRegistry registry) { + chep = registry.getExtensionPoint(CorbaHostExtensionPoint.class); + host = new ExtensibleCorbaHost(chep); + } + /** + * @see org.apache.tuscany.sca.provider.BindingProviderFactory#createReferenceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding) + */ + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference epr) { + return new CorbaReferenceBindingProvider(epr, host); + } + + /** + * @see org.apache.tuscany.sca.provider.BindingProviderFactory#createServiceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) + */ + public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint ep) { + return new CorbaServiceBindingProvider(ep, host); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class<CorbaBinding> getModelType() { + return CorbaBinding.class; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.java new file mode 100644 index 0000000000..0ad3b2240e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaInvoker.java @@ -0,0 +1,89 @@ +/* + * 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.corba.provider; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.Map; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaRequest; +import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaResponse; +import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.omg.CORBA.Object; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaInvoker implements Invoker { + + private Object remoteObject; + private Class<?> referenceClass; + private Map<Method, String> operationsMap; + private Map<Operation, Method> operationMethodMapping; + + public CorbaInvoker(RuntimeComponentReference reference, Object remoteObject, Class<?> referenceClass, Map<Method, String> operationsMap) { + this.remoteObject = remoteObject; + this.referenceClass = referenceClass; + this.operationsMap = operationsMap; + this.operationMethodMapping = OperationMapper.mapOperationToMethod(reference.getInterfaceContract().getInterface().getOperations(), referenceClass); + } + + /** + * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message) + */ + public Message invoke(Message msg) { + try { + DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName()); + request.setReferenceClass(referenceClass); + request.setOperationsMap(operationsMap); + if (msg.getOperation().getOutputType() != null) { + Annotation[] notes = operationMethodMapping.get(msg.getOperation()).getAnnotations(); + request.setOutputType(msg.getOperation().getOutputType().getPhysical(), notes); + } + java.lang.Object[] args = msg.getBody(); + if (args != null) { + Annotation[][] notes = operationMethodMapping.get(msg.getOperation()).getParameterAnnotations(); + for (int i = 0; i < args.length; i++) { + request.addArgument(args[i], notes[i]); + } + } + if (msg.getOperation().getFaultTypes() != null) { + for (DataType<?> type : msg.getOperation().getFaultTypes()) { + request.addExceptionType(type.getPhysical()); + } + } + DynaCorbaResponse response = request.invoke(); + msg.setBody(response.getContent()); + } catch (RequestConfigurationException e) { + throw new ServiceRuntimeException(e); + } catch (Exception e) { + msg.setFaultBody(e); + } + return msg; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java new file mode 100644 index 0000000000..19ab58cc74 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaReferenceBindingProvider.java @@ -0,0 +1,101 @@ +/* + * 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.corba.provider; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper; +import org.apache.tuscany.sca.host.corba.CorbaHost; +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.invocation.Invoker; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.omg.CORBA.Object; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaReferenceBindingProvider implements ReferenceBindingProvider { + + private static final Logger logger = Logger.getLogger(CorbaReferenceBindingProvider.class.getName()); + private CorbaBinding binding; + private CorbaHost host; + private RuntimeComponentReference reference; + private Object remoteObject; + private Class<?> referenceClass; + private Map<Method, String> operationsMap = null; + + public CorbaReferenceBindingProvider(RuntimeEndpointReference epr, CorbaHost host) { + this.binding = (CorbaBinding) epr.getBinding(); + this.host = host; + this.reference = (RuntimeComponentReference) epr.getReference(); + this.referenceClass = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(); + operationsMap = OperationMapper.mapMethodToOperationName(referenceClass); + } + + /** + * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#createInvoker(org.apache.tuscany.sca.interfacedef.Operation) + */ + public Invoker createInvoker(Operation operation) { + try { + if (remoteObject == null) { + remoteObject = host.lookup(binding.getCorbaname()); + } + return new CorbaInvoker(reference, remoteObject, referenceClass, operationsMap); + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during creating CORBA invoker", e); + } + return null; + } + + /** + * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#getBindingInterfaceContract() + */ + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + /** + * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#start() + */ + public void start() { + } + + /** + * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#stop() + */ + public void stop() { + } + + /** + * @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#supportsOneWayInvocation() + */ + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java new file mode 100644 index 0000000000..0aa2e7394a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/CorbaServiceBindingProvider.java @@ -0,0 +1,94 @@ +/* + * 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.corba.provider; + +import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.binding.corba.provider.service.ComponentInvocationProxy; +import org.apache.tuscany.sca.binding.corba.provider.service.DynaCorbaServant; +import org.apache.tuscany.sca.binding.corba.provider.service.InvocationProxy; +import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils; +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeEndpoint endpoint; + private CorbaBinding binding; + private CorbaHost host; + // private RuntimeComponentService service; + private DynaCorbaServant servant; + + public CorbaServiceBindingProvider(RuntimeEndpoint ep, CorbaHost host) { + this.endpoint = ep; + // this.service = (RuntimeComponentService) ep.getService(); + this.binding = (CorbaBinding) ep.getBinding(); + this.host = host; + } + + /** + * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#getBindingInterfaceContract() + */ + public InterfaceContract getBindingInterfaceContract() { + return endpoint.getBindingInterfaceContract(); + } + + /** + * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#start() + */ + public void start() { + try { + Class<?> javaClass = ((JavaInterface)endpoint.getComponentTypeServiceInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy(endpoint, javaClass); + servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + servant.setIds(new String[] {binding.getId()}); + host.registerServant(binding.getCorbaname(), servant); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + + } + + /** + * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#stop() + */ + public void stop() { + try { + host.unregisterServant(binding.getCorbaname()); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + + } + + /** + * @see org.apache.tuscany.sca.provider.ServiceBindingProvider#supportsOneWayInvocation() + */ + public boolean supportsOneWayInvocation() { + return false; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java new file mode 100644 index 0000000000..b3569e43b9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/CorbaException.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.exceptions; + +/** + * @version $Rev$ $Date$ + * Represents CORBA SystemException + */ +public class CorbaException extends Exception { + + private static final long serialVersionUID = 1L; + + public CorbaException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java new file mode 100644 index 0000000000..a554f56035 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/exceptions/RequestConfigurationException.java @@ -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. + */ + +package org.apache.tuscany.sca.binding.corba.provider.exceptions; + +/** + * @version $Rev$ $Date$ + */ +public class RequestConfigurationException extends Exception { + + private static final long serialVersionUID = 1L; + private String objectId; + + public RequestConfigurationException(String message, String objectId) { + super(message + ", object id was: " + objectId); + this.objectId = objectId; + } + + public RequestConfigurationException(String message) { + super(message); + } + + public String getType() { + return objectId; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java new file mode 100644 index 0000000000..823db1e748 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaArray.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.meta; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * @version $Rev$ $Date$ + * Declares CORBA arrays lengths + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CorbaArray { + + int[] value(); + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.java new file mode 100644 index 0000000000..feb6627e25 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElement.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.meta; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * @version $Rev$ $Date$ Declares CORBA union object + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CorbaUnionElement { + + // number of option in switch clause + int optionNumber() default -1; + + // type of element + CorbaUnionElementType type(); + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.java new file mode 100644 index 0000000000..1e7a0087e0 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/meta/CorbaUnionElementType.java @@ -0,0 +1,28 @@ +/* + * 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.corba.provider.meta; + +/** + * @version $Rev$ $Date$ + * Types for union element + */ +public enum CorbaUnionElementType { + discriminator, defaultOption, option; +}
\ No newline at end of file diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java new file mode 100644 index 0000000000..e7d0b8b91b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaRequest.java @@ -0,0 +1,253 @@ +/* + * 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.corba.provider.reference; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.CorbaException; +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeCreator; +import org.apache.tuscany.sca.binding.corba.provider.types.util.TypeHelpersProxy; +import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils; +import org.apache.tuscany.sca.binding.corba.provider.util.MethodFinder; +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.Object; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.portable.ApplicationException; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.ObjectImpl; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ Represents single CORBA request + */ +public class DynaCorbaRequest { + + private TypeTree returnTree; + private Map<String, TypeTree> exceptions = new HashMap<String, TypeTree>(); + private InputStream inputStream; + private ObjectImpl remoteObject; + private String operation; + private List<java.lang.Object> arguments = new ArrayList<java.lang.Object>(); + private List<TypeTree> argumentsTypes = new ArrayList<TypeTree>(); + private Class<?> referenceClass; + private Map<Method, String> operationsMap; + + /** + * Creates request. + * + * @param ObjectremoteObject remote object reference + * @param operation operation to invoke + * @param scaBindingRules apply SCA default binding mapping rules + */ + public DynaCorbaRequest(Object remoteObject, String operation) { + this.remoteObject = (ObjectImpl)remoteObject; + this.operation = operation; + } + + /** + * Sets class which will be backed by this reference request + * @param referenceClass + */ + public void setReferenceClass(Class<?> referenceClass) { + this.referenceClass = referenceClass; + } + + /** + * Sets method to operation names mapping + * @param operationsMap + */ + public void setOperationsMap(Map<Method, String> operationsMap) { + this.operationsMap = operationsMap; + } + + /** + * Adds operation argument - stores arguments and caches its TypeTree. Annotations will be set to null by default. + * + * @param argument + */ + public void addArgument(java.lang.Object argument) throws RequestConfigurationException { + addArgument(argument, null); + } + + /** + * Adds operation argument - stores arguments and caches its TypeTree + * + * @param argument + */ + public void addArgument(java.lang.Object argument, Annotation[] notes) throws RequestConfigurationException { + TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass(), notes); + argumentsTypes.add(tree); + arguments.add(argument); + } + + /** + * Passing stored arguments to CORBA communication output stream + * + * @param outputStream + * @throws RequestConfigurationException + */ + private void passArguments(OutputStream outputStream) throws RequestConfigurationException { + for (int i = 0; i < arguments.size(); i++) { + TypeTree tree = argumentsTypes.get(i); + TypeHelpersProxy.write(tree.getRootNode(), outputStream, arguments.get(i)); + } + } + + /** + * Sets return type for operation. Annotations will be set to null by default. + * + * @param forClass + */ + public void setOutputType(Class<?> forClass) throws RequestConfigurationException { + setOutputType(forClass, null); + } + + /** + * Sets return type for operation + * + * @param forClass + */ + public void setOutputType(Class<?> forClass, Annotation[] notes) throws RequestConfigurationException { + returnTree = TypeTreeCreator.createTypeTree(forClass, notes); + } + + /** + * Configures possible exceptions + * + * @param forClass + */ + public void addExceptionType(Class<?> forClass) throws RequestConfigurationException { + TypeTree tree = TypeTreeCreator.createTypeTree(forClass, null); + String exceptionId = Utils.getTypeId(forClass); + exceptions.put(exceptionId, tree); + } + + /** + * Handles application excpeition. + * + * @param ae occured exception + * @throws Exception + */ + private void handleApplicationException(ApplicationException ae) throws Exception { + try { + if (exceptions.size() == 0) { + RequestConfigurationException exception = + new RequestConfigurationException( + "ApplicationException occured, but no exception type was specified.", + ae.getId()); + throw exception; + } + InputStream is = ae.getInputStream(); + String exceptionId = is.read_string(); + TypeTree tree = exceptions.get(exceptionId); + if (tree == null) { + RequestConfigurationException exception = + new RequestConfigurationException( + "ApplicationException occured, but no such exception was defined", + ae.getId()); + throw exception; + } else { + Exception ex = (Exception)TypeHelpersProxy.read(tree.getRootNode(), is); + throw ex; + } + } catch (Exception e) { + throw e; + } + } + + /** + * Handles exceptions generated by CORBA API + * + * @param se + */ + private void handleSystemException(SystemException se) throws Exception { + if (se instanceof BAD_OPERATION) { + throw new CorbaException("Bad operation name: " + operation, se); + } else if (se instanceof BAD_PARAM) { + throw new CorbaException("Bad parameter", se); + } else { + // TODO: handle more system exception types + throw new CorbaException(se.getMessage(), se); + } + } + + /** + * Gets operation name which is includes mapping rules + * @return + */ + private String getFinalOperationName() { + String result = operation; + if (referenceClass != null) { + Class<?>[] argumentTypes = new Class<?>[arguments.size()]; + for (int i = 0; i < arguments.size(); i++) { + argumentTypes[i] = arguments.get(i).getClass(); + } + Method method = MethodFinder.findMethod(referenceClass, operation, argumentTypes); + String newOperation = (String)operationsMap.get(method); + if (newOperation != null) { + result = newOperation; + } + } + return result; + } + + /** + * Invokes previously configured request + * + * @return + */ + public DynaCorbaResponse invoke() throws Exception { + DynaCorbaResponse response = new DynaCorbaResponse(); + String finalOperationName = getFinalOperationName(); + OutputStream outputStream = ((ObjectImpl)remoteObject)._request(finalOperationName, true); + passArguments(outputStream); + try { + inputStream = remoteObject._invoke(outputStream); + if (inputStream != null && returnTree != null) { + response.setContent(TypeHelpersProxy.read(returnTree.getRootNode(), inputStream)); + } + } catch (ApplicationException ae) { + handleApplicationException(ae); + } catch (SystemException se) { + handleSystemException(se); + } catch (Exception e) { + throw e; + } finally { + release(); + } + return response; + } + + /** + * Releases request resources + */ + private void release() { + remoteObject._releaseReply(inputStream); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.java new file mode 100644 index 0000000000..6a01c70a38 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/DynaCorbaResponse.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.reference; + +/** + * @version $Rev$ $Date$ + * Holder for content returned from DynaCorbaRequest + * + */ +public class DynaCorbaResponse { + + private Object content; + + public Object getContent() { + return content; + } + + public void setContent(Object content) { + this.content = content; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.java new file mode 100644 index 0000000000..2828e09cc7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceInstanceCreator.java @@ -0,0 +1,70 @@ +/* + * 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.corba.provider.reference; + +import java.lang.reflect.Method; + +import net.sf.cglib.proxy.Callback; +import net.sf.cglib.proxy.CallbackFilter; +import net.sf.cglib.proxy.Enhancer; +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.NoOp; + +import org.omg.CORBA.Object; + +/** + * @version $Rev$ $Date$ + */ +public class InterfaceInstanceCreator { + + private static final CallbackFilter FILTER = new CallbackFilter() { + public int accept(Method method) { + return 1; + } + }; + + /** + * Dynamically creates instance of user defined interface. Instance is + * enhanced by RemoteMethodInterceptor + * + * @param reference + * CORBA reference + * @param forClass + * user defined interface + * @return dynamic implementation instance + */ + public static java.lang.Object createInstance(Object reference, Class<?> forClass) { + java.lang.Object result = null; + try { + Enhancer enhancer = new Enhancer(); + enhancer.setInterfaces(new Class[] {forClass}); + enhancer.setCallbackFilter(FILTER); + enhancer.setCallbackTypes(new Class[] {NoOp.class, MethodInterceptor.class}); + Class<?> newClass = enhancer.createClass(); + Enhancer.registerStaticCallbacks(newClass, new Callback[] {NoOp.INSTANCE, + new InterfaceMethodInterceptor(reference, forClass)}); + result = newClass.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.java new file mode 100644 index 0000000000..c5c98ab27c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/reference/InterfaceMethodInterceptor.java @@ -0,0 +1,65 @@ +/* + * 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.corba.provider.reference; + +import java.lang.reflect.Method; + +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; + +import org.omg.CORBA.Object; + +/** + * @version $Rev$ $Date$ + * Interceptor for CORBA reference methods + */ +public class InterfaceMethodInterceptor implements MethodInterceptor { + + private Object reference; + private Class<?> javaClass; + + public InterfaceMethodInterceptor(Object reference, Class<?> javaClass) { + this.reference = reference; + this.javaClass = javaClass; + } + + /** + * Create and execute DynaCorbaRequest instance, basing on intercepted + * method arguments, return types, exceptions + */ + public java.lang.Object intercept(java.lang.Object object, + Method method, + java.lang.Object[] arguments, + MethodProxy arg3) throws Throwable { + DynaCorbaRequest request = new DynaCorbaRequest(reference, method.getName()); + request.setReferenceClass(javaClass); + for (int i = 0; i < arguments.length; i++) { + request.addArgument(arguments[i]); + } + request.setOutputType(method.getReturnType()); + Class<?>[] exceptions = method.getExceptionTypes(); + for (int i = 0; i < exceptions.length; i++) { + request.addExceptionType(exceptions[i]); + } + DynaCorbaResponse response = request.invoke(); + return response.getContent(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java new file mode 100644 index 0000000000..5babc25b07 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/ComponentInvocationProxy.java @@ -0,0 +1,122 @@ +/* + * 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.corba.provider.service; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeCreator; +import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.runtime.Invocable; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +/** + * @version $Rev$ $Date$ + * Invocation proxy for SCA components + */ +public class ComponentInvocationProxy implements InvocationProxy { + + private Invocable wire; + private Map<Method, Operation> methodOperationMapping; + private Map<Operation, Method> operationMethodMapping; + private Map<String, Method> operationsMap; + private Map<Operation, OperationTypes> operationsCache = new HashMap<Operation, OperationTypes>(); + + public ComponentInvocationProxy(RuntimeEndpoint wire, Class javaClass) + throws RequestConfigurationException { + this.wire = wire; + Interface interfaze = wire.getComponentTypeServiceInterfaceContract().getInterface(); + operationsMap = OperationMapper.mapOperationNameToMethod(javaClass); + operationMethodMapping = OperationMapper.mapOperationToMethod(interfaze.getOperations(), javaClass); + methodOperationMapping = OperationMapper.mapMethodToOperation(interfaze.getOperations(), javaClass); + cacheOperationTypes(interfaze.getOperations()); + } + + /** + * Caches TypeTree for every operation in backed component + * + * @param operations + * @throws RequestConfigurationException + */ + private void cacheOperationTypes(List<Operation> operations) throws RequestConfigurationException { + for (Operation operation : operations) { + try { + OperationTypes operationTypes = new OperationTypes(); + List<TypeTree> inputInstances = new ArrayList<TypeTree>(); + // cache output type tree + if (operation.getOutputType() != null && operation.getOutputType().getPhysical() != null + && !operation.getOutputType().getPhysical().equals(void.class)) { + Annotation[] notes = operationMethodMapping.get(operation).getAnnotations(); + TypeTree outputType = + TypeTreeCreator.createTypeTree(operation.getOutputType().getPhysical(), notes); + operationTypes.setOutputType(outputType); + } + // cache input types trees + if (operation.getInputType() != null) { + Method method = operationMethodMapping.get(operation); + Annotation[][] notes = method.getParameterAnnotations(); + int i = 0; + for (DataType<List<DataType<?>>> type : operation.getInputType().getLogical()) { + Class<?> forClass = type.getPhysical(); + TypeTree inputType = TypeTreeCreator.createTypeTree(forClass, notes[i]); + inputInstances.add(inputType); + i++; + } + + } + operationTypes.setInputType(inputInstances); + operationsCache.put(operation, operationTypes); + } catch (RequestConfigurationException e) { + throw e; + } + } + } + + private Operation getOperation4Name(String operationName) { + Method method = operationsMap.get(operationName); + return methodOperationMapping.get(method); + } + + public OperationTypes getOperationTypes(String operationName) { + return operationsCache.get(getOperation4Name(operationName)); + } + + public Object invoke(String operationName, List<Object> arguments) throws InvocationException { + Object result = null; + try { + result = wire.invoke(getOperation4Name(operationName), arguments.toArray()); + } catch (InvocationTargetException e) { + InvocationException exception = new InvocationException(e.getCause()); + throw exception; + } + return result; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java new file mode 100644 index 0000000000..d8524eaee9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/DynaCorbaServant.java @@ -0,0 +1,137 @@ +/* + * 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.corba.provider.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeCreator; +import org.apache.tuscany.sca.binding.corba.provider.types.util.TypeHelpersProxy; +import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.InvokeHandler; +import org.omg.CORBA.portable.ObjectImpl; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.ResponseHandler; + +/** + * @version $Rev$ $Date$ + * General servant which provides target component implementation via CORBA + */ +public class DynaCorbaServant extends ObjectImpl implements InvokeHandler { + + private static final Logger logger = Logger.getLogger(DynaCorbaServant.class.getName()); + + private String[] ids; + private InvocationProxy invocationProxy; + private String typeId; + + /** + * Creates servant object + * @param invocationProxy + * @param typeId + * @throws RequestConfigurationException + */ + public DynaCorbaServant(InvocationProxy invocationProxy, String typeId) throws RequestConfigurationException { + this.invocationProxy = invocationProxy; + this.typeId = typeId; + setDefaultIds(); + } + + /** + * Sets CORBA object ID + * @param ids + */ + public void setIds(String[] ids) { + for (int i = 0; i < ids.length; i++) { + if (ids[i] == null || ids[i].length() == 0) { + // if invalid id was passed then set to default + setDefaultIds(); + return; + } + } + this.ids = ids; + } + + public OutputStream _invoke(String operationName, InputStream in, ResponseHandler rh) { + OperationTypes types = invocationProxy.getOperationTypes(operationName); + if (types == null) { + // operation wasn't found + throw new org.omg.CORBA.BAD_OPERATION(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } else { + List<Object> inputInstances = new ArrayList<Object>(); + try { + // retrieving in arguments + for (TypeTree tree : types.getInputType()) { + Object o = TypeHelpersProxy.read(tree.getRootNode(), in); + inputInstances.add(o); + } + } catch (MARSHAL e) { + // parameter passed by user was not compatible with Java to + // Corba mapping + throw new org.omg.CORBA.BAD_PARAM(0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + try { + // invocation and sending result + Object result = invocationProxy.invoke(operationName, inputInstances); + OutputStream out = rh.createReply(); + if (types.getOutputType() != null) { + TypeTree tree = types.getOutputType(); + TypeHelpersProxy.write(tree.getRootNode(), out, result); + } + return out; + } catch (InvocationException ie) { + // handling user exception + try { + OutputStream out = rh.createExceptionReply(); + Class<?> exceptionClass = ie.getTargetException().getClass(); + TypeTree tree = TypeTreeCreator.createTypeTree(exceptionClass, null); + String exceptionId = Utils.getTypeId(exceptionClass); + out.write_string(exceptionId); + TypeHelpersProxy.write(tree.getRootNode(), out, ie.getTargetException()); + return out; + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during handling invocation exception", e); + } + } catch (Exception e) { + logger.log(Level.WARNING, "Unexpected exception during sending CORBA result to client", e); + } + } + return null; + } + + @Override + public String[] _ids() { + return ids; + } + + /** + * Sets servant ID to default, based on Java class name + */ + private void setDefaultIds() { + this.ids = new String[] {typeId}; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java new file mode 100644 index 0000000000..57e2fae9f4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationException.java @@ -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. + */ + +package org.apache.tuscany.sca.binding.corba.provider.service; + +/** + * @version $Rev$ $Date$ + * Wrapper for exception thrown during target invocation + */ +public class InvocationException extends Exception { + + private static final long serialVersionUID = 1L; + private Throwable targetException; + + public InvocationException(Throwable targetException) { + this.targetException = targetException; + } + + public Throwable getTargetException() { + return targetException; + } + + public void setTargetException(Throwable target) { + this.targetException = target; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.java new file mode 100644 index 0000000000..2e2066802a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/InvocationProxy.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.binding.corba.provider.service; + +import java.util.List; + +/** + * @version $Rev$ $Date$ + * Target proxy interface for service bindings + */ +public interface InvocationProxy { + + /** + * Gets operations types for target + * @param operationName + * @return + */ + public OperationTypes getOperationTypes(String operationName); + + /** + * Invokes target operation + * @param operationName + * @param arguments + * @return + * @throws InvocationException + */ + public Object invoke(String operationName, List<Object> arguments) throws InvocationException; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.java new file mode 100644 index 0000000000..766048ac64 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/service/OperationTypes.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.binding.corba.provider.service; + +import java.util.List; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTree; + +/** + * @version $Rev$ $Date$ + * Holder for Java type trees for one method + */ +public class OperationTypes { + + private TypeTree outputType; + private List<TypeTree> inputType; + + public TypeTree getOutputType() { + return outputType; + } + + public void setOutputType(TypeTree outputType) { + this.outputType = outputType; + } + + public List<TypeTree> getInputType() { + return inputType; + } + + public void setInputType(List<TypeTree> inputType) { + this.inputType = inputType; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.java new file mode 100644 index 0000000000..ab7371bbe8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/AnnotationAttributes.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.binding.corba.provider.types; + +/** + * Holds information retrieved from objects annotations + */ +public class AnnotationAttributes { + + private boolean corbaArray; + private int[] corbaArrayLength; + + public boolean isCorbaArray() { + return corbaArray; + } + + public void setCorbaArray(boolean isCorbaArray) { + this.corbaArray = isCorbaArray; + } + + public int[] getCorbaArrayLength() { + return corbaArrayLength; + } + + public void setCorbaArrayLength(int[] corbaArrayLength) { + this.corbaArrayLength = corbaArrayLength; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.java new file mode 100644 index 0000000000..706a44406b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/NodeType.java @@ -0,0 +1,28 @@ +/* + * 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.corba.provider.types; + +/** + * @version $Rev$ $Date$ + * Types of CORBA objects. + */ +public enum NodeType { + primitive, struct, union, array, sequence, reference, idl_enum, exception +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.java new file mode 100644 index 0000000000..d4207ab735 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTree.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.binding.corba.provider.types; + +/** + * @version $Rev$ $Date$ + * Helper tree for Java object hierarchy. It's closer to CORBA types + * structure than plain Java hierarchy - it helps reading and writing + * complex structures. + */ +public class TypeTree { + + private TypeTreeNode rootNode; + + /** + * Returns root node. + * + * @return root of type tree + */ + public TypeTreeNode getRootNode() { + return rootNode; + } + + /** + * Sets root of the type tree. + * + * @param rootNode root node. + */ + public void setRootNode(TypeTreeNode rootNode) { + this.rootNode = rootNode; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java new file mode 100644 index 0000000000..1ba4002303 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeCreator.java @@ -0,0 +1,497 @@ +/* + * 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.corba.provider.types; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +/** + * @version $Rev$ $Date$ + * Creator of types tree. + */ +public class TypeTreeCreator { + + /** + * Helps to determine if type is a primitive. + */ + private static List<Class<?>> primitives = new ArrayList<Class<?>>(); + + static { + primitives.add(boolean.class); + primitives.add(byte.class); + primitives.add(short.class); + primitives.add(int.class); + primitives.add(long.class); + primitives.add(double.class); + primitives.add(float.class); + primitives.add(char.class); + primitives.add(String.class); + primitives.add(Boolean.class); + primitives.add(Byte.class); + primitives.add(Short.class); + primitives.add(Integer.class); + primitives.add(Long.class); + primitives.add(Double.class); + primitives.add(Float.class); + primitives.add(Character.class); + } + + /** + * Creates class for given string argument. + * + * @param name name of type + * @return type + */ + private static Class<?> createClassFromString(String name) { + Class<?> result = null; + try { + if (name.length() == 1) { + // primitives + switch (name.charAt(0)) { + case 'Z': + result = boolean.class; + break; + case 'C': + result = char.class; + break; + case 'B': + result = byte.class; + break; + case 'S': + result = short.class; + break; + case 'I': + result = int.class; + break; + case 'J': + result = long.class; + break; + case 'F': + result = float.class; + break; + case 'D': + result = double.class; + break; + } + } else { + // class + name = name.substring(1, name.length() - 1); + result = Class.forName(name); + } + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + /** + * Reduces dimension of array. + * + * @param forClass array class + * @return reduced array + */ + private static Class<?> reduceArrayDimension(Class<?> forClass) { + String name = forClass.getName(); + try { + String reduced = name.substring(1, name.length()); + if (reduced.startsWith("[")) { + // reduced class is still an array + return Class.forName(reduced); + } else { + // reduced class may be primitive or class + return createClassFromString(reduced); + } + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + return null; + } + + /** + * Return given array without first element + * + * @param array + * @return + */ + private static int[] removeFirstElement(int[] array) { + int[] result = new int[array.length - 1]; + System.arraycopy(array, 1, result, 0, result.length); + return result; + } + + /** + * Converts objects annotations to structure which will be used by this + * class + * + * @param notes + * @return + */ + private static AnnotationAttributes createAnnotationAttributes(Annotation[] notes) { + AnnotationAttributes attrs = new AnnotationAttributes(); + for (int i = 0; notes != null && i < notes.length; i++) { + if (notes[i].annotationType().equals(CorbaArray.class)) { + attrs.setCorbaArray(true); + attrs.setCorbaArrayLength(((CorbaArray)notes[i]).value()); + } + } + return attrs; + } + + /** + * Creates tree for given type. + * + * @param forClass + * @return type tree + */ + public static TypeTree createTypeTree(Class<?> forClass, Annotation[] notes) throws RequestConfigurationException { + TypeTree tree = new TypeTree(); + TypeTreeNode rootNode = null; + AnnotationAttributes attrs = createAnnotationAttributes(notes); + rootNode = inspectClassHierarchy(forClass, attrs, tree); + tree.setRootNode(rootNode); + return tree; + + } + + /** + * Recurrent method which builds type tree. + * + * @param forClass + * @param tree + * @return + */ + private static TypeTreeNode inspectClassHierarchy(Class<?> forClass, AnnotationAttributes attributes, TypeTree tree) + throws RequestConfigurationException { + + TypeTreeNode node = null; + node = createTypeNode(forClass, attributes); + + NodeType nodeType = node.getNodeType(); + TypeTreeNode[] children = null; + + if (nodeType.equals(NodeType.primitive)) { + // stop condition for recurrent method + } else if (nodeType.equals(NodeType.array)) { + Class<?> reduced = reduceArrayDimension(node.getJavaClass()); + children = new TypeTreeNode[1]; + int[] newLengths = removeFirstElement(attributes.getCorbaArrayLength()); + attributes.setCorbaArrayLength(newLengths); + children[0] = inspectClassHierarchy(reduced, attributes, tree); + } else if (nodeType.equals(NodeType.sequence)) { + // reducing sequence dimension + Class<?> reduced = reduceArrayDimension(node.getJavaClass()); + children = new TypeTreeNode[1]; + children[0] = inspectClassHierarchy(reduced, attributes, tree); + // System.arraycopy(src, srcPos, dest, destPos, length) + } else if (nodeType.equals(NodeType.struct) || nodeType.equals(NodeType.exception)) { + // inspect types for every structure member + Field[] fields = node.getJavaClass().getFields(); + children = new TypeTreeNode[fields.length]; + for (int i = 0; i < fields.length; i++) { + Class<?> field = fields[i].getType(); + AnnotationAttributes fAttrs = createAnnotationAttributes(fields[i].getAnnotations()); + TypeTreeNode child = inspectClassHierarchy(field, fAttrs, tree); + child.setName(fields[i].getName()); + children[i] = child; + } + } else if (nodeType.equals(NodeType.idl_enum)) { + + } else if (nodeType.equals(NodeType.union)) { + // inspect types for every structure member + Field[] fields = node.getJavaClass().getDeclaredFields(); + children = new TypeTreeNode[fields.length]; + for (int i = 0; i < fields.length; i++) { + Class<?> field = fields[i].getType(); + AnnotationAttributes fAttrs = createAnnotationAttributes(fields[i].getAnnotations()); + TypeTreeNode child = inspectClassHierarchy(field, fAttrs, tree); + child.setName(fields[i].getName()); + children[i] = child; + } + } else if (nodeType.equals(NodeType.reference)) { + // TODO: CORBA references + } + + node.setChildren(children); + return node; + } + + /** + * Creating and configuring TypeTreeNode for given class. + * + * @param forClass class + * @return node + * @throws RequestConfigurationException + */ + private static TypeTreeNode createTypeNode(Class<?> forClass, AnnotationAttributes attributes) + throws RequestConfigurationException { + TypeTreeNode node = new TypeTreeNode(); + if (forClass.isArray() && !attributes.isCorbaArray()) { + node.setNodeType(NodeType.sequence); + node.setJavaClass(forClass); + } else if (forClass.isArray() && attributes.isCorbaArray()) { + node.setNodeType(NodeType.array); + node.setJavaClass(forClass); + try { + // set the actual array size for further use by ArrayTypeHelper + node.setAttributes(attributes.getCorbaArrayLength()[0]); + } catch (ArrayIndexOutOfBoundsException e) { + RequestConfigurationException exc = + new RequestConfigurationException("Annotated array size doesn't match declared arrays size"); + throw exc; + } + } else if (primitives.contains(forClass)) { + node.setNodeType(NodeType.primitive); + node.setJavaClass(forClass); + node.setChildren(null); + } else if (forClass.isInterface()) { + node.setNodeType(NodeType.reference); + node.setJavaClass(forClass); + node.setChildren(null); + } else if (isStructType(forClass)) { + node.setNodeType(NodeType.struct); + node.setJavaClass(forClass); + } else if (isEnumType(forClass)) { + node.setNodeType(NodeType.idl_enum); + node.setJavaClass(forClass); + } else if (isUserException(forClass)) { + node.setNodeType(NodeType.exception); + node.setJavaClass(forClass); + } else if (isUnionType(forClass)) { + node.setNodeType(NodeType.union); + node.setJavaClass(forClass); + node.setAttributes(getUnionAttributes(forClass)); + } else { + RequestConfigurationException e = + new RequestConfigurationException("User defined type which cannot be handled: " + forClass + .getCanonicalName()); + throw e; + } + return node; + } + + /** + * Tells whether given class is structure + * + * @param forClass + * @return + */ + private static boolean isStructType(Class<?> forClass) { + int classMods = forClass.getModifiers(); + if (!Modifier.isFinal(classMods)) { + return false; + } + boolean areCtorsValid = false; + Class<?>[] fieldsTypes = null; + Constructor<?>[] ctors = forClass.getConstructors(); + /* + * Do we have 2 ctors and one of them is null ctor? + */ + if (ctors.length != 2) { + return false; + } + for (int i = 0; i < ctors.length; i++) { + Class<?>[] params = ctors[i].getParameterTypes(); + if (params.length == 0) { + areCtorsValid = true; + } else { + fieldsTypes = params; + } + } + if (!areCtorsValid) { + return false; + } + /* + * Are constructor args declared as class fields? + */ + Field[] fields = forClass.getFields(); + Set<Class<?>> fieldsSet = new HashSet<Class<?>>(Arrays.asList(fieldsTypes)); + for (int i = 0; i < fields.length && !fieldsSet.isEmpty(); i++) { + int mods = fields[i].getModifiers(); + if (Modifier.isPublic(mods) && !Modifier.isStatic(mods) && !Modifier.isFinal(mods)) { + fieldsSet.remove(fields[i].getType()); + } + + } + return fieldsSet.isEmpty(); + } + + /** + * Tells whether given class is enum + * + * @param forClass + * @return + */ + private static boolean isEnumType(Class<?> forClass) { + boolean isValueMethod = false; + boolean isFromIntMethod = false; + /* + * enum type should have value and from_int methods + */ + try { + Method valueMet = forClass.getMethod("value", new Class[] {}); + int modValueMet = valueMet.getModifiers(); + if (valueMet.getReturnType().equals(int.class) && Modifier.isPublic(modValueMet)) { + isValueMethod = true; + } + Method fromIntMet = forClass.getMethod("from_int", new Class[] {int.class}); + int modFromIntMet = fromIntMet.getModifiers(); + if ((fromIntMet.getReturnType().equals(forClass) && Modifier.isPublic(modFromIntMet) && Modifier + .isStatic(modFromIntMet))) { + isFromIntMethod = true; + } + } catch (NoSuchMethodException e) { + } + if (!isFromIntMethod || !isValueMethod) { + return false; + } + /* + * enum type should also contain minimum one pair of fields: EnumType + * field and int _field + */ + int enumCount = 0; + Field[] fields = forClass.getFields(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].getType().equals(forClass)) { + int modifiers = fields[i].getModifiers(); + if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers) && Modifier.isFinal(modifiers)) { + try { + Field field = forClass.getField("_" + fields[i].getName()); + if (field.getType().equals(int.class)) { + enumCount++; + } + } catch (NoSuchFieldException e) { + } + + } + } + } + return enumCount > 0; + } + + /** + * Tells whether given class is CORBA user exception + * + * @param forClass + * @return + */ + private static boolean isUserException(Class<?> forClass) { + do { + if (forClass.equals(Exception.class)) { + return true; + } else { + forClass = forClass.getSuperclass(); + } + } while (forClass != null && !forClass.equals(Object.class)); + return false; + } + + /** + * Tells whether given class is CORBA union. This method validates usage of + * unions annotations. + * + * @param forClass + * @return + * @throws RequestConfigurationException + */ + private static boolean isUnionType(Class<?> forClass) throws RequestConfigurationException { + int classMods = forClass.getModifiers(); + if (!Modifier.isFinal(classMods)) { + return false; + } + boolean atLeastOneOption = false; + boolean discriminatorPresent = false; + for (int i = 0; i < forClass.getDeclaredFields().length; i++) { + CorbaUnionElement note = forClass.getDeclaredFields()[i].getAnnotation(CorbaUnionElement.class); + if (note != null) { + int fieldMod = forClass.getDeclaredFields()[i].getModifiers(); + if (Modifier.isPrivate(fieldMod) && !Modifier.isFinal(fieldMod) && !Modifier.isStatic(fieldMod)) { + if (note.type().equals(CorbaUnionElementType.discriminator)) { + if (discriminatorPresent) { + throw new RequestConfigurationException( + "More than one discriminators declared on: " + forClass); + } + discriminatorPresent = true; + } else { + atLeastOneOption = true; + } + } else { + throw new RequestConfigurationException( + "Annotated union field should be private, not final and no static on class: " + forClass); + } + } + } + if (atLeastOneOption && !discriminatorPresent) { + throw new RequestConfigurationException("No discriminator annotation found on: " + forClass); + } else if (!atLeastOneOption && discriminatorPresent) { + throw new RequestConfigurationException("No union option found on: " + forClass); + } else if (discriminatorPresent && atLeastOneOption) { + return true; + } else { + return false; + } + } + + /** + * Gets union attributes - discriminator field name, option fields etc. This + * method relies that previously scanned class is valid (method isUnionType) + * + * @param forClass + * @return + * @throws RequestConfigurationException + */ + private static UnionAttributes getUnionAttributes(Class<?> forClass) throws RequestConfigurationException { + UnionAttributes attributes = new UnionAttributes(); + for (int i = 0; i < forClass.getDeclaredFields().length; i++) { + CorbaUnionElement note = forClass.getDeclaredFields()[i].getAnnotation(CorbaUnionElement.class); + if (note != null) { + if (note.type().equals(CorbaUnionElementType.discriminator)) { + attributes.setDiscriminatorName(forClass.getDeclaredFields()[i].getName()); + } else if (note.type().equals(CorbaUnionElementType.defaultOption)) { + attributes.setDefaultOptionName(forClass.getDeclaredFields()[i].getName()); + } else if (note.type().equals(CorbaUnionElementType.option)) { + if (attributes.getOptionsMapping().containsKey(note.optionNumber())) { + throw new RequestConfigurationException("In " + forClass + + ": field \"" + + forClass.getDeclaredFields()[i].getName() + + "\" uses already used option id: " + + note.optionNumber()); + } else { + attributes.getOptionsMapping().put(note.optionNumber(), + forClass.getDeclaredFields()[i].getName()); + } + } + } + } + return attributes; + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.java new file mode 100644 index 0000000000..009eac3377 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/TypeTreeNode.java @@ -0,0 +1,75 @@ +/* + * 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.corba.provider.types; + +/** + * @version $Rev$ $Date$ + * Represents single tree node. + * + */ +public class TypeTreeNode { + + private NodeType nodeType; + private TypeTreeNode[] children; + private Class<?> javaClass; + private String name; + private Object attributes; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public NodeType getNodeType() { + return nodeType; + } + + public void setNodeType(NodeType nodeType) { + this.nodeType = nodeType; + } + + public TypeTreeNode[] getChildren() { + return children; + } + + public void setChildren(TypeTreeNode[] children) { + this.children = children; + } + + public Class<?> getJavaClass() { + return javaClass; + } + + public void setJavaClass(Class<?> javaClass) { + this.javaClass = javaClass; + } + + public Object getAttributes() { + return attributes; + } + + public void setAttributes(Object attributes) { + this.attributes = attributes; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.java new file mode 100644 index 0000000000..34bee2a0e4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/UnionAttributes.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.corba.provider.types; + +import java.util.HashMap; +import java.util.Map; + +/** + * @version $Rev$ $Date$ + * Stores attributes for previously scanned CORBA union type + */ +public class UnionAttributes { + + public String discriminatorName; + public String defaultOptionName; + public Map<Integer, String> optionsMapping = new HashMap<Integer, String>(); + + public String getDiscriminatorName() { + return discriminatorName; + } + + public void setDiscriminatorName(String discriminatorName) { + this.discriminatorName = discriminatorName; + } + + public String getDefaultOptionName() { + return defaultOptionName; + } + + public void setDefaultOptionName(String defaultOptionName) { + this.defaultOptionName = defaultOptionName; + } + + public Map<Integer, String> getOptionsMapping() { + return optionsMapping; + } + + public void setOptionsMapping(Map<Integer, String> optionsMapping) { + this.optionsMapping = optionsMapping; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.java new file mode 100644 index 0000000000..35a1e539d9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ArrayTypeHelper.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import java.lang.reflect.Array; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class ArrayTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + Object array = null; + try { + int size = (Integer)node.getAttributes(); + array = Array.newInstance(node.getChildren()[0].getJavaClass(), size); + for (int i = 0; i < size; i++) { + Array.set(array, i, TypeHelpersProxy.read(node.getChildren()[0], is)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return array; + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + for (int i = 0; i < (Integer)node.getAttributes(); i++) { + TypeHelpersProxy.write(node.getChildren()[0], os, Array.get(data, i)); + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.java new file mode 100644 index 0000000000..bbc2012a38 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/BooleanTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class BooleanTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_boolean(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_boolean((Boolean)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.java new file mode 100644 index 0000000000..761cc5d62c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ByteTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class ByteTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_octet(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_octet((Byte)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.java new file mode 100644 index 0000000000..b2d2afd011 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/CharTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class CharTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_char(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_char((Character)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.java new file mode 100644 index 0000000000..f667123bb7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/DoubleTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class DoubleTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_double(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_double((Double)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java new file mode 100644 index 0000000000..5661232e1e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/EnumTypeHelper.java @@ -0,0 +1,41 @@ +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import java.lang.reflect.Method; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class EnumTypeHelper implements TypeHelper { + + private static final Logger logger = Logger.getLogger(EnumTypeHelper.class.getName()); + + public Object read(TypeTreeNode node, InputStream is) { + int value = is.read_long(); + Object result = null; + try { + Method method = node.getJavaClass().getMethod("from_int", new Class[] {int.class}); + result = method.invoke(null, new Object[] {value}); + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during reading CORBA enum data", e); + e.printStackTrace(); + } + return result; + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + int value = 0; + try { + Method method = data.getClass().getMethod("value", new Class[] {}); + value = (Integer)method.invoke(data, new Object[] {}); + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during writing CORBA enum data", e); + } + os.write_long(value); + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.java new file mode 100644 index 0000000000..7c39725012 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/FloatTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class FloatTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_float(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_float((Float)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.java new file mode 100644 index 0000000000..e903b59e50 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/IntTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class IntTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_long(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_long((Integer)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.java new file mode 100644 index 0000000000..79d3c0cbc8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/LongTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class LongTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_longlong(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_longlong((Long)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java new file mode 100644 index 0000000000..c89a25401d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ReferenceTypeHelper.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.reference.InterfaceInstanceCreator; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.Object; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class ReferenceTypeHelper implements TypeHelper { + + public java.lang.Object read(TypeTreeNode node, InputStream is) { + Object reference = is.read_Object(); + return (java.lang.Object)InterfaceInstanceCreator.createInstance(reference, node.getJavaClass()); + } + + public void write(TypeTreeNode node, OutputStream os, java.lang.Object data) { + os.write_Object((Object)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.java new file mode 100644 index 0000000000..911c787b11 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/SequenceTypeHelper.java @@ -0,0 +1,70 @@ +/* + * 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.corba.provider.types.util; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class SequenceTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + Object sequence = null; + try { + int size = is.read_long(); + sequence = Array.newInstance(node.getChildren()[0].getJavaClass(), size); + for (int i = 0; i < size; i++) { + Array.set(sequence, i, TypeHelpersProxy.read(node.getChildren()[0], is)); + } + } catch (Exception e) { + e.printStackTrace(); + } + return sequence; + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + int sum = 0; + // determine length of array + List<Object> array = new ArrayList<Object>(); + while (true) { + try { + array.add(Array.get(data, sum)); + sum++; + } catch (ArrayIndexOutOfBoundsException e) { + break; + } + } + os.write_long(sum); + Iterator<Object> iter = array.iterator(); + while (iter.hasNext()) { + Object elem = iter.next(); + TypeHelpersProxy.write(node.getChildren()[0], os, elem); + } + + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.java new file mode 100644 index 0000000000..f4cdabc8e2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/ShortTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class ShortTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_short(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_short((Short)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.java new file mode 100644 index 0000000000..5a4fcba221 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StringTypeHelper.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class StringTypeHelper implements TypeHelper { + + public Object read(TypeTreeNode node, InputStream is) { + return is.read_string(); + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + os.write_string((String)data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java new file mode 100644 index 0000000000..1fc729b926 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/StructTypeHelper.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import java.lang.reflect.Field; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class StructTypeHelper implements TypeHelper { + + private static final Logger logger = Logger.getLogger(StructTypeHelper.class.getName()); + + public Object read(TypeTreeNode node, InputStream is) { + TypeTreeNode[] children = node.getChildren(); + Object result = null; + if (children != null) { + try { + result = node.getJavaClass().newInstance(); + for (int i = 0; i < children.length; i++) { + Object childResult = TypeHelpersProxy.read(children[i], is); + Field childField = result.getClass().getField(children[i].getName()); + childField.set(result, childResult); + } + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during reading CORBA struct data", e); + } + } + return result; + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + TypeTreeNode[] children = node.getChildren(); + if (children != null) { + try { + for (int i = 0; i < children.length; i++) { + Field childField = node.getJavaClass().getField(children[i].getName()); + TypeHelpersProxy.write(children[i], os, childField.get(data)); + } + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during writing CORBA struct data", e); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.java new file mode 100644 index 0000000000..0f1f973f49 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelper.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.corba.provider.types.util; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public interface TypeHelper { + + /** + * Reads CORBA object + * @param node + * @param is + * @return + */ + Object read(TypeTreeNode node, InputStream is); + + /** + * Writes CORBA object + * @param node + * @param os + * @param data + */ + void write(TypeTreeNode node, OutputStream os, Object data); + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java new file mode 100644 index 0000000000..ded82bf12e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/TypeHelpersProxy.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tuscany.sca.binding.corba.provider.types.NodeType; +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + * Proxies getType(), write(), read() methods to appropriate TypeHelper implementation. + */ +public class TypeHelpersProxy { + + /** + * Maps primitive types to its TypeHelper implementations + */ + private static Map<Class<?>, TypeHelper> primitiveTypes = null; + + /** + * Maps other types to its TypeHelper implementations + */ + private static Map<NodeType, TypeHelper> complexTypes = null; + + static { + // initiate type helpers + primitiveTypes = new HashMap<Class<?>, TypeHelper>(); + complexTypes = new HashMap<NodeType, TypeHelper>(); + + primitiveTypes.put(boolean.class, new BooleanTypeHelper()); + primitiveTypes.put(char.class, new CharTypeHelper()); + primitiveTypes.put(byte.class, new ByteTypeHelper()); + primitiveTypes.put(short.class, new ShortTypeHelper()); + primitiveTypes.put(int.class, new IntTypeHelper()); + primitiveTypes.put(long.class, new LongTypeHelper()); + primitiveTypes.put(float.class, new FloatTypeHelper()); + primitiveTypes.put(double.class, new DoubleTypeHelper()); + primitiveTypes.put(String.class, new StringTypeHelper()); + primitiveTypes.put(Boolean.class, primitiveTypes.get(boolean.class)); + primitiveTypes.put(Character.class, primitiveTypes.get(char.class)); + primitiveTypes.put(Byte.class, primitiveTypes.get(byte.class)); + primitiveTypes.put(Short.class, primitiveTypes.get(short.class)); + primitiveTypes.put(Integer.class, primitiveTypes.get(int.class)); + primitiveTypes.put(Long.class, primitiveTypes.get(long.class)); + primitiveTypes.put(Float.class, primitiveTypes.get(float.class)); + primitiveTypes.put(Double.class, primitiveTypes.get(double.class)); + primitiveTypes.put(String.class, primitiveTypes.get(String.class)); + complexTypes.put(NodeType.array, new ArrayTypeHelper()); + complexTypes.put(NodeType.struct, new StructTypeHelper()); + complexTypes.put(NodeType.reference, new ReferenceTypeHelper()); + complexTypes.put(NodeType.sequence, new SequenceTypeHelper()); + complexTypes.put(NodeType.idl_enum, new EnumTypeHelper()); + complexTypes.put(NodeType.exception, new StructTypeHelper()); + complexTypes.put(NodeType.union, new UnionTypeHelper()); + } + + /** + * Gets type helper basing on given type + * + * @param node + * @return + */ + private static TypeHelper getTypeHelper(TypeTreeNode node) { + TypeHelper typeHelper = null; + NodeType type = node.getNodeType(); + if (type.equals(NodeType.primitive)) { + typeHelper = primitiveTypes.get(node.getJavaClass()); + } else { + typeHelper = complexTypes.get(type); + } + return typeHelper; + } + + /** + * Proxies read method invocation to appropriate TypeHelper implementation. + * + * @param node + * @param is + * @return + */ + public static final Object read(TypeTreeNode node, InputStream is) { + TypeHelper helper = getTypeHelper(node); + return helper.read(node, is); + } + + /** + * Proxies write method invocation to appropriate TypeHelper implementation. + * + * @param node + * @param os + * @param data + */ + public static final void write(TypeTreeNode node, OutputStream os, Object data) { + TypeHelper helper = getTypeHelper(node); + helper.write(node, os, data); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java new file mode 100644 index 0000000000..df2e833fcd --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/UnionTypeHelper.java @@ -0,0 +1,92 @@ +/* + * 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.corba.provider.types.util; + +import java.lang.reflect.Field; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.binding.corba.provider.types.TypeTreeNode; +import org.apache.tuscany.sca.binding.corba.provider.types.UnionAttributes; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * @version $Rev$ $Date$ + */ +public class UnionTypeHelper implements TypeHelper { + + private static final Logger logger = Logger.getLogger(UnionTypeHelper.class.getName()); + + public Object read(TypeTreeNode node, InputStream is) { + Object result = null; + try { + int discriminator = is.read_long(); + UnionAttributes attrs = (UnionAttributes)node.getAttributes(); + String childName = attrs.getOptionsMapping().get(discriminator); + if (childName == null) { + // get default if option numbers field not found + childName = attrs.getDefaultOptionName(); + } + result = node.getJavaClass().newInstance(); + Field discField = result.getClass().getDeclaredField(attrs.getDiscriminatorName()); + discField.setAccessible(true); + discField.set(result, discriminator); + for (int i = 0; i < node.getChildren().length; i++) { + if (node.getChildren()[i].getName().equals(childName)) { + Object unionValue = TypeHelpersProxy.read(node.getChildren()[i], is); + Field childField = result.getClass().getDeclaredField(childName); + childField.setAccessible(true); + childField.set(result, unionValue); + break; + } + } + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during reading CORBA union data", e); + } + return result; + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + try { + UnionAttributes attrs = (UnionAttributes)node.getAttributes(); + Field discriminatorField = data.getClass().getDeclaredField(attrs.getDiscriminatorName()); + discriminatorField.setAccessible(true); + int discriminator = discriminatorField.getInt(data); + os.write_long(discriminator); + String childName = attrs.getOptionsMapping().get(discriminator); + if (childName == null) { + // get default if option numbers field not found + childName = attrs.getDefaultOptionName(); + } + for (int i = 0; i < node.getChildren().length; i++) { + if (node.getChildren()[i].getName().equals(childName)) { + Field childField = data.getClass().getDeclaredField(childName); + childField.setAccessible(true); + TypeHelpersProxy.write(node.getChildren()[i], os, childField.get(data)); + break; + } + } + } catch (Exception e) { + logger.log(Level.WARNING, "Exception during writing CORBA union data", e); + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java new file mode 100644 index 0000000000..7ccd70f69e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/types/util/Utils.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.provider.types.util; + +/** + * @version $Rev$ $Date$ + * Class for type utilities + */ +public class Utils { + + /** + * Creates CORBA id for Java class + * @param forClass + * @return + */ + public static String getTypeId(Class<?> forClass) { + String result = forClass.getName().replace('.', '/'); + result = result.replaceAll("Package", ""); + result = "IDL:" + result + ":1.0"; + return result; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java new file mode 100644 index 0000000000..f9facac0cc --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/MethodFinder.java @@ -0,0 +1,97 @@ +/* + * 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.corba.provider.util; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * @version $Rev$ $Date$ + * Utility for finding method in given class. + */ +public class MethodFinder { + + private static Map<Class<?>, Class<?>> boxingMapping; + + static { + boxingMapping = new HashMap<Class<?>, Class<?>>(); + boxingMapping.put(boolean.class, Boolean.class); + boxingMapping.put(byte.class, Byte.class); + boxingMapping.put(short.class, Short.class); + boxingMapping.put(char.class, Character.class); + boxingMapping.put(int.class, Integer.class); + boxingMapping.put(long.class, Long.class); + boxingMapping.put(float.class, Float.class); + boxingMapping.put(double.class, Double.class); + } + + /** + * Converts primitive class to its object equivalent. + * + * @param parameter class to convert + * @return object equivalent for primitive type. If parameter wasn't + * primitive then returns parameter. + */ + private static Class<?> normalizePrimitive(Class<?> parameter) { + Class<?> result = boxingMapping.get(parameter); + if (result != null) { + return result; + } else { + // not a primitive - no need to normalize + return parameter; + } + } + + /** + * Finds appropriate method. This method ignores difference between + * primitive types and theirs object equivalents. Ie. if we want to find + * method "get" in java.util.List with only one parameter, which type is + * Integer then we'll obtain method get(int). + * + * @param forClass class which possibly contains desired method + * @param methodName desired methods name + * @param parameterTypes desired methods parameter types + * @return desired method, if no method was found then null will be returned + */ + public static Method findMethod(Class<?> forClass, String methodName, Class<?>[] parameterTypes) { + Method[] methods = forClass.getMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals(methodName)) { + Class<?>[] methodPTypes = methods[i].getParameterTypes(); + if (methodPTypes.length == parameterTypes.length) { + boolean parameterMatch = true; + for (int j = 0; j < methodPTypes.length; j++) { + Class<?> nMethodPType = normalizePrimitive(methodPTypes[j]); + Class<?> nParameterType = normalizePrimitive(parameterTypes[j]); + if (!nMethodPType.equals(nParameterType)) { + parameterMatch = false; + break; + } + } + if (parameterMatch) { + return methods[i]; + } + } + } + } + return null; + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java new file mode 100644 index 0000000000..414e50abf4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/provider/util/OperationMapper.java @@ -0,0 +1,578 @@ +/* + * 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.corba.provider.util; + +import java.lang.reflect.Method; +import java.rmi.RemoteException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.omg.CORBA.portable.IDLEntity; + +/** + * @version $Rev$ $Date$ + */ +public final class OperationMapper { + + private static Set<Class<?>> getAllInterfaces(Class<?> intfClass) { + Set<Class<?>> allInterfaces = new LinkedHashSet<Class<?>>(); + + LinkedList<Class<?>> stack = new LinkedList<Class<?>>(); + stack.addFirst(intfClass); + + while (!stack.isEmpty()) { + Class<?> intf = stack.removeFirst(); + allInterfaces.add(intf); + for (Class<?> i : intf.getInterfaces()) { + stack.add(0, i); + } + } + + return allInterfaces; + } + + /** + * Maps Java methods to operation names + * @param intfClass + * @return + */ + @SuppressWarnings("unchecked") + public static Map<Method, String> mapMethodToOperationName(Class<?> intfClass) { + return iiopMap(intfClass, false); + } + + /** + * Maps operation names to Java methods + * @param intfClass + * @return + */ + @SuppressWarnings("unchecked") + public static Map<String, Method> mapOperationNameToMethod(Class<?> intfClass) { + return iiopMap(intfClass, true); + } + + @SuppressWarnings("unchecked") + private static Map iiopMap(Class<?> intfClass, boolean operationToMethod) { + Method[] methods = getAllMethods(intfClass); + + // find every valid getter + Map<Method, String> getterByMethod = new HashMap<Method, String>(methods.length); + Map<String, Method> getterByName = new HashMap<String, Method>(methods.length); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + String methodName = method.getName(); + + // no arguments allowed + if (method.getParameterTypes().length != 0) { + continue; + } + + // must start with get or is + String verb; + if (methodName.startsWith("get") && methodName.length() > 3 && method.getReturnType() != void.class) { + verb = "get"; + } else if (methodName.startsWith("is") && methodName.length() > 2 && method.getReturnType() == boolean.class) { + verb = "is"; + } else { + continue; + } + + // must only throw Remote or Runtime Exceptions + boolean exceptionsValid = true; + Class[] exceptionTypes = method.getExceptionTypes(); + for (int j = 0; j < exceptionTypes.length; j++) { + Class<?> exceptionType = exceptionTypes[j]; + if (!RemoteException.class.isAssignableFrom(exceptionType) && + !RuntimeException.class.isAssignableFrom(exceptionType) && + !Error.class.isAssignableFrom(exceptionType)) { + exceptionsValid = false; + break; + } + } + if (!exceptionsValid) { + continue; + } + + String propertyName; + if (methodName.length() > verb.length() + 1 && Character.isUpperCase(methodName.charAt(verb.length() + 1))) { + propertyName = methodName.substring(verb.length()); + } else { + propertyName = Character.toLowerCase(methodName.charAt(verb.length())) + methodName.substring(verb.length() + 1); + } + getterByMethod.put(method, propertyName); + getterByName.put(propertyName, method); + } + + Map<Method, String> setterByMethod = new HashMap<Method, String>(methods.length); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + String methodName = method.getName(); + + // must have exactally one arg + if (method.getParameterTypes().length != 1) { + continue; + } + + // must return non void + if (method.getReturnType() != void.class) { + continue; + } + + // must start with set + if (!methodName.startsWith("set") || methodName.length() <= 3) { + continue; + } + + // must only throw Remote or Runtime Exceptions + boolean exceptionsValid = true; + Class<?>[] exceptionTypes = method.getExceptionTypes(); + for (int j = 0; j < exceptionTypes.length; j++) { + Class<?> exceptionType = exceptionTypes[j]; + if (!RemoteException.class.isAssignableFrom(exceptionType) && + !RuntimeException.class.isAssignableFrom(exceptionType) && + !Error.class.isAssignableFrom(exceptionType)) { + exceptionsValid = false; + break; + } + } + if (!exceptionsValid) { + continue; + } + + String propertyName; + if (methodName.length() > 4 && Character.isUpperCase(methodName.charAt(4))) { + propertyName = methodName.substring(3); + } else { + propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); + } + + // must have a matching getter + Method getter = (Method) getterByName.get(propertyName); + if (getter == null) { + continue; + } + + // setter property must match getter return value + if (!method.getParameterTypes()[0].equals(getter.getReturnType())) { + continue; + } + setterByMethod.put(method, propertyName); + } + + // index the methods by name... used to determine which methods are overloaded + HashMap<String, List<Method>> overloadedMethods = new HashMap<String, List<Method>>(methods.length); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (getterByMethod.containsKey(method) || setterByMethod.containsKey(method)) { + continue; + } + String methodName = method.getName(); + List<Method> methodList = overloadedMethods.get(methodName); + if (methodList == null) { + methodList = new LinkedList<Method>(); + overloadedMethods.put(methodName, methodList); + } + methodList.add(method); + } + + // index the methods by lower case name... used to determine which methods differ only by case + Map<String, Set<String>> caseCollisionMethods = new HashMap<String, Set<String>>(methods.length); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + if (getterByMethod.containsKey(method) || setterByMethod.containsKey(method)) { + continue; + } + String lowerCaseMethodName = method.getName().toLowerCase(); + Set<String> methodSet = caseCollisionMethods.get(lowerCaseMethodName); + if (methodSet == null) { + methodSet = new HashSet<String>(); + caseCollisionMethods.put(lowerCaseMethodName, methodSet); + } + methodSet.add(method.getName()); + } + + String className = getClassName(intfClass); + Map iiopMap = new HashMap(methods.length); + for (int i = 0; i < methods.length; i++) { + Method method = methods[i]; + + String iiopName = (String) getterByMethod.get(method); + if (iiopName != null) { + // if we have a leading underscore prepend with J + if (iiopName.charAt(0) == '_') { + iiopName = "J_get_" + iiopName.substring(1); + } else { + iiopName = "_get_" + iiopName; + } + } else { + iiopName = (String) setterByMethod.get(method); + if (iiopName != null) { + // if we have a leading underscore prepend with J + if (iiopName.charAt(0) == '_') { + iiopName = "J_set_" + iiopName.substring(1); + } else { + iiopName = "_set_" + iiopName; + } + } else { + iiopName = method.getName(); + + // if we have a leading underscore prepend with J + if (iiopName.charAt(0) == '_') { + iiopName = "J" + iiopName; + } + } + } + + // if this name only differs by case add the case index to the end + Set<String> caseCollisions = caseCollisionMethods.get(method.getName().toLowerCase()); + if (caseCollisions != null && caseCollisions.size() > 1) { + iiopName += upperCaseIndexString(iiopName); + } + + // if this is an overloaded method append the parameter string + List<Method> overloads = overloadedMethods.get(method.getName()); + if (overloads != null && overloads.size() > 1) { + iiopName += buildOverloadParameterString(method.getParameterTypes()); + } + + // if we have a leading underscore prepend with J + iiopName = replace(iiopName, '$', "U0024"); + + // if we have matched a keyword prepend with an underscore + if (keywords.contains(iiopName.toLowerCase())) { + iiopName = "_" + iiopName; + } + + // if the name is the same as the class name, append an underscore + if (iiopName.equalsIgnoreCase(className)) { + iiopName += "_"; + } + + if (operationToMethod) { + iiopMap.put(iiopName, method); + } else { + iiopMap.put(method, iiopName); + } + } + + return iiopMap; + } + + private static Method[] getAllMethods(Class<?> intfClass) { + List<Method> methods = new LinkedList<Method>(); + for (Iterator<Class<?>> iterator = getAllInterfaces(intfClass).iterator(); iterator.hasNext();) { + Class<?> intf = iterator.next(); + methods.addAll(Arrays.asList(intf.getDeclaredMethods())); + } + + return (Method[]) methods.toArray(new Method[methods.size()]); + } + + /** + * Return the a string containing an underscore '_' index of each uppercase + * character in the IIOP name. This is used for distinction of names that + * only differ by case, since CORBA does not support case sensitive names. + */ + private static String upperCaseIndexString(String iiopName) { + StringBuffer stringBuffer = new StringBuffer(); + for (int i = 0; i < iiopName.length(); i++) { + char c = iiopName.charAt(i); + if (Character.isUpperCase(c)) { + stringBuffer.append('_').append(i); + } + } + return stringBuffer.toString(); + } + + /** + * Replaces any occurances of the specified "oldChar" with the new string. + * This is used to replace occurances if '$' in CORBA names since '$' is a + * special character + */ + private static String replace(String source, char oldChar, String newString) { + StringBuffer stringBuffer = new StringBuffer(source.length()); + for (int i = 0; i < source.length(); i++) { + char c = source.charAt(i); + if (c == oldChar) { + stringBuffer.append(newString); + } else { + stringBuffer.append(c); + } + } + return stringBuffer.toString(); + } + + /** + * Return the a string containing a double underscore '__' list of parameter + * types encoded using the Java to IDL rules. This is used for distinction + * of methods that only differ by parameter lists. + */ + private static String buildOverloadParameterString(Class<?>[] parameterTypes) { + String name = ""; + if (parameterTypes.length == 0) { + name += "__"; + } else { + for (int i = 0; i < parameterTypes.length; i++) { + Class<?> parameterType = parameterTypes[i]; + name += buildOverloadParameterString(parameterType); + } + } + return name.replace('.', '_'); + } + + /** + * Returns a single parameter type encoded using the Java to IDL rules. + */ + private static String buildOverloadParameterString(Class<?> parameterType) { + String name = "_"; + + int arrayDimensions = 0; + while (parameterType.isArray()) { + arrayDimensions++; + parameterType = parameterType.getComponentType(); + } + + // arrays start with org_omg_boxedRMI_ + if (arrayDimensions > 0) { + name += "_org_omg_boxedRMI"; + } + + // IDLEntity types must be prefixed with org_omg_boxedIDL_ + if (IDLEntity.class.isAssignableFrom(parameterType)) { + name += "_org_omg_boxedIDL"; + } + + // add package... some types have special mappings in corba + String packageName = (String)specialTypePackages.get(parameterType.getName()); + if (packageName == null) { + packageName = getPackageName(parameterType.getName()); + } + if (packageName.length() > 0) { + name += "_" + packageName; + } + + // arrays now contain a dimension indicator + if (arrayDimensions > 0) { + name += "_" + "seq" + arrayDimensions; + } + + // add the class name + String className = (String)specialTypeNames.get(parameterType.getName()); + if (className == null) { + className = buildClassName(parameterType); + } + name += "_" + className; + + return name; + } + + /** + * Returns a string containing an encoded class name. + */ + private static String buildClassName(Class<?> type) { + if (type.isArray()) { + throw new IllegalArgumentException("type is an array: " + type); + } + + // get the classname + String typeName = type.getName(); + int endIndex = typeName.lastIndexOf('.'); + if (endIndex < 0) { + return typeName; + } + StringBuffer className = new StringBuffer(typeName.substring(endIndex + 1)); + + // for innerclasses replace the $ separator with two underscores + // we can't just blindly replace all $ characters since class names can + // contain the $ character + if (type.getDeclaringClass() != null) { + String declaringClassName = getClassName(type.getDeclaringClass()); + assert className.toString().startsWith(declaringClassName + "$"); + className.replace(declaringClassName.length(), declaringClassName.length() + 1, "__"); + } + + // if we have a leading underscore prepend with J + if (className.charAt(0) == '_') { + className.insert(0, "J"); + } + return className.toString(); + } + + private static String getClassName(Class<?> type) { + if (type.isArray()) { + throw new IllegalArgumentException("type is an array: " + type); + } + + // get the classname + String typeName = type.getName(); + int endIndex = typeName.lastIndexOf('.'); + if (endIndex < 0) { + return typeName; + } + return typeName.substring(endIndex + 1); + } + + private static String getPackageName(String interfaceName) { + int endIndex = interfaceName.lastIndexOf('.'); + if (endIndex < 0) { + return ""; + } + return interfaceName.substring(0, endIndex); + } + + private static final Map<String, String> specialTypeNames; + private static final Map<String, String> specialTypePackages; + private static final Set<String> keywords; + + static { + specialTypeNames = new HashMap<String, String>(); + specialTypeNames.put("boolean", "boolean"); + specialTypeNames.put("char", "wchar"); + specialTypeNames.put("byte", "octet"); + specialTypeNames.put("short", "short"); + specialTypeNames.put("int", "long"); + specialTypeNames.put("long", "long_long"); + specialTypeNames.put("float", "float"); + specialTypeNames.put("double", "double"); + specialTypeNames.put("java.lang.Class", "ClassDesc"); + specialTypeNames.put("java.lang.String", "WStringValue"); + specialTypeNames.put("org.omg.CORBA.Object", "Object"); + + specialTypePackages = new HashMap<String, String>(); + specialTypePackages.put("boolean", ""); + specialTypePackages.put("char", ""); + specialTypePackages.put("byte", ""); + specialTypePackages.put("short", ""); + specialTypePackages.put("int", ""); + specialTypePackages.put("long", ""); + specialTypePackages.put("float", ""); + specialTypePackages.put("double", ""); + specialTypePackages.put("java.lang.Class", "javax.rmi.CORBA"); + specialTypePackages.put("java.lang.String", "CORBA"); + specialTypePackages.put("org.omg.CORBA.Object", ""); + + keywords = new HashSet<String>(); + keywords.add("abstract"); + keywords.add("any"); + keywords.add("attribute"); + keywords.add("boolean"); + keywords.add("case"); + keywords.add("char"); + keywords.add("const"); + keywords.add("context"); + keywords.add("custom"); + keywords.add("default"); + keywords.add("double"); + keywords.add("enum"); + keywords.add("exception"); + keywords.add("factory"); + keywords.add("false"); + keywords.add("fixed"); + keywords.add("float"); + keywords.add("in"); + keywords.add("inout"); + keywords.add("interface"); + keywords.add("long"); + keywords.add("module"); + keywords.add("native"); + keywords.add("object"); + keywords.add("octet"); + keywords.add("oneway"); + keywords.add("out"); + keywords.add("private"); + keywords.add("public"); + keywords.add("raises"); + keywords.add("readonly"); + keywords.add("sequence"); + keywords.add("short"); + keywords.add("string"); + keywords.add("struct"); + keywords.add("supports"); + keywords.add("switch"); + keywords.add("true"); + keywords.add("truncatable"); + keywords.add("typedef"); + keywords.add("union"); + keywords.add("unsigned"); + keywords.add("valuebase"); + keywords.add("valuetype"); + keywords.add("void"); + keywords.add("wchar"); + keywords.add("wstring"); + } + + @SuppressWarnings("unchecked") + public static Map<Operation, Method> mapOperationToMethod(List<Operation> operations, Class<?> forClass) { + return (Map<Operation, Method>)createMethod2OperationMapping(operations, forClass, false); + } + + @SuppressWarnings("unchecked") + public static Map<Method, Operation> mapMethodToOperation(List<Operation> operations, Class<?> forClass) { + return (Map<Method, Operation>)createMethod2OperationMapping(operations, forClass, true); + } + + /** + * Maps Java methods to Tuscany operations + */ + @SuppressWarnings("unchecked") + private static Map createMethod2OperationMapping(List<Operation> operations, Class<?> forClass, boolean method2operation) { + // for every operation find all methods with the same name, then + // compare operations and methods parameters + Map mapping = new HashMap(); + for (Operation operation : operations) { + List<DataType> inputTypes = operation.getInputType().getLogical(); + Method[] methods = forClass.getMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals(operation.getName()) && inputTypes.size() == methods[i] + .getParameterTypes().length) { + Class<?>[] parameterTypes = methods[i].getParameterTypes(); + int j = 0; + boolean parameterMatch = true; + for (DataType dataType : inputTypes) { + if (!dataType.getPhysical().equals(parameterTypes[j])) { + parameterMatch = false; + break; + } + j++; + } + if (parameterMatch) { + // match found + if (method2operation) { + mapping.put(methods[i], operation); + } else { + mapping.put(operation, methods[i]); + } + break; + } + } + } + } + return mapping; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..9855dec8af --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.corba.provider.CorbaBindingProviderFactory;model=org.apache.tuscany.sca.binding.corba.CorbaBinding
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java new file mode 100644 index 0000000000..f1025e0693 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java @@ -0,0 +1,565 @@ +/* + * 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.corba.testing; + +import static junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Array; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.CorbaException; +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaRequest; +import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaResponse; +import org.apache.tuscany.sca.binding.corba.provider.service.ComponentInvocationProxy; +import org.apache.tuscany.sca.binding.corba.provider.service.DynaCorbaServant; +import org.apache.tuscany.sca.binding.corba.provider.service.InvocationProxy; +import org.apache.tuscany.sca.binding.corba.provider.types.util.Utils; +import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests; +import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper; +import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct; +import org.apache.tuscany.sca.binding.corba.testing.enums.Color; +import org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager; +import org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported; +import org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter; +import org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper; +import org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter; +import org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper; +import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct; +import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct; +import org.apache.tuscany.sca.binding.corba.testing.generated.TestObject; +import org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.NonCorbaException; +import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsTuscanyServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.InvalidTestObjectServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.InvalidTypesServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.NonCorbaServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant; +import org.apache.tuscany.sca.binding.corba.testing.service.mocks.TestRuntimeComponentService; +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.omg.CORBA.BAD_OPERATION; +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; + +/** + * @version $Rev$ $Date$ + * Tests API for dynamic CORBA servants + */ +public class CorbaServantTestCase { + + private static ORB orb; + private static TransientNameServer server; + + @BeforeClass + public static void start() { + try { + server = + new TransientNameServer(TestConstants.TEST2_HOST, TestConstants.TEST2_PORT, + TransientNameService.DEFAULT_SERVICE_NAME); + Thread t = server.start(); + if (t == null) { + Assert.fail("The naming server cannot be started"); + } + orb = server.getORB(); + } catch (Throwable e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + + @AfterClass + public static void stop() { + server.stop(); + } + + /** + * Binds servant implementation to name + */ + private void bindServant(DynaCorbaServant servant, String name) { + try { + Object nameService = orb.resolve_initial_references("NameService"); + NamingContext namingContext = NamingContextHelper.narrow(nameService); + + NameComponent nc = new NameComponent(name, ""); + NameComponent[] path = new NameComponent[] {nc}; + namingContext.rebind(path, servant); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Returns object reference which is binded to given name + * + * @param name + * @return + */ + private org.omg.CORBA.Object bindReference(String name) { + try { + org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); + NamingContext ncRef = NamingContextHelper.narrow(objRef); + NameComponent nc = new NameComponent(name, ""); + NameComponent path[] = {nc}; + return ncRef.resolve(path); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * Tests primitives (arguments, return types) + */ + @Test + public void test_primitivesSetter() { + try { + PrimitivesSetter primitivesSetter = new PrimitivesSetterServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(primitivesSetter); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = + new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"}; + servant.setIds(ids); + bindServant(servant, "PrimitivesSetter"); + PrimitivesSetter psClient = PrimitivesSetterHelper.narrow(bindReference("PrimitivesSetter")); + assertTrue(psClient.setBoolean(true) == true); + assertTrue(psClient.setChar('A') == 'A'); + assertTrue(psClient.setString("SomeTest").equals("SomeTest")); + assertTrue(psClient.setDouble(2d) == 2d); + assertTrue(psClient.setFloat(3f) == 3f); + assertTrue(psClient.setLong(1) == 1); + assertTrue(psClient.setLongLong(0L) == 0L); + assertTrue(psClient.setOctet((byte)8) == (byte)8); + assertTrue(psClient.setShort((short)6) == (short)6); + assertTrue(psClient.setUnsignedLong(9) == 9); + assertTrue(psClient.setUnsignedLongLong(11L) == 11L); + assertTrue(psClient.setUnsignedShort((short)15) == (short)15); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests if array values are equal + */ + private boolean areArraysEqual(java.lang.Object arr1, java.lang.Object arr2, int arrLen) { + try { + for (int i = 0; i < arrLen; i++) { + if (!Array.get(arr1, i).equals(Array.get(arr2, i))) { + return false; + } + } + return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + /** + * Tests arrays (arguments, return types) + */ + @Test + public void test_arraysSetter() { + try { + ArraysSetter arraysSetter = new ArraysSetterServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(arraysSetter); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"}; + servant.setIds(ids); + java.lang.Object result = null; + bindServant(servant, "ArraysSetter"); + ArraysSetter asClient = ArraysSetterHelper.narrow(bindReference("ArraysSetter")); + + boolean[] bArr = new boolean[] {true, false}; + result = (java.lang.Object)asClient.setBoolean(bArr); + assertTrue(areArraysEqual(bArr, result, bArr.length)); + + byte[] byArr = new byte[] {1, 2}; + result = (java.lang.Object)asClient.setOctet(byArr); + assertTrue(areArraysEqual(byArr, result, byArr.length)); + + short[] shArr = new short[] {1, 2}; + result = (java.lang.Object)asClient.setShort(shArr); + assertTrue(areArraysEqual(shArr, result, shArr.length)); + + int[] iArr = new int[] {1, 2}; + result = (java.lang.Object)asClient.setLong(iArr); + assertTrue(areArraysEqual(iArr, result, iArr.length)); + + long[] lArr = new long[] {1, 2}; + result = (java.lang.Object)asClient.setLongLong(lArr); + assertTrue(areArraysEqual(lArr, result, lArr.length)); + + String[] strArr = new String[] {"Some", "Test"}; + result = (java.lang.Object)asClient.setString(strArr); + assertTrue(areArraysEqual(strArr, result, strArr.length)); + + char[] chArr = new char[] {'A', 'B'}; + result = (java.lang.Object)asClient.setChar(chArr); + assertTrue(areArraysEqual(chArr, result, chArr.length)); + + float[] flArr = new float[] {1, 2}; + result = (java.lang.Object)asClient.setFloat(flArr); + assertTrue(areArraysEqual(flArr, result, flArr.length)); + + double[] dbArr = new double[] {1, 2}; + result = (java.lang.Object)asClient.setDouble(dbArr); + assertTrue(areArraysEqual(dbArr, result, dbArr.length)); + + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests structures (arguments, return types) + */ + @Test + public void test_TestObject_setStruct() { + try { + TestObject to = new TestObjectServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(to); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; + servant.setIds(ids); + bindServant(servant, "TestObject"); + TestObject testObject = TestObjectHelper.narrow(bindReference("TestObject")); + SomeStruct ss = new SomeStruct(); + SimpleStruct inner = new SimpleStruct(); + inner.field1 = TestConstants.STR_1; + inner.field2 = TestConstants.INT_1; + ss.innerStruct = inner; + ss.str = TestConstants.STR_2; + ss.str_list = TestConstants.STR_ARR_1; + ss.threeDimSeq = TestConstants.INT_ARRAY_3_DIM; + ss.twoDimSeq = TestConstants.INT_ARRAY_2_DIM; + SomeStruct result = testObject.setStruct(ss); + assertTrue(TestConstants.are2DimArraysEqual(result.twoDimSeq, TestConstants.INT_ARRAY_2_DIM)); + assertTrue(TestConstants.are3DimArraysEqual(result.threeDimSeq, TestConstants.INT_ARRAY_3_DIM)); + assertTrue(result.str.equals(ss.str)); + assertTrue(result.innerStruct.field1.equals(ss.innerStruct.field1)); + assertTrue(result.innerStruct.field2 == ss.innerStruct.field2); + assertTrue(areArraysEqual(result.str_list, ss.str_list, ss.str_list.length)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests handling BAD_OPERATION system exception + */ + @Test + public void test_systemException_BAD_OPERATION() { + try { + TestObjectServant tos = new TestObjectServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(tos); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; + servant.setIds(ids); + bindServant(servant, "TestObject"); + DynaCorbaRequest request = + new DynaCorbaRequest(bindReference("TestObject"), "methodThatSurelyDoesNotExist"); + request.invoke(); + fail(); + } catch (Exception e) { + if (e instanceof CorbaException) { + assertTrue(true); + } else { + e.printStackTrace(); + } + } + + try { + InvalidTestObjectServant tos = new InvalidTestObjectServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(tos); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; + servant.setIds(ids); + bindServant(servant, "InvalidTestObject"); + TestObject to = TestObjectHelper.narrow(bindReference("InvalidTestObject")); + SomeStruct str = new SomeStruct(); + str.innerStruct = new SimpleStruct(); + str.innerStruct.field1 = "Whatever"; + str.str = "Whatever"; + str.str_list = new String[] {}; + str.threeDimSeq = new int[][][] {}; + str.twoDimSeq = new int[][] {}; + to.setStruct(str); + } catch (Exception e) { + if (e instanceof BAD_OPERATION) { + assertTrue(true); + } else { + e.printStackTrace(); + } + } + } + + /** + * Tests handling user exceptions + */ + @Test + public void test_userExceptions() { + try { + CalcServant calc = new CalcServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(calc); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"}; + servant.setIds(ids); + bindServant(servant, "Calc"); + Calc calcClient = CalcHelper.narrow(bindReference("Calc")); + calcClient.div(1, 0); + fail(); + } catch (Exception e) { + if (e instanceof DivByZero) { + assertTrue(true); + } else { + e.printStackTrace(); + fail(); + } + } + + try { + CalcServant calc = new CalcServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(calc); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"}; + servant.setIds(ids); + bindServant(servant, "Calc"); + Calc calcClient = CalcHelper.narrow(bindReference("Calc")); + calcClient.divForSmallArgs(255, 255); + fail(); + } catch (Exception e) { + if (e instanceof NotSupported) { + assertTrue(true); + } else { + e.printStackTrace(); + fail(); + } + } + } + + /** + * Tests enums (arguments, return types) + */ + @Test + public void test_enums() { + try { + EnumManagerServant ems = new EnumManagerServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(ems); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"}; + servant.setIds(ids); + bindServant(servant, "Enum"); + EnumManager em = EnumManagerHelper.narrow(bindReference("Enum")); + Color color = Color.red; + assertTrue(em.getColor(color).value() == color.value()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + @Test + public void test_nonCorbaServants() { + try { + NonCorbaServant ncs = new NonCorbaServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(ncs); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + bindServant(servant, "NonCorbaServant"); + // it's non corba servant so we don't have stubs to test them + DynaCorbaRequest request = new DynaCorbaRequest(bindReference("NonCorbaServant"), "setString"); + request.addArgument(TestConstants.STR_1); + request.setOutputType(String.class); + DynaCorbaResponse response = request.invoke(); + assertTrue(response.getContent().equals(TestConstants.STR_1)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + + try { + NonCorbaServant ncs = new NonCorbaServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(ncs); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + bindServant(servant, "NonCorbaServant"); + // it's non corba servant so we don't have stubs to test them + DynaCorbaRequest request = new DynaCorbaRequest(bindReference("NonCorbaServant"), "throwException"); + request.addExceptionType(NonCorbaException.class); + request.invoke(); + fail(); + } catch (Exception e) { + if (e instanceof NonCorbaException) { + assertTrue(true); + } else { + e.printStackTrace(); + fail(); + } + } + } + + /** + * Tests handling BAD_PARAM system exception + */ + @Test + public void test_systemException_BAD_PARAM() { + try { + CalcServant calc = new CalcServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(calc); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; + servant.setIds(ids); + bindServant(servant, "Calc"); + DynaCorbaRequest request = new DynaCorbaRequest(bindReference("Calc"), "div"); + request.addArgument(2d); + request.setOutputType(double.class); + request.invoke(); + fail(); + } catch (Exception e) { + if (e instanceof CorbaException) { + assertTrue(true); + } else { + e.printStackTrace(); + fail(); + } + } + } + + /** + * Tests handling BAD_PARAM system exception + */ + @Test + public void test_invalidServantConfiguraion() { + try { + InvalidTypesServant its = new InvalidTypesServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(its); + //expecting exception... + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + fail(); + } catch (Exception e) { + if (e instanceof RequestConfigurationException) { + assertTrue(true); + } else { + e.printStackTrace(); + fail(); + } + } + } + + /** + * Tests serving CORBA arrays by Tuscany CORBA servants + */ + @Test + public void test_arraysPassing() { + try { + ArraysUnionsTuscanyServant arraysUnions = new ArraysUnionsTuscanyServant(); + TestRuntimeComponentService service = new TestRuntimeComponentService(arraysUnions); + Class<?> javaClass = ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass(); + InvocationProxy proxy = new ComponentInvocationProxy((RuntimeEndpoint) service.getEndpoints().get(0), javaClass); + DynaCorbaServant servant = new DynaCorbaServant(proxy, Utils.getTypeId(javaClass)); + String[] ids = new String[] {"IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"}; + servant.setIds(ids); + bindServant(servant, "ArraysUnions"); + Object reference = bindReference("ArraysUnions"); + ArraysUnionsTests objRef = ArraysUnionsTestsHelper.narrow(reference); + String[][] stringArray = {{"Hello", "World"}, {"Hi", "Again"}}; + String[][] result = objRef.passStringArray(stringArray); + for (int i = 0; i < stringArray.length; i++) { + for (int j = 0; j < stringArray[i].length; j++) { + assertEquals(stringArray[i][j], result[i][j]); + } + } + TestStruct struct = new TestStruct(); + String[] field1 = {"Hello", "World"}; + int[][] field2 = { {4, 2, 2, 5}, {6, 12, 5, 8}}; + float[][][] field3 = { { {2, 6}, {2, 7}, {9, 3}, {4, 6}}, { {3, 7}, {6, 6}, {3, 5}, {6, 2}}}; + struct.oneDimArray = field1; + struct.twoDimArray = field2; + struct.threeDimArray = field3; + + TestStruct structResult = objRef.passTestStruct(struct); + for (int i = 0; i < struct.oneDimArray.length; i++) { + assertEquals(struct.oneDimArray[i], structResult.oneDimArray[i]); + } + for (int i = 0; i < struct.twoDimArray.length; i++) { + for (int j = 0; j < struct.twoDimArray[i].length; j++) { + assertEquals(struct.twoDimArray[i][j], structResult.twoDimArray[i][j]); + } + } + for (int i = 0; i < struct.threeDimArray.length; i++) { + for (int j = 0; j < struct.threeDimArray[i].length; j++) { + for (int k = 0; k < struct.threeDimArray[i][j].length; k++) { + assertEquals(struct.threeDimArray[i][j][k], structResult.threeDimArray[i][j][k], 0.0); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java new file mode 100644 index 0000000000..1b1754f347 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java @@ -0,0 +1,841 @@ +/* + * 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.corba.testing; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Array; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.binding.corba.provider.exceptions.CorbaException; +import org.apache.tuscany.sca.binding.corba.provider.exceptions.RequestConfigurationException; +import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaRequest; +import org.apache.tuscany.sca.binding.corba.provider.reference.DynaCorbaResponse; +import org.apache.tuscany.sca.binding.corba.testing.enums.Color; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported; +import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct; +import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.ArraysTestStruct; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.DummyObject; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InnerUnion; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidCorbaArray; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum1; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum2; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum3; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct1; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct2; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct3; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion1; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion2; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion3; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion4; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidUnion5; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.RichUnion; +import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysUnionsTuscanyServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.ObjectManagerServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant; +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextExt; +import org.omg.CosNaming.NamingContextExtHelper; +import org.omg.CosNaming.NamingContextHelper; + +/** + * @version $Rev$ $Date$ + * Tests API for dynamic CORBA requests. Tests handling various Java + * types. + */ +public class CorbaTypesTestCase { + private static TransientNameServer server; + private static ORB orb; + + private static Object refPrimitivesSetter; + private static Object refArraysSetter; + private static Object refTestObject; + private static Object refCalcObject; + private static Object refObjectManager; + private static Object refEnumManager; + private static Object refArraysUnions; + + /** + * Spawns tnameserv process (must be in PATH). Initializes test servants and + * stores it's references so tests can use it. + */ + @BeforeClass + public static void setUp() { + try { + try { + server = + new TransientNameServer(TestConstants.TEST1_HOST, TestConstants.TEST1_PORT, + TransientNameService.DEFAULT_SERVICE_NAME); + Thread t = server.start(); + if (t == null) { + Assert.fail("The naming server cannot be started"); + } + orb = server.getORB(); + } catch (Throwable e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + + Object nameService = orb.resolve_initial_references("NameService"); + NamingContext namingContext = NamingContextHelper.narrow(nameService); + + PrimitivesSetterServant singleSetter = new PrimitivesSetterServant(); + ArraysSetterServant arraysSetter = new ArraysSetterServant(); + TestObjectServant complexObject = new TestObjectServant(); + CalcServant calcObject = new CalcServant(); + ObjectManagerServant objectManager = new ObjectManagerServant(); + EnumManagerServant enumManager = new EnumManagerServant(); + ArraysUnionsServant arraysUnions = new ArraysUnionsServant(); + + orb.connect(singleSetter); + orb.connect(arraysSetter); + + NameComponent nc; + NameComponent[] path; + + nc = new NameComponent("PrimitivesSetter", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, singleSetter); + + nc = new NameComponent("ArraysSetter", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, arraysSetter); + + nc = new NameComponent("TestObject", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, complexObject); + + nc = new NameComponent("CalcObject", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, calcObject); + + nc = new NameComponent("ObjectManager", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, objectManager); + + nc = new NameComponent("EnumManager", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, enumManager); + + nc = new NameComponent("ArraysUnions", ""); + path = new NameComponent[] {nc}; + namingContext.rebind(path, arraysUnions); + + NamingContextExt nce = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); + + refArraysSetter = nce.resolve(nce.to_name("ArraysSetter")); + refPrimitivesSetter = nce.resolve(nce.to_name("PrimitivesSetter")); + refTestObject = nce.resolve(nce.to_name("TestObject")); + refCalcObject = nce.resolve(nce.to_name("CalcObject")); + refObjectManager = nce.resolve(nce.to_name("ObjectManager")); + refEnumManager = nce.resolve(nce.to_name("EnumManager")); + refArraysUnions = nce.resolve(nce.to_name("ArraysUnions")); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void stop() { + server.stop(); + } + + /** + * Tests remote operation, basing on given reference, operation name, + * arguments, expected return type and content + * + * @param ref remote object + * @param operationName operation to invoke + * @param clazz expected return type + * @param arguments array of operation arguments + * @param equalTo expected return content + */ + private void dynaTestInvoker(Object ref, + String operationName, + Class<?> clazz, + java.lang.Object[] arguments, + java.lang.Object equalTo) { + + try { + DynaCorbaRequest request = new DynaCorbaRequest(ref, operationName); + request.setOutputType(clazz); + for (int i = 0; arguments != null && i < arguments.length; i++) { + request.addArgument(arguments[i]); + } + + DynaCorbaResponse response = request.invoke(); + java.lang.Object content = (java.lang.Object)response.getContent(); + assertTrue(content.getClass().equals(clazz)); + if (equalTo != null && equalTo.getClass().isArray()) { + for (int i = 0; i < Array.getLength(equalTo); i++) { + assertTrue(Array.get(content, i).equals(Array.get(equalTo, i))); + } + } else { + assertTrue(content.equals(equalTo)); + } + } catch (Exception e) { + e.printStackTrace(); + fail("Error while invoking " + operationName); + } + } + + /** + * Tests passing (and getting as result) varied primitives + */ + @Test + public void test_setPrimitives() { + + dynaTestInvoker(refPrimitivesSetter, "setBoolean", Boolean.class, new Boolean[] {true}, true); + dynaTestInvoker(refPrimitivesSetter, "setOctet", Byte.class, new Byte[] {1}, (byte)1); + dynaTestInvoker(refPrimitivesSetter, "setChar", Character.class, new Character[] {'A'}, 'A'); + dynaTestInvoker(refPrimitivesSetter, "setShort", Short.class, new Short[] {1}, (short)1); + dynaTestInvoker(refPrimitivesSetter, "setLong", Integer.class, new Integer[] {1}, (int)1); + dynaTestInvoker(refPrimitivesSetter, "setLongLong", Long.class, new Long[] {(long)1}, (long)1); + dynaTestInvoker(refPrimitivesSetter, "setFloat", Float.class, new Float[] {(float)1}, (float)1); + dynaTestInvoker(refPrimitivesSetter, "setDouble", Double.class, new Double[] {(double)1}, (double)1); + dynaTestInvoker(refPrimitivesSetter, "setString", String.class, new String[] {"1"}, "1"); + + } + + /** + * Tests passing (and getting as result) varied types sequences + */ + @Test + public void test_setArrays() { + + dynaTestInvoker(refArraysSetter, + "setBoolean", + Boolean[].class, + new Boolean[][] {new Boolean[] {false, true}}, + new Boolean[] {false, true}); + + dynaTestInvoker(refArraysSetter, + "setChar", + Character[].class, + new Character[][] {new Character[] {'A', 'B'}}, + new Character[] {'A', 'B'}); + + dynaTestInvoker(refArraysSetter, "setOctet", Byte[].class, new Byte[][] {new Byte[] {1, 2}}, new Byte[] {1, 2}); + + dynaTestInvoker(refArraysSetter, "setShort", Short[].class, new Short[][] {new Short[] {1, 2}}, new Short[] {1, + 2}); + + dynaTestInvoker(refArraysSetter, + "setLong", + Integer[].class, + new Integer[][] {new Integer[] {1, 2}}, + new Integer[] {1, 2}); + + dynaTestInvoker(refArraysSetter, + "setLongLong", + Long[].class, + new Long[][] {new Long[] {new Long(1), new Long(2)}}, + new Long[] {new Long(1), new Long(2)}); + + dynaTestInvoker(refArraysSetter, + "setFloat", + Float[].class, + new Float[][] {new Float[] {new Float(1.0), new Float(2.0)}}, + new Float[] {new Float(1.0), new Float(2.0)}); + + dynaTestInvoker(refArraysSetter, + "setDouble", + Double[].class, + new Double[][] {new Double[] {new Double(1.0), new Double(2.0)}}, + new Double[] {new Double(1.0), new Double(2.0)}); + + dynaTestInvoker(refArraysSetter, + "setString", + String[].class, + new String[][] {new String[] {"A", "B"}}, + new String[] {"A", "B"}); + + } + + /** + * Tests passing (and getting as result) complex structure + */ + @Test + public void test_TestObject_setStruct() { + DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setStruct"); + + SomeStruct struct = new SomeStruct(); + SimpleStruct inner = new SimpleStruct(); + inner.field1 = TestConstants.STR_1; + inner.field2 = TestConstants.INT_1; + struct.innerStruct = inner; + struct.str_list = TestConstants.STR_ARR_2; + struct.twoDimSeq = TestConstants.INT_ARRAY_2_DIM; + struct.threeDimSeq = TestConstants.INT_ARRAY_3_DIM; + struct.str = TestConstants.STR_1; + + try { + request.addArgument(struct); + request.setOutputType(SomeStruct.class); + DynaCorbaResponse response = request.invoke(); + SomeStruct result = (SomeStruct)response.getContent(); + assertTrue(TestConstants.are2DimArraysEqual(result.twoDimSeq, TestConstants.INT_ARRAY_2_DIM)); + assertTrue(TestConstants.are3DimArraysEqual(result.threeDimSeq, TestConstants.INT_ARRAY_3_DIM)); + assertEquals(TestConstants.STR_1, result.str); + assertEquals(TestConstants.STR_ARR_2[0], result.str_list[0]); + assertEquals(TestConstants.STR_ARR_2[1], result.str_list[1]); + assertEquals(TestConstants.STR_1, result.innerStruct.field1); + assertEquals(TestConstants.INT_1, result.innerStruct.field2); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception occured during tests: " + e); + } + } + + /** + * Test passing (and getting as result) simple two-field structure + */ + @Test + public void test_TestObject_setSimpleStruct() { + SimpleStruct struct = new SimpleStruct(); + struct.field1 = TestConstants.STR_1; + struct.field2 = TestConstants.INT_1; + DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setSimpleStruct"); + try { + request.setOutputType(SimpleStruct.class); + request.addArgument(struct); + DynaCorbaResponse response = request.invoke(); + SimpleStruct retStruct = (SimpleStruct)response.getContent(); + assertTrue(retStruct.field1.equals(struct.field1) && retStruct.field2 == struct.field2); + } catch (Exception e) { + e.printStackTrace(); + fail("Exception occured during tests: " + e); + } + } + + /** + * Tests passing (and getting as result) two dim. sequence of long. + */ + @Test + public void test_TestObject_setLongSeq2() { + int[][] arr1 = new int[2][2]; + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + arr1[i][j] = (int)(Math.random() * 1000); + } + } + DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setLongSeq2"); + try { + request.setOutputType(arr1.getClass()); + request.addArgument(arr1); + DynaCorbaResponse response = request.invoke(); + int[][] arr2 = (int[][])response.getContent(); + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + assertEquals(arr1[i][j], arr2[i][j]); + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("Exception occured during tests: " + e); + } + } + + /** + * Tests passing multiple complex attributes. + */ + @Test + public void test_TestObject_pickStructFromArgs() { + SomeStruct arg1 = new SomeStruct(); + SomeStruct arg2 = new SomeStruct(); + SomeStruct arg3 = new SomeStruct(); + + SimpleStruct inner = new SimpleStruct(); + inner.field1 = TestConstants.STR_1; + inner.field2 = TestConstants.INT_1; + + arg1.innerStruct = inner; + arg2.innerStruct = inner; + arg3.innerStruct = inner; + + arg1.str = TestConstants.STR_1; + arg2.str = TestConstants.STR_2; + arg3.str = TestConstants.STR_3; + + arg1.str_list = TestConstants.STR_ARR_1; + arg2.str_list = TestConstants.STR_ARR_2; + arg3.str_list = TestConstants.STR_ARR_2; + + arg1.threeDimSeq = TestConstants.INT_ARRAY_3_DIM; + arg2.threeDimSeq = TestConstants.INT_ARRAY_3_DIM; + arg3.threeDimSeq = TestConstants.INT_ARRAY_3_DIM; + + arg1.twoDimSeq = TestConstants.INT_ARRAY_2_DIM; + arg2.twoDimSeq = TestConstants.INT_ARRAY_2_DIM; + arg3.twoDimSeq = TestConstants.INT_ARRAY_2_DIM; + + DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "pickStructFromArgs"); + try { + + request.setOutputType(SomeStruct.class); + request.addArgument(arg1); + request.addArgument(arg2); + request.addArgument(arg3); + request.addArgument(1); + DynaCorbaResponse response = request.invoke(); + SomeStruct result = (SomeStruct)response.getContent(); + + // just make sure that servant returned right structure + assertTrue(result.str.equals(TestConstants.STR_1)); + } catch (Exception e) { + fail("Exception occured during tests " + e); + e.printStackTrace(); + } + + } + + /** + * Tests handling user defined remote exception (single declared) + */ + @Test + public void test_singleException() { + DynaCorbaRequest request1 = new DynaCorbaRequest(refCalcObject, "div"); + try { + request1.addArgument(2d); + request1.addArgument(2d); + request1.setOutputType(Double.class); + request1.addExceptionType(DivByZero.class); + request1.invoke(); + } catch (Exception e) { + fail(); + } + + DynaCorbaRequest request2 = new DynaCorbaRequest(refCalcObject, "div"); + try { + request2.addArgument(2d); + request2.addArgument(0d); + request2.setOutputType(Double.class); + request2.addExceptionType(DivByZero.class); + request2.invoke(); + } catch (DivByZero e) { + assertTrue(e.info != null && e.arguments != null && e.arguments.arg1 == 2 && e.arguments.arg2 == 0); + } catch (Exception exc) { + exc.printStackTrace(); + fail(); + } + } + + /** + * Tests handling user defined multiple exceptions + */ + @Test + public void test_multipleExceptions() { + DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "divForSmallArgs"); + try { + request.addArgument(101d); + request.addArgument(101d); + request.setOutputType(Double.class); + request.addExceptionType(DivByZero.class); + request.addExceptionType(NotSupported.class); + request.invoke(); + } catch (Exception e) { + assertTrue(e instanceof NotSupported); + } + } + + /** + * Tests handling exceptions while user defined no exceptions + */ + @Test + public void test_noExceptionsDeclared() { + DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div"); + try { + request.addArgument(1d); + request.addArgument(0d); + request.setOutputType(Double.class); + request.invoke(); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + } + + /** + * Tests handling exceptions while user defined no such exception + */ + @Test + public void test_noSuchExceptionDeclared() { + DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div"); + try { + request.addArgument(1d); + request.addArgument(0d); + request.addExceptionType(NotSupported.class); + request.setOutputType(Double.class); + request.invoke(); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + } + + /** + * Tests handling non existing operation situation + */ + @Test + public void test_systemException_BAD_OPERATION() { + DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "thisOperationSurelyDoesNotExist"); + try { + request.invoke(); + fail(); + } catch (Exception e) { + assertTrue(e instanceof CorbaException); + } + } + + /** + * Tests obtaining references to other objects and using them with specified + * user interface + */ + @Test + @Ignore("Cause of tnameservice hang on stop") + public void test_enchancedReferences() { + DynaCorbaRequest request = null; + try { + request = new DynaCorbaRequest(refObjectManager, "getDummyObject"); + request.setOutputType(DummyObject.class); + DynaCorbaResponse response = request.invoke(); + DummyObject dummy = (DummyObject)response.getContent(); + DummyObject dummy2 = dummy.cloneObject(); + dummy2.cloneObject(); + assertNotSame(dummy.getLong(), dummy2.getLong()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Test passing enums as arguments and retrieving them as a result + */ + @Test + public void test_enums() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refEnumManager, "getColor"); + Color color = Color.green; + request.addArgument(color); + request.setOutputType(Color.class); + DynaCorbaResponse response = request.invoke(); + Color result = (Color)response.getContent(); + assertEquals(color.value(), result.value()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests recognizing structures + */ + @Test + public void test_structValidation() { + DynaCorbaRequest request = null; + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidStruct1.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidStruct2.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidStruct3.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(SomeStruct.class); + } catch (Exception e) { + fail(); + } + } + + /** + * Tests recognizing enums + */ + @Test + public void test_enumValidation() { + DynaCorbaRequest request = null; + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidEnum1.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidEnum2.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidEnum3.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + + try { + request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(Color.class); + } catch (Exception e) { + fail(); + } + } + + /** + * Tests handling passing wrong params + */ + @Test + public void test_systemException_BAD_PARAM() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div"); + request.setOutputType(Double.class); + request.addArgument(3d); + request.invoke(); + fail(); + } catch (Exception e) { + if (e instanceof CorbaException) { + assertTrue(true); + } else { + e.printStackTrace(); + fail(); + } + } + } + + /** + * Tests passing CORBA arrays + */ + @Test + public void test_arraysPassing() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray"); + Annotation[] notes = + ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class}) + .getAnnotations(); + request.setOutputType(String[][].class, notes); + String[][] argument = { {"Hello", "World"}, {"Hi", "again"}}; + request.addArgument(argument, notes); + DynaCorbaResponse response = request.invoke(); + String[][] result = (String[][])response.getContent(); + for (int i = 0; i < argument.length; i++) { + for (int j = 0; j < argument[i].length; j++) { + assertEquals(argument[i][j], result[i][j]); + } + } + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passTestStruct"); + ArraysTestStruct arg = new ArraysTestStruct(); + String[] field1 = {"Hello", "World"}; + arg.field1 = field1; + int[][] field2 = { {4, 2, 2, 5}, {6, 12, 5, 8}}; + arg.field2 = field2; + float[][][] field3 = { { {2, 6}, {2, 7}, {9, 3}, {4, 6}}, { {3, 7}, {6, 6}, {3, 5}, {6, 2}}}; + arg.field3 = field3; + request.addArgument(arg); + request.setOutputType(ArraysTestStruct.class); + DynaCorbaResponse response = request.invoke(); + ArraysTestStruct result = (ArraysTestStruct)response.getContent(); + for (int i = 0; i < arg.field1.length; i++) { + assertEquals(arg.field1[i], result.field1[i]); + } + for (int i = 0; i < arg.field2.length; i++) { + for (int j = 0; j < arg.field2[i].length; j++) { + assertEquals(arg.field2[i][j], result.field2[i][j]); + } + } + for (int i = 0; i < arg.field2.length; i++) { + for (int j = 0; j < arg.field2[i].length; j++) { + for (int k = 0; k < arg.field3[i][j].length; k++) { + assertEquals(arg.field3[i][j][k], result.field3[i][j][k], 0.0); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests situation when CORBA array dimension size doesn't match + * CORBA array annotation arguments (which sets dimension lengths) + */ + @Test + public void test_invalidArrayAnnotationSize() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray"); + Annotation[] notes = + ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class}) + .getAnnotations(); + request.setOutputType(String[][][].class, notes); + fail(); + } catch (RequestConfigurationException e) { + // expected + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray"); + Annotation[] notes = + ArraysUnionsTuscanyServant.class.getMethod("passStringArray", new Class<?>[] {String[][].class}) + .getAnnotations(); + request.addArgument(new String[0][0][0], notes); + fail(); + } catch (RequestConfigurationException e) { + // expected + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passStringArray"); + request.addArgument(new InvalidCorbaArray(), null); + fail(); + } catch (RequestConfigurationException e) { + // expected + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests passing CORBA unions + */ + @Test + public void test_passingUnions() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passRichUnion"); + request.setOutputType(RichUnion.class); + RichUnion arg = new RichUnion(); + InnerUnion argIu = new InnerUnion(); + argIu.setX(10); + arg.setIu(argIu); + request.addArgument(arg); + DynaCorbaResponse response = request.invoke(); + RichUnion result = (RichUnion)response.getContent(); + assertEquals(arg.getIu().getX(), result.getIu().getX()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "passRichUnion"); + request.setOutputType(RichUnion.class); + RichUnion arg = new RichUnion(); + arg.setDef(true); + request.addArgument(arg); + DynaCorbaResponse response = request.invoke(); + RichUnion result = (RichUnion)response.getContent(); + assertEquals(arg.isDef(), result.isDef()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests handling invalid union declarations + */ + @Test + public void test_testInvalidUnionClasses() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever"); + request.setOutputType(InvalidUnion1.class); + } catch (Exception e) { + assertEquals(RequestConfigurationException.class, e.getClass()); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever"); + request.setOutputType(InvalidUnion2.class); + } catch (Exception e) { + assertEquals(RequestConfigurationException.class, e.getClass()); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever"); + request.setOutputType(InvalidUnion3.class); + } catch (Exception e) { + assertEquals(RequestConfigurationException.class, e.getClass()); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever"); + request.setOutputType(InvalidUnion4.class); + } catch (Exception e) { + assertEquals(RequestConfigurationException.class, e.getClass()); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysUnions, "whatever"); + request.setOutputType(InvalidUnion5.class); + } catch (Exception e) { + assertEquals(RequestConfigurationException.class, e.getClass()); + } + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.java new file mode 100644 index 0000000000..f0dccd9e7e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MappingTestInterface.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.binding.corba.testing; + +/** + * @version $Rev$ $Date$ + * Interface that can be tested for operations mapping + */ +public interface MappingTestInterface { + + int getIntField(); + + void setIntField(int intField); + + boolean isBoolField(); + + void setBoolField(boolean boolField); + + void overloadedName(); + + void overloadedName(String arg1); + + void overloadedName(String arg1, int arg2); + + void caseCollision(); + + void CaseCollision(); + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.java new file mode 100644 index 0000000000..6975c62ddb --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/MethodFinderTestCase.java @@ -0,0 +1,70 @@ +/* + * 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.corba.testing; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.binding.corba.provider.util.MethodFinder; +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + * Various tests for MethodFinder + */ +public class MethodFinderTestCase { + + /** + * Tests finding existing methods + */ + @Test + public void test_findExistingMethod() { + try { + String methodName = "rotateLeft"; + Method sample = Integer.class.getMethod(methodName, new Class<?>[] {int.class, int.class}); + Method m1 = MethodFinder.findMethod(Integer.class, methodName, new Class<?>[] {int.class, int.class}); + Method m2 = + MethodFinder.findMethod(Integer.class, methodName, new Class<?>[] {Integer.class, Integer.class}); + assertEquals(sample, m1); + assertEquals(sample, m2); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests null result value for not existing method + */ + @Test + public void test_findNotExistingMethod() { + try { + String methodName = "rotateLeft"; + Method method = MethodFinder.findMethod(Integer.class, methodName, new Class<?>[] {}); + assertEquals(null, method); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java new file mode 100644 index 0000000000..4767728db7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/OperationMappingTestCase.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.Map; + +import org.apache.tuscany.sca.binding.corba.provider.util.OperationMapper; +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + * Various tests for OperationsMapping + */ +public class OperationMappingTestCase { + + /** + * Tests if Java2IDLUtil maps methods to operations correctly + */ + @Test + public void test_mappingRules() { + Map<Method, String> met2op = OperationMapper.mapMethodToOperationName(MappingTestInterface.class); + for (Method method : met2op.keySet()) { + String name = method.getName(); + String translatedName = met2op.get(method); + if (name.equals("getIntField")) { + assertEquals("_get_intField", translatedName); + } else if (name.equals("setIntField")) { + assertEquals("_set_intField", translatedName); + } else if (name.equals("isBoolField")) { + assertEquals("_get_boolField", translatedName); + } else if (name.equals("setBoolField")) { + assertEquals("_set_boolField", translatedName); + } else if (name.equals("overloadedName") && method.getParameterTypes().length == 0) { + assertEquals("overloadedName__", translatedName); + } else if (name.equals("overloadedName") && method.getParameterTypes().length == 1) { + assertEquals("overloadedName__CORBA_WStringValue", translatedName); + } else if (name.equals("overloadedName") && method.getParameterTypes().length == 2) { + assertEquals("overloadedName__CORBA_WStringValue__long", translatedName); + } else if (name.equals("caseCollision")) { + assertEquals("caseCollision_4", translatedName); + } else if (name.equals("CaseCollision")) { + assertEquals("CaseCollision_0_4", translatedName); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java new file mode 100644 index 0000000000..962a00d002 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/TestConstants.java @@ -0,0 +1,87 @@ +/* + * 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.corba.testing; + +/** + * Some constants and utilities for module tests + * @version $Rev$ $Date$ + */ +public class TestConstants { + + public static final String STR_1 = "Hello world!"; + public static final String STR_2 = "2nd string"; + public static final String STR_3 = "Other string"; + public static final String[] STR_ARR_1 = {"Hello", "World"}; + public static final String[] STR_ARR_2 = {"Another", "string", "array"}; + public static final int INT_1 = 0; + + public static final int TEST1_PORT = 11100; + public static final String TEST1_HOST = "localhost"; + + public static final int TEST2_PORT = 11101; + public static final String TEST2_HOST = "localhost"; + + public static final int[][] INT_ARRAY_2_DIM = { {1, 2}, {3, 4}}; + public static final int[][][] INT_ARRAY_3_DIM = { { {1, 2}, {3, 4}}, { {5, 6}, {7, 8}}}; + + public static final long TNAMESERV_SPAWN_WAIT = 300; + + /** + * Tests if given 2D arrays values are equal + * @param arr1 + * @param arr2 + * @return + */ + public static boolean are2DimArraysEqual(int[][] arr1, int[][] arr2) { + int sum = 0; + int expSum = 0; + for (int i = 0; i < arr1.length; i++) { + for (int j = 0; j < arr1[i].length; j++) { + expSum++; + if (arr1[i][j] == arr2[i][j]) { + sum++; + } + } + } + return sum == expSum; + } + + /** + * Tests if given 3D arrays values are equal + * @param arr1 + * @param arr2 + * @return + */ + public static boolean are3DimArraysEqual(int[][][] arr1, int[][][] arr2) { + int sum = 0; + int expSum = 0; + for (int i = 0; i < arr1.length; i++) { + for (int j = 0; j < arr1[i].length; j++) { + for (int k = 0; k < arr1[i][j].length; k++) { + expSum++; + if (arr1[i][j][k] == arr2[i][j][k]) { + sum++; + } + } + } + } + return sum == expSum; + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java new file mode 100644 index 0000000000..f4ca1577f5 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java @@ -0,0 +1,13 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public interface ArraysUnionsTests extends ArraysUnionsTestsOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface ArraysUnionsTests diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java new file mode 100644 index 0000000000..d10bc498b7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java @@ -0,0 +1,85 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +abstract public class ArraysUnionsTestsHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests 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.binding.corba.testing.arrays_unions.ArraysUnionsTests 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.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.id (), "ArraysUnionsTests"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_ArraysUnionsTestsStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests) + return (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)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.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub stub = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests) + return (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub stub = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java new file mode 100644 index 0000000000..98987c1252 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class ArraysUnionsTestsHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests value = null; + + public ArraysUnionsTestsHolder () + { + } + + public ArraysUnionsTestsHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTestsHelper.type (); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java new file mode 100644 index 0000000000..d80adb476a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java @@ -0,0 +1,16 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTestsOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public interface ArraysUnionsTestsOperations +{ + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct passTestStruct (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg); + String[][] passStringArray (String[][] arg); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion passRichUnion (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion arg); +} // interface ArraysUnionsTestsOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java new file mode 100644 index 0000000000..9f520f3c5d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java @@ -0,0 +1,112 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class InnerUnion implements org.omg.CORBA.portable.IDLEntity +{ + private int ___x; + private float ___y; + private int __discriminator; + private boolean __uninitialized = true; + + public InnerUnion () + { + } + + public int discriminator () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + return __discriminator; + } + + public int x () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyx (__discriminator); + return ___x; + } + + public void x (int value) + { + __discriminator = 1; + ___x = value; + __uninitialized = false; + } + + public void x (int discriminator, int value) + { + verifyx (discriminator); + __discriminator = discriminator; + ___x = value; + __uninitialized = false; + } + + private void verifyx (int discriminator) + { + if (discriminator != 1) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public float y () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyy (__discriminator); + return ___y; + } + + public void y (float value) + { + __discriminator = 2; + ___y = value; + __uninitialized = false; + } + + public void y (int discriminator, float value) + { + verifyy (discriminator); + __discriminator = discriminator; + ___y = value; + __uninitialized = false; + } + + private void verifyy (int discriminator) + { + if (discriminator != 2) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public void _default () + { + __discriminator = -2147483648; + __uninitialized = false; + } + + public void _default (int discriminator) + { + verifyDefault( discriminator ) ; + __discriminator = discriminator ; + __uninitialized = false; + } + + private void verifyDefault( int value ) + { + switch (value) { + case 1: + case 2: + throw new org.omg.CORBA.BAD_OPERATION() ; + + default: + return; + } + } + +} // class InnerUnion diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java new file mode 100644 index 0000000000..11c22f1d72 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java @@ -0,0 +1,106 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +abstract public class InnerUnionHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnion/InnerUnion:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion 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.binding.corba.testing.arrays_unions.InnerUnion 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) + { + org.omg.CORBA.TypeCode _disTypeCode0; + _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [2]; + org.omg.CORBA.TypeCode _tcOf_members0; + org.omg.CORBA.Any _anyOf_members0; + + // Branch for x (case label 1) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)1); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + _members0[0] = new org.omg.CORBA.UnionMember ( + "x", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for y (case label 2) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)2); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float); + _members0[1] = new org.omg.CORBA.UnionMember ( + "y", + _anyOf_members0, + _tcOf_members0, + null); + __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.id (), "InnerUnion", _disTypeCode0, _members0); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion read (org.omg.CORBA.portable.InputStream istream) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion (); + int _dis0 = (int)0; + _dis0 = istream.read_long (); + switch (_dis0) + { + case 1: + int _x = (int)0; + _x = istream.read_long (); + value.x (_x); + break; + case 2: + float _y = (float)0; + _y = istream.read_float (); + value.y (_y); + break; + default: + value._default( _dis0 ) ; + break; + } + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value) + { + ostream.write_long (value.discriminator ()); + switch (value.discriminator ()) + { + case 1: + ostream.write_long (value.x ()); + break; + case 2: + ostream.write_float (value.y ()); + break; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java new file mode 100644 index 0000000000..ca9233c77f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/InnerUnionHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class InnerUnionHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value = null; + + public InnerUnionHolder () + { + } + + public InnerUnionHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.type (); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java new file mode 100644 index 0000000000..1a1a36fd16 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java @@ -0,0 +1,177 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class RichUnion implements org.omg.CORBA.portable.IDLEntity +{ + private int ___x; + private float ___y; + private String ___z; + private org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion ___iu; + private boolean ___a; + private int __discriminator; + private boolean __uninitialized = true; + + public RichUnion () + { + } + + public int discriminator () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + return __discriminator; + } + + public int x () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyx (__discriminator); + return ___x; + } + + public void x (int value) + { + __discriminator = 1; + ___x = value; + __uninitialized = false; + } + + public void x (int discriminator, int value) + { + verifyx (discriminator); + __discriminator = discriminator; + ___x = value; + __uninitialized = false; + } + + private void verifyx (int discriminator) + { + if (discriminator != 1) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public float y () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyy (__discriminator); + return ___y; + } + + public void y (float value) + { + __discriminator = 2; + ___y = value; + __uninitialized = false; + } + + public void y (int discriminator, float value) + { + verifyy (discriminator); + __discriminator = discriminator; + ___y = value; + __uninitialized = false; + } + + private void verifyy (int discriminator) + { + if (discriminator != 2) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public String z () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyz (__discriminator); + return ___z; + } + + public void z (String value) + { + __discriminator = 3; + ___z = value; + __uninitialized = false; + } + + public void z (int discriminator, String value) + { + verifyz (discriminator); + __discriminator = discriminator; + ___z = value; + __uninitialized = false; + } + + private void verifyz (int discriminator) + { + if (discriminator != 3) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion iu () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyiu (__discriminator); + return ___iu; + } + + public void iu (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value) + { + __discriminator = 4; + ___iu = value; + __uninitialized = false; + } + + public void iu (int discriminator, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion value) + { + verifyiu (discriminator); + __discriminator = discriminator; + ___iu = value; + __uninitialized = false; + } + + private void verifyiu (int discriminator) + { + if (discriminator != 4) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public boolean a () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifya (__discriminator); + return ___a; + } + + public void a (boolean value) + { + __discriminator = -2147483648; + ___a = value; + __uninitialized = false; + } + + public void a (int discriminator, boolean value) + { + verifya (discriminator); + __discriminator = discriminator; + ___a = value; + __uninitialized = false; + } + + private void verifya (int discriminator) + { + if (discriminator == 1 || discriminator == 2 || discriminator == 3 || discriminator == 4) + throw new org.omg.CORBA.BAD_OPERATION (); + } + +} // class RichUnion diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java new file mode 100644 index 0000000000..7cef0ea189 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java @@ -0,0 +1,157 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +abstract public class RichUnionHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnion/RichUnion:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion 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.binding.corba.testing.arrays_unions.RichUnion 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) + { + org.omg.CORBA.TypeCode _disTypeCode0; + _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [5]; + org.omg.CORBA.TypeCode _tcOf_members0; + org.omg.CORBA.Any _anyOf_members0; + + // Branch for x (case label 1) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)1); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + _members0[0] = new org.omg.CORBA.UnionMember ( + "x", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for y (case label 2) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)2); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float); + _members0[1] = new org.omg.CORBA.UnionMember ( + "y", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for z (case label 3) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)3); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0); + _members0[2] = new org.omg.CORBA.UnionMember ( + "z", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for iu (case label 4) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)4); + _tcOf_members0 = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.type (); + _members0[3] = new org.omg.CORBA.UnionMember ( + "iu", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for a (Default case) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_octet ((byte)0); // default member label + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_boolean); + _members0[4] = new org.omg.CORBA.UnionMember ( + "a", + _anyOf_members0, + _tcOf_members0, + null); + __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.id (), "RichUnion", _disTypeCode0, _members0); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion read (org.omg.CORBA.portable.InputStream istream) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion (); + int _dis0 = (int)0; + _dis0 = istream.read_long (); + switch (_dis0) + { + case 1: + int _x = (int)0; + _x = istream.read_long (); + value.x (_x); + break; + case 2: + float _y = (float)0; + _y = istream.read_float (); + value.y (_y); + break; + case 3: + String _z = null; + _z = istream.read_string (); + value.z (_z); + break; + case 4: + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnion _iu = null; + _iu = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.read (istream); + value.iu (_iu); + break; + default: + boolean _a = false; + _a = istream.read_boolean (); + value.a (_dis0, _a); + break; + } + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion value) + { + ostream.write_long (value.discriminator ()); + switch (value.discriminator ()) + { + case 1: + ostream.write_long (value.x ()); + break; + case 2: + ostream.write_float (value.y ()); + break; + case 3: + ostream.write_string (value.z ()); + break; + case 4: + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.InnerUnionHelper.write (ostream, value.iu ()); + break; + default: + ostream.write_boolean (value.a ()); + break; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java new file mode 100644 index 0000000000..5498104905 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/RichUnionHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class RichUnionHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion value = null; + + public RichUnionHolder () + { + } + + public RichUnionHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.type (); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java new file mode 100644 index 0000000000..72beff0537 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java @@ -0,0 +1,76 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +abstract public class StringArrayHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArray:1.0"; + + public static void insert (org.omg.CORBA.Any a, String[][] 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 String[][] 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_string_tc (0); + __typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode ); + __typeCode = org.omg.CORBA.ORB.init ().create_array_tc (2, __typeCode ); + __typeCode = org.omg.CORBA.ORB.init ().create_alias_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.id (), "StringArray", __typeCode); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static String[][] read (org.omg.CORBA.portable.InputStream istream) + { + String value[][] = null; + value = new String[2][]; + for (int _o0 = 0;_o0 < (2); ++_o0) + { + value[_o0] = new String[2]; + for (int _o1 = 0;_o1 < (2); ++_o1) + { + value[_o0][_o1] = istream.read_string (); + } + } + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, String[][] value) + { + if (value.length != (2)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i0 = 0;_i0 < (2); ++_i0) + { + if (value[_i0].length != (2)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i1 = 0;_i1 < (2); ++_i1) + { + ostream.write_string (value[_i0][_i1]); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java new file mode 100644 index 0000000000..747337597c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java @@ -0,0 +1,39 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/StringArrayHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class StringArrayHolder implements org.omg.CORBA.portable.Streamable +{ + public String value[][] = null; + + public StringArrayHolder () + { + } + + public StringArrayHolder (String[][] initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.type (); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java new file mode 100644 index 0000000000..2b239deadc --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java @@ -0,0 +1,28 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class TestStruct implements org.omg.CORBA.portable.IDLEntity +{ + public String oneDimArray[] = null; + public int twoDimArray[][] = null; + public float threeDimArray[][][] = null; + + public TestStruct () + { + } // ctor + + public TestStruct (String[] _oneDimArray, int[][] _twoDimArray, float[][][] _threeDimArray) + { + oneDimArray = _oneDimArray; + twoDimArray = _twoDimArray; + threeDimArray = _threeDimArray; + } // ctor + +} // class TestStruct diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java new file mode 100644 index 0000000000..6427d9d200 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java @@ -0,0 +1,149 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +abstract public class TestStructHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStruct/TestStruct:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct 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.binding.corba.testing.arrays_unions.TestStruct extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + synchronized (org.omg.CORBA.TypeCode.class) + { + if (__typeCode == null) + { + if (__active) + { + return org.omg.CORBA.ORB.init().create_recursive_tc ( _id ); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [3]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 ); + _members0[0] = new org.omg.CORBA.StructMember ( + "oneDimArray", + _tcOf_members0, + null); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 ); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (4, _tcOf_members0 ); + _members0[1] = new org.omg.CORBA.StructMember ( + "twoDimArray", + _tcOf_members0, + null); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 ); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (4, _tcOf_members0 ); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_array_tc (2, _tcOf_members0 ); + _members0[2] = new org.omg.CORBA.StructMember ( + "threeDimArray", + _tcOf_members0, + null); + __typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.id (), "TestStruct", _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct read (org.omg.CORBA.portable.InputStream istream) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value = new org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct (); + value.oneDimArray = new String[2]; + for (int _o0 = 0;_o0 < (2); ++_o0) + { + value.oneDimArray[_o0] = istream.read_string (); + } + value.twoDimArray = new int[2][]; + for (int _o1 = 0;_o1 < (2); ++_o1) + { + value.twoDimArray[_o1] = new int[4]; + for (int _o2 = 0;_o2 < (4); ++_o2) + { + value.twoDimArray[_o1][_o2] = istream.read_long (); + } + } + value.threeDimArray = new float[2][][]; + for (int _o3 = 0;_o3 < (2); ++_o3) + { + value.threeDimArray[_o3] = new float[4][]; + for (int _o4 = 0;_o4 < (4); ++_o4) + { + value.threeDimArray[_o3][_o4] = new float[2]; + for (int _o5 = 0;_o5 < (2); ++_o5) + { + value.threeDimArray[_o3][_o4][_o5] = istream.read_float (); + } + } + } + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value) + { + if (value.oneDimArray.length != (2)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i0 = 0;_i0 < (2); ++_i0) + { + ostream.write_string (value.oneDimArray[_i0]); + } + if (value.twoDimArray.length != (2)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i1 = 0;_i1 < (2); ++_i1) + { + if (value.twoDimArray[_i1].length != (4)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i2 = 0;_i2 < (4); ++_i2) + { + ostream.write_long (value.twoDimArray[_i1][_i2]); + } + } + if (value.threeDimArray.length != (2)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i3 = 0;_i3 < (2); ++_i3) + { + if (value.threeDimArray[_i3].length != (4)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i4 = 0;_i4 < (4); ++_i4) + { + if (value.threeDimArray[_i3][_i4].length != (2)) + throw new org.omg.CORBA.MARSHAL (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + for (int _i5 = 0;_i5 < (2); ++_i5) + { + ostream.write_float (value.threeDimArray[_i3][_i4][_i5]); + } + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java new file mode 100644 index 0000000000..94683e0327 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/TestStructHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public final class TestStructHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct value = null; + + public TestStructHolder () + { + } + + public TestStructHolder (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.type (); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java new file mode 100644 index 0000000000..e4cac28e4f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java @@ -0,0 +1,86 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public abstract class _ArraysUnionsTestsImplBase extends org.omg.CORBA.portable.ObjectImpl + implements org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + public _ArraysUnionsTestsImplBase () + { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("passTestStruct", new java.lang.Integer (0)); + _methods.put ("passStringArray", new java.lang.Integer (1)); + _methods.put ("passRichUnion", new java.lang.Integer (2)); + } + + 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/binding/corba/testing/arrays_unions/ArraysUnionsTests/passTestStruct + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read (in); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct $result = null; + $result = this.passTestStruct (arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write (out, $result); + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passStringArray + { + String arg[][] = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read (in); + String $result[][] = null; + $result = this.passStringArray (arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write (out, $result); + break; + } + + case 2: // org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests/passRichUnion + { + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion arg = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.read (in); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion $result = null; + $result = this.passRichUnion (arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.write (out, $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/binding/corba/testing/arrays_unions/ArraysUnionsTests:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + +} // class _ArraysUnionsTestsImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java new file mode 100644 index 0000000000..38e29c0d63 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java @@ -0,0 +1,100 @@ +package org.apache.tuscany.sca.binding.corba.testing.arrays_unions; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/arrays_unions/_ArraysUnionsTestsStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from arrays_unions.idl +* niedziela, 17 sierpieñ 2008 15:45:39 CEST +*/ + +public class _ArraysUnionsTestsStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.binding.corba.testing.arrays_unions.ArraysUnionsTests +{ + + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct passTestStruct (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct arg) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("passTestStruct", true); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.write ($out, arg); + $in = _invoke ($out); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct $result = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStructHelper.read ($in); + 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 passTestStruct (arg ); + } finally { + _releaseReply ($in); + } + } // passTestStruct + + public String[][] passStringArray (String[][] arg) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("passStringArray", true); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.write ($out, arg); + $in = _invoke ($out); + String $result[][] = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.StringArrayHelper.read ($in); + 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 passStringArray (arg ); + } finally { + _releaseReply ($in); + } + } // passStringArray + + public org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion passRichUnion (org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion arg) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("passRichUnion", true); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.write ($out, arg); + $in = _invoke ($out); + org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion $result = org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnionHelper.read ($in); + 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 passRichUnion (arg ); + } finally { + _releaseReply ($in); + } + } // passRichUnion + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:org/apache/tuscany/sca/binding/corba/testing/arrays_unions/ArraysUnionsTests: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 _ArraysUnionsTestsStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java new file mode 100644 index 0000000000..e3c28f8b91 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.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.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/Color.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public class Color implements org.omg.CORBA.portable.IDLEntity { + private int __value; + private static int __size = 3; + private static org.apache.tuscany.sca.binding.corba.testing.enums.Color[] __array = + new org.apache.tuscany.sca.binding.corba.testing.enums.Color[__size]; + + public static final int _red = 0; + public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color red = + new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_red); + public static final int _yellow = 1; + public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color yellow = + new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_yellow); + public static final int _green = 2; + public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color green = + new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_green); + + public int value() { + return __value; + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.Color from_int(int value) { + if (value >= 0 && value < __size) + return __array[value]; + else + throw new org.omg.CORBA.BAD_PARAM(); + } + + protected Color(int value) { + __value = value; + __array[__value] = this; + } +} // class Color diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java new file mode 100644 index 0000000000..775cac8e16 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +abstract public class ColorHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/Color:1.0"; + + public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.enums.Color 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.binding.corba.testing.enums.Color 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_enum_tc(org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper + .id(), + "Color", + new String[] {"red", "yellow", "green"}); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.Color read(org.omg.CORBA.portable.InputStream istream) { + return org.apache.tuscany.sca.binding.corba.testing.enums.Color.from_int(istream.read_long()); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.enums.Color value) { + ostream.write_long(value.value()); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java new file mode 100644 index 0000000000..32cd9c8df6 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.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.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public final class ColorHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.enums.Color value = null; + + public ColorHolder() { + } + + public ColorHolder(org.apache.tuscany.sca.binding.corba.testing.enums.Color initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java new file mode 100644 index 0000000000..3f73557952 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.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.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public interface EnumManager extends EnumManagerOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface EnumManager diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java new file mode 100644 index 0000000000..a6160a7643 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.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.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +abstract public class EnumManagerHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"; + + public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager 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.binding.corba.testing.enums.EnumManager 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.binding.corba.testing.enums.EnumManagerHelper.id(), + "EnumManager"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_EnumManagerStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager) + return (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)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.binding.corba.testing.enums._EnumManagerStub stub = + new org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager) + return (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub stub = + new org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java new file mode 100644 index 0000000000..6afa6bc806 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.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.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public final class EnumManagerHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager value = null; + + public EnumManagerHolder() { + } + + public EnumManagerHolder(org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java new file mode 100644 index 0000000000..bab0c27f77 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java @@ -0,0 +1,32 @@ +/* + * 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.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public interface EnumManagerOperations { + + org.apache.tuscany.sca.binding.corba.testing.enums.Color getColor(org.apache.tuscany.sca.binding.corba.testing.enums.Color color); +} // interface EnumManagerOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java new file mode 100644 index 0000000000..514627ff4b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public abstract class _EnumManagerImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _EnumManagerImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("getColor", 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/binding/corba/testing/enums/EnumManager/getColor + { + org.apache.tuscany.sca.binding.corba.testing.enums.Color color = + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.enums.Color $result = null; + $result = this.getColor(color); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write(out, $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/binding/corba/testing/enums/EnumManager:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _EnumManagerImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java new file mode 100644 index 0000000000..4629ca9cff --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public class _EnumManagerStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager { + + public org.apache.tuscany.sca.binding.corba.testing.enums.Color getColor(org.apache.tuscany.sca.binding.corba.testing.enums.Color color) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("getColor", true); + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write($out, color); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.enums.Color $result = + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read($in); + 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 getColor(color); + } finally { + _releaseReply($in); + } + } // getColor + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"}; + + @Override + 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 _EnumManagerStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java new file mode 100644 index 0000000000..aa480f93ac --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.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.binding.corba.testing.exceptions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public interface Calc extends CalcOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface Calc diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java new file mode 100644 index 0000000000..5ed36ca19b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.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.binding.corba.testing.exceptions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +abstract public class CalcHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"; + + public static void insert(org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc 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.binding.corba.testing.exceptions.Calc 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.binding.corba.testing.exceptions.CalcHelper.id(), + "Calc"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_CalcStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc) + return (org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc)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.binding.corba.testing.exceptions._CalcStub stub = + new org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc) + return (org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub stub = + new org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java new file mode 100644 index 0000000000..ec1cfadd1e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.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.binding.corba.testing.exceptions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class CalcHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc value = null; + + public CalcHolder() { + } + + public CalcHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java new file mode 100644 index 0000000000..29865ace06 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.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.corba.testing.exceptions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public interface CalcOperations { + double div(double arg1, double arg2) + throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero; + + double divForSmallArgs(double arg1, double arg2) + throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported; +} // interface CalcOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java new file mode 100644 index 0000000000..d7839ec4db --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/Arguments.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class Arguments implements org.omg.CORBA.portable.IDLEntity { + public double arg1 = (double)0; + public double arg2 = (double)0; + + public Arguments() { + } // ctor + + public Arguments(double _arg1, double _arg2) { + arg1 = _arg1; + arg2 = _arg2; + } // ctor + +} // class Arguments diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java new file mode 100644 index 0000000000..c47d63208f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java @@ -0,0 +1,94 @@ +/* + * 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.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +abstract public class ArgumentsHelper { + private static String _id = + "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/Arguments/Arguments:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments 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.binding.corba.testing.exceptions.CalcPackage.Arguments extract(org.omg.CORBA.Any a) { + return read(a.create_input_stream()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + + synchronized public static org.omg.CORBA.TypeCode type() { + if (__typeCode == null) { + synchronized (org.omg.CORBA.TypeCode.class) { + if (__typeCode == null) { + if (__active) { + return org.omg.CORBA.ORB.init().create_recursive_tc(_id); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[2]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_double); + _members0[0] = new org.omg.CORBA.StructMember("arg1", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_double); + _members0[1] = new org.omg.CORBA.StructMember("arg2", _tcOf_members0, null); + __typeCode = + org.omg.CORBA.ORB + .init() + .create_struct_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper + .id(), + "Arguments", + _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments read(org.omg.CORBA.portable.InputStream istream) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments value = + new org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments(); + value.arg1 = istream.read_double(); + value.arg2 = istream.read_double(); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments value) { + ostream.write_double(value.arg1); + ostream.write_double(value.arg2); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java new file mode 100644 index 0000000000..f767e8c11a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.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.binding.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/ArgumentsHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class ArgumentsHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments value = null; + + public ArgumentsHolder() { + } + + public ArgumentsHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java new file mode 100644 index 0000000000..e7cbb4b8ca --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java @@ -0,0 +1,52 @@ +/* + * 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.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZero.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class DivByZero extends org.omg.CORBA.UserException { + public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments arguments = null; + public String info = null; + + public DivByZero() { + super(DivByZeroHelper.id()); + } // ctor + + public DivByZero(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments _arguments, + String _info) { + super(DivByZeroHelper.id()); + arguments = _arguments; + info = _info; + } // ctor + + public DivByZero(String $reason, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments _arguments, + String _info) { + super(DivByZeroHelper.id() + " " + $reason); + arguments = _arguments; + info = _info; + } // ctor + +} // class DivByZero diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java new file mode 100644 index 0000000000..5d27f9969c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java @@ -0,0 +1,100 @@ +/* + * 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.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +abstract public class DivByZeroHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/DivByZero:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero 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.binding.corba.testing.exceptions.CalcPackage.DivByZero extract(org.omg.CORBA.Any a) { + return read(a.create_input_stream()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + + synchronized public static org.omg.CORBA.TypeCode type() { + if (__typeCode == null) { + synchronized (org.omg.CORBA.TypeCode.class) { + if (__typeCode == null) { + if (__active) { + return org.omg.CORBA.ORB.init().create_recursive_tc(_id); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[2]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + _tcOf_members0 = + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.type(); + _members0[0] = new org.omg.CORBA.StructMember("arguments", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0); + _members0[1] = new org.omg.CORBA.StructMember("info", _tcOf_members0, null); + __typeCode = + org.omg.CORBA.ORB + .init() + .create_exception_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper + .id(), + "DivByZero", + _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero read(org.omg.CORBA.portable.InputStream istream) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero value = + new org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero(); + // read and discard the repository ID + istream.read_string(); + value.arguments = + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.read(istream); + value.info = istream.read_string(); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero value) { + // write the repository ID + ostream.write_string(id()); + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.ArgumentsHelper.write(ostream, + value.arguments); + ostream.write_string(value.info); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java new file mode 100644 index 0000000000..ab01c66675 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.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.binding.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/DivByZeroHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class DivByZeroHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero value = null; + + public DivByZeroHolder() { + } + + public DivByZeroHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java new file mode 100644 index 0000000000..f4ea58e55e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.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.binding.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupported.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class NotSupported extends org.omg.CORBA.UserException { + public String info = null; + + public NotSupported() { + super(NotSupportedHelper.id()); + } // ctor + + public NotSupported(String _info) { + super(NotSupportedHelper.id()); + info = _info; + } // ctor + + public NotSupported(String $reason, String _info) { + super(NotSupportedHelper.id() + " " + $reason); + info = _info; + } // ctor + +} // class NotSupported diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java new file mode 100644 index 0000000000..82609a36c1 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +abstract public class NotSupportedHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/NotSupported:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported 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.binding.corba.testing.exceptions.CalcPackage.NotSupported extract(org.omg.CORBA.Any a) { + return read(a.create_input_stream()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + + synchronized public static org.omg.CORBA.TypeCode type() { + if (__typeCode == null) { + synchronized (org.omg.CORBA.TypeCode.class) { + if (__typeCode == null) { + if (__active) { + return org.omg.CORBA.ORB.init().create_recursive_tc(_id); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[1]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0); + _members0[0] = new org.omg.CORBA.StructMember("info", _tcOf_members0, null); + __typeCode = + org.omg.CORBA.ORB + .init() + .create_exception_tc(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper + .id(), + "NotSupported", + _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported read(org.omg.CORBA.portable.InputStream istream) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported value = + new org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported(); + // read and discard the repository ID + istream.read_string(); + value.info = istream.read_string(); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported value) { + // write the repository ID + ostream.write_string(id()); + ostream.write_string(value.info); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java new file mode 100644 index 0000000000..1389bd33d9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.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.binding.corba.testing.exceptions.CalcPackage; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/CalcPackage/NotSupportedHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public final class NotSupportedHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported value = null; + + public NotSupportedHolder() { + } + + public NotSupportedHolder(org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java new file mode 100644 index 0000000000..a73e252129 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java @@ -0,0 +1,102 @@ +/* + * 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.corba.testing.exceptions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public abstract class _CalcImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _CalcImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("div", new java.lang.Integer(0)); + _methods.put("divForSmallArgs", new java.lang.Integer(1)); + } + + 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/binding/corba/testing/exceptions/Calc/div + { + try { + double arg1 = in.read_double(); + double arg2 = in.read_double(); + double $result = (double)0; + $result = this.div(arg1, arg2); + out = $rh.createReply(); + out.write_double($result); + } catch (org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero $ex) { + out = $rh.createExceptionReply(); + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.write(out, $ex); + } + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/divForSmallArgs + { + try { + double arg1 = in.read_double(); + double arg2 = in.read_double(); + double $result = (double)0; + $result = this.divForSmallArgs(arg1, arg2); + out = $rh.createReply(); + out.write_double($result); + } catch (org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero $ex) { + out = $rh.createExceptionReply(); + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.write(out, $ex); + } catch (org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported $ex) { + out = $rh.createExceptionReply(); + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.write(out, + $ex); + } + 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/binding/corba/testing/exceptions/Calc:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _CalcImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java new file mode 100644 index 0000000000..65ce051129 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java @@ -0,0 +1,106 @@ +/* + * 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.corba.testing.exceptions; + +/** +* org/apache/tuscany/sca/binding/corba/testing/exceptions/_CalcStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from exceptions.idl +* sobota, 7 czerwiec 2008 16:12:31 CEST +*/ + +public class _CalcStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.exceptions.Calc { + + public double div(double arg1, double arg2) + throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("div", true); + $out.write_double(arg1); + $out.write_double(arg2); + $in = _invoke($out); + double $result = $in.read_double(); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream(); + String _id = $ex.getId(); + if (_id.equals("IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/DivByZero:1.0")) + throw org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.read($in); + else + throw new org.omg.CORBA.MARSHAL(_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return div(arg1, arg2); + } finally { + _releaseReply($in); + } + } // div + + public double divForSmallArgs(double arg1, double arg2) + throws org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero, + org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("divForSmallArgs", true); + $out.write_double(arg1); + $out.write_double(arg2); + $in = _invoke($out); + double $result = $in.read_double(); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream(); + String _id = $ex.getId(); + if (_id.equals("IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/DivByZero:1.0")) + throw org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZeroHelper.read($in); + else if (_id.equals("IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc/NotSupported:1.0")) + throw org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupportedHelper.read($in); + else + throw new org.omg.CORBA.MARSHAL(_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return divForSmallArgs(arg1, arg2); + } finally { + _releaseReply($in); + } + } // divForSmallArgs + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/exceptions/Calc:1.0"}; + + @Override + 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 _CalcStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java new file mode 100644 index 0000000000..fde204edf8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public interface ArraysSetter extends ArraysSetterOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface ArraysSetter diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java new file mode 100644 index 0000000000..71b4fbbdb6 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java @@ -0,0 +1,100 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class ArraysSetterHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter 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.binding.corba.testing.generated.ArraysSetter 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.binding.corba.testing.generated.ArraysSetterHelper.id(), + "ArraysSetter"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_ArraysSetterStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter) + return (org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter)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.binding.corba.testing.generated._ArraysSetterStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter) + return (org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java new file mode 100644 index 0000000000..d758a560a9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class ArraysSetterHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter value = null; + + public ArraysSetterHolder() { + } + + public ArraysSetterHolder(org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetterHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java new file mode 100644 index 0000000000..464c2ccbc3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetterOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public interface ArraysSetterOperations { + boolean[] setBoolean(boolean[] arg); + + char[] setChar(char[] arg); + + char[] setWchar(char[] arg); + + byte[] setOctet(byte[] arg); + + short[] setShort(short[] arg); + + short[] setUnsignedShort(short[] arg); + + int[] setLong(int[] arg); + + int[] setUnsignedLong(int[] arg); + + long[] setLongLong(long[] arg); + + long[] setUnsignedLongLong(long[] arg); + + float[] setFloat(float[] arg); + + double[] setDouble(double[] arg); + + String[] setString(String[] arg); + + String[] setWstring(String[] arg); + + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] obj); +} // interface ArraysSetterOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java new file mode 100644 index 0000000000..c053f12a02 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public interface PrimitivesSetter extends PrimitivesSetterOperations, org.omg.CORBA.Object, + org.omg.CORBA.portable.IDLEntity { +} // interface PrimitivesSetter diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java new file mode 100644 index 0000000000..566689960e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java @@ -0,0 +1,100 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class PrimitivesSetterHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter 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.binding.corba.testing.generated.PrimitivesSetter 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.binding.corba.testing.generated.PrimitivesSetterHelper + .id(), + "PrimitivesSetter"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_PrimitivesSetterStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter) + return (org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter)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.binding.corba.testing.generated._PrimitivesSetterStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter) + return (org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java new file mode 100644 index 0000000000..6564957081 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class PrimitivesSetterHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter value = null; + + public PrimitivesSetterHolder() { + } + + public PrimitivesSetterHolder(org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetterHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java new file mode 100644 index 0000000000..26669de95a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetterOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public interface PrimitivesSetterOperations { + boolean setBoolean(boolean arg); + + char setChar(char arg); + + char setWchar(char arg); + + byte setOctet(byte arg); + + short setShort(short arg); + + short setUnsignedShort(short arg); + + int setLong(int arg); + + int setUnsignedLong(int arg); + + long setLongLong(long arg); + + long setUnsignedLongLong(long arg); + + float setFloat(float arg); + + double setDouble(double arg); + + String setString(String arg); + + String setWstring(String arg); + + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj); +} // interface PrimitivesSetterOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java new file mode 100644 index 0000000000..5a140f5ecc --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public interface RemoteObject extends RemoteObjectOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface RemoteObject diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java new file mode 100644 index 0000000000..2a8fe73417 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java @@ -0,0 +1,100 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class RemoteObjectHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject 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.binding.corba.testing.generated.RemoteObject 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.binding.corba.testing.generated.RemoteObjectHelper.id(), + "RemoteObject"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_RemoteObjectStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject) + return (org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject)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.binding.corba.testing.generated._RemoteObjectStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject) + return (org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._RemoteObjectStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java new file mode 100644 index 0000000000..63e3926dd2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class RemoteObjectHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value = null; + + public RemoteObjectHolder() { + } + + public RemoteObjectHolder(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java new file mode 100644 index 0000000000..a8231236eb --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObjectOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public interface RemoteObjectOperations { +} // interface RemoteObjectOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java new file mode 100644 index 0000000000..ca86420240 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class SimpleStruct implements org.omg.CORBA.portable.IDLEntity { + public String field1 = null; + public int field2 = (int)0; + + public SimpleStruct() { + } // ctor + + public SimpleStruct(String _field1, int _field2) { + field1 = _field1; + field2 = _field2; + } // ctor + +} // class SimpleStruct diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java new file mode 100644 index 0000000000..2a8898d38f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class SimpleStructHelper { + private static String _id = + "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStruct/SimpleStruct:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct 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.binding.corba.testing.generated.SimpleStruct extract(org.omg.CORBA.Any a) { + return read(a.create_input_stream()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + + synchronized public static org.omg.CORBA.TypeCode type() { + if (__typeCode == null) { + synchronized (org.omg.CORBA.TypeCode.class) { + if (__typeCode == null) { + if (__active) { + return org.omg.CORBA.ORB.init().create_recursive_tc(_id); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[2]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0); + _members0[0] = new org.omg.CORBA.StructMember("field1", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + _members0[1] = new org.omg.CORBA.StructMember("field2", _tcOf_members0, null); + __typeCode = + org.omg.CORBA.ORB.init() + .create_struct_tc(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper + .id(), + "SimpleStruct", + _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct read(org.omg.CORBA.portable.InputStream istream) { + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct value = + new org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct(); + value.field1 = istream.read_string(); + value.field2 = istream.read_long(); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct value) { + ostream.write_string(value.field1); + ostream.write_long(value.field2); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java new file mode 100644 index 0000000000..bed30e00ca --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/SimpleStructHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class SimpleStructHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct value = null; + + public SimpleStructHolder() { + } + + public SimpleStructHolder(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java new file mode 100644 index 0000000000..73dbd6c198 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class SomeStruct implements org.omg.CORBA.portable.IDLEntity { + public org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct innerStruct = null; + public String str = null; + public String str_list[] = null; + public int twoDimSeq[][] = null; + public int threeDimSeq[][][] = null; + + public SomeStruct() { + } // ctor + + public SomeStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct _innerStruct, + String _str, + String[] _str_list, + int[][] _twoDimSeq, + int[][][] _threeDimSeq) { + innerStruct = _innerStruct; + str = _str; + str_list = _str_list; + twoDimSeq = _twoDimSeq; + threeDimSeq = _threeDimSeq; + } // ctor + +} // class SomeStruct diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java new file mode 100644 index 0000000000..8f524ffeb1 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java @@ -0,0 +1,146 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class SomeStructHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/SomeStruct/SomeStruct:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct 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.binding.corba.testing.generated.SomeStruct extract(org.omg.CORBA.Any a) { + return read(a.create_input_stream()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + private static boolean __active = false; + + synchronized public static org.omg.CORBA.TypeCode type() { + if (__typeCode == null) { + synchronized (org.omg.CORBA.TypeCode.class) { + if (__typeCode == null) { + if (__active) { + return org.omg.CORBA.ORB.init().create_recursive_tc(_id); + } + __active = true; + org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember[5]; + org.omg.CORBA.TypeCode _tcOf_members0 = null; + _tcOf_members0 = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.type(); + _members0[0] = new org.omg.CORBA.StructMember("innerStruct", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0); + _members0[1] = new org.omg.CORBA.StructMember("str", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_string_tc(0); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0); + _tcOf_members0 = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper + .id(), + "string_list", + _tcOf_members0); + _members0[2] = new org.omg.CORBA.StructMember("str_list", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0); + _tcOf_members0 = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper + .id(), + "long_seq1", + _tcOf_members0); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0); + _tcOf_members0 = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper + .id(), + "long_seq2", + _tcOf_members0); + _members0[3] = new org.omg.CORBA.StructMember("twoDimSeq", _tcOf_members0, null); + _tcOf_members0 = org.omg.CORBA.ORB.init().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0); + _tcOf_members0 = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper + .id(), + "long_seq1", + _tcOf_members0); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0); + _tcOf_members0 = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper + .id(), + "long_seq2", + _tcOf_members0); + _tcOf_members0 = org.omg.CORBA.ORB.init().create_sequence_tc(0, _tcOf_members0); + _tcOf_members0 = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper + .id(), + "long_seq3", + _tcOf_members0); + _members0[4] = new org.omg.CORBA.StructMember("threeDimSeq", _tcOf_members0, null); + __typeCode = + org.omg.CORBA.ORB.init() + .create_struct_tc(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper + .id(), + "SomeStruct", + _members0); + __active = false; + } + } + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct read(org.omg.CORBA.portable.InputStream istream) { + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct value = + new org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct(); + value.innerStruct = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read(istream); + value.str = istream.read_string(); + value.str_list = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read(istream); + value.twoDimSeq = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(istream); + value.threeDimSeq = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read(istream); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct value) { + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(ostream, value.innerStruct); + ostream.write_string(value.str); + org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write(ostream, value.str_list); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(ostream, value.twoDimSeq); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(ostream, value.threeDimSeq); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java new file mode 100644 index 0000000000..3231a136dc --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/SomeStructHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class SomeStructHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct value = null; + + public SomeStructHolder() { + } + + public SomeStructHolder(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java new file mode 100644 index 0000000000..28d3ecdc91 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/TestObject.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public interface TestObject extends TestObjectOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface TestObject diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java new file mode 100644 index 0000000000..29ff2edfd2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java @@ -0,0 +1,99 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class TestObjectHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.TestObject 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.binding.corba.testing.generated.TestObject 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.binding.corba.testing.generated.TestObjectHelper.id(), + "TestObject"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_TestObjectStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.TestObject value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.TestObject) + return (org.apache.tuscany.sca.binding.corba.testing.generated.TestObject)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.binding.corba.testing.generated._TestObjectStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.TestObject unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.generated.TestObject) + return (org.apache.tuscany.sca.binding.corba.testing.generated.TestObject)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub stub = + new org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java new file mode 100644 index 0000000000..b8aea13c8d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class TestObjectHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.TestObject value = null; + + public TestObjectHolder() { + } + + public TestObjectHolder(org.apache.tuscany.sca.binding.corba.testing.generated.TestObject initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.TestObjectHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java new file mode 100644 index 0000000000..0bacb6746a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/TestObjectOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public interface TestObjectOperations { + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct pickStructFromArgs(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg1, + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg2, + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg3, + int structNumber); + + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct setStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg); + + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct setSimpleStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder arg); + + int[] setLongSeq1(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder arg); + + int[][] setLongSeq2(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder arg); + + int[][][] setLongSeq3(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder arg); +} // interface TestObjectOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java new file mode 100644 index 0000000000..c6e8c2a4e0 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java @@ -0,0 +1,232 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public abstract class _ArraysSetterImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _ArraysSetterImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("setBoolean", new java.lang.Integer(0)); + _methods.put("setChar", new java.lang.Integer(1)); + _methods.put("setWchar", new java.lang.Integer(2)); + _methods.put("setOctet", new java.lang.Integer(3)); + _methods.put("setShort", new java.lang.Integer(4)); + _methods.put("setUnsignedShort", new java.lang.Integer(5)); + _methods.put("setLong", new java.lang.Integer(6)); + _methods.put("setUnsignedLong", new java.lang.Integer(7)); + _methods.put("setLongLong", new java.lang.Integer(8)); + _methods.put("setUnsignedLongLong", new java.lang.Integer(9)); + _methods.put("setFloat", new java.lang.Integer(10)); + _methods.put("setDouble", new java.lang.Integer(11)); + _methods.put("setString", new java.lang.Integer(12)); + _methods.put("setWstring", new java.lang.Integer(13)); + _methods.put("setRemoteObject", new java.lang.Integer(14)); + } + + 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/binding/corba/testing/generated/ArraysSetter/setBoolean + { + boolean arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.read(in); + boolean $result[] = null; + $result = this.setBoolean(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.write(out, $result); + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setChar + { + char arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.read(in); + char $result[] = null; + $result = this.setChar(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.write(out, $result); + break; + } + + case 2: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setWchar + { + char arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.read(in); + char $result[] = null; + $result = this.setWchar(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.write(out, $result); + break; + } + + case 3: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setOctet + { + byte arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.read(in); + byte $result[] = null; + $result = this.setOctet(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.write(out, $result); + break; + } + + case 4: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setShort + { + short arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.read(in); + short $result[] = null; + $result = this.setShort(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.write(out, $result); + break; + } + + case 5: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setUnsignedShort + { + short arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.read(in); + short $result[] = null; + $result = this.setUnsignedShort(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.write(out, $result); + break; + } + + case 6: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setLong + { + int arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.read(in); + int $result[] = null; + $result = this.setLong(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.write(out, $result); + break; + } + + case 7: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setUnsignedLong + { + int arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.read(in); + int $result[] = null; + $result = this.setUnsignedLong(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.write(out, $result); + break; + } + + case 8: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setLongLong + { + long arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.read(in); + long $result[] = null; + $result = this.setLongLong(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.write(out, $result); + break; + } + + case 9: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setUnsignedLongLong + { + long arg[] = + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.read(in); + long $result[] = null; + $result = this.setUnsignedLongLong(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper + .write(out, $result); + break; + } + + case 10: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setFloat + { + float arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.read(in); + float $result[] = null; + $result = this.setFloat(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.write(out, $result); + break; + } + + case 11: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setDouble + { + double arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.read(in); + double $result[] = null; + $result = this.setDouble(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.write(out, $result); + break; + } + + case 12: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setString + { + String arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read(in); + String $result[] = null; + $result = this.setString(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write(out, $result); + break; + } + + case 13: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setWstring + { + String arg[] = org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.read(in); + String $result[] = null; + $result = this.setWstring(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.write(out, $result); + break; + } + + case 14: // org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter/setRemoteObject + { + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj[] = + org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result[] = null; + $result = this.setRemoteObject(obj); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.write(out, $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/binding/corba/testing/generated/ArraysSetter:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _ArraysSetterImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java new file mode 100644 index 0000000000..079cc6e899 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java @@ -0,0 +1,343 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_ArraysSetterStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public class _ArraysSetterStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.ArraysSetter { + + public boolean[] setBoolean(boolean[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setBoolean", true); + org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.write($out, arg); + $in = _invoke($out); + boolean $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.read($in); + 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 setBoolean(arg); + } finally { + _releaseReply($in); + } + } // setBoolean + + public char[] setChar(char[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setChar", true); + org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.write($out, arg); + $in = _invoke($out); + char $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.read($in); + 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 setChar(arg); + } finally { + _releaseReply($in); + } + } // setChar + + public char[] setWchar(char[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setWchar", true); + org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.write($out, arg); + $in = _invoke($out); + char $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.read($in); + 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 setWchar(arg); + } finally { + _releaseReply($in); + } + } // setWchar + + public byte[] setOctet(byte[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setOctet", true); + org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.write($out, arg); + $in = _invoke($out); + byte $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.read($in); + 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 setOctet(arg); + } finally { + _releaseReply($in); + } + } // setOctet + + public short[] setShort(short[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setShort", true); + org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.write($out, arg); + $in = _invoke($out); + short $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.read($in); + 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 setShort(arg); + } finally { + _releaseReply($in); + } + } // setShort + + public short[] setUnsignedShort(short[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedShort", true); + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.write($out, arg); + $in = _invoke($out); + short $result[] = + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.read($in); + 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 setUnsignedShort(arg); + } finally { + _releaseReply($in); + } + } // setUnsignedShort + + public int[] setLong(int[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLong", true); + org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.write($out, arg); + $in = _invoke($out); + int $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.read($in); + 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 setLong(arg); + } finally { + _releaseReply($in); + } + } // setLong + + public int[] setUnsignedLong(int[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLong", true); + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.write($out, arg); + $in = _invoke($out); + int $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.read($in); + 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 setUnsignedLong(arg); + } finally { + _releaseReply($in); + } + } // setUnsignedLong + + public long[] setLongLong(long[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLongLong", true); + org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.write($out, arg); + $in = _invoke($out); + long $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.read($in); + 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 setLongLong(arg); + } finally { + _releaseReply($in); + } + } // setLongLong + + public long[] setUnsignedLongLong(long[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLongLong", true); + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.write($out, arg); + $in = _invoke($out); + long $result[] = + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.read($in); + 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 setUnsignedLongLong(arg); + } finally { + _releaseReply($in); + } + } // setUnsignedLongLong + + public float[] setFloat(float[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setFloat", true); + org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.write($out, arg); + $in = _invoke($out); + float $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.read($in); + 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 setFloat(arg); + } finally { + _releaseReply($in); + } + } // setFloat + + public double[] setDouble(double[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setDouble", true); + org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.write($out, arg); + $in = _invoke($out); + double $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.read($in); + 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 setDouble(arg); + } finally { + _releaseReply($in); + } + } // setDouble + + public String[] setString(String[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setString", true); + org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write($out, arg); + $in = _invoke($out); + String $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read($in); + 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 setString(arg); + } finally { + _releaseReply($in); + } + } // setString + + public String[] setWstring(String[] arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setWstring", true); + org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.write($out, arg); + $in = _invoke($out); + String $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.read($in); + 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 setWstring(arg); + } finally { + _releaseReply($in); + } + } // setWstring + + public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] obj) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setRemoteObject", true); + org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.write($out, obj); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result[] = + org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.read($in); + 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 setRemoteObject(obj); + } finally { + _releaseReply($in); + } + } // setRemoteObject + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/ArraysSetter:1.0"}; + + @Override + 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 _ArraysSetterStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java new file mode 100644 index 0000000000..b444ce68d8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java @@ -0,0 +1,230 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public abstract class _PrimitivesSetterImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _PrimitivesSetterImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("setBoolean", new java.lang.Integer(0)); + _methods.put("setChar", new java.lang.Integer(1)); + _methods.put("setWchar", new java.lang.Integer(2)); + _methods.put("setOctet", new java.lang.Integer(3)); + _methods.put("setShort", new java.lang.Integer(4)); + _methods.put("setUnsignedShort", new java.lang.Integer(5)); + _methods.put("setLong", new java.lang.Integer(6)); + _methods.put("setUnsignedLong", new java.lang.Integer(7)); + _methods.put("setLongLong", new java.lang.Integer(8)); + _methods.put("setUnsignedLongLong", new java.lang.Integer(9)); + _methods.put("setFloat", new java.lang.Integer(10)); + _methods.put("setDouble", new java.lang.Integer(11)); + _methods.put("setString", new java.lang.Integer(12)); + _methods.put("setWstring", new java.lang.Integer(13)); + _methods.put("setRemoteObject", new java.lang.Integer(14)); + } + + 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/binding/corba/testing/generated/PrimitivesSetter/setBoolean + { + boolean arg = in.read_boolean(); + boolean $result = false; + $result = this.setBoolean(arg); + out = $rh.createReply(); + out.write_boolean($result); + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setChar + { + char arg = in.read_char(); + char $result = (char)0; + $result = this.setChar(arg); + out = $rh.createReply(); + out.write_char($result); + break; + } + + case 2: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setWchar + { + char arg = in.read_wchar(); + char $result = (char)0; + $result = this.setWchar(arg); + out = $rh.createReply(); + out.write_wchar($result); + break; + } + + case 3: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setOctet + { + byte arg = in.read_octet(); + byte $result = (byte)0; + $result = this.setOctet(arg); + out = $rh.createReply(); + out.write_octet($result); + break; + } + + case 4: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setShort + { + short arg = in.read_short(); + short $result = (short)0; + $result = this.setShort(arg); + out = $rh.createReply(); + out.write_short($result); + break; + } + + case 5: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setUnsignedShort + { + short arg = in.read_ushort(); + short $result = (short)0; + $result = this.setUnsignedShort(arg); + out = $rh.createReply(); + out.write_ushort($result); + break; + } + + case 6: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setLong + { + int arg = in.read_long(); + int $result = (int)0; + $result = this.setLong(arg); + out = $rh.createReply(); + out.write_long($result); + break; + } + + case 7: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setUnsignedLong + { + int arg = in.read_ulong(); + int $result = (int)0; + $result = this.setUnsignedLong(arg); + out = $rh.createReply(); + out.write_ulong($result); + break; + } + + case 8: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setLongLong + { + long arg = in.read_longlong(); + long $result = (long)0; + $result = this.setLongLong(arg); + out = $rh.createReply(); + out.write_longlong($result); + break; + } + + case 9: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setUnsignedLongLong + { + long arg = in.read_ulonglong(); + long $result = (long)0; + $result = this.setUnsignedLongLong(arg); + out = $rh.createReply(); + out.write_ulonglong($result); + break; + } + + case 10: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setFloat + { + float arg = in.read_float(); + float $result = (float)0; + $result = this.setFloat(arg); + out = $rh.createReply(); + out.write_float($result); + break; + } + + case 11: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setDouble + { + double arg = in.read_double(); + double $result = (double)0; + $result = this.setDouble(arg); + out = $rh.createReply(); + out.write_double($result); + break; + } + + case 12: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setString + { + String arg = in.read_string(); + String $result = null; + $result = this.setString(arg); + out = $rh.createReply(); + out.write_string($result); + break; + } + + case 13: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setWstring + { + String arg = in.read_wstring(); + String $result = null; + $result = this.setWstring(arg); + out = $rh.createReply(); + out.write_wstring($result); + break; + } + + case 14: // org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter/setRemoteObject + { + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj = + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result = null; + $result = this.setRemoteObject(obj); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write(out, $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/binding/corba/testing/generated/PrimitivesSetter:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _PrimitivesSetterImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java new file mode 100644 index 0000000000..0b08e1fb67 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java @@ -0,0 +1,341 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_PrimitivesSetterStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public class _PrimitivesSetterStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.PrimitivesSetter { + + public boolean setBoolean(boolean arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setBoolean", true); + $out.write_boolean(arg); + $in = _invoke($out); + boolean $result = $in.read_boolean(); + 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 setBoolean(arg); + } finally { + _releaseReply($in); + } + } // setBoolean + + public char setChar(char arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setChar", true); + $out.write_char(arg); + $in = _invoke($out); + char $result = $in.read_char(); + 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 setChar(arg); + } finally { + _releaseReply($in); + } + } // setChar + + public char setWchar(char arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setWchar", true); + $out.write_wchar(arg); + $in = _invoke($out); + char $result = $in.read_wchar(); + 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 setWchar(arg); + } finally { + _releaseReply($in); + } + } // setWchar + + public byte setOctet(byte arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setOctet", true); + $out.write_octet(arg); + $in = _invoke($out); + byte $result = $in.read_octet(); + 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 setOctet(arg); + } finally { + _releaseReply($in); + } + } // setOctet + + public short setShort(short arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setShort", true); + $out.write_short(arg); + $in = _invoke($out); + short $result = $in.read_short(); + 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 setShort(arg); + } finally { + _releaseReply($in); + } + } // setShort + + public short setUnsignedShort(short arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedShort", true); + $out.write_ushort(arg); + $in = _invoke($out); + short $result = $in.read_ushort(); + 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 setUnsignedShort(arg); + } finally { + _releaseReply($in); + } + } // setUnsignedShort + + public int setLong(int arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLong", 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 setLong(arg); + } finally { + _releaseReply($in); + } + } // setLong + + public int setUnsignedLong(int arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLong", true); + $out.write_ulong(arg); + $in = _invoke($out); + int $result = $in.read_ulong(); + 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 setUnsignedLong(arg); + } finally { + _releaseReply($in); + } + } // setUnsignedLong + + public long setLongLong(long arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLongLong", true); + $out.write_longlong(arg); + $in = _invoke($out); + long $result = $in.read_longlong(); + 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 setLongLong(arg); + } finally { + _releaseReply($in); + } + } // setLongLong + + public long setUnsignedLongLong(long arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setUnsignedLongLong", true); + $out.write_ulonglong(arg); + $in = _invoke($out); + long $result = $in.read_ulonglong(); + 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 setUnsignedLongLong(arg); + } finally { + _releaseReply($in); + } + } // setUnsignedLongLong + + public float setFloat(float arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setFloat", true); + $out.write_float(arg); + $in = _invoke($out); + float $result = $in.read_float(); + 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 setFloat(arg); + } finally { + _releaseReply($in); + } + } // setFloat + + public double setDouble(double arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setDouble", true); + $out.write_double(arg); + $in = _invoke($out); + double $result = $in.read_double(); + 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 setDouble(arg); + } finally { + _releaseReply($in); + } + } // setDouble + + public String setString(String arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setString", true); + $out.write_string(arg); + $in = _invoke($out); + String $result = $in.read_string(); + 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 setString(arg); + } finally { + _releaseReply($in); + } + } // setString + + public String setWstring(String arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setWstring", true); + $out.write_wstring(arg); + $in = _invoke($out); + String $result = $in.read_wstring(); + 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 setWstring(arg); + } finally { + _releaseReply($in); + } + } // setWstring + + public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject setRemoteObject(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject obj) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setRemoteObject", true); + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write($out, obj); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject $result = + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read($in); + 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 setRemoteObject(obj); + } finally { + _releaseReply($in); + } + } // setRemoteObject + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/PrimitivesSetter:1.0"}; + + @Override + 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 _PrimitivesSetterStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java new file mode 100644 index 0000000000..a87534f88b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public abstract class _RemoteObjectImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _RemoteObjectImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + } + + 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); + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _RemoteObjectImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java new file mode 100644 index 0000000000..e219dfa338 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_RemoteObjectStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public class _RemoteObjectStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject { + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/RemoteObject:1.0"}; + + @Override + 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 _RemoteObjectStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java new file mode 100644 index 0000000000..c0bc0d6ebd --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java @@ -0,0 +1,149 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public abstract class _TestObjectImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.TestObject, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _TestObjectImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("pickStructFromArgs", new java.lang.Integer(0)); + _methods.put("setStruct", new java.lang.Integer(1)); + _methods.put("setSimpleStruct", new java.lang.Integer(2)); + _methods.put("setLongSeq1", new java.lang.Integer(3)); + _methods.put("setLongSeq2", new java.lang.Integer(4)); + _methods.put("setLongSeq3", new java.lang.Integer(5)); + } + + 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/binding/corba/testing/generated/TestObject/pickStructFromArgs + { + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg1 = + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg2 = + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg3 = + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in); + int structNumber = in.read_long(); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result = null; + $result = this.pickStructFromArgs(arg1, arg2, arg3, structNumber); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write(out, $result); + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setStruct + { + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg = + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result = null; + $result = this.setStruct(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write(out, $result); + break; + } + + case 2: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setSimpleStruct + { + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder arg = + new org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder(); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct $result = null; + $result = this.setSimpleStruct(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(out, $result); + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write(out, arg.value); + break; + } + + case 3: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setLongSeq1 + { + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder arg = + new org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder(); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read(in); + int $result[] = null; + $result = this.setLongSeq1(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(out, $result); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(out, arg.value); + break; + } + + case 4: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setLongSeq2 + { + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder arg = + new org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder(); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(in); + int $result[][] = null; + $result = this.setLongSeq2(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(out, $result); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(out, arg.value); + break; + } + + case 5: // org/apache/tuscany/sca/binding/corba/testing/generated/TestObject/setLongSeq3 + { + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder arg = + new org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder(); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read(in); + int $result[][][] = null; + $result = this.setLongSeq3(arg); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(out, $result); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(out, arg.value); + 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/binding/corba/testing/generated/TestObject:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _TestObjectImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java new file mode 100644 index 0000000000..ad47595ddf --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java @@ -0,0 +1,182 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/_TestObjectStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public class _TestObjectStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.generated.TestObject { + + public org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct pickStructFromArgs(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg1, + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg2, + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg3, + int structNumber) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("pickStructFromArgs", true); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg1); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg2); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg3); + $out.write_long(structNumber); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result = + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read($in); + 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 pickStructFromArgs(arg1, arg2, arg3, structNumber); + } finally { + _releaseReply($in); + } + } // pickStructFromArgs + + public org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct setStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setStruct", true); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.write($out, arg); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct $result = + org.apache.tuscany.sca.binding.corba.testing.generated.SomeStructHelper.read($in); + 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 setStruct(arg); + } finally { + _releaseReply($in); + } + } // setStruct + + public org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct setSimpleStruct(org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setSimpleStruct", true); + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.write($out, arg.value); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct $result = + org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read($in); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHelper.read($in); + 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 setSimpleStruct(arg); + } finally { + _releaseReply($in); + } + } // setSimpleStruct + + public int[] setLongSeq1(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLongSeq1", true); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write($out, arg.value); + $in = _invoke($out); + int $result[] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read($in); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read($in); + 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 setLongSeq1(arg); + } finally { + _releaseReply($in); + } + } // setLongSeq1 + + public int[][] setLongSeq2(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLongSeq2", true); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write($out, arg.value); + $in = _invoke($out); + int $result[][] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read($in); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read($in); + 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 setLongSeq2(arg); + } finally { + _releaseReply($in); + } + } // setLongSeq2 + + public int[][][] setLongSeq3(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder arg) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("setLongSeq3", true); + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write($out, arg.value); + $in = _invoke($out); + int $result[][][] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read($in); + arg.value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read($in); + 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 setLongSeq3(arg); + } finally { + _releaseReply($in); + } + } // setLongSeq3 + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/generated/TestObject:1.0"}; + + @Override + 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 _TestObjectStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java new file mode 100644 index 0000000000..f3d96e8fd7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class boolean_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/boolean_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, boolean[] 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 boolean[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.id(), + "boolean_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static boolean[] read(org.omg.CORBA.portable.InputStream istream) { + boolean value[] = null; + int _len0 = istream.read_long(); + value = new boolean[_len0]; + istream.read_boolean_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, boolean[] value) { + ostream.write_long(value.length); + ostream.write_boolean_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java new file mode 100644 index 0000000000..cb0ab8bcfd --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/boolean_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class boolean_listHolder implements org.omg.CORBA.portable.Streamable { + public boolean value[] = null; + + public boolean_listHolder() { + } + + public boolean_listHolder(boolean[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.boolean_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java new file mode 100644 index 0000000000..0bde1e701c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/char_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class char_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/char_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, char[] 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 char[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_char); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.id(), + "char_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static char[] read(org.omg.CORBA.portable.InputStream istream) { + char value[] = null; + int _len0 = istream.read_long(); + value = new char[_len0]; + istream.read_char_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, char[] value) { + ostream.write_long(value.length); + ostream.write_char_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java new file mode 100644 index 0000000000..19b2942cfe --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/char_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class char_listHolder implements org.omg.CORBA.portable.Streamable { + public char value[] = null; + + public char_listHolder() { + } + + public char_listHolder(char[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.char_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java new file mode 100644 index 0000000000..8bb5a9c69d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/double_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class double_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/double_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, double[] 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 double[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_double); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.id(), + "double_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static double[] read(org.omg.CORBA.portable.InputStream istream) { + double value[] = null; + int _len0 = istream.read_long(); + value = new double[_len0]; + istream.read_double_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, double[] value) { + ostream.write_long(value.length); + ostream.write_double_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java new file mode 100644 index 0000000000..dc89e71092 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/double_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class double_listHolder implements org.omg.CORBA.portable.Streamable { + public double value[] = null; + + public double_listHolder() { + } + + public double_listHolder(double[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.double_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java new file mode 100644 index 0000000000..7b71aa0a9f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/float_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class float_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/float_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, float[] 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 float[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_float); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.id(), + "float_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static float[] read(org.omg.CORBA.portable.InputStream istream) { + float value[] = null; + int _len0 = istream.read_long(); + value = new float[_len0]; + istream.read_float_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, float[] value) { + ostream.write_long(value.length); + ostream.write_float_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java new file mode 100644 index 0000000000..513bab37cc --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/float_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class float_listHolder implements org.omg.CORBA.portable.Streamable { + public float value[] = null; + + public float_listHolder() { + } + + public float_listHolder(float[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.float_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java new file mode 100644 index 0000000000..c1d06e2ba9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class long_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, int[] 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 int[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.id(), + "long_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static int[] read(org.omg.CORBA.portable.InputStream istream) { + int value[] = null; + int _len0 = istream.read_long(); + value = new int[_len0]; + istream.read_long_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, int[] value) { + ostream.write_long(value.length); + ostream.write_long_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java new file mode 100644 index 0000000000..f9ad7b77ac --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class long_listHolder implements org.omg.CORBA.portable.Streamable { + public int value[] = null; + + public long_listHolder() { + } + + public long_listHolder(int[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.long_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java new file mode 100644 index 0000000000..cfb292fc01 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +abstract public class long_long_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_long_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, long[] 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 long[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_longlong); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.id(), + "long_long_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static long[] read(org.omg.CORBA.portable.InputStream istream) { + long value[] = null; + int _len0 = istream.read_long(); + value = new long[_len0]; + istream.read_longlong_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, long[] value) { + ostream.write_long(value.length); + ostream.write_longlong_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java new file mode 100644 index 0000000000..02f46a7d85 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_long_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 14:12:28 CEST +*/ + +public final class long_long_listHolder implements org.omg.CORBA.portable.Streamable { + public long value[] = null; + + public long_long_listHolder() { + } + + public long_long_listHolder(long[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.long_long_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java new file mode 100644 index 0000000000..505aa3f026 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Helper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class long_seq1Helper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1:1.0"; + + public static void insert(org.omg.CORBA.Any a, int[] 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 int[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.id(), + "long_seq1", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static int[] read(org.omg.CORBA.portable.InputStream istream) { + int value[] = null; + int _len0 = istream.read_long(); + value = new int[_len0]; + istream.read_long_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, int[] value) { + ostream.write_long(value.length); + ostream.write_long_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java new file mode 100644 index 0000000000..5cbaa109ee --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq1Holder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class long_seq1Holder implements org.omg.CORBA.portable.Streamable { + public int value[] = null; + + public long_seq1Holder() { + } + + public long_seq1Holder(int[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java new file mode 100644 index 0000000000..2f792888fb --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Helper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class long_seq2Helper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2:1.0"; + + public static void insert(org.omg.CORBA.Any a, int[][] 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 int[][] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.id(), + "long_seq1", + __typeCode); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.id(), + "long_seq2", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static int[][] read(org.omg.CORBA.portable.InputStream istream) { + int value[][] = null; + int _len0 = istream.read_long(); + value = new int[_len0][]; + for (int _o1 = 0; _o1 < value.length; ++_o1) + value[_o1] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.read(istream); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, int[][] value) { + ostream.write_long(value.length); + for (int _i0 = 0; _i0 < value.length; ++_i0) + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.write(ostream, value[_i0]); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java new file mode 100644 index 0000000000..8b2ccc1f73 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq2Holder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class long_seq2Holder implements org.omg.CORBA.portable.Streamable { + public int value[][] = null; + + public long_seq2Holder() { + } + + public long_seq2Holder(int[][] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java new file mode 100644 index 0000000000..67e224f0be --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java @@ -0,0 +1,89 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Helper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class long_seq3Helper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3:1.0"; + + public static void insert(org.omg.CORBA.Any a, int[][][] 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 int[][][] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_long); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Helper.id(), + "long_seq1", + __typeCode); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.id(), + "long_seq2", + __typeCode); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.id(), + "long_seq3", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static int[][][] read(org.omg.CORBA.portable.InputStream istream) { + int value[][][] = null; + int _len0 = istream.read_long(); + value = new int[_len0][][]; + for (int _o1 = 0; _o1 < value.length; ++_o1) + value[_o1] = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.read(istream); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, int[][][] value) { + ostream.write_long(value.length); + for (int _i0 = 0; _i0 < value.length; ++_i0) + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Helper.write(ostream, value[_i0]); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java new file mode 100644 index 0000000000..5d4adfba2d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/long_seq3Holder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class long_seq3Holder implements org.omg.CORBA.portable.Streamable { + public int value[][][] = null; + + public long_seq3Holder() { + } + + public long_seq3Holder(int[][][] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Helper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java new file mode 100644 index 0000000000..c7d86d9179 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class octet_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/octet_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, byte[] 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 byte[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_octet); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.id(), + "octet_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static byte[] read(org.omg.CORBA.portable.InputStream istream) { + byte value[] = null; + int _len0 = istream.read_long(); + value = new byte[_len0]; + istream.read_octet_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, byte[] value) { + ostream.write_long(value.length); + ostream.write_octet_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java new file mode 100644 index 0000000000..09b2b85c6a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/octet_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class octet_listHolder implements org.omg.CORBA.portable.Streamable { + public byte value[] = null; + + public octet_listHolder() { + } + + public octet_listHolder(byte[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.octet_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java new file mode 100644 index 0000000000..e88b1e06c4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java @@ -0,0 +1,80 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class remote_object_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] 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.binding.corba.testing.generated.RemoteObject[] 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.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.type(); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper + .id(), + "remote_object_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] read(org.omg.CORBA.portable.InputStream istream) { + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value[] = null; + int _len0 = istream.read_long(); + value = new org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[_len0]; + for (int _o1 = 0; _o1 < value.length; ++_o1) + value[_o1] = org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.read(istream); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] value) { + ostream.write_long(value.length); + for (int _i0 = 0; _i0 < value.length; ++_i0) + org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObjectHelper.write(ostream, value[_i0]); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java new file mode 100644 index 0000000000..d3f996c5b4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/remote_object_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class remote_object_listHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject value[] = null; + + public remote_object_listHolder() { + } + + public remote_object_listHolder(org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.remote_object_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java new file mode 100644 index 0000000000..7c58d47f7c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/short_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class short_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/short_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, short[] 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 short[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_short); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.id(), + "short_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static short[] read(org.omg.CORBA.portable.InputStream istream) { + short value[] = null; + int _len0 = istream.read_long(); + value = new short[_len0]; + istream.read_short_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, short[] value) { + ostream.write_long(value.length); + ostream.write_short_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java new file mode 100644 index 0000000000..5be5a65c43 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/short_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class short_listHolder implements org.omg.CORBA.portable.Streamable { + public short value[] = null; + + public short_listHolder() { + } + + public short_listHolder(short[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.short_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java new file mode 100644 index 0000000000..a40d5fa8de --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java @@ -0,0 +1,77 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/string_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class string_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/string_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, String[] 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 String[] 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_string_tc(0); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.id(), + "string_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static String[] read(org.omg.CORBA.portable.InputStream istream) { + String value[] = null; + int _len0 = istream.read_long(); + value = new String[_len0]; + for (int _o1 = 0; _o1 < value.length; ++_o1) + value[_o1] = istream.read_string(); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, String[] value) { + ostream.write_long(value.length); + for (int _i0 = 0; _i0 < value.length; ++_i0) + ostream.write_string(value[_i0]); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java new file mode 100644 index 0000000000..76f99408f2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/string_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class string_listHolder implements org.omg.CORBA.portable.Streamable { + public String value[] = null; + + public string_listHolder() { + } + + public string_listHolder(String[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.string_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java new file mode 100644 index 0000000000..d7594b0815 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class unsigned_long_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, int[] 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 int[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulong); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper + .id(), + "unsigned_long_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static int[] read(org.omg.CORBA.portable.InputStream istream) { + int value[] = null; + int _len0 = istream.read_long(); + value = new int[_len0]; + istream.read_ulong_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, int[] value) { + ostream.write_long(value.length); + ostream.write_ulong_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java new file mode 100644 index 0000000000..e9fbcccc36 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class unsigned_long_listHolder implements org.omg.CORBA.portable.Streamable { + public int value[] = null; + + public unsigned_long_listHolder() { + } + + public unsigned_long_listHolder(int[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java new file mode 100644 index 0000000000..6ef187c4e5 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java @@ -0,0 +1,78 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class unsigned_long_long_listHelper { + private static String _id = + "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, long[] 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 long[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_ulonglong); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB + .init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper + .id(), + "unsigned_long_long_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static long[] read(org.omg.CORBA.portable.InputStream istream) { + long value[] = null; + int _len0 = istream.read_long(); + value = new long[_len0]; + istream.read_ulonglong_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, long[] value) { + ostream.write_long(value.length); + ostream.write_ulonglong_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java new file mode 100644 index 0000000000..59bc015c38 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_long_long_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class unsigned_long_long_listHolder implements org.omg.CORBA.portable.Streamable { + public long value[] = null; + + public unsigned_long_long_listHolder() { + } + + public unsigned_long_long_listHolder(long[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_long_long_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java new file mode 100644 index 0000000000..ec4526cebf --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class unsigned_short_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, short[] 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 short[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_ushort); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper + .id(), + "unsigned_short_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static short[] read(org.omg.CORBA.portable.InputStream istream) { + short value[] = null; + int _len0 = istream.read_long(); + value = new short[_len0]; + istream.read_ushort_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, short[] value) { + ostream.write_long(value.length); + ostream.write_ushort_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java new file mode 100644 index 0000000000..56ab28f0be --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/unsigned_short_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class unsigned_short_listHolder implements org.omg.CORBA.portable.Streamable { + public short value[] = null; + + public unsigned_short_listHolder() { + } + + public unsigned_short_listHolder(short[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.unsigned_short_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java new file mode 100644 index 0000000000..73a10d3b7f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java @@ -0,0 +1,75 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class wchar_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/wchar_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, char[] 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 char[] 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().get_primitive_tc(org.omg.CORBA.TCKind.tk_wchar); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.id(), + "wchar_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static char[] read(org.omg.CORBA.portable.InputStream istream) { + char value[] = null; + int _len0 = istream.read_long(); + value = new char[_len0]; + istream.read_wchar_array(value, 0, _len0); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, char[] value) { + ostream.write_long(value.length); + ostream.write_wchar_array(value, 0, value.length); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java new file mode 100644 index 0000000000..c5c1e87756 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/wchar_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class wchar_listHolder implements org.omg.CORBA.portable.Streamable { + public char value[] = null; + + public wchar_listHolder() { + } + + public wchar_listHolder(char[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.wchar_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java new file mode 100644 index 0000000000..3e45568f01 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java @@ -0,0 +1,77 @@ +/* + * 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.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +abstract public class wstring_listHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/generated/wstring_list:1.0"; + + public static void insert(org.omg.CORBA.Any a, String[] 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 String[] 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_wstring_tc(0); + __typeCode = org.omg.CORBA.ORB.init().create_sequence_tc(0, __typeCode); + __typeCode = + org.omg.CORBA.ORB.init() + .create_alias_tc(org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.id(), + "wstring_list", + __typeCode); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static String[] read(org.omg.CORBA.portable.InputStream istream) { + String value[] = null; + int _len0 = istream.read_long(); + value = new String[_len0]; + for (int _o1 = 0; _o1 < value.length; ++_o1) + value[_o1] = istream.read_wstring(); + return value; + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, String[] value) { + ostream.write_long(value.length); + for (int _i0 = 0; _i0 < value.length; ++_i0) + ostream.write_wstring(value[_i0]); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java new file mode 100644 index 0000000000..bdbf9d995b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.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.binding.corba.testing.generated; + +/** +* org/apache/tuscany/sca/binding/corba/testing/generated/wstring_listHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from general_tests.idl +* monday, 23 june 2008 2008 14:12:28 CEST +*/ + +public final class wstring_listHolder implements org.omg.CORBA.portable.Streamable { + public String value[] = null; + + public wstring_listHolder() { + } + + public wstring_listHolder(String[] initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.generated.wstring_listHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java new file mode 100644 index 0000000000..ba1a5c0a51 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/ArraysTestStruct.java @@ -0,0 +1,45 @@ +/* + * 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.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray; + +public final class ArraysTestStruct { + + public ArraysTestStruct() { + + } + + public ArraysTestStruct(String[] field1, int[][] field2, float[][][] field3) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + } + + @CorbaArray( {2}) + public String[] field1; + + @CorbaArray( {2, 4}) + public int[][] field2; + + @CorbaArray( {2, 4, 2}) + public float[][][] field3; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.java new file mode 100644 index 0000000000..7c33b1d449 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/Calc.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.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero; + +public interface Calc { + + public double div(double arg1, double arg2) throws DivByZero; + + public double divForSmallArgs(double arg1, double arg2); + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.java new file mode 100644 index 0000000000..d0ebff5fec --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/DummyObject.java @@ -0,0 +1,28 @@ +/* + * 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.corba.testing.hierarchy; + +public interface DummyObject { + + int getLong(); + + DummyObject cloneObject(); + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java new file mode 100644 index 0000000000..6e4204b9b7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InnerUnion.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +public final class InnerUnion { + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1) + private int x; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2) + private float y; + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int discriminator; + + public int getX() { + return x; + } + + public void setX(int x) { + discriminator = 1; + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + discriminator = 2; + this.y = y; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.java new file mode 100644 index 0000000000..cb3b6842c3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidCorbaArray.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray; + +public final class InvalidCorbaArray { + + // annotation argument array is not equal to declared arrays dimension + @CorbaArray( {1}) + public String[][] array; + + public InvalidCorbaArray() { + + } + + public InvalidCorbaArray(String[][] arg) { + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java new file mode 100644 index 0000000000..0c9de5bb31 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.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.corba.testing.hierarchy; + +public class InvalidEnum1 { + + public static final InvalidEnum1 red = new InvalidEnum1(0); + + public int value() { + return 0; + } + + public static InvalidEnum1 from_int(int value) { + return null; + } + + protected InvalidEnum1(int value) { + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java new file mode 100644 index 0000000000..8746eb7f9b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.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.corba.testing.hierarchy; + +public class InvalidEnum2 { + + public static final int _red = 0; + public static final InvalidEnum2 red = new InvalidEnum2(_red); + + public static InvalidEnum2 from_int(int value) { + return null; + } + + protected InvalidEnum2(int value) { + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java new file mode 100644 index 0000000000..6d124b0485 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.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.corba.testing.hierarchy; + +public class InvalidEnum3 { + + public static final int _red = 0; + public static final InvalidEnum2 red = new InvalidEnum2(_red); + + public int value() { + return 0; + } + + protected InvalidEnum3(int value) { + } +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java new file mode 100644 index 0000000000..8cf66e2fac --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java @@ -0,0 +1,28 @@ +/* + * 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.corba.testing.hierarchy; + +public final class InvalidStruct1 { + + public InvalidStruct1() { + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java new file mode 100644 index 0000000000..5f361512f0 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.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.binding.corba.testing.hierarchy; + +public final class InvalidStruct2 { + + public int f1; + public String f2; + + public InvalidStruct2(int f1, String f2) { + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java new file mode 100644 index 0000000000..adc81ea5a2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.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.corba.testing.hierarchy; + +public final class InvalidStruct3 { + + public int f1; + public String f2; + public static byte f3; + + public InvalidStruct3() { + + } + + public InvalidStruct3(int f1, String f2, byte f3) { + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.java new file mode 100644 index 0000000000..4f6d0085af --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion1.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +/** + * More than one discriminators + */ +public final class InvalidUnion1 { + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int a; + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int b; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java new file mode 100644 index 0000000000..98462bbabe --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion2.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +/** + * Discriminator is missing + */ +public final class InvalidUnion2 { + + @CorbaUnionElement(type=CorbaUnionElementType.defaultOption) + @SuppressWarnings("unused") + private int a; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.java new file mode 100644 index 0000000000..994ed6aea3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion3.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.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +/** + * No option, only discriminator + */ +public final class InvalidUnion3{ + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int a; + +} + diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.java new file mode 100644 index 0000000000..d68d903375 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion4.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +/** + * Invalid field modifiers + */ +public final class InvalidUnion4{ + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private static int a; + + @CorbaUnionElement(type = CorbaUnionElementType.defaultOption) + @SuppressWarnings("unused") + private static int b; + +} + diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java new file mode 100644 index 0000000000..d4f8b0e6fa --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidUnion5.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +/** + * Reused option id + */ +public final class InvalidUnion5 { + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int a; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1) + @SuppressWarnings("unused") + private int b; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1) + @SuppressWarnings("unused") + private int c; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.java new file mode 100644 index 0000000000..a514b5e222 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/NonCorbaException.java @@ -0,0 +1,28 @@ +/* + * 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.corba.testing.hierarchy; + +public class NonCorbaException extends Exception { + + private static final long serialVersionUID = 1L; + + public String someField; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.java new file mode 100644 index 0000000000..452dee8d95 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/RichUnion.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.hierarchy; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaUnionElementType; + +public final class RichUnion { + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1) + private int x; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2) + private float y; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 3) + private String z; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 4) + private InnerUnion iu; + + @CorbaUnionElement(type = CorbaUnionElementType.defaultOption) + private boolean def; + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int discriminator = -1; + + public int getX() { + return x; + } + + public void setX(int x) { + this.discriminator = 1; + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + this.discriminator = 2; + this.y = y; + } + + public String getZ() { + return z; + } + + public void setZ(String z) { + this.discriminator = 3; + this.z = z; + } + + public boolean isDef() { + return def; + } + + public void setDef(boolean def) { + this.discriminator = -1; + this.def = def; + } + + public InnerUnion getIu() { + return iu; + } + + public void setIu(InnerUnion iu) { + this.discriminator = 4; + this.iu = iu; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.java new file mode 100644 index 0000000000..85ca3798f4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SimpleStruct.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.binding.corba.testing.hierarchy; + +/** + * @version $Rev$ $Date$ + */ +public class SimpleStruct { + + public String field1; + public int field2; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.java new file mode 100644 index 0000000000..d8cdf1835a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/SomeStruct.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.corba.testing.hierarchy; + +/** + * @version $Rev$ $Date$ + */ +public class SomeStruct { + + public SimpleStruct innerStruct; + public String str; + public String[] str_list; + public int[][] twoDimSeq; + public int[][][] threeDimSeq; + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java new file mode 100644 index 0000000000..bb72fdbbf3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.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.binding.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/DummyObject.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public interface DummyObject extends DummyObjectOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface DummyObject diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java new file mode 100644 index 0000000000..606d333bb3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java @@ -0,0 +1,100 @@ +/* + * 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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +abstract public class DummyObjectHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/references/DummyObject:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject 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.binding.corba.testing.references.DummyObject 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.binding.corba.testing.references.DummyObjectHelper.id(), + "DummyObject"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_DummyObjectStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.DummyObject) + return (org.apache.tuscany.sca.binding.corba.testing.references.DummyObject)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.binding.corba.testing.references._DummyObjectStub stub = + new org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.references.DummyObject unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.DummyObject) + return (org.apache.tuscany.sca.binding.corba.testing.references.DummyObject)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub stub = + new org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java new file mode 100644 index 0000000000..0ff9540502 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.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.binding.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public final class DummyObjectHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject value = null; + + public DummyObjectHolder() { + } + + public DummyObjectHolder(org.apache.tuscany.sca.binding.corba.testing.references.DummyObject initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java new file mode 100644 index 0000000000..912bd16f9b --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/DummyObjectOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public interface DummyObjectOperations { + int getLong(); + + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject cloneObject(); +} // interface DummyObjectOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java new file mode 100644 index 0000000000..79f7959c72 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.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.binding.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public interface ObjectManager extends ObjectManagerOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity { +} // interface ObjectManager diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java new file mode 100644 index 0000000000..495a614d84 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java @@ -0,0 +1,100 @@ +/* + * 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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +abstract public class ObjectManagerHelper { + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager:1.0"; + + public static void insert(org.omg.CORBA.Any a, + org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager 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.binding.corba.testing.references.ObjectManager 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.binding.corba.testing.references.ObjectManagerHelper + .id(), + "ObjectManager"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager read(org.omg.CORBA.portable.InputStream istream) { + return narrow(istream.read_Object(_ObjectManagerStub.class)); + } + + public static void write(org.omg.CORBA.portable.OutputStream ostream, + org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager) + return (org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager)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.binding.corba.testing.references._ObjectManagerStub stub = + new org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager unchecked_narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager) + return (org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager)obj; + else { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate(); + org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub stub = + new org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java new file mode 100644 index 0000000000..11cfc82ac2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.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.binding.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public final class ObjectManagerHolder implements org.omg.CORBA.portable.Streamable { + public org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager value = null; + + public ObjectManagerHolder() { + } + + public ObjectManagerHolder(org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.binding.corba.testing.references.ObjectManagerHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java new file mode 100644 index 0000000000..e0e56d1017 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/ObjectManagerOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public interface ObjectManagerOperations { + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getDummyObject(); + + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getObjectByArgument(org.apache.tuscany.sca.binding.corba.testing.references.DummyObject dummy); +} // interface ObjectManagerOperations diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java new file mode 100644 index 0000000000..c706661eaa --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java @@ -0,0 +1,84 @@ +/* + * 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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public abstract class _DummyObjectImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _DummyObjectImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("getLong", new java.lang.Integer(0)); + _methods.put("cloneObject", new java.lang.Integer(1)); + } + + 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/binding/corba/testing/references/DummyObject/getLong + { + int $result = (int)0; + $result = this.getLong(); + out = $rh.createReply(); + out.write_long($result); + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/references/DummyObject/cloneObject + { + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = null; + $result = this.cloneObject(); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(out, $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/binding/corba/testing/references/DummyObject:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _DummyObjectImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java new file mode 100644 index 0000000000..c9a31deb27 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java @@ -0,0 +1,92 @@ +/* + * 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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/_DummyObjectStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public class _DummyObjectStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject { + + public int getLong() { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("getLong", true); + $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 getLong(); + } finally { + _releaseReply($in); + } + } // getLong + + public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject cloneObject() { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("cloneObject", true); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read($in); + 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 cloneObject(); + } finally { + _releaseReply($in); + } + } // cloneObject + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/references/DummyObject:1.0"}; + + @Override + 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 _DummyObjectStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java new file mode 100644 index 0000000000..a6b55b8bae --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java @@ -0,0 +1,86 @@ +/* + * 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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public abstract class _ObjectManagerImplBase extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager, org.omg.CORBA.portable.InvokeHandler { + + // Constructors + public _ObjectManagerImplBase() { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable(); + static { + _methods.put("getDummyObject", new java.lang.Integer(0)); + _methods.put("getObjectByArgument", new java.lang.Integer(1)); + } + + 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/binding/corba/testing/references/ObjectManager/getDummyObject + { + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = null; + $result = this.getDummyObject(); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(out, $result); + break; + } + + case 1: // org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager/getObjectByArgument + { + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject dummy = + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read(in); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = null; + $result = this.getObjectByArgument(dummy); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write(out, $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/binding/corba/testing/references/ObjectManager:1.0"}; + + @Override + public String[] _ids() { + return (String[])__ids.clone(); + } + +} // class _ObjectManagerImplBase diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java new file mode 100644 index 0000000000..e06a078a93 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java @@ -0,0 +1,94 @@ +/* + * 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.corba.testing.references; + +/** +* org/apache/tuscany/sca/binding/corba/testing/references/_ObjectManagerStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from remote_objects.idl +* niedziela, 8 czerwiec 2008 16:43:12 CEST +*/ + +public class _ObjectManagerStub extends org.omg.CORBA.portable.ObjectImpl implements + org.apache.tuscany.sca.binding.corba.testing.references.ObjectManager { + + public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getDummyObject() { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("getDummyObject", true); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read($in); + 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 getDummyObject(); + } finally { + _releaseReply($in); + } + } // getDummyObject + + public org.apache.tuscany.sca.binding.corba.testing.references.DummyObject getObjectByArgument(org.apache.tuscany.sca.binding.corba.testing.references.DummyObject dummy) { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request("getObjectByArgument", true); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.write($out, dummy); + $in = _invoke($out); + org.apache.tuscany.sca.binding.corba.testing.references.DummyObject $result = + org.apache.tuscany.sca.binding.corba.testing.references.DummyObjectHelper.read($in); + 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 getObjectByArgument(dummy); + } finally { + _releaseReply($in); + } + } // getObjectByArgument + + // Type-specific CORBA::Object operations + private static String[] __ids = {"IDL:org/apache/tuscany/sca/binding/corba/testing/references/ObjectManager:1.0"}; + + @Override + 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 _ObjectManagerStub diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.java new file mode 100644 index 0000000000..0aec4d278d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysSetterServant.java @@ -0,0 +1,89 @@ +/* + * 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.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject; +import org.apache.tuscany.sca.binding.corba.testing.generated._ArraysSetterImplBase; + +public class ArraysSetterServant extends _ArraysSetterImplBase { + + private static final long serialVersionUID = 1L; + + public boolean[] setBoolean(boolean[] arg) { + return arg; + } + + public char[] setChar(char[] arg) { + return arg; + } + + public double[] setDouble(double[] arg) { + return arg; + } + + public float[] setFloat(float[] arg) { + return arg; + } + + public int[] setLong(int[] arg) { + return arg; + } + + public long[] setLongLong(long[] arg) { + return arg; + } + + public byte[] setOctet(byte[] arg) { + return arg; + } + + public RemoteObject[] setRemoteObject(RemoteObject[] obj) { + return obj; + } + + public short[] setShort(short[] arg) { + return arg; + } + + public String[] setString(String[] arg) { + return arg; + } + + public int[] setUnsignedLong(int[] arg) { + return arg; + } + + public long[] setUnsignedLongLong(long[] arg) { + return arg; + } + + public short[] setUnsignedShort(short[] arg) { + return arg; + } + + public char[] setWchar(char[] arg) { + return arg; + } + + public String[] setWstring(String[] arg) { + return arg; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java new file mode 100644 index 0000000000..d9bde48a5a --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsServant.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.RichUnion; +import org.apache.tuscany.sca.binding.corba.testing.arrays_unions.TestStruct; +import org.apache.tuscany.sca.binding.corba.testing.arrays_unions._ArraysUnionsTestsImplBase; + +public class ArraysUnionsServant extends _ArraysUnionsTestsImplBase { + + private static final long serialVersionUID = 1L; + + public TestStruct passTestStruct(TestStruct arg) { + return arg; + } + + public String[][] passStringArray(String[][] arg) { + return arg; + } + + public RichUnion passRichUnion(RichUnion arg) { + return arg; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java new file mode 100644 index 0000000000..9ff94f8313 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ArraysUnionsTuscanyServant.java @@ -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. + */ + +package org.apache.tuscany.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.provider.meta.CorbaArray; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.ArraysTestStruct; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.RichUnion; + +public class ArraysUnionsTuscanyServant { + + private static final long serialVersionUID = 1L; + + public ArraysTestStruct passTestStruct(ArraysTestStruct arg) { + return arg; + } + + @CorbaArray( {2, 2}) + public String[][] passStringArray(@CorbaArray( {2, 2})String[][] arg) { + return arg; + } + + public RichUnion passRichUnion(RichUnion arg) { + return arg; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.java new file mode 100644 index 0000000000..fd789e19cb --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/CalcServant.java @@ -0,0 +1,52 @@ +/* + * 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.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.exceptions._CalcImplBase; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.Arguments; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero; +import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported; + +public class CalcServant extends _CalcImplBase { + + private static final long serialVersionUID = 1L; + + public double div(double arg1, double arg2) throws DivByZero { + if (arg2 == 0) { + DivByZero exception = new DivByZero(); + exception.arguments = new Arguments(arg1, arg2); + exception.info = "Error occured during div: div by zero"; + throw exception; + } else { + return arg1 / arg2; + } + } + + public double divForSmallArgs(double arg1, double arg2) throws DivByZero, NotSupported { + if (arg1 > 100 || arg2 > 100) { + NotSupported exception = new NotSupported(); + exception.info = "arg1: " + arg1 + ", arg2: " + arg2; + throw exception; + } else { + return div(arg1, arg2); + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java new file mode 100644 index 0000000000..2e205f1d0f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/DummyObjectServant.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.references.DummyObject; +import org.apache.tuscany.sca.binding.corba.testing.references._DummyObjectImplBase; + +public class DummyObjectServant extends _DummyObjectImplBase { + + private static final long serialVersionUID = 1L; + private int retVal; + + public DummyObjectServant() { + retVal = (int)System.currentTimeMillis(); + } + + public int getLong() { + return retVal; + } + + public DummyObject cloneObject() { + return new DummyObjectServant(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java new file mode 100644 index 0000000000..52386aeef7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.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.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.enums.Color; +import org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerImplBase; + +public class EnumManagerServant extends _EnumManagerImplBase { + + private static final long serialVersionUID = 1L; + + public Color getColor(Color color) { + return color; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java new file mode 100644 index 0000000000..b7fbb69627 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTestObjectServant.java @@ -0,0 +1,24 @@ +/* + * 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.corba.testing.servants; + +public class InvalidTestObjectServant { + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java new file mode 100644 index 0000000000..dda8203f79 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/InvalidTypesServant.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct1; + +public class InvalidTypesServant { + + public InvalidStruct1 firstMethodWithInvalidArg() { + return null; + } + + public void secondMethodWithInvalidArg(InvalidStruct1 arg) { + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.java new file mode 100644 index 0000000000..20700a0392 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/NonCorbaServant.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.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.NonCorbaException; + +public class NonCorbaServant { + + public String setString(String arg) { + return arg; + } + + public void throwException() throws NonCorbaException { + NonCorbaException e = new NonCorbaException(); + e.someField = "test"; + throw e; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.java new file mode 100644 index 0000000000..213c7fbd7c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/ObjectManagerServant.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.references.DummyObject; +import org.apache.tuscany.sca.binding.corba.testing.references._ObjectManagerImplBase; + +public class ObjectManagerServant extends _ObjectManagerImplBase { + + private static final long serialVersionUID = 1L; + + public DummyObject getObjectByArgument(DummyObject arg) { + return arg; + } + + public DummyObject getDummyObject() { + return new DummyObjectServant(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.java new file mode 100644 index 0000000000..92e18741ae --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/PrimitivesSetterServant.java @@ -0,0 +1,89 @@ +/* + * 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.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.generated.RemoteObject; +import org.apache.tuscany.sca.binding.corba.testing.generated._PrimitivesSetterImplBase; + +public class PrimitivesSetterServant extends _PrimitivesSetterImplBase { + + private static final long serialVersionUID = 1L; + + public boolean setBoolean(boolean arg) { + return arg; + } + + public char setChar(char arg) { + return arg; + } + + public double setDouble(double arg) { + return arg; + } + + public float setFloat(float arg) { + return arg; + } + + public int setLong(int arg) { + return arg; + } + + public long setLongLong(long arg) { + return arg; + } + + public byte setOctet(byte arg) { + return arg; + } + + public RemoteObject setRemoteObject(RemoteObject obj) { + return obj; + } + + public short setShort(short arg) { + return arg; + } + + public String setString(String arg) { + return arg; + } + + public int setUnsignedLong(int arg) { + return arg; + } + + public long setUnsignedLongLong(long arg) { + return arg; + } + + public short setUnsignedShort(short arg) { + return arg; + } + + public char setWchar(char arg) { + return arg; + } + + public String setWstring(String arg) { + return arg; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.java new file mode 100644 index 0000000000..153268983f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/TestObjectServant.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct; +import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStructHolder; +import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct; +import org.apache.tuscany.sca.binding.corba.testing.generated._TestObjectImplBase; +import org.apache.tuscany.sca.binding.corba.testing.generated.long_seq1Holder; +import org.apache.tuscany.sca.binding.corba.testing.generated.long_seq2Holder; +import org.apache.tuscany.sca.binding.corba.testing.generated.long_seq3Holder; + +/** + * @version $Rev$ $Date$ + */ +public class TestObjectServant extends _TestObjectImplBase { + + private static final long serialVersionUID = 1L; + + public int[] setLongSeq1(long_seq1Holder arg) { + return arg.value; + } + + public int[][] setLongSeq2(long_seq2Holder arg) { + + return arg.value; + } + + public int[][][] setLongSeq3(long_seq3Holder arg) { + return arg.value; + } + + public SimpleStruct setSimpleStruct(SimpleStructHolder arg) { + return arg.value; + } + + public SomeStruct setStruct(SomeStruct arg) { + return arg; + } + + public SomeStruct pickStructFromArgs(SomeStruct arg1, SomeStruct arg2, SomeStruct arg3, int structNumber) { + switch (structNumber) { + case 1: + return arg1; + case 2: + return arg2; + case 3: + return arg3; + default: + return arg1; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java new file mode 100644 index 0000000000..7ebc3fce85 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java @@ -0,0 +1,88 @@ +/* + * 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.corba.testing.service.mocks; + +import java.lang.reflect.Type; + +import org.apache.tuscany.sca.interfacedef.DataType; + +/** + * Mock DataType implementation. Only few methods needs to be implemented. + */ +public class TestDataType<L> implements DataType<L> { + + public Class<?> typeClass; + public L logical; + + public TestDataType(Class<?> typeClass) { + this.typeClass = typeClass; + } + + public TestDataType(Class<?> typeClass, L logical) { + this.typeClass = typeClass; + this.logical = logical; + } + + public String getDataBinding() { + return null; + } + + public Type getGenericType() { + return null; + } + + public L getLogical() { + return logical; + } + + public <T> T getMetaData(Class<T> arg0) { + return null; + } + + public Class<?> getPhysical() { + return typeClass; + } + + public void setDataBinding(String arg0) { + + } + + public void setGenericType(Type arg0) { + + } + + public void setLogical(L arg0) { + + } + + public <T> void setMetaData(Class<T> arg0, T arg1) { + + } + + public void setPhysical(Class<?> arg0) { + + } + + @Override + public Object clone() { + return null; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java new file mode 100644 index 0000000000..757beeae7d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java @@ -0,0 +1,163 @@ +/* + * 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.corba.testing.service.mocks; + +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Mock TestInterface implementation. Only few methods needs to be implemented. + */ +public class TestInterface implements JavaInterface { + + private List<Operation> operations; + private Class<?> javaClass; + + public TestInterface(List<Operation> opearations, Class<?> javaClass) { + this.operations = opearations; + this.javaClass = javaClass; + } + + public List<Operation> getOperations() { + return operations; + } + + public boolean isConversational() { + return false; + } + + public boolean isDynamic() { + return false; + } + + public boolean isRemotable() { + return false; + } + + public void resetDataBinding(String dataBinding) { + + } + + public void setConversational(boolean conversational) { + + } + + public void setDefaultDataBinding(String dataBinding) { + + } + + public void setRemotable(boolean remotable) { + + } + + public List<PolicySet> getApplicablePolicySets() { + return null; + } + + public List<PolicySet> getPolicySets() { + return null; + } + + public List<Intent> getRequiredIntents() { + return null; + } + + @Override + public Object clone() { + return null; + } + + public Class<?> getCallbackClass() { + return null; + } + + public Class<?> getJavaClass() { + return javaClass; + } + + public String getName() { + return null; + } + + public QName getQName() { + return null; + } + + public void setCallbackClass(Class<?> arg0) { + } + + public void setJavaClass(Class<?> javaClass) { + this.javaClass = javaClass; + } + + public void setName(String arg0) { + } + + public void setQName(QName arg0) { + + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean arg0) { + } + + public Map<Object, Object> getAttributes() { + // TODO Auto-generated method stub + return null; + } + + public boolean isRemotableSet() { + // TODO Auto-generated method stub + return false; + } + + public void resetInterfaceInputTypes(Interface newInterface) { + // TODO Auto-generated method stub + + } + + public void resetInterfaceOutputTypes(Interface newInterface) { + // TODO Auto-generated method stub + + } + + public ExtensionType getExtensionType() { + // TODO Auto-generated method stub + return null; + } + + public void setExtensionType(ExtensionType type) { + // TODO Auto-generated method stub + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java new file mode 100644 index 0000000000..d691705955 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; + +/** + * Mock InterfaceContract implementation. Only few methods needs to be + * implemented. + */ +public class TestInterfaceContract implements InterfaceContract { + + private Interface iface; + + public Interface getCallbackInterface() { + return null; + } + + public Interface getInterface() { + return iface; + } + + public InterfaceContract makeUnidirectional(boolean isCallback) { + return null; + } + + public void setCallbackInterface(Interface callbackInterface) { + + } + + public void setInterface(Interface callInterface) { + this.iface = callInterface; + } + + @Override + public Object clone() { + return null; + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java new file mode 100644 index 0000000000..3a55eb642c --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java @@ -0,0 +1,173 @@ +/* + * 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.corba.testing.service.mocks; + +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.util.WrapperInfo; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Mock Operation implementation. Only few methods needs to be implemented. + */ +public class TestOperation implements Operation { + + private DataType<List<DataType>> inputType; + private DataType outputType; + private String name; + + public String getDataBinding() { + return null; + } + + public Map<QName, List<DataType<XMLType>>> getFaultBeans() { + return null; + } + + public List<DataType> getFaultTypes() { + return null; + } + + public DataType<List<DataType>> getInputType() { + return inputType; + } + + public Interface getInterface() { + return null; + } + + public String getName() { + return name; + } + + public DataType getOutputType() { + return outputType; + } + + public WrapperInfo getWrapper() { + return null; + } + + public boolean isDynamic() { + return false; + } + + public boolean isNonBlocking() { + return false; + } + + public boolean isUnresolved() { + return false; + } + + public boolean isWrapperStyle() { + return false; + } + + public void setDataBinding(String dataBinding) { + + } + + public void setDynamic(boolean b) { + + } + + public void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans) { + + } + + public void setFaultTypes(List<DataType> faultTypes) { + + } + + public void setInputType(DataType<List<DataType>> inputType) { + this.inputType = inputType; + } + + public void setInterface(Interface interfaze) { + + } + + public void setName(String name) { + this.name = name; + } + + public void setNonBlocking(boolean nonBlocking) { + + } + + public void setOutputType(DataType outputType) { + this.outputType = outputType; + } + + public void setUnresolved(boolean unresolved) { + + } + + public void setWrapper(WrapperInfo wrapperInfo) { + + } + + public void setWrapperStyle(boolean wrapperStyle) { + + } + + public List<PolicySet> getApplicablePolicySets() { + return null; + } + + public List<PolicySet> getPolicySets() { + return null; + } + + @Override + public Object clone() { + return null; + } + + public List<Intent> getRequiredIntents() { + return null; + } + + public Map<Object, Object> getAttributes() { + // TODO Auto-generated method stub + return null; + } + + public ExtensionType getExtensionType() { + // TODO Auto-generated method stub + return null; + } + + public void setExtensionType(ExtensionType type) { + // TODO Auto-generated method stub + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java new file mode 100644 index 0000000000..bc19b82aec --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java @@ -0,0 +1,220 @@ +/* + * 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.corba.testing.service.mocks; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Callback; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +/** + * Mock RuntimeComponentService implementation. Only few methods needs to be + * implemented. + */ +public class TestRuntimeComponentService implements RuntimeComponentService { + + private InterfaceContract interfaceContract; + private RuntimeEndpoint runtimeWire; + + public TestRuntimeComponentService(Object invocationTarget) { + List<Operation> operations = new ArrayList<Operation>(); + Method[] methods = invocationTarget.getClass().getMethods(); + for (int i = 0; i < methods.length; i++) { + int mod = methods[i].getModifiers(); + if (methods[i].getDeclaringClass().equals(invocationTarget.getClass()) && Modifier.isPublic(mod) + && !methods[i].getName().startsWith("_")) { + Operation operation = new TestOperation(); + DataType returnType = new TestDataType(methods[i].getReturnType()); + operation.setOutputType(returnType); + Class<?>[] argTypes = methods[i].getParameterTypes(); + List<DataType> argDataTypes = new ArrayList<DataType>(); + for (int j = 0; j < argTypes.length; j++) { + argDataTypes.add(new TestDataType(argTypes[j])); + } + TestDataType<List<DataType>> inputDataType = new TestDataType<List<DataType>>(null, argDataTypes); + operation.setInputType(inputDataType); + operations.add(operation); + operation.setName(methods[i].getName()); + } + } + TestInterface iface = new TestInterface(operations, invocationTarget.getClass()); + interfaceContract = new TestInterfaceContract(); + interfaceContract.setInterface(iface); + runtimeWire = new TestRuntimeWire(interfaceContract, invocationTarget); + } + + public ComponentReference getCallbackReference() { + // TODO Auto-generated method stub + return null; + } + + public Service getService() { + // TODO Auto-generated method stub + return null; + } + + public void setCallbackReference(ComponentReference callbackReference) { + // TODO Auto-generated method stub + + } + + public void setService(Service service) { + // TODO Auto-generated method stub + + } + + public List<Endpoint> getEndpoints() { + // TODO Auto-generated method stub + return Arrays.asList((Endpoint)runtimeWire); + } + + public <B> B getBinding(Class<B> bindingClass) { + // TODO Auto-generated method stub + return null; + } + + public List<Binding> getBindings() { + // TODO Auto-generated method stub + return null; + } + + public Callback getCallback() { + // TODO Auto-generated method stub + return null; + } + + public <B> B getCallbackBinding(Class<B> bindingClass) { + // TODO Auto-generated method stub + return null; + } + + public InterfaceContract getInterfaceContract(Binding binding) { + // TODO Auto-generated method stub + return interfaceContract; + } + + public boolean isOverridingBindings() { + // TODO Auto-generated method stub + return false; + } + + public void setCallback(Callback callback) { + // TODO Auto-generated method stub + + } + + public void setOverridingBindings(boolean overridingBindings) { + // TODO Auto-generated method stub + + } + + public InterfaceContract getInterfaceContract() { + // TODO Auto-generated method stub + return interfaceContract; + } + + public String getName() { + // TODO Auto-generated method stub + return null; + } + + public boolean isForCallback() { + // TODO Auto-generated method stub + return false; + } + + public void setForCallback(boolean isCallback) { + // TODO Auto-generated method stub + + } + + public void setInterfaceContract(InterfaceContract interfaceContract) { + // TODO Auto-generated method stub + + } + + public void setName(String name) { + // TODO Auto-generated method stub + + } + + public List<Extension> getAttributeExtensions() { + // TODO Auto-generated method stub + return null; + } + + public List<Object> getExtensions() { + // TODO Auto-generated method stub + return null; + } + + public boolean isUnresolved() { + // TODO Auto-generated method stub + return false; + } + + public void setUnresolved(boolean unresolved) { + // TODO Auto-generated method stub + + } + + @Override + public Object clone() throws CloneNotSupportedException { + // TODO Auto-generated method stub + return super.clone(); + } + + public ExtensionType getExtensionType() { + // TODO Auto-generated method stub + return null; + } + + public List<PolicySet> getPolicySets() { + // TODO Auto-generated method stub + return null; + } + + public List<Intent> getRequiredIntents() { + // TODO Auto-generated method stub + return null; + } + + public void setExtensionType(ExtensionType type) { + // TODO Auto-generated method stub + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java new file mode 100644 index 0000000000..e68f4dee72 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java @@ -0,0 +1,292 @@ +/* + * 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.corba.testing.service.mocks; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Contract; +import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; + +/** + * Mock RuntimeWire implementation. Only few methods needs to be implemented. + */ +public class TestRuntimeWire implements RuntimeEndpoint { + private Object invocationTarget; + private InterfaceContract interfaceContract; + + public TestRuntimeWire(InterfaceContract interfaceContract, Object invocationTarget) { + this.interfaceContract = interfaceContract; + this.invocationTarget = invocationTarget; + } + + + public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { + Class<?>[] types = new Class<?>[args.length]; + for (int i = 0; i < args.length; i++) { + types[i] = args[i].getClass(); + } + Object result = null; + try { + Method[] methods = invocationTarget.getClass().getMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals(operation.getName())) { + result = methods[i].invoke(invocationTarget, args); + break; + } + } + } catch (InvocationTargetException e) { + throw e; + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + return result; + } + + + @Override + public Object clone() throws CloneNotSupportedException { + // TODO Auto-generated method stub + return super.clone(); + } + + + public InterfaceContract getBindingInterfaceContract() { + // TODO Auto-generated method stub + return interfaceContract; + } + + + public ServiceBindingProvider getBindingProvider() { + // TODO Auto-generated method stub + return null; + } + + + public InterfaceContract getComponentTypeServiceInterfaceContract() { + // TODO Auto-generated method stub + return interfaceContract; + } + + + public void setBindingProvider(ServiceBindingProvider provider) { + // TODO Auto-generated method stub + + } + + + public boolean isUnresolved() { + // TODO Auto-generated method stub + return false; + } + + + public void setUnresolved(boolean unresolved) { + // TODO Auto-generated method stub + + } + + + public ExtensionType getExtensionType() { + // TODO Auto-generated method stub + return null; + } + + + public List<PolicySet> getPolicySets() { + // TODO Auto-generated method stub + return null; + } + + + public List<Intent> getRequiredIntents() { + // TODO Auto-generated method stub + return null; + } + + + public void setExtensionType(ExtensionType type) { + // TODO Auto-generated method stub + + } + + + public void bind(CompositeContext context) { + // TODO Auto-generated method stub + + } + + + public void bind(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) { + // TODO Auto-generated method stub + + } + + + public InvocationChain getBindingInvocationChain() { + // TODO Auto-generated method stub + return null; + } + + + public CompositeContext getCompositeContext() { + // TODO Auto-generated method stub + return null; + } + + + public Contract getContract() { + // TODO Auto-generated method stub + return null; + } + + + public InvocationChain getInvocationChain(Operation operation) { + // TODO Auto-generated method stub + return null; + } + + + public List<InvocationChain> getInvocationChains() { + // TODO Auto-generated method stub + return null; + } + + + public List<PolicyProvider> getPolicyProviders() { + // TODO Auto-generated method stub + return null; + } + + + public Message invoke(Message msg) { + // TODO Auto-generated method stub + return null; + } + + + public Message invoke(Operation operation, Message msg) { + // TODO Auto-generated method stub + return null; + } + + + public void unbind() { + // TODO Auto-generated method stub + + } + + + public Binding getBinding() { + // TODO Auto-generated method stub + return null; + } + + + public List<EndpointReference> getCallbackEndpointReferences() { + // TODO Auto-generated method stub + return null; + } + + + public Component getComponent() { + // TODO Auto-generated method stub + return null; + } + + + public InterfaceContract getComponentServiceInterfaceContract() { + // TODO Auto-generated method stub + return interfaceContract; + } + + + public ComponentService getService() { + // TODO Auto-generated method stub + return null; + } + + + public String getURI() { + // TODO Auto-generated method stub + return null; + } + + + public boolean isRemote() { + // TODO Auto-generated method stub + return false; + } + + + public boolean matches(String serviceURI) { + // TODO Auto-generated method stub + return false; + } + + + public void setBinding(Binding binding) { + // TODO Auto-generated method stub + + } + + + public void setComponent(Component component) { + // TODO Auto-generated method stub + + } + + + public void setRemote(boolean remote) { + // TODO Auto-generated method stub + + } + + + public void setService(ComponentService service) { + // TODO Auto-generated method stub + + } + + + public void setURI(String uri) { + // TODO Auto-generated method stub + + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl new file mode 100644 index 0000000000..0f4ed03b4e --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/arrays_unions.idl @@ -0,0 +1,69 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase arrays_unions.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module arrays_unions {
+
+ struct TestStruct {
+ string oneDimArray[2];
+ long twoDimArray[2][4];
+ float threeDimArray[2][4][2];
+ };
+
+ typedef string StringArray[2][2];
+
+ union InnerUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ };
+
+ union RichUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ case 3: string z;
+ case 4: InnerUnion iu;
+ default: boolean a;
+ };
+
+ interface ArraysUnionsTests {
+ TestStruct passTestStruct(in TestStruct arg);
+ StringArray passStringArray(in StringArray arg);
+ RichUnion passRichUnion(in RichUnion arg);
+ };
+
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
+
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/enums.idl b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/enums.idl new file mode 100644 index 0000000000..2e4e829b0f --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/enums.idl @@ -0,0 +1,44 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase enums.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module enums {
+ enum Color {red, yellow, green};
+ interface EnumManager {
+ Color getColor(in Color color);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/exceptions.idl b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/exceptions.idl new file mode 100644 index 0000000000..b34ec46458 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/exceptions.idl @@ -0,0 +1,58 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase exceptions.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module exceptions {
+ interface Calc {
+ struct Arguments {
+ double arg1;
+ double arg2;
+ };
+
+ exception DivByZero{
+ Arguments arguments;
+ string info;
+ };
+
+ exception NotSupported {
+ string info;
+ };
+
+ double div(in double arg1, in double arg2) raises(DivByZero);
+ double divForSmallArgs(in double arg1, in double arg2) raises(DivByZero, NotSupported);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/general_tests.idl b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/general_tests.idl new file mode 100644 index 0000000000..db253338c3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/general_tests.idl @@ -0,0 +1,124 @@ +/*
+ * 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 general_tests.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module generated {
+
+ interface RemoteObject {
+
+ };
+
+ typedef sequence<RemoteObject> remote_object_list;
+ typedef sequence<boolean> boolean_list;
+ typedef sequence<char> char_list;
+ typedef sequence<wchar> wchar_list;
+ typedef sequence<octet> octet_list;
+ typedef sequence<short> short_list;
+ typedef sequence<unsigned short> unsigned_short_list;
+ typedef sequence<long> long_list;
+ typedef sequence<unsigned long> unsigned_long_list;
+ typedef sequence<long long> long_long_list;
+ typedef sequence<unsigned long long> unsigned_long_long_list;
+ typedef sequence<float> float_list;
+ typedef sequence<double> double_list;
+ typedef sequence<string> string_list;
+ typedef sequence<wstring> wstring_list;
+
+ interface PrimitivesSetter {
+ boolean setBoolean(in boolean arg);
+ char setChar(in char arg);
+ wchar setWchar(in wchar arg);
+ octet setOctet(in octet arg);
+ short setShort(in short arg);
+ unsigned short setUnsignedShort(in unsigned short arg);
+ long setLong(in long arg);
+ unsigned long setUnsignedLong(in unsigned long arg);
+ long long setLongLong(in long long arg);
+ unsigned long long setUnsignedLongLong(in unsigned long long arg);
+ float setFloat(in float arg);
+ double setDouble(in double arg);
+ string setString(in string arg);
+ wstring setWstring(in wstring arg);
+ RemoteObject setRemoteObject(in RemoteObject obj);
+ };
+
+ interface ArraysSetter {
+ boolean_list setBoolean(in boolean_list arg);
+ char_list setChar(in char_list arg);
+ wchar_list setWchar(in wchar_list arg);
+ octet_list setOctet(in octet_list arg);
+ short_list setShort(in short_list arg);
+ unsigned_short_list setUnsignedShort(in unsigned_short_list arg);
+ long_list setLong(in long_list arg);
+ unsigned_long_list setUnsignedLong(in unsigned_long_list arg);
+ long_long_list setLongLong(in long_long_list arg);
+ unsigned_long_long_list setUnsignedLongLong(in unsigned_long_long_list arg);
+ float_list setFloat(in float_list arg);
+ double_list setDouble(in double_list arg);
+ string_list setString(in string_list arg);
+ wstring_list setWstring(in wstring_list arg);
+ remote_object_list setRemoteObject(in remote_object_list obj);
+ };
+
+ typedef sequence<long> long_seq1;
+ typedef sequence<long_seq1> long_seq2;
+ typedef sequence<long_seq2> long_seq3;
+
+ struct SimpleStruct {
+ string field1;
+ long field2;
+ };
+
+
+ struct SomeStruct {
+ SimpleStruct innerStruct;
+ string str;
+ string_list str_list;
+ long_seq2 twoDimSeq;
+ long_seq3 threeDimSeq;
+ };
+
+ interface TestObject {
+ SomeStruct pickStructFromArgs(in SomeStruct arg1, in SomeStruct arg2, in SomeStruct arg3, in long structNumber);
+ SomeStruct setStruct(in SomeStruct arg);
+ SimpleStruct setSimpleStruct(inout SimpleStruct arg);
+ long_seq1 setLongSeq1(inout long_seq1 arg);
+ long_seq2 setLongSeq2(inout long_seq2 arg);
+ long_seq3 setLongSeq3(inout long_seq3 arg);
+ };
+
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/references.idl b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/references.idl new file mode 100644 index 0000000000..72b58806e6 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/resources/references.idl @@ -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.
+ */
+
+/*
+ * compile by
+ * idlj -fall -oldImplBase remote_objects.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module binding {
+ module corba {
+ module testing {
+ module references {
+
+ interface DummyObject {
+ long getLong();
+ DummyObject cloneObject();
+ };
+
+ interface ObjectManager {
+ DummyObject getDummyObject();
+ DummyObject getObjectByArgument(in DummyObject dummy);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sca-java-2.x/trunk/modules/binding-corba/LICENSE b/sca-java-2.x/trunk/modules/binding-corba/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-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/sca-java-2.x/trunk/modules/binding-corba/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-corba/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..6dfeae91cb --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/META-INF/MANIFEST.MF @@ -0,0 +1,29 @@ +Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.corba;uses:="org.apache
+ .tuscany.sca.assembly,javax.xml.namespace";version="2.0.0"
+Private-Package: org.apache.tuscany.sca.binding.corba.impl;version="1.
+ 4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA CORBA Binding Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397128062
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA CORBA Binding Extension
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0",
+ org.apache.tuscany.sca.binding.corba;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.corba
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sca-java-2.x/trunk/modules/binding-corba/NOTICE b/sca-java-2.x/trunk/modules/binding-corba/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/trunk/modules/binding-corba/pom.xml b/sca-java-2.x/trunk/modules/binding-corba/pom.xml new file mode 100644 index 0000000000..fd6a3d12ff --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/pom.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>tuscany-binding-corba</artifactId> + <name>Apache Tuscany SCA CORBA Binding Extension</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-core-spi</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-assembly-xml</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + </dependencies> + +</project> diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.java new file mode 100644 index 0000000000..db8c32a400 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBinding.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.corba; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.Base; +import org.apache.tuscany.sca.assembly.Binding; + +/** + * @version $Rev$ $Date$ + */ +public interface CorbaBinding extends Binding { + String BINDING_CORBA = "binding.corba"; + QName BINDING_CORBA_QNAME = new QName(Base.SCA11_TUSCANY_NS, BINDING_CORBA); + + String getHost(); + + void setHost(String host); + + int getPort(); + + void setPort(int port); + + String getId(); + + void setId(String id); + + String getCorbaname(); +} diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.java new file mode 100644 index 0000000000..67e3bdcf74 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/CorbaBindingFactory.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.binding.corba; + +/** + * @version $Rev$ $Date$ + */ +public interface CorbaBindingFactory { + /** + * Create a CorbaBinding model + * @return The CorbaBinding model + */ + CorbaBinding createCorbaBinding(); +} diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java new file mode 100644 index 0000000000..cecb4fb567 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingFactoryImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.impl; + +import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.binding.corba.CorbaBindingFactory; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaBindingFactoryImpl implements CorbaBindingFactory { + + /** + * @see org.apache.tuscany.sca.binding.corba.CorbaBindingFactory#createCorbaBinding() + */ + public CorbaBinding createCorbaBinding() { + return new CorbaBindingImpl(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.java new file mode 100644 index 0000000000..25d8ed6c99 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingImpl.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.binding.corba.impl; + +import org.apache.tuscany.sca.assembly.impl.BindingImpl; +import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.host.corba.CorbaHostUtils; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaBindingImpl extends BindingImpl implements CorbaBinding { + private String host; + private int port; + private String id; + + /** + * @param type + */ + public CorbaBindingImpl() { + super(CorbaBinding.BINDING_CORBA_QNAME); + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCorbaname() { + return CorbaHostUtils.isValidCorbanameURI(getURI()) ? getURI(): CorbaHostUtils.createCorbanameURI(getHost(), getPort(), getName()); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java new file mode 100644 index 0000000000..8e5fcdc6e1 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProcessor.java @@ -0,0 +1,137 @@ +/* + * 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.corba.impl; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor; +import org.apache.tuscany.sca.binding.corba.CorbaBinding; +import org.apache.tuscany.sca.binding.corba.CorbaBindingFactory; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; +import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; +import org.apache.tuscany.sca.contribution.processor.ProcessorContext; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.policy.PolicyFactory; + +/** + * @version $Rev$ $Date$ + */ +public class CorbaBindingProcessor implements StAXArtifactProcessor<CorbaBinding> { + private CorbaBindingFactory factory; + private PolicyFactory policyFactory; + private PolicySubjectProcessor policyProcessor; + + public CorbaBindingProcessor(FactoryExtensionPoint modelFactories) { + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); + this.factory = modelFactories.getFactory(CorbaBindingFactory.class); + this.policyProcessor = new PolicySubjectProcessor(policyFactory); + } + + /** + * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#getArtifactType() + */ + public QName getArtifactType() { + return CorbaBinding.BINDING_CORBA_QNAME; + } + + /** + * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#read(javax.xml.stream.XMLStreamReader) + */ + public CorbaBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { + CorbaBinding binding = factory.createCorbaBinding(); + + // Read the policies + policyProcessor.readPolicies(binding, reader); + + binding.setHost(reader.getAttributeValue(null, "host")); + String port = reader.getAttributeValue(null, "port"); + if (port != null) { + binding.setPort(Integer.parseInt(port)); + } + + // Read the name + String name = reader.getAttributeValue(null, "name"); + if (name != null) { + binding.setName(name); + } + + // Read binding URI + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null) { + binding.setURI(uri); + } + + // Read CORBA id + String id = reader.getAttributeValue(null, "id"); + if (id != null) { + binding.setId(id); + } + return binding; + } + + /** + * @see org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor#write(java.lang.Object, javax.xml.stream.XMLStreamWriter) + */ + public void write(CorbaBinding model, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { + // Write a <binding.corba> + writer.writeStartElement(CorbaBinding.BINDING_CORBA_QNAME.getNamespaceURI(), CorbaBinding.BINDING_CORBA); + + if (model.getName() != null) { + writer.writeAttribute("name", model.getName()); + } + + if (model.getURI() != null) { + writer.writeAttribute("uri", model.getURI()); + } + + if (model.getHost() != null) { + writer.writeAttribute("host", model.getHost()); + } + + if (model.getPort() != -1) { + writer.writeAttribute("port", String.valueOf(model.getPort())); + } + + if (model.getId() != null) { + writer.writeAttribute("id", model.getId()); + } + writer.writeEndElement(); + } + + /** + * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#getModelType() + */ + public Class<CorbaBinding> getModelType() { + return CorbaBinding.class; + } + + /** + * @see org.apache.tuscany.sca.contribution.processor.ArtifactProcessor#resolve(java.lang.Object, org.apache.tuscany.sca.contribution.resolver.ModelResolver) + */ + public void resolve(CorbaBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory b/sca-java-2.x/trunk/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory new file mode 100644 index 0000000000..57959840d4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.corba.CorbaBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the model factory
+org.apache.tuscany.sca.binding.corba.impl.CorbaBindingFactoryImpl
\ No newline at end of file diff --git a/sca-java-2.x/trunk/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/trunk/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..71d14bc077 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.corba.impl.CorbaBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.corba,model=org.apache.tuscany.sca.binding.corba.CorbaBinding,factory=org.apache.tuscany.sca.binding.corba.CorbaBindingFactory
diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/LICENSE b/sca-java-2.x/trunk/modules/host-corba-jee/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/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-2.x/trunk/modules/host-corba-jee/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/host-corba-jee/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..71fbb7e6a9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.host.corba.jee;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JEE environment CORBA Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397427890
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JEE environment CORBA Host
+Import-Package: javax.naming,
+ javax.naming.spi;resolution:=optional,
+ javax.rmi,
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.omg.CORBA,
+ org.omg.CORBA.portable;resolution:=optional,
+ org.omg.CosNaming,
+ org.omg.CosNaming.NamingContextPackage
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba.jee
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/NOTICE b/sca-java-2.x/trunk/modules/host-corba-jee/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/pom.xml b/sca-java-2.x/trunk/modules/host-corba-jee/pom.xml new file mode 100644 index 0000000000..29cd6209ae --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/pom.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + <artifactId>tuscany-host-corba-jee</artifactId> + <name>Apache Tuscany SCA JEE environment CORBA Host</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba-jse</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + </dependencies> + +</project> diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java new file mode 100644 index 0000000000..4d86a08eaa --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java @@ -0,0 +1,164 @@ +/* + * 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.jee; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; + +import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.CorbaHostUtils; +import org.apache.tuscany.sca.host.corba.CorbanameURL; +import org.oasisopen.sca.ServiceRuntimeException; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextExt; +import org.omg.CosNaming.NamingContextExtHelper; +import org.omg.CosNaming.NamingContextHelper; +import org.omg.CosNaming.NamingContextPackage.InvalidName; +import org.omg.CosNaming.NamingContextPackage.NotFound; + +/** + * @version $Rev$ $Date$ + * Implementation of JEE CORBA host + */ +public class JEECorbaHost implements CorbaHost, LifeCycleListener { + + public static final String ORB_NAME = "java:comp/ORB"; + + private List<String> registeredServants = Collections.synchronizedList(new ArrayList<String>()); + private ORB orb; + + private void registerURI(String uri) { + registeredServants.add(uri); + } + + private void removeURI(String uri) { + registeredServants.remove(uri); + } + + private NamingContextExt getNamingContext(String nameService) throws Exception { + org.omg.CORBA.Object objRef = orb.resolve_initial_references(nameService); + return NamingContextExtHelper.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 uri, Object servantObject) throws CorbaHostException { + CorbanameURL details = CorbaHostUtils.getServiceDetails(uri); + try { + NamingContext namingCtx = getNamingContext(details.getNameService()); + for (int i = 0; i < details.getNamePath().size() - 1; i++) { + NameComponent nc = new NameComponent(details.getNamePath().get(i), ""); + NameComponent[] path = new NameComponent[] {nc}; + try { + namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path)); + } catch (Exception e) { + namingCtx = namingCtx.bind_new_context(path); + } + } + NameComponent finalName = + new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), ""); + try { + namingCtx.resolve(new NameComponent[] {finalName}); + // 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) { + namingCtx.bind(new NameComponent[] {finalName}, servantObject); + registerURI(uri); + } + } catch (CorbaHostException e) { + throw e; + } catch (Exception e) { + handleException(e); + } + } + + public void unregisterServant(String uri) throws CorbaHostException { + CorbanameURL details = CorbaHostUtils.getServiceDetails(uri); + try { + NamingContextExt namingCtx = getNamingContext(details.getNameService()); + namingCtx.unbind(namingCtx.to_name(details.getName())); + removeURI(uri); + } catch (Exception e) { + handleException(e); + } + } + + public Object lookup(String uri) throws CorbaHostException { + Object result = null; + try { + CorbanameURL url = new CorbanameURL(uri); + NamingContextExt context = getNamingContext(url.getNameService()); + result = context.resolve_str(url.getName()); + } catch (Exception e) { + // e.printStackTrace(); + handleException(e); + } + if (result == null) { + throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT); + } + return result; + } + + // obtain ORB from environment + public void start() { + Context ctx; + try { + ctx = new InitialContext(); + orb = (ORB)PortableRemoteObject.narrow(ctx.lookup(ORB_NAME), org.omg.CORBA.ORB.class); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + + // unregister registered servants + public void stop() { + // use copy because unregisterServant(...) method removes from + // registeredServants collection + List<String> rsCopy = new ArrayList<String>(registeredServants); + for (String servantURI : rsCopy) { + try { + unregisterServant(servantURI); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java new file mode 100644 index 0000000000..fd952a02c7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java @@ -0,0 +1,208 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba.jee.testing; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; + +import javax.naming.Context; + +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.jee.JEECorbaHost; +import org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface; +import org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper; +import org.apache.tuscany.sca.host.corba.jee.testing.servants.TestInterfaceServant; +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * General tests for JEECorbaHost. Uses host-corba-jdk as mock for JEE + * environment ORB. + */ +public class JEECorbaHostTestCase { + + public static final String LOCALHOST = "localhost"; + public static final int DEFAULT_PORT = 11100; + private static JEECorbaHost host; + private static TransientNameServer server; + private static String factoryClassName; + + private String createCorbanameURI(String name) { + return "corbaname:#" + name; + } + + @BeforeClass + public static void start() { + try { + server = new TransientNameServer(LOCALHOST, DEFAULT_PORT, TransientNameService.DEFAULT_SERVICE_NAME); + Thread t = server.start(); + if (t == null) { + fail("The naming server cannot be started"); + } + factoryClassName = System.getProperty(Context.INITIAL_CONTEXT_FACTORY); + System.setProperty(Context.INITIAL_CONTEXT_FACTORY, TestInitialContextFactory.class.getName()); + host = new JEECorbaHost(); + host.start(); + } catch (Throwable e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @AfterClass + public static void stop() { + server.stop(); + if (factoryClassName != null) { + System.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryClassName); + } else { + System.clearProperty(Context.INITIAL_CONTEXT_FACTORY); + } + } + + /** + * Tests registering and lookup CORBA services + */ + @Test + public void test_registerServant() { + try { + String uri = createCorbanameURI("Nested/Test"); + TestInterface servant = new TestInterfaceServant(); + host.registerServant(uri, servant); + TestInterface ref = TestInterfaceHelper.narrow(host.lookup(uri)); + assertEquals(2, ref.getInt(2)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests unregistering servants + */ + @Test + public void test_unregisterServant() { + try { + String uri = createCorbanameURI("Unregistering/Test"); + TestInterface servant = new TestInterfaceServant(); + + // creating and releasing using corbaname URI + host.registerServant(uri, servant); + host.unregisterServant(uri); + host.registerServant(uri, servant); + host.unregisterServant(uri); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests situation when name is already registered + */ + @Test + public void test_nameAlreadyRegistered() { + // test using URI + try { + TestInterface servant = new TestInterfaceServant(); + String uri = createCorbanameURI("AlreadyRegisteredTest2"); + host.registerServant(uri, servant); + host.registerServant(uri, 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 to fetch object with corbaname URI + try { + host.lookup(createCorbanameURI("NonExistingOne")); + fail(); + } catch (CorbaHostException e) { + // The message is JDK-specific + // assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT)); + } catch (Exception e) { + // e.printStackTrace(); + fail(); + } + } + + /** + * Tests unregistering non existing reference + */ + @Test + public void test_unregisterNonExistentObject() { + // test using URI + try { + String uri = createCorbanameURI("NonExistingReference1"); + host.unregisterServant(uri); + fail(); + } catch (CorbaHostException e) { + assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests unregistering servants on host stop + */ + @Test + public void test_unregisterOnStop() { + try { + String uri1 = createCorbanameURI("TempService1"); + String uri2 = createCorbanameURI("TempService2"); + JEECorbaHost innerHost = new JEECorbaHost(); + innerHost.start(); + TestInterfaceServant servant = new TestInterfaceServant(); + innerHost.registerServant(uri1, servant); + innerHost.registerServant(uri2, servant); + innerHost.stop(); + try { + innerHost.lookup(uri1); + fail(); + } catch (CorbaHostException e) { + assertEquals(CorbaHostException.NO_SUCH_OBJECT, e.getMessage()); + } + try { + innerHost.lookup(uri2); + fail(); + } catch (CorbaHostException e) { + assertEquals(CorbaHostException.NO_SUCH_OBJECT, e.getMessage()); + } + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java new file mode 100644 index 0000000000..a0b9b7c514 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java @@ -0,0 +1,174 @@ +/* + * 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.jee.testing; + +import java.util.Hashtable; + +import javax.naming.Binding; +import javax.naming.Context; +import javax.naming.Name; +import javax.naming.NameClassPair; +import javax.naming.NameParser; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; + +import org.apache.tuscany.sca.host.corba.jee.JEECorbaHost; +import org.omg.CORBA.ORB; + +/** + * Mock implementation of javax.naming.Context interface. + */ +public class TestContext implements Context { + + private ORB orb; + + public Object addToEnvironment(String propName, Object propVal) throws NamingException { + return null; + } + + public void bind(Name name, Object obj) throws NamingException { + + } + + public void bind(String name, Object obj) throws NamingException { + + } + + public void close() throws NamingException { + + } + + public Name composeName(Name name, Name prefix) throws NamingException { + return null; + } + + public String composeName(String name, String prefix) throws NamingException { + return null; + } + + public Context createSubcontext(Name name) throws NamingException { + return null; + } + + public Context createSubcontext(String name) throws NamingException { + return null; + } + + public void destroySubcontext(Name name) throws NamingException { + + } + + public void destroySubcontext(String name) throws NamingException { + + } + + public Hashtable<?, ?> getEnvironment() throws NamingException { + return null; + } + + public String getNameInNamespace() throws NamingException { + return null; + } + + public NameParser getNameParser(Name name) throws NamingException { + return null; + } + + public NameParser getNameParser(String name) throws NamingException { + return null; + } + + public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { + return null; + } + + public NamingEnumeration<NameClassPair> list(String name) throws NamingException { + return null; + } + + public NamingEnumeration<Binding> listBindings(Name name) throws NamingException { + return null; + } + + public NamingEnumeration<Binding> listBindings(String name) throws NamingException { + return null; + } + + public Object lookup(Name name) throws NamingException { + return null; + } + + public Object lookup(String name) throws NamingException { + try { + if (name.equals(JEECorbaHost.ORB_NAME)) { + if (orb == null) { + // get ORB which was spawned under host and port declared in + // test class + String[] args = + {"-ORBInitialHost", JEECorbaHostTestCase.LOCALHOST, "-ORBInitialPort", + "" + JEECorbaHostTestCase.DEFAULT_PORT}; + orb = ORB.init(args, null); + } + } else { + throw new NamingException("Unknown name: " + name); + } + } catch (Exception e) { + throw new NamingException(e.getMessage()); + } + return orb; + } + + public Object lookupLink(Name name) throws NamingException { + return null; + } + + public Object lookupLink(String name) throws NamingException { + return null; + } + + public void rebind(Name name, Object obj) throws NamingException { + + } + + public void rebind(String name, Object obj) throws NamingException { + + } + + public Object removeFromEnvironment(String propName) throws NamingException { + return null; + } + + public void rename(Name oldName, Name newName) throws NamingException { + + } + + public void rename(String oldName, String newName) throws NamingException { + + } + + public void unbind(Name name) throws NamingException { + + } + + public void unbind(String name) throws NamingException { + + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java new file mode 100644 index 0000000000..f480235fa8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba.jee.testing; + +import java.util.Hashtable; + +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.spi.InitialContextFactory; + +/** + * Factory for mock implementation of javax.naming.Context interface. + */ +public class TestInitialContextFactory implements InitialContextFactory { + + public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { + return new TestContext(); + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java new file mode 100644 index 0000000000..f9f3d4789e --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/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.jee.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/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java new file mode 100644 index 0000000000..9ed4c81248 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java @@ -0,0 +1,100 @@ +/* + * 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.jee.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.jee.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.jee.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.jee.testing.general.TestInterfaceHelper.id(), + "TestInterface"); + } + return __typeCode; + } + + public static String id() { + return _id; + } + + public static org.apache.tuscany.sca.host.corba.jee.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.jee.testing.general.TestInterface value) { + ostream.write_Object((org.omg.CORBA.Object)value); + } + + public static org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface narrow(org.omg.CORBA.Object obj) { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface) + return (org.apache.tuscany.sca.host.corba.jee.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.jee.testing.general._TestInterfaceStub stub = + new org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceStub(); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.host.corba.jee.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.jee.testing.general.TestInterface) + return (org.apache.tuscany.sca.host.corba.jee.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.jee.testing.general._TestInterfaceStub stub = + new org.apache.tuscany.sca.host.corba.jee.testing.general._TestInterfaceStub(); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java new file mode 100644 index 0000000000..357c1eddb0 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/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.jee.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.jee.testing.general.TestInterface value = null; + + public TestInterfaceHolder() { + } + + public TestInterfaceHolder(org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterface initialValue) { + value = initialValue; + } + + public void _read(org.omg.CORBA.portable.InputStream i) { + value = org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.read(i); + } + + public void _write(org.omg.CORBA.portable.OutputStream o) { + org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.write(o, value); + } + + public org.omg.CORBA.TypeCode _type() { + return org.apache.tuscany.sca.host.corba.jee.testing.general.TestInterfaceHelper.type(); + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java new file mode 100644 index 0000000000..c2d4877791 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/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.jee.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/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java new file mode 100644 index 0000000000..9846748775 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/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.jee.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.jee.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/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java new file mode 100644 index 0000000000..cd722214ed --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/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.jee.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.jee.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/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java new file mode 100644 index 0000000000..6195f3af9c --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/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.jee.testing.servants; + +import org.apache.tuscany.sca.host.corba.jee.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/sca-java-2.x/trunk/modules/host-corba-jee/src/test/resources/general.idl b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/resources/general.idl new file mode 100644 index 0000000000..9194a37334 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jee/src/test/resources/general.idl @@ -0,0 +1,45 @@ +/*
+ * 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 general.idl
+ */
+
+module org {
+ module apache {
+ module tuscany {
+ module sca {
+ module host {
+ module corba {
+ module jee {
+ module testing {
+ module general {
+ interface TestInterface {
+ long getInt(in long arg);
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+};
diff --git a/sca-java-2.x/trunk/modules/host-corba-jse-tns/LICENSE b/sca-java-2.x/trunk/modules/host-corba-jse-tns/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse-tns/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-2.x/trunk/modules/host-corba-jse-tns/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/host-corba-jse-tns/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..8edf701bf7 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse-tns/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.host.corba.jse.tns;version="1.
+ 4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Transient Name Server CORBA Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397430015
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Transient Name Server CORBA Hos
+ t
+Import-Package: org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.host.corba;version="2.0.0",
+ org.apache.tuscany.sca.host.corba.jse;version="2.0.0",
+ org.apache.tuscany.sca.host.corba.naming;version="2.0.0",
+ org.omg.CORBA
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba.jse.tns
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sca-java-2.x/trunk/modules/host-corba-jse-tns/NOTICE b/sca-java-2.x/trunk/modules/host-corba-jse-tns/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse-tns/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/trunk/modules/host-corba-jse-tns/pom.xml b/sca-java-2.x/trunk/modules/host-corba-jse-tns/pom.xml new file mode 100644 index 0000000000..5014507384 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse-tns/pom.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + <artifactId>tuscany-host-corba-jse-tns</artifactId> + <name>Apache Tuscany SCA Transient Name Server CORBA Host</name> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba-jse</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-corba-runtime</artifactId> + <version>2.0-SNAPSHOT</version> + <scope>test</scope> + </dependency> + + </dependencies> + +</project> diff --git a/sca-java-2.x/trunk/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java b/sca-java-2.x/trunk/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java new file mode 100644 index 0000000000..4a395631b1 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java @@ -0,0 +1,120 @@ +/* + * 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.jse.tns; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.CorbanameURL; +import org.apache.tuscany.sca.host.corba.SocketUtil; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +import org.omg.CORBA.Object; + +/** + * @version $Rev$ $Date$ + * Default implementation of CORBA host + */ +public class TnsDefaultCorbaHost implements CorbaHost, LifeCycleListener { + + private static final Logger logger = Logger.getLogger(TnsDefaultCorbaHost.class.getName()); + private Map<Integer, TransientNameServer> localServers = new ConcurrentHashMap<Integer, TransientNameServer>(); + private Map<Integer, Integer> clientsCount = new ConcurrentHashMap<Integer, Integer>(); + private CorbaHost targetHost = new DefaultCorbaHost(); + + public void registerServant(String uri, Object servantObject) throws CorbaHostException { + CorbanameURL details = new CorbanameURL(uri); + if (SocketUtil.isLocalhost(details.getHost())) { + createLocalNameServer(details.getPort()); + } + targetHost.registerServant(uri, servantObject); + } + + public void unregisterServant(String uri) throws CorbaHostException { + targetHost.unregisterServant(uri); + CorbanameURL details = new CorbanameURL(uri); + if (SocketUtil.isLocalhost(details.getHost())) { + releaseLocalNameServer(details.getPort()); + } + } + + public Object lookup(String uri) throws CorbaHostException { + return targetHost.lookup(uri); + } + + /** + * Starts transient name server under given port. If TNS was previously + * spawned it increments clients counter. + */ + synchronized private void createLocalNameServer(int port) throws CorbaHostException { + int useCount = clientsCount.containsKey(port) ? clientsCount.get(port) : 0; + // no server previously spawned + if (useCount == 0) { + TransientNameServer server = + new TransientNameServer("localhost", port, TransientNameService.DEFAULT_SERVICE_NAME); + Thread thread = server.start(); + if (thread == null) { + throw new CorbaHostException("TransientNameServer couldn't be started"); + } else { + localServers.put(port, server); + } + } + clientsCount.put(port, ++useCount); + } + + /** + * Stops transient name server if there is only one client left using such + * TNS. Decrements clients counter if TNS is used by 2 or more clients. + */ + synchronized private void releaseLocalNameServer(int port) throws CorbaHostException { + int useCount = clientsCount.containsKey(port) ? clientsCount.get(port) : 0; + if (useCount == 1) { + // last client executed stop, cleaning up + TransientNameServer server = localServers.get(port); + if (server != null) { + server.stop(); + clientsCount.remove(port); + localServers.remove(port); + } else { + logger.warning("Local name server on port " + port + " was null!"); + } + } else if (useCount > 1) { + clientsCount.put(port, --useCount); + } else { + logger.warning("Tried to release non existing local name server on port " + port); + } + + } + + public void stop() { + for (TransientNameServer tns : localServers.values()) { + tns.stop(); + } + } + + public void start() { + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java b/sca-java-2.x/trunk/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java new file mode 100644 index 0000000000..85ac98cfef --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java @@ -0,0 +1,99 @@ +/* + * 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.assertTrue; +import static junit.framework.Assert.fail; + +import java.net.Socket; +import java.net.SocketException; + +import org.apache.tuscany.sca.binding.corba.provider.service.DynaCorbaServant; +import org.apache.tuscany.sca.host.corba.jse.tns.TnsDefaultCorbaHost; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + * General tests + */ +public class TnsDefaultCorbaHostTestCase { + + private static TnsDefaultCorbaHost host; + + @BeforeClass + public static void start() { + try { + host = new TnsDefaultCorbaHost(); + } catch (Throwable e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @AfterClass + public static void stop() { + host.stop(); + } + + /** + * Test for creating and releasing local name server + */ + @Test + @Ignore + public void test_localNameServer() { + int testPort = 5070; + try { + String testUri1 = "corbaname::localhost:" + testPort + "#Test1"; + String testUri2 = "corbaname::localhost:" + testPort + "#Test2"; + String testUri3 = "corbaname::localhost:" + testPort + "#Test3"; + DynaCorbaServant servant = new DynaCorbaServant(null, "IDL:org/apache/tuscany:1.0"); + host.registerServant(testUri1, servant); + host.registerServant(testUri2, servant); + host.registerServant(testUri3, servant); + Thread.sleep(1000); + // make test connection to name server + Socket socket = new Socket("localhost", testPort); + socket.close(); + // and stop server + host.unregisterServant(testUri1); + host.unregisterServant(testUri2); + // after releasing 2 clients 3rd should still hold the server + socket = new Socket("localhost", testPort); + socket.close(); + host.unregisterServant(testUri3); + Thread.sleep(1000); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + try { + // previously made 3rd stop so there should be no name server under + // this port + new Socket("localhost", testPort); + fail(); + } catch (Exception e) { + assertTrue(e instanceof SocketException); + } + } +} + diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/LICENSE b/sca-java-2.x/trunk/modules/host-corba-jse/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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-2.x/trunk/modules/host-corba-jse/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/host-corba-jse/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..701f471038 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/META-INF/MANIFEST.MF @@ -0,0 +1,32 @@ +Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.corba.jse;version="2.0.0";
+ uses:="org.omg.CosNaming.NamingContextPackage,
+ org.omg.CosNaming,
+ org.apache.tuscany.sca.host.corba,
+ org.omg.CORBA,
+ org.apache.tuscany.sca.core",
+ org.apache.tuscany.sca.host.corba.naming;version="2.0.0";
+ uses:="org.omg.CosNaming.NamingContextPackage,
+ org.omg.CosNaming,
+ org.omg.CosNaming.NamingContextExtPackage,
+ org.omg.CORBA,
+ org.omg.PortableServer"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JSE built-in CORBA Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397133187
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA JSE built-in CORBA Host
+Import-Package: org.apache.tuscany.sca.core;version="2.0.0",org.apache.t
+ uscany.sca.host.corba;version="2.0.0",org.apache.tuscany.sca.host.corba
+ .jse;version="2.0.0",org.apache.tuscany.sca.host.corba.naming;version="
+ 1.4",org.omg.CORBA,org.omg.CosNaming,org.omg.CosNaming.NamingContextE
+ xtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.PortableServ
+ er,org.omg.CORBA.portable;resolu
+ tion:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba.jse
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/NOTICE b/sca-java-2.x/trunk/modules/host-corba-jse/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/pom.xml b/sca-java-2.x/trunk/modules/host-corba-jse/pom.xml new file mode 100644 index 0000000000..72cb65f5b4 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + <artifactId>tuscany-host-corba-jse</artifactId> + <name>Apache Tuscany SCA JSE built-in CORBA Host</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-corba</artifactId> + <version>2.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project> diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java new file mode 100644 index 0000000000..9bdcd12988 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java @@ -0,0 +1,185 @@ +/* + * 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.jse; + +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.CorbaHostUtils; +import org.apache.tuscany.sca.host.corba.CorbanameURL; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextExt; +import org.omg.CosNaming.NamingContextExtHelper; +import org.omg.CosNaming.NamingContextHelper; +import org.omg.CosNaming.NamingContextPackage.InvalidName; +import org.omg.CosNaming.NamingContextPackage.NotFound; + +/** + * @version $Rev$ $Date$ + * Default implementation of JSE CORBA host + */ +public class DefaultCorbaHost implements CorbaHost, LifeCycleListener { + private static final Logger logger = Logger.getLogger(DefaultCorbaHost.class.getName()); + + private Map<String, ORB> orbs = new ConcurrentHashMap<String, ORB>(); + + private void validatePort(int port) throws IllegalArgumentException { + if (port < 1) { + throw new IllegalArgumentException("Port value should be > 0"); + } + } + + private NamingContextExt getNamingContext(ORB orb, String nameService) throws Exception { + org.omg.CORBA.Object objRef = orb.resolve_initial_references(nameService); + return NamingContextExtHelper.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 uri, Object servantObject) throws CorbaHostException { + CorbanameURL details = CorbaHostUtils.getServiceDetails(uri); + ORB orb = createORB(details.getHost(), details.getPort(), false); + try { + NamingContext namingCtx = getNamingContext(orb, details.getNameService()); + for (int i = 0; i < details.getNamePath().size() - 1; i++) { + NameComponent nc = new NameComponent(details.getNamePath().get(i), ""); + NameComponent[] path = new NameComponent[] {nc}; + try { + namingCtx = NamingContextHelper.narrow(namingCtx.resolve(path)); + } catch (Exception e) { + namingCtx = namingCtx.bind_new_context(path); + } + } + NameComponent finalName = + new NameComponent(details.getNamePath().get(details.getNamePath().size() - 1), ""); + try { + namingCtx.resolve(new NameComponent[] {finalName}); + // 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) { + namingCtx.bind(new NameComponent[] {finalName}, servantObject); + } + } catch (CorbaHostException e) { + throw e; + } catch (Exception e) { + handleException(e); + } + } + + public void unregisterServant(String uri) throws CorbaHostException { + CorbanameURL details = CorbaHostUtils.getServiceDetails(uri); + ORB orb = createORB(details.getHost(), details.getPort(), false); + try { + NamingContextExt namingCtx = getNamingContext(orb, details.getNameService()); + namingCtx.unbind(namingCtx.to_name(details.getName())); + } catch (Exception e) { + handleException(e); + } + } + + public Object lookup(String uri) throws CorbaHostException { + Object result = null; + try { + CorbanameURL url = new CorbanameURL(uri); + ORB orb = createORB(url.getHost(), url.getPort(), false); + NamingContextExt context = getNamingContext(orb, url.getNameService()); + result = context.resolve_str(url.getName()); + } catch (Exception e) { + handleException(e); + } + if (result == null) { + throw new CorbaHostException(CorbaHostException.NO_SUCH_OBJECT); + } + return result; + } + + public ORB createORB(String host, int port, boolean server) throws CorbaHostException { + validatePort(port); + + String key = host + ":" + port; + ORB orb = orbs.get(key); + if (orb != null) { + return orb; + } + // Create an ORB object + Properties props = new Properties(); + props.putAll(System.getProperties()); + + String portStr = String.valueOf(port); + props.put("org.omg.CORBA.ORBServerId", "1000000"); + props.put("org.omg.CORBA.ORBInitialHost", host); + props.put("org.omg.CORBA.ORBInitialPort", portStr); + + // STEP 1: Set ORBPeristentServerPort property + // Set the proprietary property to open up a port to listen to + // INS requests. + + if (server) { + props.put("com.sun.CORBA.POA.ORBPersistentServerPort", portStr); + props.put("com.ibm.CORBA.ListenerPort", portStr); + props.put("gnu.CORBA.ListenerPort", portStr); + // props.put("org.omg.CORBA.ORBClass", + // "org.apache.yoko.orb.CORBA.ORB"); + // props.put("org.omg.CORBA.ORBSingletonClass", + // "org.apache.yoko.orb.CORBA.ORBSingleton"); + props.put("yoko.orb.oa.endpoint", "iiop --host " + host + " --port " + port); + props.put("yoko.orb.poamanager.TNameService.endpoint", "iiop --host " + host); + } + + String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port}; + orb = ORB.init(args, props); + orbs.put(key, orb); + return orb; + } + + public void start() { + + } + public void stop() { + for (ORB orb : orbs.values()) { + try { + orb.shutdown(true); + orb.destroy(); + } catch (Throwable e) { + logger.log(Level.SEVERE, e.getMessage(), e); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java new file mode 100644 index 0000000000..59f0ce9a53 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java @@ -0,0 +1,863 @@ +/* + * 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. + */ +/** + * @version $Rev$ $Date$ + */ + +package org.apache.tuscany.sca.host.corba.naming; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CosNaming.BindingType; +import org.omg.CosNaming.BindingTypeHolder; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextExtPOA; +import org.omg.CosNaming.NamingContextHelper; +import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress; +import org.omg.CosNaming.NamingContextPackage.AlreadyBound; +import org.omg.CosNaming.NamingContextPackage.InvalidName; +import org.omg.CosNaming.NamingContextPackage.NotFound; +import org.omg.CosNaming.NamingContextPackage.NotFoundReason; +import org.omg.PortableServer.POA; + +public abstract class NamingContextBase extends NamingContextExtPOA { + // the real logger backing instance. We use the interface class as the locator + protected static final Logger logger = Logger.getLogger(NamingContext.class.getName()); + + // set of URL characters that don't require escaping when encoded. + protected final String nonEscaped = ";/?:@&=+$;-_.!~* ()"; + // the orb we're attached to + protected ORB orb; + // the poa we're associated with + protected POA poa; + + /** + * Create a new base NamingContext (super class constructor + * for the derived classes). + * + * @param orb The ORB this is hosted on. + * + * @exception java.lang.Exception + */ + public NamingContextBase(ORB orb, POA poa) throws java.lang.Exception { + super(); + this.orb = orb; + this.poa = poa; + } + + /** + * Bind an object to a given name. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * @param obj The object to be bound. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public void bind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj) + throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, + org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound { + // perform various name validations + validateName(n); + + logNameComponent("bind() name", n); + + // do we need to push through to a deeper naming context first? + if (n.length > 1) { + // resolve the top level name to a context, and have that context + // resolve the rest. + NamingContext context = resolveContext(n[0]); + NameComponent[] subName = extractSubName(n); + + // now pass this along to the next context for the real bind operation. + context.bind(subName, obj); + } else { + NameComponent name = n[0]; + // we need the resolveObject() and bindObject() calls to be consistent, so + // synchronize on this + synchronized (this) { + // see if we have this bound already...can't replace these. + BindingTypeHolder type = new BindingTypeHolder(); + if (resolveObject(name, type) != null) { + throw new AlreadyBound(); + } + type.value = BindingType.nobject; + // ok, this is a new binding, go do it. + bindObject(name, obj, type); + } + } + } + + /** + * Rebind an object to a given name. If an object is + * already bound with this name, the new object replaces + * the bound object's value. If no object has been + * bound already, this is the same as a bind operation. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * @param obj The new value for this binding. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public void rebind(org.omg.CosNaming.NameComponent[] n, org.omg.CORBA.Object obj) + throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, + org.omg.CosNaming.NamingContextPackage.InvalidName { + // perform various name validations + validateName(n); + + logNameComponent("rebind() name", n); + + // do we need to push through to a deeper naming context first? + if (n.length > 1) { + // resolve the top level name to a context, and have that context + // resolve the rest. + NamingContext context = resolveContext(n[0]); + NameComponent[] subName = extractSubName(n); + + // now pass this along to the next context for the real bind operation. + context.rebind(subName, obj); + } else { + NameComponent name = n[0]; + // we need the resolveObject() and bindObject() calls to be consistent, so + // synchronize on this + synchronized (this) { + // see if we have this bound already...can't replace these. + BindingTypeHolder type = new BindingTypeHolder(); + // for a rebind, we must have an object, and it must be a real object + if (resolveObject(name, type) != null) { + // it has to resolve to a real object. If it is a naming context, + // then this is the wrong binding operation. + if (type.value.value() == BindingType._ncontext) { + throw new NotFound(NotFoundReason.not_object, n); + } + // safe to unbind + unbindObject(name); + } + type.value = BindingType.nobject; + // now bind this object + bindObject(name, obj, type); + } + } + } + + /** + * Bind a new context to a given name. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * @param nc The new naming context added to the tree. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public void bind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc) + throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, + org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound { + // perform various name validations + validateName(n); + + logNameComponent("bind_context() name", n); + + // do we need to push through to a deeper naming context first? + if (n.length > 1) { + // resolve the top level name to a context, and have that context + // resolve the rest. + NamingContext context = resolveContext(n[0]); + NameComponent[] subName = extractSubName(n); + + // now pass this along to the next context for the real bind operation. + context.bind_context(subName, nc); + } else { + NameComponent name = n[0]; + // we need the resolveObject() and bindObject() calls to be consistent, so + // synchronize on this + synchronized (this) { + // see if we have this bound already...can't replace these. + BindingTypeHolder type = new BindingTypeHolder(); + if (resolveObject(name, type) != null) { + throw new AlreadyBound(); + } + type.value = BindingType.ncontext; + // ok, this is a new binding, go do it. + bindObject(name, nc, type); + } + } + } + + /** + * Rebind a context to a given name. If a context is + * already bound with this name, the new context replaces + * the existing context. If no context has been + * bound already, this is the same as a bind operation. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * @param nc The new context to be bound with the name. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public void rebind_context(org.omg.CosNaming.NameComponent[] n, org.omg.CosNaming.NamingContext nc) + throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, + org.omg.CosNaming.NamingContextPackage.InvalidName { + // perform various name validations + validateName(n); + + logNameComponent("rebind_context() name", n); + + // do we need to push through to a deeper naming context first? + if (n.length > 1) { + // resolve the top level name to a context, and have that context + // resolve the rest. + NamingContext context = resolveContext(n[0]); + NameComponent[] subName = extractSubName(n); + + // now pass this along to the next context for the real bind operation. + context.rebind_context(subName, nc); + } else { + NameComponent name = n[0]; + // we need the resolveObject() and bindObject() calls to be consistent, so + // synchronize on this + synchronized (this) { + // see if we have this bound already...can't replace these. + BindingTypeHolder type = new BindingTypeHolder(); + // for a rebind, we must have an object, and it must be a real object + if (resolveObject(name, type) != null) { + // it has to resolve to a real object. If it is a naming context, + // then this is the wrong binding operation. + if (type.value.value() != BindingType._ncontext) { + throw new NotFound(NotFoundReason.not_context, n); + } + // safe to unbind + unbindObject(name); + } + type.value = BindingType.ncontext; + // now bind this object + bindObject(name, nc, type); + } + } + } + + /** + * Resolve an an entry in the context tree. The + * resolved object may be a bound object or another + * NamingContext. If the named entry is not found, + * a NotFound exception is thrown. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * + * @return The object bound at the indicated location. + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public org.omg.CORBA.Object resolve(org.omg.CosNaming.NameComponent[] n) + throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, + org.omg.CosNaming.NamingContextPackage.InvalidName { + // perform various name validations + validateName(n); + + logNameComponent("resolve() name", n); + + // do we need to push through to a deeper naming context first? + if (n.length > 1) { + // resolve the top level name to a context, and have that context + // resolve the rest. + NamingContext context = resolveContext(n[0]); + NameComponent[] subName = extractSubName(n); + + // now pass this along to the next context for the real bind operation. + return context.resolve(subName); + } else { + NameComponent name = n[0]; + // see if we have this bound already...can't replace these. + BindingTypeHolder type = new BindingTypeHolder(); + org.omg.CORBA.Object obj = resolveObject(name, type); + if (obj == null) { + // Object was not found + throw new NotFound(NotFoundReason.missing_node, n); + } + return obj; + } + } + + /** + * Remove an entry from the context tree. The + * target object may be a bound object or another + * NamingContext. If the named entry is not found, + * a NotFound exception is thrown. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public void unbind(org.omg.CosNaming.NameComponent[] n) throws org.omg.CosNaming.NamingContextPackage.NotFound, + org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { + // perform various name validations + validateName(n); + + logNameComponent("unbind() name", n); + + // do we need to push through to a deeper naming context first? + if (n.length > 1) { + // resolve the top level name to a context, and have that context + // resolve the rest. + NamingContext context = resolveContext(n[0]); + NameComponent[] subName = extractSubName(n); + + // now pass this along to the next context for the real bind operation. + context.unbind(subName); + } else { + NameComponent name = n[0]; + synchronized (this) { + // see if we have this bound already...can't replace these. + BindingTypeHolder type = new BindingTypeHolder(); + org.omg.CORBA.Object obj = unbindObject(name); + if (obj == null) { + // Object was not found + throw new NotFound(NotFoundReason.missing_node, n); + } + } + } + } + + /** + * Create a new context and bind it in at the target + * location. + * + * @param n An array of NameComponents that are the target name. + * The last element in the array is binding name for the + * object. The remainder of the array is the path + * for resolving the naming context, relative to the + * current context. All path contexts must already be + * bound in the context tree. + * + * @return The newly created context. + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound + */ + public synchronized org.omg.CosNaming.NamingContext bind_new_context(org.omg.CosNaming.NameComponent[] n) + throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.AlreadyBound, + org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { + logNameComponent("bind_new_context() name", n); + + NamingContext context = new_context(); + try { + bind_context(n, context); + NamingContext returnContext = context; + // transfer this to another variable so the finally block doesn't try to destroy this. + context = null; + return returnContext; + } finally { + // if there is a bind failure on this, we need to ensure the context has + // an opportunity to clean up any of its resources. + if (context != null) { + try { + context.destroy(); + } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty e) { + // new contexts should be empty. + } + } + } + } + + /** + * Convert an array of NameComponents into the string + * form of a context name. + * + * @param n The array of NameComponents to convert. + * + * @return The context name, in string form. + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + */ + public String to_string(org.omg.CosNaming.NameComponent[] n) + throws org.omg.CosNaming.NamingContextPackage.InvalidName { + validateName(n); + + logNameComponent("to_string() name", n); + + // convert the first part of the name + StringBuffer value = new StringBuffer(); + ; + // convert the first component, then build up from there. + nameToString(n[0], value); + + // the remainder need to get a separator + for (int i = 1; i < n.length; i++) { + value.append('/'); + nameToString(n[i], value); + } + return value.toString(); + } + + /** + * Perform the reverse operation of the to_string() method, + * parsing a String context name into an array of + * NameComponents. + * + * @param sn The string form of the name. + * + * @return An array of NameComponents parsed from the String name. + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + */ + public org.omg.CosNaming.NameComponent[] to_name(String sn) + throws org.omg.CosNaming.NamingContextPackage.InvalidName { + // must have a argument to parse + if (sn == null || sn.length() == 0) { + throw new InvalidName(); + } + + List components = new ArrayList(); + + StringBuffer component = new StringBuffer(); + + int index = 0; + String id = null; + String kind = null; + while (index < sn.length()) { + char ch = sn.charAt(index++); + + // found an escape character or a delimiter? + if (ch == '\\') { + // nothing after the escape? Trouble + if (index >= sn.length()) { + throw new InvalidName(); + } + // get the next character + ch = sn.charAt(index++); + component.append(ch); + } + // we need to process the periods here, to avoid getting + // mixed up with unescaped periods. + else if (ch == '.') { + // already seen a period while scanning? That's not allowed + if (id != null) { + throw new InvalidName(); + } + // pull off the id piece and reset the buffer + id = component.toString(); + component.setLength(0); + } + // found a component delimiter? + else if (ch == '/') { + // not seen a id/kind separator yet? This is an id with no kind + if (id == null) { + id = component.toString(); + kind = ""; + } else { + // we have an id already, pull off the kind + kind = component.toString(); + } + // add the parsed name component + components.add(new NameComponent(id, kind)); + // make sure these are all reset after pulling off a component + component.setLength(0); + id = null; + kind = null; + } else { + component.append(ch); + } + } + + // parse the last section + // not seen a id/kind separator yet? This is an id with no kind + if (id == null) { + id = component.toString(); + kind = ""; + } else { + // we have an id already, pull off the kind + kind = component.toString(); + } + // add the parsed name component + components.add(new NameComponent(id, kind)); + + // and turn this into a component array + return (NameComponent[])components.toArray(new NameComponent[components.size()]); + } + + /** + * Create a URL name for accessing a component by name. The + * URL will have a corbaname: protocol. + * + * @param addr The address location for the naming service used + * to resolve the object. This is in "host:port" form, + * just line a corbaloc: URL. + * @param sn The string mae of the target object. + * + * @return A URL for accessing this object, in String form. + * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidAddress + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + */ + public String to_url(String addr, String sn) throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress, + org.omg.CosNaming.NamingContextPackage.InvalidName { + // basic validation + if (addr == null || addr.length() == 0) { + throw new InvalidAddress(); + } + + if (sn == null || sn.length() == 0) { + throw new InvalidName(); + } + + // TODO: What validation, if any, needs to be done here? + return "corbaname:" + addr + "#" + encodeRFC2396Name(sn); + } + + /** + * Resolve a bound object or context using a name + * in String form. + * + * @param n The string name of the object context. This must + * be a form parseable by to_name(). + * + * @return The bound object or context. + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed + * @exception org.omg.CosNaming.NamingContextPackage.InvalidName + */ + public org.omg.CORBA.Object resolve_str(String n) throws org.omg.CosNaming.NamingContextPackage.NotFound, + org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { + // this is just a simple convenience method + return resolve(to_name(n)); + } + + // abstract methods that are part of the NamingContext interface that need to be + // implemented by the subclasses. + + /** + * Create a new context of the same type as the + * calling context. + * + * @return A new NamingContext item. + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception SystemException + */ + public abstract org.omg.CosNaming.NamingContext new_context() throws SystemException; + + /** + * Destroy a context. This method should clean up + * any backing resources associated with the context. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty + */ + public abstract void destroy() throws org.omg.CosNaming.NamingContextPackage.NotEmpty; + + /** + * Create a list of bound objects an contexts contained + * within this context. + * + * @param how_many The count of elements to return as a BindingList. + * @param bl A holder element for returning the source binding list. + * @param bi A holder for returning a BindingIterator. Any extra + * elements not returned in the BindingList are returned + * in the BindingIterator. + * + * @exception SystemException + */ + public abstract void list(int how_many, + org.omg.CosNaming.BindingListHolder bl, + org.omg.CosNaming.BindingIteratorHolder bi) throws SystemException; + + // abstract methods for the sub class to implement + + /** + * Resolve an object in this context (single level + * resolution). + * + * @param n The name of the target object. + * @param type A type holder for returning the bound object type + * information. + * + * @return The bound object. Returns null if the object does not + * exist in the context. + * @exception SystemException + */ + protected abstract org.omg.CORBA.Object resolveObject(NameComponent n, BindingTypeHolder type) + throws SystemException; + + /** + * Bind an object into the current context. This can + * be either an object or a naming context. + * + * @param n The single-level name of the target object. + * @param obj The object or context to be bound. + * @param type + * + * @exception SystemException + */ + protected abstract void bindObject(NameComponent n, org.omg.CORBA.Object obj, BindingTypeHolder type) + throws SystemException; + + /** + * Unbind an object from the current context. + * + * @param n The name of the target object (single level). + * + * @return The object associated with the binding. Returns null + * if there was no binding currently associated with this + * name. + * @exception SystemException + */ + protected abstract org.omg.CORBA.Object unbindObject(NameComponent n) throws SystemException; + + // implementation specific routines + + /** + * Resolve a name to a context object stored that has + * already been stored in this context. Throws an exception + * if the name cannot be resolved or if the resolved + * object is not a naming context. + * + * @param name The target name. + * + * @return The resolved NamingContext object. + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + */ + protected synchronized NamingContext resolveContext(NameComponent name) + throws org.omg.CosNaming.NamingContextPackage.NotFound { + BindingTypeHolder type = new BindingTypeHolder(); + // Resolve this to an object. We must be able to resolve this. + org.omg.CORBA.Object resolvedReference = resolveObject(name, type); + if (resolvedReference == null) { + throw new NotFound(NotFoundReason.missing_node, new NameComponent[] {name}); + } + + // it has to resolve to a naming context + if (type.value.value() != BindingType._ncontext) { + throw new NotFound(NotFoundReason.not_context, new NameComponent[] {name}); + } + + // in theory, this is a naming context. Narrow it an return. Any + // errors just become a NotFound exception + try { + return NamingContextHelper.narrow(resolvedReference); + } catch (org.omg.CORBA.BAD_PARAM ex) { + throw new NotFound(NotFoundReason.not_context, new NameComponent[] {name}); + } + } + + /** + * Extract the tail portion of a name. This is used + * to strip off the first name element so we can recurse + * on the name resolutions with a resolved context. + * + * @param name The current name array (this MUST have 2 or more + * elements). + * + * @return An array of NameComponent items that is one element + * smaller than the argument array, with the elements + * shifted over. + */ + protected NameComponent[] extractSubName(NameComponent[] name) { + NameComponent[] subName = new NameComponent[name.length - 1]; + System.arraycopy(name, 1, subName, 0, name.length - 1); + return subName; + } + + /** + * Perform common name validity checking. + * + * @param n The NameComponent array to check. + * + * @exception InvalidName + */ + protected void validateName(NameComponent[] n) throws InvalidName { + // perform various name validations + if (n == null) { + throw new BAD_PARAM(27 | org.omg.CORBA.OMGVMCID.value, CompletionStatus.COMPLETED_NO); + } + + // Valid name? + if (n.length < 1) { + throw new InvalidName(); + } + + // we have at least one name, so validate the toplevel item + NameComponent name = n[0]; + + // more name validation + if (name.id.length() == 0 && name.kind.length() == 0) { + throw new InvalidName(); + } + } + + /** + * Convert a NameComponent item into a string form, + * appending it to a StringBuffer. + * + * @param name The source NameComponent. + * @param out The StringBuffer location used to store the name + * value (appended to the end). + */ + protected void nameToString(NameComponent name, StringBuffer out) { + // if the id is null, then we base off of the kind. + if (name.id == null || name.id.length() == 0) { + out.append("."); + // true null name element? That displays as a "." + if (name.kind != null && name.kind.length() != 0) { + escapeName(name.kind, out); + } + } else { + // escape the name + escapeName(name.id, out); + // have a kind qualifier to add on? + if (name.kind != null && name.kind.length() != 0) { + out.append("."); + escapeName(name.kind, out); + } + } + } + + /** + * Process a name or kind element of a NameComponent, + * adding escape characters for '.' or '/' characters + * that might appear in the name. + * + * @param name The name element to process. + * @param out The StringBuffer to copy the escaped name into. + */ + protected void escapeName(String name, StringBuffer out) { + // no characters requiring escapes (common)? + // use this directly + if (name.indexOf('.') == -1 && name.indexOf('/') == -1) { + out.append(name); + } else { + // scan the string adding the escapes + for (int i = 0; i < name.length(); i++) { + char ch = name.charAt(i); + if (ch == '.' || ch == '/') { + out.append('/'); + } + out.append(ch); + } + } + } + + /** + * Perform RFC 2396 escape encoding of a name value. + * + * @param name The input name value. + * + * @return An encoded name, with special characters converted + * into a hex encoded value. + */ + protected String encodeRFC2396Name(String name) { + StringBuffer value = new StringBuffer(); + + for (int i = 0; i < name.length(); i++) { + char ch = name.charAt(i); + + // Alphanumerics and the "acceptable" set of special characters just get copied + // without encoding. + if (Character.isLetterOrDigit(ch) || nonEscaped.indexOf(ch) != -1) { + value.append(ch); + } else { + // this gets converted into a hex value, marked by "%". + value.append('%'); + value.append(Integer.toHexString((int)ch)); + } + } + return value.toString(); + } + + /** + * Test if debug logging is currently available. + * + * @return True if debug level (FINE) logging is currently turned on. + */ + protected boolean isDebugEnabled() { + return logger.isLoggable(Level.FINE); + } + + /** + * Log a line of debug output + * + * @param message The message to log + */ + protected void debug(String message) { + logger.fine(message); + } + + /** + * Log the name components passed in for a request. + * + * @param message A message describing the request context. + * @param n The array of name components. + */ + protected void logNameComponent(String message, NameComponent[] n) { + if (isDebugEnabled()) { + debug(message); + for (int i = 0; i < n.length; i++) { + debug(" NameComponent " + i + " id=" + n[i].id + " kind=" + n[i].kind); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java new file mode 100644 index 0000000000..087b2e4357 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java @@ -0,0 +1,134 @@ +/* + * 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. + */ + +/** + * @version $Rev$ $Date$ + */ +package org.apache.tuscany.sca.host.corba.naming; + +import org.omg.CORBA.ORB; + +/** + * A stand-alone naming service launchable from a command line. + */ +public class TransientNameServer { + private final TransientNameService service; + private final Object flag = new Object(); + private Boolean started; + + public TransientNameServer(String host, int port, String serviceName) { + this.service = new TransientNameService(host, port, serviceName); + } + + public ORB getORB() { + return service.getORB(); + } + + public Thread start() { + Thread t = new Thread() { + public void run() { + ORB orb = null; + synchronized (flag) { + try { + service.run(); + orb = service.getORB(); + started = Boolean.TRUE; + } catch (Throwable e) { + started = Boolean.FALSE; + throw new IllegalStateException(e); + } finally { + flag.notifyAll(); + } + } + // Wait for requests + orb.run(); + } + }; + t.setDaemon(true); + t.start(); + checkState(); + return t.isAlive() ? t : null; + } + + private Boolean checkState() { + synchronized (flag) { + while (started == null) { + try { + flag.wait(); + } catch (InterruptedException e) { + return null; + } + } + return started; + } + } + + public void stop() { + if (Boolean.TRUE.equals(started)) { + service.destroy(); + started = Boolean.FALSE; + } + } + + /** + * Launch a name service as a stand alone process. The + * Host, port, and service name are controlled using + * program arguments. + * + * @param args The array of arguments for tailoring the service. + * + * @exception Exception + */ + public static void main(String args[]) throws Exception { + int port = TransientNameService.DEFAULT_SERVICE_PORT; + String host = TransientNameService.DEFAULT_SERVICE_HOST; + String serviceName = TransientNameService.DEFAULT_SERVICE_NAME; + + // see if we have + for (int i = 0; i < args.length; i++) { + if (args[i].equals("-ORBInitialPort")) { + i++; + if (i < args.length) { + port = java.lang.Integer.parseInt(args[i]); + } else { + throw new IllegalArgumentException("Invalid -ORBInitialPort option"); + } + } else if (args[i].equals("-ORBInitialHost")) { + i++; + if (i < args.length) { + host = args[i]; + } else { + throw new IllegalArgumentException("Invalid -ORBInitialHost option"); + } + } else if (args[i].equals("-ORBServiceName")) { + i++; + if (i < args.length) { + serviceName = args[i]; + } else { + throw new IllegalArgumentException("Invalid -ORBServiceName option"); + } + } + + } + // create a services, and just spin it off. We wait forever after that. + TransientNameServer server = new TransientNameServer(host, port, serviceName); + server.start().join(); + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java new file mode 100644 index 0000000000..77617a6c5c --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java @@ -0,0 +1,200 @@ +/* + * 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. + */ + +/** + * @version $Rev$ $Date$ + */ +package org.apache.tuscany.sca.host.corba.naming; + +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Properties; + +import org.omg.CORBA.ORB; +import org.omg.CORBA.Policy; +import org.omg.PortableServer.IdAssignmentPolicyValue; +import org.omg.PortableServer.LifespanPolicyValue; +import org.omg.PortableServer.POA; +import org.omg.PortableServer.ServantRetentionPolicyValue; + +/** + * A transient name service attached to an ORB. This + * class manages all of the housekeeping for creating a + * TransientNamingContext and a exposing it using an + * ORB. + */ +public class TransientNameService { + // the default registered name service + static public final String DEFAULT_SERVICE_NAME = "TNameService"; + // the default listening port + static public final int DEFAULT_SERVICE_PORT = 900; + // the default host name + static public final String DEFAULT_SERVICE_HOST = "localhost"; + + // the service root context + protected TransientNamingContext initialContext; + // initial listening port + protected int port; + // initial listening host + protected String host; + // the service name (used for registing for the corbaloc:: URL name + protected String serviceName; + // the orb instance we're running on + protected ORB createdOrb; + + /** + * Create a new TransientNameService, using all default + * attributes. + */ + public TransientNameService() { + this(DEFAULT_SERVICE_HOST, DEFAULT_SERVICE_PORT, DEFAULT_SERVICE_NAME); + } + + /** + * Create a default-named name service using the specified + * host and port parameters. + * + * @param host The host to expose this under. + * @param port The initial listening port. + */ + public TransientNameService(String host, int port) { + this(host, port, DEFAULT_SERVICE_NAME); + } + + /** + * Create a specifically-named name service using the specified + * host and port parameters. + * + * @param host The host to expose this under. + * @param port The initial listening port. + * @param name The name to register this service under using the + * BootManager. + */ + public TransientNameService(String host, int port, String name) { + this.port = port; + this.host = host; + this.serviceName = name; + } + + /** + * Start up the name service, including creating an + * ORB instance to expose it under. + * + * @exception TransientServiceException + */ + public void run() throws TransientServiceException { + // Create an ORB object + Properties props = new Properties(); + props.putAll(System.getProperties()); + + String portStr = String.valueOf(port); + props.put("org.omg.CORBA.ORBServerId", "1000000"); + props.put("org.omg.CORBA.ORBInitialHost", host); + props.put("org.omg.CORBA.ORBInitialPort", portStr); + + // STEP 1: Set ORBPeristentServerPort property + // Set the proprietary property to open up a port to listen to + // INS requests. + + props.put("com.sun.CORBA.POA.ORBPersistentServerPort", portStr); + props.put("com.ibm.CORBA.ListenerPort", portStr); + props.put("gnu.CORBA.ListenerPort", portStr); + // props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB"); + // props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton"); + props.put("yoko.orb.oa.endpoint", "iiop --host " + host + " --port " + port); + props.put("yoko.orb.poamanager.TNameService.endpoint", "iiop --host " + host); + + String[] args = {"-ORBInitialHost", host, "-ORBInitialPort", "" + port}; + createdOrb = ORB.init(args, props); + + // now initialize the service + initialize(createdOrb); + + } + + /** + * Initialize a transient name service on a specific + * ORB. + * + * @param orb The ORB hosting the service. + * + * @exception TransientServiceException + */ + public void initialize(ORB orb) throws TransientServiceException { + try { + // get the root POA. We're going to re + POA rootPOA = (POA)orb.resolve_initial_references("RootPOA"); + rootPOA.the_POAManager().activate(); + + // we need to create a POA to manage this named instance, and then activate + // a context on it. + Policy[] policy = new Policy[3]; + policy[0] = rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT); + policy[1] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID); + policy[2] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN); + + POA nameServicePOA = rootPOA.create_POA("TNameService", null, policy); + nameServicePOA.the_POAManager().activate(); + + // create our initial context, and register that with the ORB as the name service + initialContext = new TransientNamingContext(orb, nameServicePOA); + org.omg.CORBA.Object context = initialContext.getRootContext(); + Method method = + orb.getClass().getMethod("register_initial_reference", String.class, org.omg.CORBA.Object.class); + method.invoke(orb, serviceName, context); + method.invoke(orb, "NamingService", context); + method.invoke(orb, "NameService", context); + } catch (Exception e) { + throw new TransientServiceException("Unable to initialize name service", e); + } + } + + /** + * Destroy the created service. + */ + public void destroy() { + // only destroy this if we created the orb instance. + if (createdOrb != null) { + createdOrb.shutdown(false); + createdOrb.destroy(); + + try { + // This is a workaround to close the sockets for SUN ORB + Method m = createdOrb.getClass().getMethod("getTransportManager"); + Object tm = m.invoke(createdOrb); + m = tm.getClass().getMethod("close"); + m.invoke(tm); + m = tm.getClass().getMethod("getAcceptors"); + Collection acceptors = (Collection) m.invoke(tm); + for(Object a: acceptors) { + m = a.getClass().getMethod("close"); + m.invoke(a); + } + } catch (Throwable e) { + // Ignore + } + createdOrb = null; + } + } + + public ORB getORB() { + return createdOrb; + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java new file mode 100644 index 0000000000..a7164e9ef3 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java @@ -0,0 +1,440 @@ +/* + * 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. + */ +/** + * @version $Rev$ $Date$ + */ + +package org.apache.tuscany.sca.host.corba.naming; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.omg.CORBA.INTERNAL; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CosNaming.Binding; +import org.omg.CosNaming.BindingHolder; +import org.omg.CosNaming.BindingIteratorHelper; +import org.omg.CosNaming.BindingIteratorPOA; +import org.omg.CosNaming.BindingType; +import org.omg.CosNaming.BindingTypeHolder; +import org.omg.CosNaming.NameComponent; +import org.omg.CosNaming.NamingContext; +import org.omg.CosNaming.NamingContextHelper; +import org.omg.CosNaming.NamingContextPackage.NotEmpty; +import org.omg.PortableServer.POA; + +public class TransientNamingContext extends NamingContextBase { + // the bindings maintained by this context + protected HashMap bindings = new HashMap(); + // the root context object + protected org.omg.CORBA.Object rootContext = null; + + /** + * Create a top-level naming context. + * + * @param orb The orb hosting this context. + * @param poa The POA used to activate the object. + * + * @exception Exception + */ + public TransientNamingContext(ORB orb, POA poa) throws Exception { + this(orb, poa, null); + // now get the initial root context as a corba object. + + byte[] objectId = poa.activate_object(this); + rootContext = poa.id_to_reference(objectId); + + } + + /** + * Construct a TransientNamingContext subcontext. + * + * @param orb The orb this context is associated with. + * @param poa The POA the root context is activated under. + * @param root The root context. + * + * @exception Exception + */ + public TransientNamingContext(ORB orb, POA poa, org.omg.CORBA.Object root) throws Exception { + super(orb, poa); + // save the root context link. + rootContext = root; + } + + // abstract methods part of the interface contract that the implementation is required + // to supply. + + /** + * Create a new context of the same type as the + * calling context. + * + * @return A new NamingContext item. + * @exception org.omg.CosNaming.NamingContextPackage.NotFound + * @exception SystemException + */ + public NamingContext new_context() throws SystemException { + try { + // create a new context. Then we need to register this with the POA and activate it. + TransientNamingContext newContext = new TransientNamingContext(orb, poa, rootContext); + + byte[] objectId = poa.activate_object(newContext); + org.omg.CORBA.Object obj = poa.id_to_reference(objectId); + return NamingContextHelper.narrow(obj); + } catch (SystemException e) { + // just propagate system exceptions + throw e; + } catch (Exception e) { + throw (INTERNAL)(new INTERNAL("Unable to create new naming context").initCause(e)); + } + } + + /** + * Destroy a context. This method should clean up + * any backing resources associated with the context. + * + * @exception org.omg.CosNaming.NamingContextPackage.NotEmpty + */ + public synchronized void destroy() throws org.omg.CosNaming.NamingContextPackage.NotEmpty { + // still holding bound objects? Not allowed to destroy + if (!bindings.isEmpty()) { + throw new NotEmpty(); + } + + try { + // now detach ourselves from the POA + byte[] objectId = poa.servant_to_id(this); + if (objectId != null) { + poa.deactivate_object(objectId); + } + } catch (Exception e) { + // ignore + } + } + + /** + * Create a list of bound objects an contexts contained + * within this context. + * + * @param how_many The count of elements to return as a BindingList. + * @param bl A holder element for returning the source binding list. + * @param bi A holder for returning a BindingIterator. Any extra + * elements not returned in the BindingList are returned + * in the BindingIterator. + * + * @exception SystemException + */ + public synchronized void list(int how_many, + org.omg.CosNaming.BindingListHolder bl, + org.omg.CosNaming.BindingIteratorHolder bi) throws SystemException { + TransientBindingIterator iterator = new TransientBindingIterator(poa, (HashMap)bindings.clone()); + // have the iterator fill in the entries here + iterator.next_n(how_many, bl); + + // now it's necessary to activate this iterator with the poa. The value we pass + // back is the narrowed activated object + try { + byte[] objectId = poa.activate_object(iterator); + org.omg.CORBA.Object obj = poa.id_to_reference(objectId); + + bi.value = BindingIteratorHelper.narrow(obj); + } catch (SystemException e) { + // just propagate system exceptions + throw e; + } catch (Exception e) { + throw (INTERNAL)(new INTERNAL("Unable to activate BindingIterator").initCause(e)); + } + } + + // lower level functions that are used by the base class + + /** + * Resolve an object in this context (single level + * resolution). + * + * @param n The name of the target object. + * @param type A type holder for returning the bound object type + * information. + * + * @return The bound object. Returns null if the object does not + * exist in the context. + * @exception SystemException + */ + protected org.omg.CORBA.Object resolveObject(NameComponent n, BindingTypeHolder type) throws SystemException { + // special call to resolve the root context. This is the only one that goes backwards. + if (n.id.length() == 0 && n.kind.length() == 0) { + // this is a name context item, so set it properly. + type.value = BindingType.ncontext; + return rootContext; + } + + BindingKey key = new BindingKey(n); + BoundObject obj = (BoundObject)bindings.get(key); + // if not in the table, just return null + if (obj == null) { + return null; + } + // update the type information and return the bound object reference. + type.value = obj.type; + return obj.boundObject; + } + + /** + * Bind an object into the current context. This can + * be either an object or a naming context. + * + * @param n The single-level name of the target object. + * @param obj The object or context to be bound. + * @param type + * + * @exception SystemException + */ + protected void bindObject(NameComponent n, org.omg.CORBA.Object obj, BindingTypeHolder type) throws SystemException { + // fairly simple table put... + bindings.put(new BindingKey(n), new BoundObject(n, obj, type.value)); + } + + /** + * Unbind an object from the current context. + * + * @param n The name of the target object (single level). + * + * @return The object associated with the binding. Returns null + * if there was no binding currently associated with this + * name. + * @exception SystemException + */ + protected org.omg.CORBA.Object unbindObject(NameComponent n) throws SystemException { + //remove the object from the hash table, returning the bound object if it exists. + BindingKey key = new BindingKey(n); + BoundObject obj = (BoundObject)bindings.remove(key); + + if (obj != null) { + return obj.boundObject; + } + return null; + } + + /** + * Retrieve the rootContext for this NamingContext. + * + * @return The rootContext CORBA object associated with this context. + */ + public org.omg.CORBA.Object getRootContext() { + return rootContext; + } + + /** + * Internal class used for HashMap lookup keys. + */ + class BindingKey { + // the name component this is a HashMap key for. + public NameComponent name; + private int hashval = 0; + + /** + * Create a new BindingKey for a NameComponent. + * + * @param n The lookup name. + */ + public BindingKey(NameComponent n) { + name = n; + // create a hash value used for lookups + if (name.id != null) { + hashval += name.id.hashCode(); + } + if (name.kind != null) { + hashval += name.kind.hashCode(); + } + } + + /** + * Return the hashcode associated with this binding key. The + * hashcode is created using the NameComponent id and + * kind fields. + * + * @return The lookup hashvalue associated with this key. + */ + public int hashCode() { + return hashval; + } + + /** + * Compare two BindingKeys for equality (used for HashMap + * lookups). + * + * @param other The comparison partner. + * + * @return True if the keys are equivalent, false otherwise. + */ + public boolean equals(Object other) { + // if not given or the wrong type, this is false. + if (other == null || !(other instanceof BindingKey)) { + return false; + } + + BindingKey otherKey = (BindingKey)other; + + // verify first on the id name. + if (name.id != null) { + if (otherKey.name.id == null) { + return false; + } + if (!name.id.equals(otherKey.name.id)) { + return false; + } + } else { + if (otherKey.name.id != null) { + return false; + } + } + // this is a match so far...now compare the kinds + if (name.kind != null) { + if (otherKey.name.kind == null) { + return false; + } + if (!name.kind.equals(otherKey.name.kind)) { + return false; + } + } else { + if (otherKey.name.kind != null) { + return false; + } + } + return true; + } + } + + /** + * Internal class used to store bound objects in the HashMap. + */ + public class BoundObject { + // the name this object is bound under. + public NameComponent name; + // the type of binding (either nobject or ncontext). + public BindingType type; + // the actual bound object. + public org.omg.CORBA.Object boundObject; + + /** + * Create a new object binding for our HashMap. + * + * @param name The bound object's name. + * @param boundObject + * The bound object (real object or NamingContext). + * @param type The type information associated with this binding. + */ + public BoundObject(NameComponent name, org.omg.CORBA.Object boundObject, BindingType type) { + this.name = name; + this.boundObject = boundObject; + this.type = type; + } + } + + /** + * Context implementation version of the BindingIterator + * object used to return list items. + */ + public class TransientBindingIterator extends BindingIteratorPOA { + // the POA used to activate this object (required for destroy(); + private POA poa; + // the binding set we're iterating over (this must be a snapshot copy) + private HashMap bindings; + // the iterator use to access the bindings + private Iterator iterator; + + /** + * Create a new BindingIterator hosted by the given POA and + * iterating over the map of items. + * + * @param poa The hosting POA. + * @param bindings The HashMap of bound objects. + */ + public TransientBindingIterator(POA poa, HashMap bindings) { + this.poa = poa; + this.bindings = bindings; + this.iterator = bindings.values().iterator(); + } + + /** + * Return the next object in the iteration sequence. + * + * @param b The BindingHolder used to return the next item. If + * we've reached the end of the sequence, an item + * with an empty name is returned. + * + * @return true if there is another item, false otherwise. + */ + public boolean next_one(org.omg.CosNaming.BindingHolder b) { + if (iterator.hasNext()) { + // return this as a Binding value. + BoundObject obj = (BoundObject)iterator.next(); + b.value = new Binding(new NameComponent[] {obj.name}, obj.type); + return true; + } else { + // return an empty element + b.value = new Binding(new NameComponent[0], BindingType.nobject); + return false; + } + } + + /** + * Retrieve the next "n" items from the list, returned + * as a BindingList. + * + * @param how_many The count of items to retrieve. + * @param bl A holder for returning an array of Bindings for + * the returned items. + * + * @return true if any items were returned, false if there's + * nothing left to return. + */ + public boolean next_n(int how_many, org.omg.CosNaming.BindingListHolder bl) { + List accum = new ArrayList(); + BindingHolder holder = new BindingHolder(); + int i = 0; + // Keep iterating as long as there are entries + while (i < how_many && next_one(holder)) { + accum.add(holder.value); + i++; + } + + // convert to an array and return whether we found anything. + bl.value = (Binding[])accum.toArray(new Binding[accum.size()]); + return accum.isEmpty(); + } + + /** + * Destory this BindingIterator instance, which deativates + * it from the hosting POA. + */ + public void destroy() { + try { + // we need to deactivate this from the POA. + byte[] objectId = poa.servant_to_id(this); + if (objectId != null) { + poa.deactivate_object(objectId); + } + } catch (Exception e) { + } + } + } +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java new file mode 100644 index 0000000000..444143f173 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @version $Rev$ $Date$ + */ +package org.apache.tuscany.sca.host.corba.naming; + +public class TransientServiceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -2611596914331994827L; + + public TransientServiceException() { + super(); + } + + public TransientServiceException(String reason) { + super(reason); + } + + public TransientServiceException(String reason, Exception cause) { + super(reason, cause); + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java new file mode 100644 index 0000000000..4a6a01bf97 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java @@ -0,0 +1,253 @@ +/* + * 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.net.ConnectException; +import java.net.Socket; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.corba.CorbaHost; +import org.apache.tuscany.sca.host.corba.CorbaHostException; +import org.apache.tuscany.sca.host.corba.CorbaHostUtils; +import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; +import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; +import org.apache.tuscany.sca.host.corba.naming.TransientNameService; +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; + +/** + * General tests + */ +public class DefaultCorbaHostTestCase { + + private static final String LOCALHOST = "localhost"; + private static final int DEFAULT_PORT = 11100; // 1050; + + private static CorbaHost host; + + private static TransientNameServer server; + + @BeforeClass + public static void start() { + try { + server = new TransientNameServer(LOCALHOST, DEFAULT_PORT, TransientNameService.DEFAULT_SERVICE_NAME); + Thread t = server.start(); + if (t == null) { + fail("The naming server cannot be started"); + } + host = new DefaultCorbaHost(); + } catch (Throwable e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @AfterClass + public static void stop() { + server.stop(); + } + + /** + * Tests registering and lookup CORBA services + */ + @Test + public void test_registerServant() { + try { + String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, "Nested/Test"); + TestInterface servant = new TestInterfaceServant(); + host.registerServant(uri, servant); + TestInterface ref = TestInterfaceHelper.narrow(host.lookup(uri)); + assertEquals(2, ref.getInt(2)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests unregistering servants + */ + @Test + public void test_unregisterServant() { + try { + String objName = "Unregistering/Test"; + String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, objName); + TestInterface servant = new TestInterfaceServant(); + + // creating and releasing using corbaname URI + host.registerServant(uri, servant); + host.unregisterServant(uri); + host.registerServant(uri, servant); + host.unregisterServant(uri); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests situation when name is already registered + */ + @Test + public void test_nameAlreadyRegistered() { + // test using URI + try { + TestInterface servant = new TestInterfaceServant(); + String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, "AlreadyRegisteredTest2"); + host.registerServant(uri, servant); + host.registerServant(uri, 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 to fetch object with corbaname URI + try { + host.lookup(CorbaHostUtils.createCorbanameURI("NonExistingOne", DEFAULT_PORT, LOCALHOST)); + fail(); + } catch (CorbaHostException e) { + // The message is JDK-specific + // assertTrue(e.getMessage().equals(CorbaHostException.NO_SUCH_OBJECT)); + } catch (Exception e) { + // e.printStackTrace(); + fail(); + } + } + + /** + * Tests unregistering non existing reference + */ + @Test + public void test_unregisterNonExistentObject() { + // test using URI + try { + String uri = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT, "NonExistingReference1"); + host.unregisterServant(uri); + 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 { + String url = CorbaHostUtils.createCorbanameURI("not_" + LOCALHOST, DEFAULT_PORT, "Name"); + TestInterface servant = new TestInterfaceServant(); + host.registerServant(url, 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 { + String url = CorbaHostUtils.createCorbanameURI(LOCALHOST, DEFAULT_PORT + 1, "Name"); + TestInterface servant = new TestInterfaceServant(); + host.registerServant(url, 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("---", servant); + fail(); + } catch (CorbaHostException e) { + assertTrue(e.getMessage().equals(CorbaHostException.WRONG_NAME)); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * + */ + @Ignore + @Test + public void test_ensureORBStopped() { + try { + int innerORBPort = 11102; + TransientNameServer innerServer = + new TransientNameServer(LOCALHOST, innerORBPort, TransientNameService.DEFAULT_SERVICE_NAME); + innerServer.start(); + innerServer.stop(); + try { + Thread.sleep(500); + } catch (Exception e) { + } + Socket socket = new Socket(LOCALHOST, innerORBPort); + Assert.assertFalse(socket.isConnected()); + fail(); + } catch (Exception e) { + if (e instanceof ConnectException) { + assertTrue(true); + } else { + e.printStackTrace(); + } + } + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java new file mode 100644 index 0000000000..8d1a9db9e9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java new file mode 100644 index 0000000000..fe85dc7743 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java new file mode 100644 index 0000000000..305a4d7b97 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java new file mode 100644 index 0000000000..f557d3e020 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java new file mode 100644 index 0000000000..f993066dab --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java new file mode 100644 index 0000000000..30a77deaf5 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java new file mode 100644 index 0000000000..0ebde8ef0d --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba-jse/src/test/resources/general.idl b/sca-java-2.x/trunk/modules/host-corba-jse/src/test/resources/general.idl new file mode 100644 index 0000000000..f67566deb8 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba-jse/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/sca-java-2.x/trunk/modules/host-corba/LICENSE b/sca-java-2.x/trunk/modules/host-corba/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/sca-java-2.x/trunk/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/sca-java-2.x/trunk/modules/host-corba/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/host-corba/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2b38d299c0 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.corba;uses:="org.omg.CORBA
+ ";version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA CORBA Host Extension Point
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397126578
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA CORBA Host Extension Point
+Import-Package: org.apache.tuscany.sca.host.corba;version="2.0.0",org.om
+ g.CORBA
+Bundle-SymbolicName: org.apache.tuscany.sca.host.corba
+Bundle-DocURL: http://www.apache.org/
+
diff --git a/sca-java-2.x/trunk/modules/host-corba/NOTICE b/sca-java-2.x/trunk/modules/host-corba/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/NOTICE @@ -0,0 +1,6 @@ +${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/trunk/modules/host-corba/pom.xml b/sca-java-2.x/trunk/modules/host-corba/pom.xml new file mode 100644 index 0000000000..b1e1281e17 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-modules</artifactId> + <version>2.0-SNAPSHOT</version> + </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>2.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project> diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java new file mode 100644 index 0000000000..eb49f3f841 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.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; + +/** + * @version $Rev$ $Date$ + * CORBA Service hosting interface + */ +public interface CorbaHost { + + /** + * Registers servant in name server. + * + * @param uri corbaname URI + * @param serviceObject + * @throws CorbaHostException + */ + void registerServant(String uri, Object serviceObject) throws CorbaHostException; + + /** + * Removes servant from name server + * + * @param orb The ORB instance + * @param name binding name + * @throws CorbaHostException + */ + void unregisterServant(String uri) throws CorbaHostException; + + /** + * Gets reference to object + * + * @param name binding name + * @return objects reference + * @throws CorbaHostException + */ + Object lookup(String uri) throws CorbaHostException; +} diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java new file mode 100644 index 0000000000..049bfdb6cd --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.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.host.corba; + +/** + * @version $Rev$ $Date$ + * 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 location"; + 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/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java new file mode 100644 index 0000000000..067b9193c5 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.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; + +import java.util.List; + +/** + * @version $Rev$ $Date$ + * 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/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java new file mode 100644 index 0000000000..b90fe9c78b --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.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; + + +/** + * @version $Rev$ $Date$ + * Various utilities for host-corba + */ +public class CorbaHostUtils { + + /** + * Tests if given URI is valid corbaname string + * @param uri + * @return + */ + public static boolean isValidCorbanameURI(String uri) { + return uri != null && uri.startsWith("corbaname:") && uri.contains("#") && uri.indexOf('#') < uri.length() - 1; + } + + /** + * Creates corbaname URI basing on given parameters + * @param host + * @param port + * @param name + * + * @return + */ + public static String createCorbanameURI(String host, int port, String name) { + return new CorbanameURL(host, port, name).toString(); + } + + /** + * Translates corbaname URI to CorbanameDetails instances + * + * @param uri + * @return + */ + public static CorbanameURL getServiceDetails(String uri) { + CorbanameURL details = new CorbanameURL(uri); + return details; + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java new file mode 100644 index 0000000000..a380fd6d79 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java @@ -0,0 +1,202 @@ +/* + * 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.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.Arrays; +import java.util.List; + +/** + * @version $Rev$ $Date$ + * Holds corbaname URI details + */ +public class CorbanameURL { + public static String DEFAULT_PROTOCOL = "iiop"; + public static String DEFAULT_VERSION = ""; + public static String DEFAULT_NAME_SERVICE = "NameService"; + public static String DEFAULT_HOST = "localhost"; + public static int DEFAULT_PORT = 2809; + + private String protocol = ""; + private String version = ""; + private String host; + private int port; + private String nameService; + private List<String> namePath; + + public CorbanameURL(String host, int port, String namePath, String nameService) { + super(); + this.host = host == null ? DEFAULT_HOST : host; + this.port = port <= 0 ? DEFAULT_PORT : port; + this.namePath = parseName(namePath); + this.nameService = nameService == null ? DEFAULT_NAME_SERVICE : nameService; + } + + public CorbanameURL(String host, int port, String namePath) { + this(host, port, namePath, DEFAULT_NAME_SERVICE); + } + + public CorbanameURL(String url) { + if (url == null || (!url.startsWith("corbaname"))) { + throw new IllegalArgumentException("Malformed corbaname URL: " + url); + } + try { + url = URLDecoder.decode(url, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException(e); + } + String[] parts = url.split("#"); + if (parts.length == 2) { + String serviceLocation = parts[0]; + String servicePath = parts[1]; + namePath = parseName(servicePath); + + parts = serviceLocation.split("/"); + if (parts.length == 2) { + nameService = parts[1]; + } else { + nameService = DEFAULT_NAME_SERVICE; + } + + parts = parts[0].split(":"); + + if (parts.length >= 2) { + protocol = parts[1]; + } + if (parts.length >= 3) { + version = parts[2]; + String[] strs = version.split("@"); + if (strs.length == 2) { + version = strs[0]; + host = strs[1]; + } else { + version = ""; + host = strs[0]; + } + } + if (host == null || "".equals(host)) { + host = DEFAULT_HOST; + } + if (parts.length >= 4 && !"".equals(parts[3])) { + port = Integer.parseInt(parts[3]); + } else { + port = DEFAULT_PORT; + } + } else { + throw new IllegalArgumentException("Malformed corbaname URL: " + url); + } + } + + private static List<String> parseName(String name) { + try { + name = URLDecoder.decode(name, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException(e); + } + String[] names = name.split("/"); + return Arrays.asList(names); + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getNameService() { + return nameService; + } + + public void setNameService(String nameService) { + this.nameService = nameService; + } + + public List<String> getNamePath() { + return namePath; + } + + public String getName() { + if (namePath != null) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < namePath.size(); i++) { + buf.append(namePath.get(i)); + if (i < namePath.size() - 1) { + buf.append("/"); + } + } + return buf.toString(); + } + return null; + } + + public void setNamePath(List<String> namePath) { + this.namePath = namePath; + } + + @Override + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("corbaname:"); + buf.append(protocol).append(":"); + if (version != null && !"".equals(version)) { + buf.append(version).append("@"); + } + buf.append(host).append(":").append(port); + buf.append("/").append(nameService); + buf.append("#"); + if (namePath != null) { + for (int i = 0; i < namePath.size(); i++) { + buf.append(namePath.get(i)); + if (i < namePath.size() - 1) { + buf.append("/"); + } + } + } + return buf.toString(); + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java new file mode 100644 index 0000000000..6ed7f3ea83 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java @@ -0,0 +1,80 @@ +/* + * 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; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.LifeCycleListener; +import org.apache.tuscany.sca.extensibility.ServiceDeclaration; +import org.apache.tuscany.sca.extensibility.ServiceHelper; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * @version $Rev$ $Date$ + * Default implementation of CorbaHostExtensionPoint + */ +public class DefaultCorbaHostExtensionPoint implements CorbaHostExtensionPoint, LifeCycleListener { + private ExtensionPointRegistry registry; + private boolean loaded; + private List<CorbaHost> corbaHosts = new ArrayList<CorbaHost>(); + + public DefaultCorbaHostExtensionPoint(ExtensionPointRegistry registry) { + this.registry = registry; + } + + private synchronized void loadHosts() { + if (loaded) { + return; + } + try { + ServiceDeclaration sd = registry.getServiceDiscovery().getServiceDeclaration(CorbaHost.class); + CorbaHost host = ServiceHelper.newInstance(registry, sd); + ServiceHelper.start(host); + corbaHosts.add(host); + } catch (Throwable e) { + throw new ServiceRuntimeException(e); + } + } + + public void addCorbaHost(CorbaHost host) { + corbaHosts.add(host); + } + + public void removeCorbaHost(CorbaHost host) { + corbaHosts.remove(host); + } + + public List<CorbaHost> getCorbaHosts() { + loadHosts(); + return corbaHosts; + } + + public void start() { + } + + public void stop() { + ServiceHelper.stop(corbaHosts); + corbaHosts.clear(); + loaded = false; + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java new file mode 100644 index 0000000000..7e043667a9 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.host.corba; + +import org.omg.CORBA.Object; + +/** + * @version $Rev$ $Date$ + * Default implementation of extensible CORBA host + */ +public class ExtensibleCorbaHost implements CorbaHost { + + private CorbaHostExtensionPoint hosts; + + public ExtensibleCorbaHost(CorbaHostExtensionPoint chep) { + this.hosts = chep; + } + + public Object lookup(String uri) throws CorbaHostException { + return getCorbaHost().lookup(uri); + } + + public void registerServant(String uri, Object serviceObject) throws CorbaHostException { + getCorbaHost().registerServant(uri, serviceObject); + } + + public void unregisterServant(String uri) throws CorbaHostException { + getCorbaHost().unregisterServant(uri); + } + + protected CorbaHost getCorbaHost() throws CorbaHostException { + if (hosts.getCorbaHosts().isEmpty()) { + throw new CorbaHostException("No registered CORBA hosts"); + } + return hosts.getCorbaHosts().get(0); + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java new file mode 100755 index 0000000000..6989b3ad06 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.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; + +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.UnknownHostException; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * @version $Rev$ $Date$ + * Class partially copied from eclipse wst project + * (http://repo1.maven.org/maven2/org/eclipse/wst/server/core/1.0.205-v20070829b/). + * Finally we should use jar from maven dependency. Problem described in + * http://www.fornax-platform.org/cp/display/fornax/2.+Hello+World+Tutorial+(CSC)?replyToComment=2098#comment-2098 + * needs to be fixed. + */ +public class SocketUtil { + + protected static final Object lock = new Object(); + + private static Set<String> localHostCache; + private static Set<String> notLocalHostCache = new HashSet<String>(); + private static Map<String, CacheThread> threadMap = new HashMap<String, CacheThread>(); + + private static Set<InetAddress> addressCache; + + static class CacheThread extends Thread { + private Set<InetAddress> currentAddresses; + private Set<String> addressList; + private String host; + private Set<String> nonAddressList; + private Map<String, CacheThread> threadMap2; + + public CacheThread(String host, + Set<InetAddress> currentAddresses, + Set<String> addressList, + Set<String> nonAddressList, + Map<String, CacheThread> threadMap2) { + super("Caching localhost information"); + this.host = host; + this.currentAddresses = currentAddresses; + this.addressList = addressList; + this.nonAddressList = nonAddressList; + this.threadMap2 = threadMap2; + } + + public void run() { + if (currentAddresses != null) { + Iterator<InetAddress> iter2 = currentAddresses.iterator(); + while (iter2.hasNext()) { + InetAddress addr = iter2.next(); + String hostname = addr.getHostName(); + String hostname2 = addr.getCanonicalHostName(); + synchronized (lock) { + if (hostname != null && !addressList.contains(hostname)) + addressList.add(hostname); + if (hostname2 != null && !addressList.contains(hostname2)) + addressList.add(hostname2); + } + } + } + + try { + InetAddress[] addrs = InetAddress.getAllByName(host); + int length = addrs.length; + for (int j = 0; j < length; j++) { + InetAddress addr = addrs[0]; + String hostname = addr.getHostName(); + String hostname2 = addr.getCanonicalHostName(); + synchronized (lock) { + if (addr.isLoopbackAddress()) { + if (hostname != null && !addressList.contains(hostname)) + addressList.add(hostname); + if (hostname2 != null && !addressList.contains(hostname2)) + addressList.add(hostname2); + } else { + if (hostname != null && !nonAddressList.contains(hostname)) + nonAddressList.add(hostname); + if (hostname2 != null && !nonAddressList.contains(hostname2)) + nonAddressList.add(hostname2); + } + } + } + } catch (UnknownHostException e) { + synchronized (lock) { + if (host != null && !nonAddressList.contains(host)) + nonAddressList.add(host); + } + } + synchronized (lock) { + threadMap2.remove(host); + } + } + } + + public static boolean isLocalhost(final String host) { + if (host == null || host.equals("")) + return false; + + if ("localhost".equals(host) || "127.0.0.1".equals(host)) + return true; + + // check simple cases + try { + InetAddress localHostaddr = InetAddress.getLocalHost(); + if (localHostaddr.getHostName().equals(host) || host.equals(localHostaddr.getCanonicalHostName()) + || localHostaddr.getHostAddress().equals(host)) + return true; + } catch (Exception e) { + + } + + // check for current thread and wait if necessary + boolean currentThread = false; + try { + Thread t = null; + synchronized (lock) { + t = threadMap.get(host); + } + if (t != null && t.isAlive()) { + currentThread = true; + t.join(30); + } + } catch (Exception e) { + + } + + // check if cache is still ok + boolean refreshedCache = false; + try { + // get network interfaces + final Set<InetAddress> currentAddresses = new HashSet<InetAddress>(); + currentAddresses.add(InetAddress.getLocalHost()); + Enumeration<?> nis = NetworkInterface.getNetworkInterfaces(); + while (nis.hasMoreElements()) { + NetworkInterface inter = (NetworkInterface)nis.nextElement(); + Enumeration<InetAddress> ias = inter.getInetAddresses(); + while (ias.hasMoreElements()) + currentAddresses.add(ias.nextElement()); + } + + // check if cache is empty or old and refill it if necessary + if (addressCache == null || !addressCache.containsAll(currentAddresses) + || !currentAddresses.containsAll(addressCache)) { + CacheThread cacheThread = null; + refreshedCache = true; + + synchronized (lock) { + addressCache = currentAddresses; + notLocalHostCache = new HashSet<String>(); + localHostCache = new HashSet<String>(currentAddresses.size() * 3); + + Iterator<InetAddress> iter = currentAddresses.iterator(); + while (iter.hasNext()) { + InetAddress addr = iter.next(); + String a = addr.getHostAddress(); + if (a != null && !localHostCache.contains(a)) + localHostCache.add(a); + } + + cacheThread = new CacheThread(host, currentAddresses, localHostCache, notLocalHostCache, threadMap); + threadMap.put(host, cacheThread); + cacheThread.setDaemon(true); + cacheThread.setPriority(Thread.NORM_PRIORITY - 1); + cacheThread.start(); + } + cacheThread.join(200); + } + } catch (Exception e) { + } + + synchronized (lock) { + if (localHostCache.contains(host)) + return true; + if (notLocalHostCache.contains(host)) + return false; + } + + // if the cache hasn't been cleared, maybe we still need to lookup the + // host + if (!refreshedCache && !currentThread) { + try { + CacheThread cacheThread = null; + synchronized (lock) { + cacheThread = new CacheThread(host, null, localHostCache, notLocalHostCache, threadMap); + threadMap.put(host, cacheThread); + cacheThread.setDaemon(true); + cacheThread.setPriority(Thread.NORM_PRIORITY - 1); + cacheThread.start(); + } + cacheThread.join(75); + + synchronized (lock) { + if (localHostCache.contains(host)) + return true; + } + } catch (Exception e) { + } + } + return false; + } + +} diff --git a/sca-java-2.x/trunk/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint b/sca-java-2.x/trunk/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/sca-java-2.x/trunk/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/sca-java-2.x/trunk/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java b/sca-java-2.x/trunk/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java new file mode 100644 index 0000000000..4e076f9342 --- /dev/null +++ b/sca-java-2.x/trunk/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java @@ -0,0 +1,145 @@ +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + * Tests for host utils + */ +public class UtilsTestCase { + + private void assertDetailsAreOk(CorbanameURL details, String host, int port, String nameService, List<String> namePath) { + assertTrue(details.getHost().equals(host)); + assertTrue(details.getNameService().equals(nameService)); + assertTrue(details.getPort() == port); + assertTrue(details.getNamePath().size() == namePath.size()); + for (int i = 0; i < namePath.size(); i++) { + assertTrue(details.getNamePath().get(i).equals(namePath.get(i))); + } + } + + /** + * Tests if corbaname url is beeing processes properly + */ + @Test + public void test_validCorbaname() { + String testUri = null; + CorbanameURL details = null; + List<String> namePath = null; + + testUri = "corbaname:ignore:host:1234/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, "host", 1234, "Service", namePath); + + testUri = "corbaname:ignore:host:/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, "host", CorbanameURL.DEFAULT_PORT, "Service", namePath); + + testUri = "corbaname:ignore:host/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, "host", CorbanameURL.DEFAULT_PORT, "Service", namePath); + + testUri = "corbaname:ignore:/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath); + + testUri = "corbaname:ignore/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath); + + testUri = "corbaname:/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath); + + testUri = "corbaname/Service#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, "Service", namePath); + + testUri = "corbaname#Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Reference"); + assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, CorbanameURL.DEFAULT_NAME_SERVICE, namePath); + + testUri = "corbaname#Parent/Mid/Reference"; + details = CorbaHostUtils.getServiceDetails(testUri); + namePath = new ArrayList<String>(); + namePath.add("Parent"); + namePath.add("Mid"); + namePath.add("Reference"); + assertDetailsAreOk(details, CorbanameURL.DEFAULT_HOST, CorbanameURL.DEFAULT_PORT, CorbanameURL.DEFAULT_NAME_SERVICE, namePath); + } + + /** + * Test for invalid corbaname url + */ + @Test + public void test_invalidCorbaname() { + String testUri = null; + + try { + testUri = "this.string.should.not.appear.in.the.beggining:ignore:host:1234/Service#Reference"; + CorbaHostUtils.getServiceDetails(testUri); + fail(); + } catch (Exception e) { + assertTrue(e instanceof IllegalArgumentException); + } + + try { + testUri = "corbaname:ignore:host:1234/Service#"; + CorbaHostUtils.getServiceDetails(testUri); + fail(); + } catch (Exception e) { + assertTrue(e instanceof IllegalArgumentException); + } + } + + /** + * Test for creating corbaname url from host, port, name parameters + */ + @Test + public void test_creatingCorbanameURI() { + String uri = CorbaHostUtils.createCorbanameURI("SomeHost", 1000, "SomeName"); + assertEquals("corbaname::SomeHost:1000/NameService#SomeName", uri); + } +} |