private Object deserialize ( String serializedObject , String extension ) throws IOException { LOGGER . debug ( "Deserializing object [{}] to [{}]" , serializedObject , extension ) ; SerializerFinder finder = new SerializerFinder ( extension ) ; String serializerClass = finder . findResource ( null ) ; if ( serializerClass == null ) { LOGGER . warn ( "Serializer not found for extension [{}]" , extension ) ; return null ; } else { try { LOGGER . debug ( "Deserializing using {}" , serializerClass ) ; Class < ? > clazz = Class . forName ( serializerClass ) ; Method deserializeMethod = clazz . getMethod ( "deserialize" , new Class [ ] { String . class } ) ; LOGGER . debug ( "Calling {}.deserialize" , serializerClass ) ; return deserializeMethod . invoke ( clazz . newInstance ( ) , serializedObject ) ; } catch ( Exception e ) { LOGGER . debug ( e . getLocalizedMessage ( ) , e ) ; LOGGER . debug ( "Can't deserialize object with {} serializer" , serializerClass ) ; throw new IOException ( e . getLocalizedMessage ( ) ) ; } } }
Deserializes a serialized object that came within the response after a REST call .