1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.jbi.components; |
12 | |
|
13 | |
import org.mule.MuleManager; |
14 | |
import org.mule.impl.endpoint.MuleEndpoint; |
15 | |
import org.mule.umo.UMOException; |
16 | |
import org.mule.umo.endpoint.UMOEndpoint; |
17 | |
|
18 | |
import java.util.Map; |
19 | |
|
20 | |
import javax.jbi.JBIException; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public abstract class AbstractEndpointComponent extends AbstractJbiComponent |
27 | |
{ |
28 | |
|
29 | |
protected UMOEndpoint muleEndpoint; |
30 | |
|
31 | |
protected String endpoint; |
32 | |
|
33 | |
protected Map endpointProperties; |
34 | |
|
35 | |
protected AbstractEndpointComponent() |
36 | 2 | { |
37 | 2 | if (!MuleManager.isInstanciated()) |
38 | |
{ |
39 | 2 | MuleManager.getConfiguration().setEmbedded(true); |
40 | |
try |
41 | |
{ |
42 | 2 | MuleManager.getInstance().start(); |
43 | |
} |
44 | 0 | catch (UMOException e) |
45 | |
{ |
46 | 0 | e.printStackTrace(); |
47 | 2 | } |
48 | |
} |
49 | 2 | } |
50 | |
|
51 | |
public UMOEndpoint getMuleEndpoint() |
52 | |
{ |
53 | 0 | return muleEndpoint; |
54 | |
} |
55 | |
|
56 | |
public void setMuleEndpoint(UMOEndpoint muleEndpoint) |
57 | |
{ |
58 | 0 | this.muleEndpoint = muleEndpoint; |
59 | 0 | } |
60 | |
|
61 | |
public String getEndpoint() |
62 | |
{ |
63 | 0 | return endpoint; |
64 | |
} |
65 | |
|
66 | |
public void setEndpoint(String endpoint) |
67 | |
{ |
68 | 2 | this.endpoint = endpoint; |
69 | 2 | } |
70 | |
|
71 | |
public Map getEndpointProperties() |
72 | |
{ |
73 | 0 | return endpointProperties; |
74 | |
} |
75 | |
|
76 | |
public void setEndpointProperties(Map endpointProperties) |
77 | |
{ |
78 | 0 | this.endpointProperties = endpointProperties; |
79 | 0 | } |
80 | |
|
81 | |
protected void doInit() throws JBIException |
82 | |
{ |
83 | |
try |
84 | |
{ |
85 | 2 | if (muleEndpoint == null) |
86 | |
{ |
87 | 2 | if (endpoint == null) |
88 | |
{ |
89 | 0 | throw new IllegalArgumentException("A Mule muleEndpoint must be set on this component"); |
90 | |
} |
91 | |
else |
92 | |
{ |
93 | 2 | muleEndpoint = new MuleEndpoint(endpoint, true); |
94 | |
} |
95 | |
} |
96 | |
|
97 | 2 | if (endpointProperties != null) |
98 | |
{ |
99 | 0 | muleEndpoint.getProperties().putAll(endpointProperties); |
100 | |
} |
101 | 2 | muleEndpoint.initialise(); |
102 | |
|
103 | |
} |
104 | 0 | catch (Exception e) |
105 | |
{ |
106 | 0 | throw new JBIException(e); |
107 | 2 | } |
108 | 2 | } |
109 | |
} |