001/* _PolicyStub.java -- 002 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 003 004This file is part of GNU Classpath. 005 006GNU Classpath is free software; you can redistribute it and/or modify 007it under the terms of the GNU General Public License as published by 008the Free Software Foundation; either version 2, or (at your option) 009any later version. 010 011GNU Classpath is distributed in the hope that it will be useful, but 012WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014General Public License for more details. 015 016You should have received a copy of the GNU General Public License 017along with GNU Classpath; see the file COPYING. If not, write to the 018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 01902110-1301 USA. 020 021Linking this library statically or dynamically with other modules is 022making a combined work based on this library. Thus, the terms and 023conditions of the GNU General Public License cover the whole 024combination. 025 026As a special exception, the copyright holders of this library give you 027permission to link this library with independent modules to produce an 028executable, regardless of the license terms of these independent 029modules, and to copy and distribute the resulting executable under 030terms of your choice, provided that you also meet, for each linked 031independent module, the terms and conditions of the license of that 032module. An independent module is a module which is not derived from 033or based on this library. If you modify this library, you may extend 034this exception to your version of the library, but you are not 035obligated to do so. If you do not wish to do so, delete this 036exception statement from your version. */ 037 038 039package org.omg.CORBA; 040 041import org.omg.CORBA.MARSHAL; 042import org.omg.CORBA.portable.ApplicationException; 043import org.omg.CORBA.portable.Delegate; 044import org.omg.CORBA.portable.InputStream; 045import org.omg.CORBA.portable.ObjectImpl; 046import org.omg.CORBA.portable.OutputStream; 047import org.omg.CORBA.portable.RemarshalException; 048 049import java.io.Serializable; 050 051/** 052 * The Policy stub (proxy), used on the client side. 053 * The {@link Policy} methods contain the code for remote 054 * invocaton. 055 * 056 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 057 */ 058public class _PolicyStub 059 extends ObjectImpl 060 implements Policy, Serializable 061{ 062 /** 063 * Use serialVersionUID (v1.4) for interoperability. 064 */ 065 private static final long serialVersionUID = 2453656196708903849L; 066 067 /** 068 * Create the Policy stub. To get the stub working, 069 * you must later set the delegate with 070 * {@link ObjectImpl#_set_delegate(Delegate)}. 071 */ 072 public _PolicyStub() 073 { 074 } 075 076 /** 077 * Create the naming context stub with the given delegate. 078 */ 079 public _PolicyStub(Delegate delegate) 080 { 081 _set_delegate(delegate); 082 } 083 084 /** 085 * Return the array of repository ids for this object. 086 */ 087 public String[] _ids() 088 { 089 return new String[] { PolicyHelper.id() }; 090 } 091 092 /** {@inheritDoc} */ 093 public void destroy() 094 { 095 InputStream input = null; 096 try 097 { 098 OutputStream output = _request("destroy", true); 099 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}