diff options
Diffstat (limited to '')
57 files changed, 0 insertions, 5987 deletions
diff --git a/branches/sca-java-1.5/modules/host-corba-jee/LICENSE b/branches/sca-java-1.5/modules/host-corba-jee/LICENSE deleted file mode 100644 index 6e529a25c4..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ -
- 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/branches/sca-java-1.5/modules/host-corba-jee/NOTICE b/branches/sca-java-1.5/modules/host-corba-jee/NOTICE deleted file mode 100644 index 1325efd8bf..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name}
-Copyright (c) 2005 - 2008 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/branches/sca-java-1.5/modules/host-corba-jee/pom.xml b/branches/sca-java-1.5/modules/host-corba-jee/pom.xml deleted file mode 100644 index 41bc9fdec5..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>1.5-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>1.5-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-corba-jse</artifactId> - <version>1.5-SNAPSHOT</version> - <scope>test</scope> - </dependency> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.host.corba.jdk</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.host.corba.jdk*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/branches/sca-java-1.5/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/CorbaRuntimeModuleActivator.java b/branches/sca-java-1.5/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/CorbaRuntimeModuleActivator.java deleted file mode 100644 index b5fe9f5d0f..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/CorbaRuntimeModuleActivator.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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 org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaRuntimeModuleActivator implements ModuleActivator { - - private JEECorbaHost server; - - public void start(ExtensionPointRegistry extensionPointRegistry) { - - // Register our Corba host - CorbaHostExtensionPoint corbaHosts = extensionPointRegistry.getExtensionPoint(CorbaHostExtensionPoint.class); - - server = new JEECorbaHost(); - try { - server.start(); - corbaHosts.addCorbaHost(server); - } catch (Exception e) { - - } - } - - public void stop(ExtensionPointRegistry registry) { - if (server != null) { - server.stop(); - } - } - -} diff --git a/branches/sca-java-1.5/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java b/branches/sca-java-1.5/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java deleted file mode 100644 index 7e714c1ca5..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/main/java/org/apache/tuscany/sca/host/corba/jee/JEECorbaHost.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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.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$ - * Implementation of JEE CORBA host - */ -public class JEECorbaHost implements CorbaHost { - - 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() throws CorbaHostException { - Context ctx; - try { - ctx = new InitialContext(); - orb = (ORB)PortableRemoteObject.narrow(ctx.lookup(ORB_NAME), org.omg.CORBA.ORB.class); - } catch (Exception e) { - throw new CorbaHostException(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/branches/sca-java-1.5/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/branches/sca-java-1.5/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator deleted file mode 100644 index 3762550c01..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT 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.jee.CorbaRuntimeModuleActivator
diff --git a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java deleted file mode 100644 index fd952a02c7..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/JEECorbaHostTestCase.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java deleted file mode 100644 index a0b9b7c514..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestContext.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java deleted file mode 100644 index f480235fa8..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/TestInitialContextFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java deleted file mode 100644 index f9f3d4789e..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java deleted file mode 100644 index 9ed4c81248..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHelper.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java deleted file mode 100644 index 357c1eddb0..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceHolder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java deleted file mode 100644 index c2d4877791..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/TestInterfaceOperations.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java deleted file mode 100644 index 9846748775..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceImplBase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java deleted file mode 100644 index cd722214ed..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/general/_TestInterfaceStub.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java b/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java deleted file mode 100644 index 6195f3af9c..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/java/org/apache/tuscany/sca/host/corba/jee/testing/servants/TestInterfaceServant.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jee/src/test/resources/general.idl b/branches/sca-java-1.5/modules/host-corba-jee/src/test/resources/general.idl deleted file mode 100644 index 9194a37334..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jee/src/test/resources/general.idl +++ /dev/null @@ -1,45 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba-jse-tns/LICENSE b/branches/sca-java-1.5/modules/host-corba-jse-tns/LICENSE deleted file mode 100644 index 6e529a25c4..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ -
- 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/branches/sca-java-1.5/modules/host-corba-jse-tns/NOTICE b/branches/sca-java-1.5/modules/host-corba-jse-tns/NOTICE deleted file mode 100644 index 1325efd8bf..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name}
-Copyright (c) 2005 - 2008 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/branches/sca-java-1.5/modules/host-corba-jse-tns/pom.xml b/branches/sca-java-1.5/modules/host-corba-jse-tns/pom.xml deleted file mode 100644 index febb7461e9..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>1.5-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>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-corba-jse</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-binding-corba-runtime</artifactId> - <version>1.5-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.host.corba.jse.tns</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.host.corba.jse.tns*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/CorbaRuntimeModuleActivator.java b/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/CorbaRuntimeModuleActivator.java deleted file mode 100644 index 312d739c53..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/CorbaRuntimeModuleActivator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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 org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint; -import org.apache.tuscany.sca.host.corba.jse.DefaultCorbaHost; - -/** - * @version $Rev: 683329 $ $Date: 2008-08-06 19:06:39 +0200 (śro, 06 sie 2008) $ - */ -public class CorbaRuntimeModuleActivator implements ModuleActivator { - // private static final Logger logger = - // Logger.getLogger(CorbaRuntimeModuleActivator.class.getName()); - - private TnsDefaultCorbaHost server; - - public void start(ExtensionPointRegistry extensionPointRegistry) { - // Register our Corba host - CorbaHostExtensionPoint corbaHosts = extensionPointRegistry.getExtensionPoint(CorbaHostExtensionPoint.class); - server = new TnsDefaultCorbaHost(); - if (corbaHosts.getCorbaHosts().size() > 0 && corbaHosts.getCorbaHosts().get(0) instanceof DefaultCorbaHost) { - // Set TnsDefaultCorbaHost as default when DefaultCorbaHost was registered before - corbaHosts.getCorbaHosts().add(0, server); - } else { - corbaHosts.getCorbaHosts().add(server); - } - } - - public void stop(ExtensionPointRegistry registry) { - if (server != null) { - server.stop(); - } - } - -} diff --git a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java b/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java deleted file mode 100644 index 2dc2c7ddd4..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/java/org/apache/tuscany/sca/host/corba/jse/tns/TnsDefaultCorbaHost.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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.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 { - - 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(); - } - } - -} diff --git a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator deleted file mode 100644 index 906ec4efce..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT 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.jse.tns.CorbaRuntimeModuleActivator
diff --git a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java b/branches/sca-java-1.5/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java deleted file mode 100644 index 9f6be0f27d..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse-tns/src/test/java/org/apache/tuscany/sca/host/corba/testing/TnsDefaultCorbaHostTestCase.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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.impl.service.DynaCorbaServant; -import org.apache.tuscany.sca.host.corba.jse.tns.TnsDefaultCorbaHost; -import org.junit.AfterClass; -import org.junit.BeforeClass; -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 - 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/branches/sca-java-1.5/modules/host-corba-jse/LICENSE b/branches/sca-java-1.5/modules/host-corba-jse/LICENSE deleted file mode 100644 index 6e529a25c4..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ -
- 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/branches/sca-java-1.5/modules/host-corba-jse/NOTICE b/branches/sca-java-1.5/modules/host-corba-jse/NOTICE deleted file mode 100644 index 1325efd8bf..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name}
-Copyright (c) 2005 - 2008 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/branches/sca-java-1.5/modules/host-corba-jse/pom.xml b/branches/sca-java-1.5/modules/host-corba-jse/pom.xml deleted file mode 100644 index aa6499e4a5..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>1.5-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>1.5-SNAPSHOT</version> - </dependency> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.host.corba.jse</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.host.corba.jse*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/CorbaRuntimeModuleActivator.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/CorbaRuntimeModuleActivator.java deleted file mode 100644 index 252a1512e4..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/CorbaRuntimeModuleActivator.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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 org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint; - -/** - * @version $Rev$ $Date$ - */ -public class CorbaRuntimeModuleActivator implements ModuleActivator { - // private static final Logger logger = - // Logger.getLogger(CorbaRuntimeModuleActivator.class.getName()); - - private DefaultCorbaHost server; - - public void start(ExtensionPointRegistry extensionPointRegistry) { - - // Register our Corba host - CorbaHostExtensionPoint corbaHosts = extensionPointRegistry.getExtensionPoint(CorbaHostExtensionPoint.class); - server = new DefaultCorbaHost(); - corbaHosts.addCorbaHost(server); - } - - public void stop(ExtensionPointRegistry registry) { - if (server != null) { - server.stop(); - } - } - -} diff --git a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java deleted file mode 100644 index 015644e19d..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/jse/DefaultCorbaHost.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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.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 { - 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 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/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java deleted file mode 100644 index 59f0ce9a53..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/NamingContextBase.java +++ /dev/null @@ -1,863 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java deleted file mode 100644 index 599f5bca54..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameServer.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 (started == Boolean.TRUE) { - service.destroy(); - } - } - - /** - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java deleted file mode 100644 index 77617a6c5c..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNameService.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java deleted file mode 100644 index a7164e9ef3..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientNamingContext.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java b/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java deleted file mode 100644 index 444143f173..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/java/org/apache/tuscany/sca/host/corba/naming/TransientServiceException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/branches/sca-java-1.5/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator deleted file mode 100644 index a96baed33e..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT 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.jse.CorbaRuntimeModuleActivator
\ No newline at end of file diff --git a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java deleted file mode 100644 index 8084e39956..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/DefaultCorbaHostTestCase.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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 java.net.SocketException; - -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(); - } - } - - /** - * - */ - @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) { - } - new Socket(LOCALHOST, innerORBPort); - fail(); - } catch (Exception e) { - if (e instanceof ConnectException) { - assertTrue(true); - } else { - e.printStackTrace(); - } - } - } - -} diff --git a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java deleted file mode 100644 index 8d1a9db9e9..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java deleted file mode 100644 index fe85dc7743..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHelper.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java deleted file mode 100644 index 305a4d7b97..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceHolder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java deleted file mode 100644 index f557d3e020..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/TestInterfaceOperations.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java deleted file mode 100644 index f993066dab..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceImplBase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java deleted file mode 100644 index 30a77deaf5..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/general/_TestInterfaceStub.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java b/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java deleted file mode 100644 index 0ebde8ef0d..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/java/org/apache/tuscany/sca/host/corba/testing/servants/TestInterfaceServant.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba-jse/src/test/resources/general.idl b/branches/sca-java-1.5/modules/host-corba-jse/src/test/resources/general.idl deleted file mode 100644 index f67566deb8..0000000000 --- a/branches/sca-java-1.5/modules/host-corba-jse/src/test/resources/general.idl +++ /dev/null @@ -1,43 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba/LICENSE b/branches/sca-java-1.5/modules/host-corba/LICENSE deleted file mode 100644 index 6e529a25c4..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ -
- 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/branches/sca-java-1.5/modules/host-corba/NOTICE b/branches/sca-java-1.5/modules/host-corba/NOTICE deleted file mode 100644 index 1325efd8bf..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name}
-Copyright (c) 2005 - 2008 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (http://www.apache.org/).
-
diff --git a/branches/sca-java-1.5/modules/host-corba/pom.xml b/branches/sca-java-1.5/modules/host-corba/pom.xml deleted file mode 100644 index c3ca59e41c..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>1.5-SNAPSHOT</version> - </parent> - <artifactId>tuscany-host-corba</artifactId> - <name>Apache Tuscany SCA CORBA Host Extension Point</name> - - <dependencies> - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core-spi</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.host.corba</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.host.corba*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java deleted file mode 100644 index eb49f3f841..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHost.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java deleted file mode 100644 index 049bfdb6cd..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostException.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java deleted file mode 100644 index 067b9193c5..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostExtensionPoint.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java deleted file mode 100644 index b90fe9c78b..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbaHostUtils.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java deleted file mode 100644 index a380fd6d79..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/CorbanameURL.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java deleted file mode 100644 index 438734086d..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/DefaultCorbaHostExtensionPoint.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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; - -/** - * @version $Rev$ $Date$ - * Default implementation of CorbaHostExtensionPoint - */ -public class DefaultCorbaHostExtensionPoint implements CorbaHostExtensionPoint { - - private List<CorbaHost> corbaHosts = new ArrayList<CorbaHost>(); - - public DefaultCorbaHostExtensionPoint() { - } - - public void addCorbaHost(CorbaHost host) { - corbaHosts.add(host); - } - - public void removeCorbaHost(CorbaHost host) { - corbaHosts.remove(host); - } - - public List<CorbaHost> getCorbaHosts() { - return corbaHosts; - } - -} diff --git a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java deleted file mode 100644 index 7e043667a9..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/ExtensibleCorbaHost.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java b/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java deleted file mode 100755 index 6989b3ad06..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/java/org/apache/tuscany/sca/host/corba/SocketUtil.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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/branches/sca-java-1.5/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint b/branches/sca-java-1.5/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint deleted file mode 100644 index a72bed4ea8..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT 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/branches/sca-java-1.5/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java b/branches/sca-java-1.5/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java deleted file mode 100644 index 4e076f9342..0000000000 --- a/branches/sca-java-1.5/modules/host-corba/src/test/java/org/apache/tuscany/sca/host/corba/UtilsTestCase.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * 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); - } -} |