All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kikaha.urouting.serializers.jaxb.JAXBUnserializer Maven / Gradle / Ivy

There is a newer version: 2.1.0-alpha12
Show newest version
package kikaha.urouting.serializers.jaxb;

import kikaha.urouting.api.*;

import javax.enterprise.inject.Typed;
import javax.inject.Singleton;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.Reader;

@SuppressWarnings("unchecked")
@ContentType(Mimes.XML)
@Singleton
@Typed( Unserializer.class )
public class JAXBUnserializer extends AbstractUnserializer {

	@Override
	public  T unserialize( Reader input, Class clazz ) throws RoutingException {
		try {
			final JAXBContext context = JAXBContext.newInstance( clazz );
			final Unmarshaller unmarshaller = context.createUnmarshaller();
			return (T) unmarshaller.unmarshal( input );
		} catch ( final JAXBException cause ) {
			throw new RoutingException(cause);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy