List of usage examples for java.io ObjectInput readObject
public Object readObject() throws ClassNotFoundException, IOException;
From source file:org.apache.openjpa.persistence.EntityManagerImpl.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { try {/*from ww w. ja v a 2s . c o m*/ _ret = PersistenceExceptions.getRollbackTranslator(this); // this assumes that serialized Brokers are from something // that extends AbstractBrokerFactory. Object factoryKey = in.readObject(); AbstractBrokerFactory factory = AbstractBrokerFactory.getPooledFactoryForKey(factoryKey); byte[] brokerBytes = (byte[]) in.readObject(); ObjectInputStream innerIn = new BrokerBytesInputStream(brokerBytes, factory.getConfiguration()); Broker broker = (Broker) innerIn.readObject(); EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) JPAFacadeHelper .toEntityManagerFactory(broker.getBrokerFactory()); broker.putUserObject(JPAFacadeHelper.EM_KEY, this); initialize(emf, broker); } catch (RuntimeException re) { try { re = _ret.translate(re); } catch (Exception e) { // ignore } throw re; } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
public static Object basicReadObject(final DataInput in) throws IOException, ClassNotFoundException { checkIn(in);//from ww w . j a v a 2s. co m // Read the header byte byte header = in.readByte(); if (logger.isTraceEnabled(LogMarker.SERIALIZER)) { logger.trace(LogMarker.SERIALIZER, "basicReadObject: header={}", header); } switch (header) { case DS_FIXED_ID_BYTE: return DSFIDFactory.create(in.readByte(), in); case DS_FIXED_ID_SHORT: return DSFIDFactory.create(in.readShort(), in); case DS_FIXED_ID_INT: return DSFIDFactory.create(in.readInt(), in); case DS_NO_FIXED_ID: return readDataSerializableFixedID(in); case NULL: return null; case NULL_STRING: case STRING: case HUGE_STRING: case STRING_BYTES: case HUGE_STRING_BYTES: return readString(in, header); case CLASS: return readClass(in); case DATE: return readDate(in); case FILE: return readFile(in); case INET_ADDRESS: return readInetAddress(in); case BOOLEAN: return readBoolean(in); case CHARACTER: return readCharacter(in); case BYTE: return readByte(in); case SHORT: return readShort(in); case INTEGER: return readInteger(in); case LONG: return readLong(in); case FLOAT: return readFloat(in); case DOUBLE: return readDouble(in); case BYTE_ARRAY: return readByteArray(in); case ARRAY_OF_BYTE_ARRAYS: return readArrayOfByteArrays(in); case SHORT_ARRAY: return readShortArray(in); case STRING_ARRAY: return readStringArray(in); case INT_ARRAY: return readIntArray(in); case LONG_ARRAY: return readLongArray(in); case FLOAT_ARRAY: return readFloatArray(in); case DOUBLE_ARRAY: return readDoubleArray(in); case BOOLEAN_ARRAY: return readBooleanArray(in); case CHAR_ARRAY: return readCharArray(in); case OBJECT_ARRAY: return readObjectArray(in); case ARRAY_LIST: return readArrayList(in); case LINKED_LIST: return readLinkedList(in); case HASH_SET: return readHashSet(in); case LINKED_HASH_SET: return readLinkedHashSet(in); case HASH_MAP: return readHashMap(in); case IDENTITY_HASH_MAP: return readIdentityHashMap(in); case HASH_TABLE: return readHashtable(in); case CONCURRENT_HASH_MAP: return readConcurrentHashMap(in); case PROPERTIES: return readProperties(in); case TIME_UNIT: return readTimeUnit(in); case USER_CLASS: return readUserObject(in, in.readByte()); case USER_CLASS_2: return readUserObject(in, in.readShort()); case USER_CLASS_4: return readUserObject(in, in.readInt()); case VECTOR: return readVector(in); case STACK: return readStack(in); case TREE_MAP: return readTreeMap(in); case TREE_SET: return readTreeSet(in); case BOOLEAN_TYPE: return Boolean.TYPE; case CHARACTER_TYPE: return Character.TYPE; case BYTE_TYPE: return Byte.TYPE; case SHORT_TYPE: return Short.TYPE; case INTEGER_TYPE: return Integer.TYPE; case LONG_TYPE: return Long.TYPE; case FLOAT_TYPE: return Float.TYPE; case DOUBLE_TYPE: return Double.TYPE; case VOID_TYPE: return Void.TYPE; case USER_DATA_SERIALIZABLE: return readUserDataSerializable(in, in.readByte()); case USER_DATA_SERIALIZABLE_2: return readUserDataSerializable(in, in.readShort()); case USER_DATA_SERIALIZABLE_4: return readUserDataSerializable(in, in.readInt()); case DATA_SERIALIZABLE: return readDataSerializable(in); case SERIALIZABLE: { final boolean isDebugEnabled_SERIALIZER = logger.isTraceEnabled(LogMarker.SERIALIZER); Object serializableResult; if (in instanceof DSObjectInputStream) { serializableResult = ((DSObjectInputStream) in).readObject(); } else { InputStream stream; if (in instanceof InputStream) { stream = (InputStream) in; } else { stream = new InputStream() { @Override public int read() throws IOException { try { return in.readUnsignedByte(); // fix for bug 47249 } catch (EOFException ignored) { return -1; } } }; } ObjectInput ois = new DSObjectInputStream(stream); if (stream instanceof VersionedDataStream) { Version v = ((VersionedDataStream) stream).getVersion(); if (v != null && v != Version.CURRENT) { ois = new VersionedObjectInput(ois, v); } } serializableResult = ois.readObject(); if (isDebugEnabled_SERIALIZER) { logger.trace(LogMarker.SERIALIZER, "Read Serializable object: {}", serializableResult); } } if (isDebugEnabled_SERIALIZER) { logger.trace(LogMarker.SERIALIZER, "deserialized instanceof {}", serializableResult.getClass()); } return serializableResult; } case PDX: return readPdxSerializable(in); case PDX_ENUM: return readPdxEnum(in); case GEMFIRE_ENUM: return readGemFireEnum(in); case PDX_INLINE_ENUM: return readPdxInlineEnum(in); case BIG_INTEGER: return readBigInteger(in); case BIG_DECIMAL: return readBigDecimal(in); case UUID: return readUUID(in); case TIMESTAMP: return readTimestamp(in); default: String s = "Unknown header byte: " + header; throw new IOException(s); } }
From source file:org.apache.lens.server.query.QueryExecutionServiceImpl.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); // Restore drivers synchronized (drivers) { int numDrivers = in.readInt(); String driverQualifiedName; String driverClsName;/* w w w .j a va 2s . com*/ for (int i = 0; i < numDrivers; i++) { driverQualifiedName = in.readUTF(); driverClsName = in.readUTF(); LensDriver driver = drivers.get(driverQualifiedName); if (driver == null) { // this driver is removed in the current server restart // we will create an instance and read its state still. try { Class<? extends LensDriver> driverCls = (Class<? extends LensDriver>) Class .forName(driverClsName); driver = driverCls.newInstance(); String[] driverTypeAndName = StringUtils.split(driverQualifiedName, '/'); driver.configure(conf, driverTypeAndName[0], driverTypeAndName[1]); } catch (Exception e) { log.error("Could not instantiate driver:{} represented by class {}", driverQualifiedName, driverClsName, e); throw new IOException(e); } log.info("Driver state for {} will be ignored", driverQualifiedName); } driver.readExternal(in); } } // Restore queries synchronized (allQueries) { int numQueries = in.readInt(); for (int i = 0; i < numQueries; i++) { QueryContext ctx = (QueryContext) in.readObject(); ctx.initTransientState(); //Create DriverSelectorQueryContext by passing all the drivers and the user query //Driver conf gets reset in start DriverSelectorQueryContext driverCtx = new DriverSelectorQueryContext(ctx.getUserQuery(), new Configuration(), drivers.values()); ctx.setDriverContext(driverCtx); boolean driverAvailable = in.readBoolean(); // set the selected driver if available, if not available for the cases of queued queries, // query service will do the selection from existing drivers and update if (driverAvailable) { String selectedDriverQualifiedName = in.readUTF(); if (drivers.get(selectedDriverQualifiedName) != null) { ctx.getDriverContext().setSelectedDriver(drivers.get(selectedDriverQualifiedName)); ctx.setDriverQuery(ctx.getSelectedDriver(), ctx.getSelectedDriverQuery()); } else { log.info("Ignoring {} as the driver is not loaded", ctx.getQueryHandle()); continue; } } allQueries.put(ctx.getQueryHandle(), ctx); } } }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
@SuppressWarnings("unchecked") @Override// ww w .j ava2 s .c o m public void readExternal(ObjectInput objin) throws IOException, ClassNotFoundException { // Log.v("","rd"); long sid = objin.readLong(); if (serialVersionUID != sid) { throw new IOException("serialVersionUID was not matched by saved UID"); } paste_list = (ArrayList<FileListItem>) SerializeUtil.readArrayList(objin); paste_from_url = SerializeUtil.readUtf(objin); paste_to_url = SerializeUtil.readUtf(objin); paste_item_list = SerializeUtil.readUtf(objin); is_paste_copy = objin.readBoolean(); is_paste_enabled = objin.readBoolean(); is_paste_from_local = objin.readBoolean(); local_dir_hist = (ArrayList<String>) SerializeUtil.readArrayList(objin); remote_dir_hist = (ArrayList<String>) SerializeUtil.readArrayList(objin); remote_file_list_cache = (ArrayList<FileListCacheItem>) SerializeUtil.readArrayList(objin); remote_curr_file_list = (FileListCacheItem) objin.readObject(); local_file_list_cache = (ArrayList<FileListCacheItem>) SerializeUtil.readArrayList(objin); local_curr_file_list = (FileListCacheItem) objin.readObject(); vsa = new ViewSaveArea(); vsa.readExternal(objin); dialog_msg_cat = objin.readUTF(); remoteBase = SerializeUtil.readUtf(objin); localBase = SerializeUtil.readUtf(objin); remoteDir = SerializeUtil.readUtf(objin); localDir = SerializeUtil.readUtf(objin); currentTabName = SerializeUtil.readUtf(objin); smbUser = SerializeUtil.readUtf(objin); smbPass = SerializeUtil.readUtf(objin); localUpButtonEnabled = objin.readBoolean(); localTopButtonEnabled = objin.readBoolean(); remoteUpButtonEnabled = objin.readBoolean(); remoteTopButtonEnabled = objin.readBoolean(); }