tests/libjava-mauve/src/gnu/testlet/org/omg/PortableServer/POA/TestLocationForwardServerHelper.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: not-a-test
       
     2 // Copyright (c) Object Oriented Concepts, Inc. Billerica, MA, USA
       
     3 
       
     4 // Adapted for Mauve by Audrius Meskauskas <audriusa@bluewin.ch>
       
     5 
       
     6 // This file is part of Mauve.
       
     7 
       
     8 // Mauve is free software; you can redistribute it and/or modify
       
     9 // it under the terms of the GNU General Public License as published by
       
    10 // the Free Software Foundation; either version 2, or (at your option)
       
    11 // any later version.
       
    12 
       
    13 // Mauve is distributed in the hope that it will be useful,
       
    14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16 // GNU General Public License for more details.
       
    17 
       
    18 // You should have received a copy of the GNU General Public License
       
    19 // along with Mauve; see the file COPYING.  If not, write to
       
    20 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    21 // Boston, MA 02111-1307, USA.
       
    22 
       
    23 /*
       
    24 This code originally came from the OMG's CORBA Open Source Testing project,
       
    25 which lived at cost.omg.org. That site no longer exists.
       
    26 
       
    27 All the contributing companies agreed to release their tests under the
       
    28 terms of the GNU Lesser General Public License, available in the file
       
    29 COPYING.LIB.
       
    30 
       
    31 The code has been modified integrating into Mauve test environment and
       
    32 removing tests that are not yet supported by Suns jre 1.4. Hence the license
       
    33 is now GPL.
       
    34 
       
    35 We downloaded the code from http://sourceforge.net/projects/corba-cost/,
       
    36 administrated by Duncan Grisby.
       
    37 */
       
    38 
       
    39 package gnu.testlet.org.omg.PortableServer.POA;
       
    40 
       
    41 import org.omg.CORBA.Any;
       
    42 import org.omg.CORBA.BAD_PARAM;
       
    43 import org.omg.CORBA.ORB;
       
    44 import org.omg.CORBA.TypeCode;
       
    45 import org.omg.CORBA.portable.Delegate;
       
    46 import org.omg.CORBA.portable.InputStream;
       
    47 import org.omg.CORBA.portable.ObjectImpl;
       
    48 import org.omg.CORBA.portable.OutputStream;
       
    49 
       
    50 public abstract class TestLocationForwardServerHelper
       
    51 {
       
    52   private static String _id = "IDL:test/poa/TestLocationForwardServer:1.0";
       
    53 
       
    54   public static void insert(Any a, TestLocationForwardServer that)
       
    55   {
       
    56     OutputStream out = a.create_output_stream();
       
    57     a.type(type());
       
    58     write(out, that);
       
    59     a.read_value(out.create_input_stream(), type());
       
    60   }
       
    61 
       
    62   public static TestLocationForwardServer extract(Any a)
       
    63   {
       
    64     return read(a.create_input_stream());
       
    65   }
       
    66 
       
    67   public static TypeCode type()
       
    68   {
       
    69     return ORB.init().create_interface_tc(TestLocationForwardServerHelper.id(),
       
    70                                           "TestLocationForwardServer"
       
    71                                          );
       
    72   }
       
    73 
       
    74   public static String id()
       
    75   {
       
    76     return _id;
       
    77   }
       
    78 
       
    79   public static TestLocationForwardServer read(InputStream istream)
       
    80   {
       
    81     return narrow(istream.read_Object(_TestLocationForwardServerStub.class));
       
    82   }
       
    83 
       
    84   public static void write(OutputStream ostream, TestLocationForwardServer value)
       
    85   {
       
    86     ostream.write_Object((org.omg.CORBA.Object) value);
       
    87   }
       
    88 
       
    89   public static TestLocationForwardServer narrow(org.omg.CORBA.Object obj)
       
    90   {
       
    91     if (obj == null)
       
    92       return null;
       
    93     else if (obj instanceof TestLocationForwardServer)
       
    94       return (TestLocationForwardServer) obj;
       
    95     else if (!obj._is_a(id()))
       
    96       throw new BAD_PARAM();
       
    97     else
       
    98       {
       
    99         Delegate delegate = ((ObjectImpl) obj)._get_delegate();
       
   100         _TestLocationForwardServerStub stub =
       
   101           new _TestLocationForwardServerStub();
       
   102         stub._set_delegate(delegate);
       
   103         return stub;
       
   104       }
       
   105   }
       
   106 }