/** * deep clones this SpaceURL instance - makes a distinct copy of each of the SpaceURL fields, * and underlying tables. Basically overrides {@link Properties#clone()} method, which creates * only a shallow copy. * * @return a distinct copy of this SpaceURL (including all object references). * @see IOUtils#deepClone(Object) */ @SuppressWarnings("CloneDoesntCallSuperClone") @Override public synchronized SpaceURL clone() { return (SpaceURL) IOUtils.deepClone(this); }
/** * A deep copy makes a distinct copy of each of the object's fields, recursing through the * entire graph of other objects referenced by the object being copied. Deep clone by serialize * and deserialize the object and return the deserialized version. A deep copy/clone, assuming * everything in the tree is serializable. * * NOTE: This method is very expensive!, don't use this method if you need performance. * * @param obj the object to clone, the object and object context must implement * java.io.Serializable. * @return the copied object include all object references. * @throws IllegalArgumentException Failed to perform deep clone. The object of the context * object is not implements java.io.Serializable. **/ public static Object deepClone(Object obj) { try { byte[] bArray = objectToByteBuffer(obj); return objectFromByteBuffer(bArray); } catch (Exception ex) { throw new IllegalArgumentException("Failed to perform deep clone on [" + obj + "] object. Check that the all object context are implements java.io.Serializable.", ex); } }
private final void deserializePacket(ObjectInput in) throws IOException, ClassNotFoundException { _extendedMatchCodes = IOUtils.readShortArray(in); _rangeValues = IOUtils.readObjectArray(in); _rangeValuesInclusion = IOUtils.readBooleanArray(in); }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { constructorParameterNames = IOUtils.readStringArray(in); excludedIndexes = IOUtils.readBooleanArray(in); spacePropertyToConstructorIndex = IOUtils.readIntegerArray(in); constructorParameterTypes = new Class<?>[constructorParameterNames.length]; for (int i = 0; i < constructorParameterTypes.length; i++) { String typeName = IOUtils.readString(in); Class<?> type = ObjectUtils.isPrimitive(typeName) ? ObjectUtils.getPrimitive(typeName) : ClassLoaderHelper.loadClass(typeName, false /* localOnly */); constructorParameterTypes[i] = type; } idPropertyConstructorIndex = in.readInt(); dynamicPropertiesConstructorIndex = in.readInt(); versionConstructorIndex = in.readInt(); persistConstructorIndex = in.readInt(); leaseConstructorIndex = in.readInt(); }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); short flags = in.readShort(); this.queryPacket = IOUtils.readObject(in); PlatformLogicalVersion version = LRMIInvocationContext.getEndpointLogicalVersion(); if (version.greaterOrEquals(PlatformLogicalVersion.v12_1_0)) { this.aggregators = new ArrayList<SpaceEntriesAggregator>(); IOUtils.deserializeSupportCodeChangeCollection(in, aggregators); } else { this.aggregators = IOUtils.readObject(in); } if (flags != 0) { if ((flags & FLAG_TRANSACTION) != 0) this.txn = IOUtils.readWithCachedStubs(in); this.readModifiers = (flags & FLAG_MODIFIERS) != 0 ? in.readInt() : DEFAULT_MODIFIERS; } else { this.readModifiers = DEFAULT_MODIFIERS; } }
isPortOccupiedByAnotherAppl) { while (IOUtils.isPortBusy(jndiPort, null)) { //find another free port jndiPort = IOUtils.getAnonymousPort();
public void writeExternal(AnnotatedObjectOutputStream out) throws IOException { out.writeByte(SERIAL_VERSION); out.writeByte(buildFlags()); if (_requestObj != null) { out.writeObject(_requestObj); } else { /** write stubClassId, so that the ServerPeer will marsh/unmarsh the method arguments more faster */ out.writeLong(lrmiId); out.writeLong(objectId); out.writeInt(methodOrderId); out.writeLong(remoteClassLoaderId); if (operationPriority == OperationPriority.CUSTOM && targetVersion.greaterOrEquals(PlatformLogicalVersion.v9_7_0)) { //Place holder for dedicated thread pools IOUtils.writeRepetitiveString(out, ""); } Class<?>[] types = invokeMethod.methodTypes; for (int i = 0; i < types.length; i++) { IOUtils.marshalValue(types[i], args[i], out); } } }
public static <T extends ISwapExternalizable> T readSwapExternalizableObject(ObjectInput in) throws IOException, ClassNotFoundException { int classCode = in.readInt(); Class<?> clazz = getClass(classCode); try { T newInstance = (T) clazz.newInstance(); newInstance.readFromSwap(in); return newInstance; } catch (IOException e) { throw e; } catch (ClassNotFoundException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
public static void writeSwapExternalizableObject(ObjectOutput out, ISwapExternalizable swapExternalizable) throws IOException { Class<? extends ISwapExternalizable> clazz = swapExternalizable.getClass(); int code = getCode(clazz); out.writeInt(code); swapExternalizable.writeToSwap(out); out.flush(); }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); final short flags = in.readShort(); this._templatePacket = IOUtils.readObject(in); PlatformLogicalVersion version = LRMIInvocationContext.getEndpointLogicalVersion(); if (version.greaterOrEquals(PlatformLogicalVersion.v12_1_0)) { this._mutators = new LinkedList<SpaceEntryMutator>(); IOUtils.deserializeSupportCodeChangeCollection(in, _mutators); } else { this._mutators = IOUtils.readObject(in); } if (flags != 0) { if ((flags & FLAG_TRANSACTION) != 0) this._txn = IOUtils.readWithCachedStubs(in); this._timeout = (flags & FLAG_TIMEOUT) != 0 ? in.readLong() : DEFAULT_TIMEOUT; this._lease = (flags & FLAG_LEASE) != 0 ? in.readLong() : DEFAULT_LEASE; this._modifiers = (flags & FLAG_MODIFIERS) != 0 ? in.readInt() : DEFAULT_MODIFIERS; } else { this._timeout = DEFAULT_TIMEOUT; this._lease = DEFAULT_LEASE; this._modifiers = DEFAULT_MODIFIERS; } }