-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Sofaboot 4.0 support (#89) * feat: atomic * feat: ignore failure when set accessible * feat: replace reflection with specific get set for atomic * fix: remove handle * fix: log level * feat: stack trace serialize without reflect * add test case for stack trace * fix: log * feat: throw v1 * feat: throwable * format * format * chore: cr fix * chore: format * remove version specific * version * chore: add ci on sofaboot-4.0-support --------- Co-authored-by: lo1nt <[email protected]> * Sofaboot 4.0 support (#90) * feat: atomic * feat: ignore failure when set accessible * feat: replace reflection with specific get set for atomic-s * fix: remove handle * fix: log level * feat: stack trace serialize without reflect * add test case for stack trace * fix: log * feat: throw v1 * feat: throwable * format * format * chore: cr fix * chore: format * add ci fo jdk17 * update jdk * remove version specific * version * chore: add ci on sofaboot-4.0-support * 3.5.0.beta.1 release --------- Co-authored-by: 均源 <[email protected]> * Sofaboot 4.0 support (#92) * feat: atomic * feat: ignore failure when set accessible * feat: replace reflection with specific get set for atomic-s * fix: remove handle * fix: log level * feat: stack trace serialize without reflect * add test case for stack trace * fix: log * feat: throw v1 * feat: throwable * format * format * chore: cr fix * chore: format * add ci fo jdk17 * update jdk * remove version specific * version * chore: add ci on sofaboot-4.0-support * 3.5.0.beta.1 release * remove aci on sofaboot-4.0-support --------- Co-authored-by: 均源 <[email protected]> * Sofaboot 4.0 support (#96) * feat: atomic * feat: ignore failure when set accessible * feat: replace reflection with specific get set for atomic-s * fix: remove handle * fix: log level * feat: stack trace serialize without reflect * add test case for stack trace * fix: log * feat: throw v1 * feat: throwable * format * format * chore: cr fix * chore: format * add ci fo jdk17 * update jdk * remove version specific * version * chore: add ci on sofaboot-4.0-support * 3.5.0.beta.1 release * remove aci on sofaboot-4.0-support * feat: add support on java util currency * format * init 3.5 snapshot * optimized code (#94) Co-authored-by: liujianjun.ljj <[email protected]> * format * fix: ref problem on currency * format * fix: ref bug on atomic * version snapshot * enhance: ref * fix: test --------- Co-authored-by: 均源 <[email protected]> Co-authored-by: evenliu <[email protected]> Co-authored-by: liujianjun.ljj <[email protected]> * Sofaboot 4.0 support (#97) * feat: atomic * feat: ignore failure when set accessible * feat: replace reflection with specific get set for atomic-s * fix: remove handle * fix: log level * feat: stack trace serialize without reflect * add test case for stack trace * fix: log * feat: throw v1 * feat: throwable * format * format * chore: cr fix * chore: format * add ci fo jdk17 * update jdk * remove version specific * version * chore: add ci on sofaboot-4.0-support * 3.5.0.beta.1 release * remove aci on sofaboot-4.0-support * feat: add support on java util currency * format * init 3.5 snapshot * optimized code (#94) Co-authored-by: liujianjun.ljj <[email protected]> * format * fix: ref problem on currency * format * enhance: ref * fix: test * fix: test exception * fix: curency test --------- Co-authored-by: 均源 <[email protected]> Co-authored-by: evenliu <[email protected]> Co-authored-by: liujianjun.ljj <[email protected]> * fix: deser log (#98) Co-authored-by: lo1nt <[email protected]> * release version 3.5.0 (#100) Co-authored-by: lo1nt <[email protected]> --------- Co-authored-by: lo1nt <[email protected]> Co-authored-by: evenliu <[email protected]> Co-authored-by: liujianjun.ljj <[email protected]>
- Loading branch information
1 parent
39b1dcb
commit 691b4f2
Showing
40 changed files
with
4,039 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/caucho/hessian/io/AbstractFieldAdaptorDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Ant Group | ||
* Copyright (c) 2004-2023 All Rights Reserved. | ||
*/ | ||
package com.caucho.hessian.io; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Modifier; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* | ||
* @author junyuan | ||
* @version AbstractFieldAdaptorDeserializer.java, v 0.1 2023年05月06日 14:21 junyuan Exp $ | ||
*/ | ||
public abstract class AbstractFieldAdaptorDeserializer extends AbstractDeserializer { | ||
|
||
protected Map<String, Field> _fields; | ||
|
||
public AbstractFieldAdaptorDeserializer(Class<?> cl) { | ||
_fields = getFieldMapForSerialize(cl); | ||
} | ||
|
||
protected Map<String, Field> getFieldMapForSerialize(Class cl) { | ||
Map<String, Field> fields = new HashMap<String, Field>(); | ||
for (; cl != null; cl = cl.getSuperclass()) { | ||
Field[] originFields = cl.getDeclaredFields(); | ||
for (int i = 0; i < originFields.length; i++) { | ||
Field field = originFields[i]; | ||
if (Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) { | ||
continue; | ||
} else if (fields.containsKey(field.getName())) { | ||
continue; | ||
} | ||
fields.put(field.getName(), field); | ||
} | ||
} | ||
return fields; | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
src/main/java/com/caucho/hessian/io/AbstractFieldAdaptorSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Ant Group | ||
* Copyright (c) 2004-2023 All Rights Reserved. | ||
*/ | ||
package com.caucho.hessian.io; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Modifier; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author junyuan | ||
* @version AbstractFieldAdaptorSerializer.java, v 0.1 2023年04月10日 19:34 junyuan Exp $ | ||
*/ | ||
public abstract class AbstractFieldAdaptorSerializer extends AbstractSerializer { | ||
|
||
protected Field[] _fields; | ||
|
||
public AbstractFieldAdaptorSerializer(Class<?> clazz) { | ||
this._fields = getFieldsForSerialize(clazz); | ||
} | ||
|
||
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { | ||
if (obj == null) { | ||
out.writeNull(); | ||
return; | ||
} | ||
|
||
if (out.addRef(obj)) { | ||
return; | ||
} | ||
Class cl = obj.getClass(); | ||
int ref = out.writeObjectBegin(cl.getName()); | ||
|
||
if (ref < -1) { | ||
writeObject10(obj, out); | ||
} | ||
else { | ||
if (ref == -1) { | ||
writeDefinition20(out); | ||
out.writeObjectBegin(cl.getName()); | ||
} | ||
|
||
writeInstance(obj, out); | ||
} | ||
} | ||
|
||
private void writeObject10(Object obj, AbstractHessianOutput out) | ||
throws IOException | ||
{ | ||
for (int i = 0; i < _fields.length; i++) { | ||
Field field = _fields[i]; | ||
|
||
out.writeString(field.getName()); | ||
|
||
serializeField(out, obj, field); | ||
} | ||
|
||
out.writeMapEnd(); | ||
} | ||
|
||
private void writeDefinition20(AbstractHessianOutput out) | ||
throws IOException | ||
{ | ||
out.writeClassFieldLength(_fields.length); | ||
|
||
for (int i = 0; i < _fields.length; i++) { | ||
Field field = _fields[i]; | ||
|
||
out.writeString(field.getName()); | ||
} | ||
} | ||
|
||
public void writeInstance(Object obj, AbstractHessianOutput out) | ||
throws IOException | ||
{ | ||
for (int i = 0; i < _fields.length; i++) { | ||
Field field = _fields[i]; | ||
serializeField(out, obj, field); | ||
} | ||
} | ||
|
||
protected abstract void serializeField(AbstractHessianOutput out, Object obj, Field field) throws IOException; | ||
|
||
/** | ||
* get all fields | ||
* include super class | ||
* exclude transient or static | ||
* @param cl | ||
* @return | ||
*/ | ||
protected Field[] getFieldsForSerialize(Class cl) { | ||
List<Field> fields = new ArrayList<Field>(); | ||
for (; cl != null; cl = cl.getSuperclass()) { | ||
Field[] originFields = cl.getDeclaredFields(); | ||
for (int i = 0; i < originFields.length; i++) { | ||
Field field = originFields[i]; | ||
if (Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) { | ||
continue; | ||
} | ||
fields.add(field); | ||
} | ||
} | ||
return fields.toArray(new Field[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.