1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport.jms;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import javax.jms.BytesMessage;
22 import javax.jms.JMSException;
23 import javax.jms.MessageEOFException;
24
25 import org.springframework.util.Assert;
26
27
28
29
30
31
32
33 class BytesMessageInputStream extends InputStream {
34
35 private final BytesMessage message;
36
37 BytesMessageInputStream(BytesMessage message) {
38 Assert.notNull(message, "'message' must not be null");
39 this.message = message;
40 }
41
42 public int read(byte b[]) throws IOException {
43 try {
44 return message.readBytes(b);
45 }
46 catch (JMSException ex) {
47 throw new JmsTransportException(ex);
48 }
49 }
50
51 public int read(byte b[], int off, int len) throws IOException {
52 if (off == 0) {
53 try {
54 return message.readBytes(b, len);
55 }
56 catch (JMSException ex) {
57 throw new JmsTransportException(ex);
58 }
59 }
60 else {
61 return super.read(b, off, len);
62 }
63 }
64
65 public int read() throws IOException {
66 try {
67 return message.readByte();
68 }
69 catch (MessageEOFException ex) {
70 return -1;
71 }
72 catch (JMSException ex) {
73 throw new JmsTransportException(ex);
74 }
75 }
76 }