Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.serializers; |
| 2 | |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 3 | import java.nio.ByteBuffer; |
| 4 | |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 5 | // TODO: To be replaced with SerializationService from IOLoop activity |
| 6 | /** |
| 7 | * Service to serialize Objects into byte array. |
| 8 | */ |
| 9 | public interface KryoSerializationService { |
| 10 | |
| 11 | /** |
| 12 | * Serializes the specified object into bytes using one of the |
| 13 | * pre-registered serializers. |
| 14 | * |
| 15 | * @param obj object to be serialized |
| 16 | * @return serialized bytes |
| 17 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame^] | 18 | public byte[] encode(final Object obj); |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 19 | |
| 20 | /** |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 21 | * Serializes the specified object into bytes using one of the |
| 22 | * pre-registered serializers. |
| 23 | * |
| 24 | * @param obj object to be serialized |
| 25 | * @param buffer to write serialized bytes |
| 26 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame^] | 27 | public void encode(final Object obj, ByteBuffer buffer); |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 30 | * Deserializes the specified bytes into an object using one of the |
| 31 | * pre-registered serializers. |
| 32 | * |
| 33 | * @param bytes bytes to be deserialized |
| 34 | * @return deserialized object |
| 35 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame^] | 36 | public <T> T decode(final byte[] bytes); |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 37 | |
Yuta HIGUCHI | f6d1170 | 2014-09-30 19:18:59 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Deserializes the specified bytes into an object using one of the |
| 40 | * pre-registered serializers. |
| 41 | * |
| 42 | * @param buffer bytes to be deserialized |
| 43 | * @return deserialized object |
| 44 | */ |
Yuta HIGUCHI | 53a285d | 2014-10-06 23:58:01 -0700 | [diff] [blame^] | 45 | public <T> T decode(final ByteBuffer buffer); |
Yuta HIGUCHI | ad4c218 | 2014-09-29 11:16:23 -0700 | [diff] [blame] | 46 | } |