001/* ValueHandler.java -- 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.io.Serializable; 042 043import org.omg.CORBA.CustomMarshal; 044import org.omg.CORBA.portable.InputStream; 045import org.omg.CORBA.portable.OutputStream; 046import org.omg.CORBA.portable.Streamable; 047import org.omg.SendingContext.RunTime; 048 049/** 050 * Serializes Java objects to and from CDR (GIOP) streams. The working instance 051 * of the value handler is returned by {@link Util#createValueHandler} and can 052 * be altered by setting the system property "javax.rmi.CORBA.ValueHandlerClass" 053 * to the name of the alternative class that must implement ValueHandler. 054 * 055 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 056 */ 057public interface ValueHandler 058{ 059 /** 060 * Get CORBA repository Id for the given java class. 061 * 062 * The syntax of the repository ID is the initial ?RMI:?, followed by the Java 063 * class name, followed by name, followed by a hash code string, followed 064 * optionally by a serialization version UID string. 065 * 066 * For Java identifiers that contain illegal OMG IDL identifier characters 067 * such as ?$?, any such illegal characters are replaced by ?\U? followed by 068 * the 4 hexadecimal characters (in upper case) representing the Unicode 069 * value. 070 * 071 * @param clz a class for that the repository Id is required. 072 * 073 * @return the class repository id. 074 */ 075 String getRMIRepositoryID(Class clz); 076 077 /** 078 * Returns the CodeBase for this ValueHandler. 079 * 080 * @return the codebase. 081 */ 082 RunTime getRunTimeCodeBase(); 083 084 /** 085 * Indicates that the given class is responsible itself for writing its 086 * content to the stream. Such classes implement either {@link Streamable} 087 * (default marshalling, generated by IDL-to-java compiler) or 088 * {@link CustomMarshal} (the user-programmed marshalling). 089 * 090 * @param clz the class being checked. 091 * @return true if the class supports custom or default marshalling, false 092 * otherwise. 093 */ 094 boolean isCustomMarshaled(Class clz); 095 096 /** 097 * Read value from the CORBA input stream in the case when the value is not 098 * Streamable or CustomMarshall'ed. The fields of the class being written will 099 * be accessed using reflection. 100 * 101 * @param in a CORBA stream to read. 102 * @param offset the current position in the input stream. 103 * @param clz the type of value being read. 104 * @param repositoryID the repository Id of the value being read. 105 * @param sender the sending context that should provide data about the 106 * message originator. 107 * 108 * @return the object, extracted from the stream. 109 */ 110 Serializable readValue(InputStream in, int offset, Class clz, 111 String repositoryID, RunTime sender); 112 113 /** 114 * When the value provides the writeReplace method, the result of this method 115 * is written. Otherwise, the value itself is written. 116 * 117 * @param value the value that should be written to the stream. 118 * 119 * @return the value that will be actually written to the stream. 120 */ 121 Serializable writeReplace(Serializable value); 122 123 /** 124 * Write value to CORBA output stream using java senmatics. 125 * 126 * @param out a stream to write into. 127 * @param value a java object to write. 128 */ 129 void writeValue(OutputStream out, Serializable value); 130}