1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.file; |
12 | |
|
13 | |
import org.mule.MuleRuntimeException; |
14 | |
import org.mule.config.i18n.CoreMessages; |
15 | |
import org.mule.impl.ThreadSafeAccess; |
16 | |
import org.mule.umo.MessagingException; |
17 | |
|
18 | |
import java.io.File; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class FileContentsMessageAdapter extends FileMessageAdapter |
27 | |
{ |
28 | |
|
29 | |
|
30 | |
|
31 | |
private static final long serialVersionUID = 7368719494535568721L; |
32 | |
|
33 | |
public FileContentsMessageAdapter(Object message) throws MessagingException |
34 | |
{ |
35 | 0 | super(message); |
36 | 0 | } |
37 | |
|
38 | |
public FileContentsMessageAdapter(FileContentsMessageAdapter template) |
39 | |
{ |
40 | 0 | super(template); |
41 | 0 | } |
42 | |
|
43 | |
protected void setMessage(File message) throws MessagingException |
44 | |
{ |
45 | 0 | super.setMessage(message); |
46 | |
|
47 | 0 | this.getPayload(); |
48 | 0 | } |
49 | |
|
50 | |
public Object getPayload() |
51 | |
{ |
52 | 0 | synchronized (this) |
53 | |
{ |
54 | |
try |
55 | |
{ |
56 | 0 | return this.getPayloadAsBytes(); |
57 | |
} |
58 | 0 | catch (Exception noPayloadException) |
59 | |
{ |
60 | 0 | throw new MuleRuntimeException(CoreMessages.failedToReadPayload(), noPayloadException); |
61 | |
} |
62 | 0 | } |
63 | |
} |
64 | |
|
65 | |
public ThreadSafeAccess newThreadCopy() |
66 | |
{ |
67 | 0 | return new FileContentsMessageAdapter(this); |
68 | |
} |
69 | |
} |