Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
MailExchange |
|
| 0.0;0 |
1 | /** |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.camel.component.mail; |
|
18 | ||
19 | import javax.mail.Message; |
|
20 | ||
21 | import org.apache.camel.CamelContext; |
|
22 | import org.apache.camel.Exchange; |
|
23 | import org.apache.camel.impl.DefaultExchange; |
|
24 | ||
25 | /** |
|
26 | * Represents an {@ilnk Exchange} for working with Mail |
|
27 | * |
|
28 | * @version $Revision:520964 $ |
|
29 | */ |
|
30 | 77 | public class MailExchange extends DefaultExchange { |
31 | private MailBinding binding; |
|
32 | ||
33 | public MailExchange(CamelContext context, MailBinding binding) { |
|
34 | 11 | super(context); |
35 | 11 | this.binding = binding; |
36 | 11 | } |
37 | ||
38 | public MailExchange(CamelContext context, MailBinding binding, Message message) { |
|
39 | 6 | this(context, binding); |
40 | 6 | setIn(new MailMessage(message)); |
41 | 6 | } |
42 | ||
43 | @Override |
|
44 | public MailMessage getIn() { |
|
45 | 40 | return (MailMessage) super.getIn(); |
46 | } |
|
47 | ||
48 | @Override |
|
49 | public MailMessage getOut() { |
|
50 | 9 | return (MailMessage) super.getOut(); |
51 | } |
|
52 | ||
53 | @Override |
|
54 | public MailMessage getOut(boolean lazyCreate) { |
|
55 | 13 | return (MailMessage) super.getOut(lazyCreate); |
56 | } |
|
57 | ||
58 | @Override |
|
59 | public MailMessage getFault() { |
|
60 | 4 | return (MailMessage) super.getFault(); |
61 | } |
|
62 | ||
63 | public MailBinding getBinding() { |
|
64 | 6 | return binding; |
65 | } |
|
66 | ||
67 | @Override |
|
68 | public Exchange newInstance() { |
|
69 | 4 | return new MailExchange(getContext(), binding); |
70 | } |
|
71 | ||
72 | // Expose Email APIs |
|
73 | //------------------------------------------------------------------------- |
|
74 | ||
75 | // Implementation methods |
|
76 | //------------------------------------------------------------------------- |
|
77 | ||
78 | @Override |
|
79 | protected MailMessage createInMessage() { |
|
80 | 5 | return new MailMessage(); |
81 | } |
|
82 | ||
83 | @Override |
|
84 | protected MailMessage createOutMessage() { |
|
85 | 9 | return new MailMessage(); |
86 | } |
|
87 | } |