001/** 002 * GRANITE DATA SERVICES 003 * Copyright (C) 2006-2013 GRANITE DATA SERVICES S.A.S. 004 * 005 * This file is part of the Granite Data Services Platform. 006 * 007 * Granite Data Services is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * Granite Data Services is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 015 * General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this library; if not, write to the Free Software 019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 020 * USA, or see <http://www.gnu.org/licenses/>. 021 */ 022package org.granite.messaging.jmf; 023 024import java.io.IOException; 025import java.io.InvalidObjectException; 026import java.io.NotActiveException; 027import java.io.ObjectInputStream; 028import java.io.ObjectInputValidation; 029import java.lang.reflect.InvocationTargetException; 030 031import org.granite.messaging.reflect.ClassDescriptor; 032import org.granite.messaging.reflect.Property; 033 034@SuppressWarnings("deprecation") 035/** 036 * @author Franck WOLFF 037 */ 038public class JMFObjectInputStream extends ObjectInputStream { 039 040 private final InputContext in; 041 private final ClassDescriptor desc; 042 private final Object v; 043 044 public JMFObjectInputStream(InputContext in, ClassDescriptor desc, Object v) throws IOException { 045 super(); 046 047 this.in = in; 048 this.desc = desc; 049 this.v = v; 050 } 051 052 @Override 053 protected Object readObjectOverride() throws ClassNotFoundException, IOException { 054 return in.readObject(); 055 } 056 057 @Override 058 public void defaultReadObject() throws IOException, ClassNotFoundException { 059 for (Property property : desc.getSerializableProperties()) { 060 try { 061 in.readAndSetProperty(v, property); 062 } 063 catch (IllegalAccessException e) { 064 throw new IOException(e); 065 } 066 catch (InvocationTargetException e) { 067 throw new IOException(e); 068 } 069 } 070 } 071 072 @Override 073 public Object readUnshared() throws IOException, ClassNotFoundException { 074 throw new UnsupportedOperationException(); 075 } 076 077 @Override 078 public GetField readFields() throws IOException, ClassNotFoundException { 079 throw new UnsupportedOperationException(); 080 } 081 082 @Override 083 public void registerValidation(ObjectInputValidation obj, int prio) 084 throws NotActiveException, InvalidObjectException { 085 throw new UnsupportedOperationException(); 086 } 087 088 @Override 089 public int read() throws IOException { 090 return in.read(); 091 } 092 093 @Override 094 public int read(byte[] buf, int off, int len) throws IOException { 095 return in.read(buf, off, len); 096 } 097 098 @Override 099 public int available() throws IOException { 100 return in.available(); 101 } 102 103 @Override 104 public void close() throws IOException { 105 in.close(); 106 } 107 108 @Override 109 public boolean readBoolean() throws IOException { 110 return in.readBoolean(); 111 } 112 113 @Override 114 public byte readByte() throws IOException { 115 return in.readByte(); 116 } 117 118 @Override 119 public int readUnsignedByte() throws IOException { 120 return in.readUnsignedByte(); 121 } 122 123 @Override 124 public char readChar() throws IOException { 125 return in.readChar(); 126 } 127 128 @Override 129 public short readShort() throws IOException { 130 return in.readShort(); 131 } 132 133 @Override 134 public int readUnsignedShort() throws IOException { 135 return in.readUnsignedShort(); 136 } 137 138 @Override 139 public int readInt() throws IOException { 140 return in.readInt(); 141 } 142 143 @Override 144 public long readLong() throws IOException { 145 return in.readLong(); 146 } 147 148 @Override 149 public float readFloat() throws IOException { 150 return in.readFloat(); 151 } 152 153 @Override 154 public double readDouble() throws IOException { 155 return in.readDouble(); 156 } 157 158 @Override 159 public void readFully(byte[] buf) throws IOException { 160 in.readFully(buf); 161 } 162 163 @Override 164 public void readFully(byte[] buf, int off, int len) throws IOException { 165 in.readFully(buf, off, len); 166 } 167 168 @Override 169 public int skipBytes(int len) throws IOException { 170 return in.skipBytes(len); 171 } 172 173 @Override 174 public String readLine() throws IOException { 175 return in.readLine(); 176 } 177 178 @Override 179 public String readUTF() throws IOException { 180 return in.readUTF(); 181 } 182 183 @Override 184 public int read(byte[] b) throws IOException { 185 return in.read(b); 186 } 187 188 @Override 189 public long skip(long n) throws IOException { 190 return in.skip(n); 191 } 192 193 @Override 194 public synchronized void mark(int readlimit) { 195 throw new UnsupportedOperationException(); 196 } 197 198 @Override 199 public synchronized void reset() throws IOException { 200 throw new UnsupportedOperationException(); 201 } 202 203 @Override 204 public boolean markSupported() { 205 return false; 206 } 207}