tests/libjava-mauve/src/gnu/testlet/org/omg/PortableServer/POAOperations/communication/poa_Servant.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 // Uses: poa_comTesterPOA
       
     3 
       
     4 // Copyright (C) 2005 Audrius Meskauskas (AudriusA@Bioinformatics.org)
       
     5 
       
     6 // Mauve is free software; you can redistribute it and/or modify
       
     7 // it under the terms of the GNU General Public License as published by
       
     8 // the Free Software Foundation; either version 2, or (at your option)
       
     9 // any later version.
       
    10 
       
    11 // Mauve is distributed in the hope that it will be useful,
       
    12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    14 // GNU General Public License for more details.
       
    15 
       
    16 // You should have received a copy of the GNU General Public License
       
    17 // along with Mauve; see the file COPYING.  If not, write to
       
    18 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    19 // Boston, MA 02111-1307, USA.  */
       
    20 
       
    21 package gnu.testlet.org.omg.PortableServer.POAOperations.communication;
       
    22 
       
    23 import org.omg.CORBA.BAD_OPERATION;
       
    24 import org.omg.CORBA.CompletionStatus;
       
    25 
       
    26 /**
       
    27  * This class handles the actual server functionality in this test
       
    28  * application. When the client calls the remote method, this
       
    29  * finally results calling the method of this class.
       
    30  *
       
    31  * The parameters, passed to the server only, are just parameters of the
       
    32  * java methods. The parameters that shuld be returned to client
       
    33  * are wrapped into holder classes.
       
    34  *
       
    35  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
       
    36  */
       
    37 public class poa_Servant
       
    38   extends poa_comTesterPOA
       
    39 {
       
    40   /**
       
    41    * The field, that can be set and checked by remote client.
       
    42    */
       
    43   private int m_theField = 17;
       
    44 
       
    45   /**
       
    46    * Passes wide (UTF-16) string and narrow (ISO8859_1) string.
       
    47    * @see gnu.CORBA.GIOP.CharSets_OSF for supported and default
       
    48    * encodings. Returs they generalization as a wide string.
       
    49    */
       
    50   public String passCharacters(String wide, String narrow)
       
    51   {
       
    52     return "return '" + narrow + "' and '" + wide + "'";
       
    53   }
       
    54 
       
    55   /**
       
    56    * Just prints the hello message.
       
    57    */
       
    58   public String sayHello()
       
    59   {
       
    60     byte[] id = _get_delegate().object_id(this);
       
    61     StringBuffer b = new StringBuffer();
       
    62     for (int i = 0; i < id.length; i++)
       
    63       {
       
    64         b.append(Integer.toHexString(id [ i ]));
       
    65         b.append(' ');
       
    66       }
       
    67     return b + ":" + hashCode();
       
    68   }
       
    69 
       
    70   /**
       
    71    * Get the value of our field.
       
    72    */
       
    73   public int theField()
       
    74   {
       
    75     return m_theField;
       
    76   }
       
    77 
       
    78   /**
       
    79    * Set the value of our field.
       
    80    */
       
    81   public void theField(int a_field)
       
    82   {
       
    83     m_theField = a_field;
       
    84   }
       
    85 
       
    86   /**
       
    87    * Throw an exception.
       
    88    *
       
    89    * @param parameter specifies which exception will be thrown.
       
    90    *
       
    91    * @throws ourUserException for the non negative parameter.
       
    92    * @throws BAD_OPERATION for the negative parameter.
       
    93    */
       
    94   public void throwException(int parameter)
       
    95                       throws ourUserException
       
    96   {
       
    97     if (parameter > 0)
       
    98       {
       
    99         throw new ourUserException(parameter);
       
   100       }
       
   101     else
       
   102       {
       
   103         throw new BAD_OPERATION(456, CompletionStatus.COMPLETED_YES);
       
   104       }
       
   105   }
       
   106 }