Source for org.omg.CORBA._PolicyStub

   1: /* _PolicyStub.java --
   2:    Copyright (C) 2005, 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath 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: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package org.omg.CORBA;
  40: 
  41: import org.omg.CORBA.MARSHAL;
  42: import org.omg.CORBA.portable.ApplicationException;
  43: import org.omg.CORBA.portable.Delegate;
  44: import org.omg.CORBA.portable.InputStream;
  45: import org.omg.CORBA.portable.ObjectImpl;
  46: import org.omg.CORBA.portable.OutputStream;
  47: import org.omg.CORBA.portable.RemarshalException;
  48: 
  49: import java.io.Serializable;
  50: 
  51: /**
  52:  * The Policy stub (proxy), used on the client side.
  53:  * The {@link Policy} methods contain the code for remote
  54:  * invocaton.
  55:  *
  56:  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  57:  */
  58: public class _PolicyStub
  59:   extends ObjectImpl
  60:   implements Policy, Serializable
  61: {
  62:   /**
  63:    * Use serialVersionUID (v1.4) for interoperability.
  64:    */
  65:   private static final long serialVersionUID = 2453656196708903849L;
  66: 
  67:   /**
  68:    * Create the Policy stub. To get the stub working,
  69:    * you must later set the delegate with
  70:    * {@link ObjectImpl#_set_delegate(Delegate)}.
  71:    */
  72:   public _PolicyStub()
  73:   {
  74:   }
  75: 
  76:   /**
  77:    * Create the naming context stub with the given delegate.
  78:    */
  79:   public _PolicyStub(Delegate delegate)
  80:   {
  81:     _set_delegate(delegate);
  82:   }
  83: 
  84:   /**
  85:    * Return the array of repository ids for this object.
  86:    */
  87:   public String[] _ids()
  88:   {
  89:     return new String[] { PolicyHelper.id() };
  90:   }
  91: 
  92:   /** {@inheritDoc} */
  93:   public void destroy()
  94:   {
  95:     InputStream input = null;
  96:     try
  97:       {
  98:         OutputStream output = _request("destroy", true);
  99:         input = _invoke(output);
 100:       }
 101:     catch (ApplicationException ex)
 102:       {
 103:         input = ex.getInputStream();
 104: 
 105:         String id = ex.getId();
 106:         throw new MARSHAL(id);
 107:       }
 108:     catch (RemarshalException remarsh)
 109:       {
 110:         destroy();
 111:       }
 112:     finally
 113:       {
 114:         _releaseReply(input);
 115:       }
 116:   }
 117: 
 118:   /** {@inheritDoc} */
 119:   public Policy copy()
 120:   {
 121:     InputStream input = null;
 122:     try
 123:       {
 124:         OutputStream output = _request("copy", true);
 125:         input = _invoke(output);
 126:         return PolicyHelper.read(input);
 127:       }
 128:     catch (ApplicationException ex)
 129:       {
 130:         input = ex.getInputStream();
 131: 
 132:         String id = ex.getId();
 133:         throw new MARSHAL(id);
 134:       }
 135:     catch (RemarshalException remarsh)
 136:       {
 137:         return copy();
 138:       }
 139:     finally
 140:       {
 141:         _releaseReply(input);
 142:       }
 143:   }
 144: 
 145:   /** {@inheritDoc} */
 146:   public int policy_type()
 147:   {
 148:     InputStream input = null;
 149:     try
 150:       {
 151:         OutputStream output = _request("policy_type", true);
 152:         input = _invoke(output);
 153: 
 154:         int returns = input.read_long();
 155: 
 156:         return returns;
 157:       }
 158:     catch (ApplicationException ex)
 159:       {
 160:         input = ex.getInputStream();
 161: 
 162:         String id = ex.getId();
 163:         throw new MARSHAL(id);
 164:       }
 165:     catch (RemarshalException remarsh)
 166:       {
 167:         return policy_type();
 168:       }
 169:     finally
 170:       {
 171:         _releaseReply(input);
 172:       }
 173:   }
 174: }