Updates in the KryoFactory:
* Renamed method newKryoImpl() to newKryoObject(), and changed it from
"private" to "public static". Thus, the method can be used to
allocate a single Kryo object.
* Updated the Javadoc comment for method newKryoObject() to reflect
its recommended usage.
* Updates some of the other Javadoc comments.
Change-Id: Id58bdb11b3c3f0468095346c9f2a96f6bb8c0bfe
diff --git a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
index dc15810..a726401 100644
--- a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
+++ b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
@@ -81,22 +81,22 @@
// Preallocate
kryoList.ensureCapacity(initialCapacity);
for (int i = 0; i < initialCapacity; i++) {
- Kryo kryo = newKryoImpl();
+ Kryo kryo = newKryoObject();
kryoList.add(kryo);
}
}
/**
- * Create and initialize a new Kryo object.
+ * Gets a new Kryo object.
*
- * @return the created Kryo object.
+ * @return the Kryo object.
*/
public Kryo newKryo() {
return newDeleteKryo(null);
}
/**
- * Delete an existing Kryo object.
+ * Deletes an existing Kryo object.
*
* @param deleteKryo the object to delete.
*/
@@ -105,7 +105,7 @@
}
/**
- * Create or delete a Kryo object.
+ * Creates or deletes a Kryo object.
*
* @param deleteKryo if null, then allocate and return a new object,
* otherwise delete the provided object.
@@ -121,7 +121,7 @@
if (kryoList.isEmpty()) {
// Preallocate
for (int i = 0; i < 100; i++) {
- kryo = newKryoImpl();
+ kryo = newKryoObject();
kryoList.add(kryo);
}
}
@@ -132,11 +132,16 @@
}
/**
- * Create and initialize a new Kryo object.
+ * Creates and initializes a new Kryo object.
+ *<p>
+ * NOTE: This operation can be slow and should be used only if the
+ * application needs a single Kryo instance (e.g., during startup).
+ * For faster allocation, the application should use #newKryo()
+ * and #deleteKryo() factory methods.
*
* @return the created Kryo object.
*/
- private Kryo newKryoImpl() {
+ public static Kryo newKryoObject() {
Kryo kryo = new Kryo();
kryo.setRegistrationRequired(true);
//