/** * @param in Input stream. * @return Binary object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @Nullable public <T> T unmarshal(BinaryInputStream in) throws BinaryObjectException { BinaryContext oldCtx = pushContext(ctx); try { return (T)BinaryUtils.unmarshal(in, ctx, null); } finally { popContext(oldCtx); } }
/** * @param bytes Bytes array. * @return Binary object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @Nullable public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws BinaryObjectException { assert bytes != null; BinaryContext oldCtx = pushContext(ctx); try { return (T) BinaryUtils.unmarshal(BinaryHeapInputStream.create(bytes, 0), ctx, clsLdr); } finally { popContext(oldCtx); } }
/** * @param arr Byte array. * @param ldr Class loader. * @return Deserialized object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @Nullable public <T> T deserialize(byte[] arr, @Nullable ClassLoader ldr) throws BinaryObjectException { assert arr != null; assert arr.length > 0; if (arr[0] == NULL) return null; BinaryContext oldCtx = pushContext(ctx); try { return (T)new BinaryReaderExImpl(ctx, BinaryHeapInputStream.create(arr, 0), ldr, true).deserialize(); } finally { popContext(oldCtx); } }
/** * @param c Closure. * @return Closure result. * @throws IgniteCheckedException If failed. */ private <T> T withBinaryContext(IgniteOutClosureX<T> c) throws IgniteCheckedException { IgniteCacheObjectProcessor objProc = ctx.cacheObjects(); BinaryContext oldCtx = null; if (objProc instanceof CacheObjectBinaryProcessorImpl) { GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl)objProc).marshaller(); oldCtx = binMarsh == null ? null : binMarsh.pushContext(); } try { return c.applyx(); } finally { if (objProc instanceof CacheObjectBinaryProcessorImpl) GridBinaryMarshaller.popContext(oldCtx); } }
/** * @param in Input stream. * @return Binary object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @SuppressWarnings("unchecked") @Nullable public <T> T unmarshal(BinaryInputStream in) throws BinaryObjectException { BinaryContext oldCtx = pushContext(ctx); try { return (T)BinaryUtils.unmarshal(in, ctx, null); } finally { popContext(oldCtx); } }
/** * @param bytes Bytes array. * @return Binary object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @SuppressWarnings("unchecked") @Nullable public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws BinaryObjectException { assert bytes != null; BinaryContext oldCtx = pushContext(ctx); try { return (T) BinaryUtils.unmarshal(BinaryHeapInputStream.create(bytes, 0), ctx, clsLdr); } finally { popContext(oldCtx); } }
/** * @param arr Byte array. * @param ldr Class loader. * @return Deserialized object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ @SuppressWarnings("unchecked") @Nullable public <T> T deserialize(byte[] arr, @Nullable ClassLoader ldr) throws BinaryObjectException { assert arr != null; assert arr.length > 0; if (arr[0] == NULL) return null; BinaryContext oldCtx = pushContext(ctx); try { return (T)new BinaryReaderExImpl(ctx, BinaryHeapInputStream.create(arr, 0), ldr, true).deserialize(); } finally { popContext(oldCtx); } }
/** * @param c Closure. * @return Closure result. * @throws IgniteCheckedException If failed. */ private <T> T withBinaryContext(IgniteOutClosureX<T> c) throws IgniteCheckedException { IgniteCacheObjectProcessor objProc = ctx.cacheObjects(); BinaryContext oldCtx = null; if (objProc instanceof CacheObjectBinaryProcessorImpl) { GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl)objProc).marshaller(); oldCtx = binMarsh == null ? null : binMarsh.pushContext(); } try { return c.applyx(); } finally { if (objProc instanceof CacheObjectBinaryProcessorImpl) GridBinaryMarshaller.popContext(oldCtx); } }