1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package net.jini.io; 20 21 import java.util.Collection; 22 23 /** 24 * Provides a collection of context information objects that are 25 * associated with an {@link java.io.ObjectOutputStream} or {@link 26 * java.io.ObjectInputStream} instance that implements this interface. 27 * 28 * <p>The class of an object that is being serialized or deserialized 29 * can test (in its private 30 * <code>writeObject(ObjectOutputStream)</code> or 31 * <code>readObject(ObjectInputStream)</code> method) if the object 32 * stream being used implements this interface. If the stream does 33 * implement this interface, the class can then retrieve context 34 * information relevant to the overall serialization or 35 * deserialization operation by invoking the {@link 36 * #getObjectStreamContext getObjectStreamContext} method and 37 * inspecting the elements of the returned collection. 38 * 39 * <p>The contents of the collection are determined by the 40 * implementation of the object stream. The context information 41 * available from a given element of the collection is determined by 42 * that element's type. 43 * 44 * Examples of types that a context object might implement include 45 * {@link net.jini.io.context.ClientHost} and 46 * {@link net.jini.io.context.ClientSubject}. 47 * 48 * @author Sun Microsystems, Inc. 49 * @since 2.0 50 */ 51 public interface ObjectStreamContext { 52 53 /** 54 * Returns this object stream's collection of context information 55 * objects. 56 * 57 * <p>The context information available from a given element of 58 * the collection is determined by that element's type. The order 59 * of the elements is insignificant. The collection may be empty. 60 * 61 * <p>The caller of this method cannot assume that the returned 62 * collection is modifiable. 63 * 64 * @return a collection of this stream's context objects 65 */ 66 Collection getObjectStreamContext(); 67 }