Skip to content

Commit e632504

Browse files
majinkaicarryxyh
authored andcommitted
Add javadoc for dubbo-serialization module(#3002). (#3004)
Add javadoc for dubbo-serialization module(#3002).
1 parent e095bd9 commit e632504

File tree

35 files changed

+171
-34
lines changed

35 files changed

+171
-34
lines changed

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Cleanable.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
*/
1717
package org.apache.dubbo.common.serialize;
1818

19+
/**
20+
* Interface defines that the object is cleanable.
21+
*/
1922
public interface Cleanable {
2023

24+
/**
25+
* Implementations must implement this cleanup method
26+
*/
2127
void cleanup();
2228
}

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/DataInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.io.IOException;
2020

2121
/**
22-
* Data input.
22+
* Basic data type input interface.
2323
*/
2424
public interface DataInput {
2525

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/DataOutput.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.io.IOException;
2020

2121
/**
22-
* Data output.
22+
* Basic data type output interface.
2323
*/
2424
public interface DataOutput {
2525

@@ -98,9 +98,9 @@ public interface DataOutput {
9898
/**
9999
* Write byte array.
100100
*
101-
* @param v value.
102-
* @param off offset.
103-
* @param len length.
101+
* @param v value.
102+
* @param off the start offset in the data.
103+
* @param len the number of bytes that are written.
104104
* @throws IOException
105105
*/
106106
void writeBytes(byte[] v, int off, int len) throws IOException;

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/ObjectInput.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,37 @@
2020
import java.lang.reflect.Type;
2121

2222
/**
23-
* Object input.
23+
* Object input interface.
2424
*/
2525
public interface ObjectInput extends DataInput {
2626

2727
/**
28-
* read object.
28+
* read object
2929
*
30-
* @return object.
30+
* @return object
31+
* @throws IOException if an I/O error occurs
32+
* @throws ClassNotFoundException if an ClassNotFoundException occurs
3133
*/
3234
Object readObject() throws IOException, ClassNotFoundException;
3335

3436
/**
35-
* read object.
37+
* read object
3638
*
37-
* @param cls object type.
38-
* @return object.
39+
* @param cls object class
40+
* @return object
41+
* @throws IOException if an I/O error occurs
42+
* @throws ClassNotFoundException if an ClassNotFoundException occurs
3943
*/
4044
<T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException;
4145

4246
/**
43-
* read object.
47+
* read object
4448
*
45-
* @param cls object type.
46-
* @return object.
49+
* @param cls object class
50+
* @param type object type
51+
* @return object
52+
* @throws IOException if an I/O error occurs
53+
* @throws ClassNotFoundException if an ClassNotFoundException occurs
4754
*/
4855
<T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException;
4956

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/ObjectOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.io.IOException;
2020

2121
/**
22-
* Object output.
22+
* Object output interface.
2323
*/
2424
public interface ObjectOutput extends DataOutput {
2525

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Serialization.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,46 @@
2525
import java.io.OutputStream;
2626

2727
/**
28-
* Serialization. (SPI, Singleton, ThreadSafe)
28+
* Serialization strategy interface that specifies a serializer. (SPI, Singleton, ThreadSafe)
29+
*
30+
* The default extension is hessian2 and the default serialization implementation of the dubbo protocol.
31+
* <pre>
32+
* e.g. &lt;dubbo:protocol serialization="xxx" /&gt;
33+
* </pre>
2934
*/
3035
@SPI("hessian2")
3136
public interface Serialization {
3237

3338
/**
34-
* get content type id
39+
* Get content type unique id, recommended that custom implementations use values greater than 20.
3540
*
3641
* @return content type id
3742
*/
3843
byte getContentTypeId();
3944

4045
/**
41-
* get content type
46+
* Get content type
4247
*
4348
* @return content type
4449
*/
4550
String getContentType();
4651

4752
/**
48-
* create serializer
53+
* Get a serialization implementation instance
4954
*
50-
* @param url
51-
* @param output
55+
* @param url URL address for the remote service
56+
* @param output the underlying output stream
5257
* @return serializer
5358
* @throws IOException
5459
*/
5560
@Adaptive
5661
ObjectOutput serialize(URL url, OutputStream output) throws IOException;
5762

5863
/**
59-
* create deserializer
64+
* Get a deserialization implementation instance
6065
*
61-
* @param url
62-
* @param input
66+
* @param url URL address for the remote service
67+
* @param input the underlying input stream
6368
* @return deserializer
6469
* @throws IOException
6570
*/

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/support/SerializableClassRegistry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,29 @@
2121
import java.util.LinkedHashMap;
2222
import java.util.Map;
2323

24+
/**
25+
* Provide a unified serialization registry, this class used for {@code dubbo-serialization-fst}
26+
* and {@code dubbo-serialization-kryo}, it will register some classes at startup time (for example {@link AbstractKryoFactory#create})
27+
*/
2428
public abstract class SerializableClassRegistry {
2529

2630

2731
private static final Map<Class, Object> registrations = new LinkedHashMap<>();
2832

2933
/**
3034
* only supposed to be called at startup time
35+
*
36+
* @param clazz object type
3137
*/
3238
public static void registerClass(Class clazz) {
3339
registerClass(clazz, null);
3440
}
3541

3642
/**
3743
* only supposed to be called at startup time
44+
*
45+
* @param clazz object type
46+
* @param serializer object serializer
3847
*/
3948
public static void registerClass(Class clazz, Serializer serializer) {
4049
if (clazz == null) {
@@ -43,6 +52,11 @@ public static void registerClass(Class clazz, Serializer serializer) {
4352
registrations.put(clazz, serializer);
4453
}
4554

55+
/**
56+
* get registered classes
57+
*
58+
* @return class serializer
59+
* */
4660
public static Map<Class, Object> getRegisteredClasses() {
4761
return registrations;
4862
}

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/support/SerializationOptimizer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
import java.util.Collection;
2020

2121
/**
22-
* This class can be replaced with the contents in config file, but for now I think the class is easier to write
23-
*
22+
* Interface defining serialization optimizer, there are nothing implementations for now.
2423
*/
2524
public interface SerializationOptimizer {
2625

26+
/**
27+
* Get serializable classes
28+
*
29+
* @return serializable classes
30+
* */
2731
Collection<Class> getSerializableClasses();
2832
}

dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectInput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import java.io.Reader;
3030
import java.lang.reflect.Type;
3131

32+
/**
33+
* FastJson object input implementation
34+
*/
3235
public class FastJsonObjectInput implements ObjectInput {
3336

3437
private final BufferedReader reader;

dubbo-serialization/dubbo-serialization-fastjson/src/main/java/org/apache/dubbo/common/serialize/fastjson/FastJsonObjectOutput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import java.io.PrintWriter;
2929
import java.io.Writer;
3030

31+
/**
32+
* FastJson object output implementation
33+
*/
3134
public class FastJsonObjectOutput implements ObjectOutput {
3235

3336
private final PrintWriter writer;

0 commit comments

Comments
 (0)