use of java.io.Externalizable in project ignite by apache.
the class OptimizedObjectInputStream method readExternalizable.
/**
* Reads {@link Externalizable} object.
*
* @param constructor Constructor.
* @param readResolveMtd {@code readResolve} method.
* @return Object.
* @throws ClassNotFoundException If class not found.
* @throws IOException In case of error.
*/
Object readExternalizable(Constructor<?> constructor, Method readResolveMtd) throws ClassNotFoundException, IOException {
Object obj;
try {
obj = constructor.newInstance();
} catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
throw new IOException(e);
}
int handle = handles.assign(obj);
Externalizable extObj = ((Externalizable) obj);
extObj.readExternal(this);
if (readResolveMtd != null) {
try {
obj = readResolveMtd.invoke(obj);
handles.set(handle, obj);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IOException(e);
}
}
return obj;
}
use of java.io.Externalizable in project ignite by apache.
the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByStringAndUUIDAndLong.
/**
* @throws Exception If failed.
*/
public void testSerializationTopicCreatedByStringAndUUIDAndLong() throws Exception {
for (Marshaller marsh : getMarshallers()) {
info("Test GridTopic externalization [marshaller=" + marsh + ']');
for (GridTopic topic : GridTopic.values()) {
Externalizable msgOut = (Externalizable) topic.topic(A_STRING, AN_UUID, A_LONG);
assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
}
}
}
use of java.io.Externalizable in project ignite by apache.
the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByStrinAndLong.
/**
* @throws Exception If failed.
*/
public void testSerializationTopicCreatedByStrinAndLong() throws Exception {
for (Marshaller marsh : getMarshallers()) {
info("Test GridTopic externalization [marshaller=" + marsh + ']');
for (GridTopic topic : GridTopic.values()) {
Externalizable msgOut = (Externalizable) topic.topic(A_STRING, A_LONG);
assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
}
}
}
use of java.io.Externalizable in project ignite by apache.
the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByStringAndIntAndLong.
/**
* @throws Exception If failed.
*/
public void testSerializationTopicCreatedByStringAndIntAndLong() throws Exception {
for (Marshaller marsh : getMarshallers()) {
info("Test GridTopic externalization [marshaller=" + marsh + ']');
for (GridTopic topic : GridTopic.values()) {
Externalizable msgOut = (Externalizable) topic.topic(A_STRING, AN_INT, A_LONG);
assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
}
}
}
use of java.io.Externalizable in project ignite by apache.
the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByGridUuidAndUUID.
/**
* @throws Exception If failed.
*/
public void testSerializationTopicCreatedByGridUuidAndUUID() throws Exception {
for (Marshaller marsh : getMarshallers()) {
info("Test GridTopic externalization [marshaller=" + marsh + ']');
for (GridTopic topic : GridTopic.values()) {
Externalizable msgOut = (Externalizable) topic.topic(A_GRID_UUID, AN_UUID);
assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
}
}
}
Aggregations