001/* PortableRemoteObjectDelegate.java -- Interface supporting PortableRemoteObject 002 Copyright (C) 2002, 2004, 2005 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 javax.rmi.CORBA; 040 041import java.rmi.NoSuchObjectException; 042import java.rmi.Remote; 043import java.rmi.RemoteException; 044 045/** 046 * A delegate, implementing the functionality, provided by the 047 * {@link PortableRemoteObject}. 048 * 049 * The default delegate can be altered by setting the system property 050 * "javax.rmi.CORBA.PortableRemoteObjectClass" to the name of the alternative 051 * class that must implement {@link PortableRemoteObjectDelegate}. 052 * 053 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 054 */ 055public interface PortableRemoteObjectDelegate 056{ 057 /** 058 * <p> 059 * Makes the remote object <code>target</code> ready for remote 060 * communication using the same communications runtime as for the passed 061 * <code>source</code> parameter. Connection normally happens implicitly 062 * when the object is sent or received as an argument on a remote method call. 063 * </p> 064 * <p> 065 * The target object is connected to the same ORB as source by calling the 066 * {@link Stub#connect} if it is a stub or by associating its tie with an ORB 067 * if it is an implementation object. 068 * </p> 069 * 070 * @param target the target object that may be either an RMI/IDL stub or an 071 * exported RMI/IDL implementation object 072 * @param source the source object may also be either an RMI/IDL stub or an 073 * exported RMI/IDL implementation object. 074 * 075 * @throws RemoteException if the target is already connected to another ORB. 076 */ 077 void connect(Remote target, Remote source) 078 throws RemoteException; 079 080 /** 081 * Register the passed object with the ORB runtimes, making it remotely 082 * accessible. When called on jre with no objects exported, creates a 083 * non-daemon thread that prevents jre from terminating until all objects are 084 * unexported. Also, such object cannot be collected by garbage collector. 085 * This is usually impemented via {@link Util#unexportObject} 086 * 087 * @param obj the object to export. 088 * 089 * @throws RemoteException 090 */ 091 void exportObject(Remote obj) 092 throws RemoteException; 093 094 /** 095 * Narrows the passed object to conform to the given interface or IDL type. 096 * This method may return different instance and cannot be replaced by the 097 * direct cast. 098 * 099 * @param narrowFrom an object to narrow. 100 * @param narrowTo a type to that the object must be narrowed. 101 * 102 * @return On success, an object of type narrowTo or null, if narrowFrom = 103 * null. 104 * 105 * @throws ClassCastException if no narrowing is possible. 106 */ 107 Object narrow(Object narrowFrom, Class narrowTo) 108 throws ClassCastException; 109 110 /** 111 * Takes a server implementation object and returns a stub object that can be 112 * used to access that server object (target). If the target is connected, the 113 * returned stub is also connected to the same ORB. If the target is 114 * unconnected, the returned stub is unconnected. 115 * 116 * @param obj a server side object. 117 * @return a stub object that can be used to access that server object. 118 * 119 * @throws NoSuchObjectException if a stub cannot be located for the given 120 * target. 121 */ 122 Remote toStub(Remote obj) 123 throws NoSuchObjectException; 124 125 /** 126 * Deregister a currently exported server object from the ORB runtimes. The 127 * object to becomes available for garbage collection. This is usually 128 * impemented via {@link Util#unexportObject} 129 * 130 * @param obj the object to unexport. 131 * 132 * @throws NoSuchObjectException if the passed object is not currently 133 * exported. 134 */ 135 void unexportObject(Remote obj) 136 throws NoSuchObjectException; 137}