Java Code Examples for org.springframework.oxm.Unmarshaller#unmarshal()

The following examples show how to use org.springframework.oxm.Unmarshaller#unmarshal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmazonProductService.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
private List<ThirdPartyProduct> buildProducts(InputStream inputStream) throws Exception {
	Unmarshaller unmarshaller = createUnmarshaller();
	StreamSource source = new StreamSource(inputStream);
	AmazonProductSearchResponse amazonProductSearchResponse = (AmazonProductSearchResponse) unmarshaller.unmarshal(source);
	return amazonProductSearchResponse.getProducts();
}
 
Example 2
Source File: MarshallingMessageConverter.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Unmarshal the given {@link TextMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromTextMessage(TextMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	Source source = new StreamSource(new StringReader(message.getText()));
	return unmarshaller.unmarshal(source);
}
 
Example 3
Source File: MarshallingMessageConverter.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Unmarshal the given {@link BytesMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromBytesMessage(BytesMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	byte[] bytes = new byte[(int) message.getBodyLength()];
	message.readBytes(bytes);
	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
	StreamSource source = new StreamSource(bis);
	return unmarshaller.unmarshal(source);
}
 
Example 4
Source File: MarshallingMessageConverter.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Unmarshal the given {@link TextMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromTextMessage(TextMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	Source source = new StreamSource(new StringReader(message.getText()));
	return unmarshaller.unmarshal(source);
}
 
Example 5
Source File: MarshallingMessageConverter.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Unmarshal the given {@link BytesMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromBytesMessage(BytesMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	byte[] bytes = new byte[(int) message.getBodyLength()];
	message.readBytes(bytes);
	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
	StreamSource source = new StreamSource(bis);
	return unmarshaller.unmarshal(source);
}
 
Example 6
Source File: MarshallingMessageConverter.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Unmarshal the given {@link TextMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromTextMessage(TextMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	Source source = new StreamSource(new StringReader(message.getText()));
	return unmarshaller.unmarshal(source);
}
 
Example 7
Source File: MarshallingMessageConverter.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Unmarshal the given {@link BytesMessage} into an object.
 * @param message the message
 * @param unmarshaller the unmarshaller to use
 * @return the unmarshalled object
 * @throws JMSException if thrown by JMS methods
 * @throws IOException in case of I/O errors
 * @throws XmlMappingException in case of OXM mapping errors
 * @see Unmarshaller#unmarshal(Source)
 */
protected Object unmarshalFromBytesMessage(BytesMessage message, Unmarshaller unmarshaller)
		throws JMSException, IOException, XmlMappingException {

	byte[] bytes = new byte[(int) message.getBodyLength()];
	message.readBytes(bytes);
	ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
	StreamSource source = new StreamSource(bis);
	return unmarshaller.unmarshal(source);
}
 
Example 8
Source File: AbstractUnmarshallXmlTest.java    From cia with Apache License 2.0 3 votes vote down vote up
/**
 * Unmarshall xml.
 *
 * @param unmarshaller
 *            the unmarshaller
 * @param filename
 *            the filename
 * @return the t
 * @throws Exception
 *             the exception
 */
protected final T unmarshallXml(final Unmarshaller unmarshaller, final String filename) throws Exception {
	final BufferedReader inputStream = new BufferedReader(new InputStreamReader(
			java.nio.file.Files.newInputStream(
					Paths.get(FilenameUtils.getFullPath(filename), FilenameUtils.getName(filename))),
			StandardCharsets.UTF_8));

	return (T) unmarshaller.unmarshal(new StreamSource(inputStream));
}