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 | |
|
27 | |
|
28 | |
|
29 | |
public abstract class AbstractEndpointComponent extends AbstractJbiComponent |
30 | |
{ |
31 | |
|
32 | |
protected UMOEndpoint muleEndpoint; |
33 | |
|
34 | |
protected String endpoint; |
35 | |
|
36 | |
protected Map endpointProperties; |
37 | |
|
38 | |
protected AbstractEndpointComponent() |
39 | 0 | { |
40 | 0 | if (!MuleManager.isInstanciated()) |
41 | |
{ |
42 | 0 | MuleManager.getConfiguration().setEmbedded(true); |
43 | |
try |
44 | |
{ |
45 | 0 | MuleManager.getInstance().start(); |
46 | |
} |
47 | 0 | catch (UMOException e) |
48 | |
{ |
49 | 0 | e.printStackTrace(); |
50 | 0 | } |
51 | |
} |
52 | 0 | } |
53 | |
|
54 | |
public UMOEndpoint getMuleEndpoint() |
55 | |
{ |
56 | 0 | return muleEndpoint; |
57 | |
} |
58 | |
|
59 | |
public void setMuleEndpoint(UMOEndpoint muleEndpoint) |
60 | |
{ |
61 | 0 | this.muleEndpoint = muleEndpoint; |
62 | 0 | } |
63 | |
|
64 | |
public String getEndpoint() |
65 | |
{ |
66 | 0 | return endpoint; |
67 | |
} |
68 | |
|
69 | |
public void setEndpoint(String endpoint) |
70 | |
{ |
71 | 0 | this.endpoint = endpoint; |
72 | 0 | } |
73 | |
|
74 | |
public Map getEndpointProperties() |
75 | |
{ |
76 | 0 | return endpointProperties; |
77 | |
} |
78 | |
|
79 | |
public void setEndpointProperties(Map endpointProperties) |
80 | |
{ |
81 | 0 | this.endpointProperties = endpointProperties; |
82 | 0 | } |
83 | |
|
84 | |
protected void doInit() throws JBIException |
85 | |
{ |
86 | |
try |
87 | |
{ |
88 | 0 | if (muleEndpoint == null) |
89 | |
{ |
90 | 0 | if (endpoint == null) |
91 | |
{ |
92 | 0 | throw new IllegalArgumentException("A Mule muleEndpoint must be set on this component"); |
93 | |
} |
94 | |
else |
95 | |
{ |
96 | 0 | muleEndpoint = new MuleEndpoint(endpoint, true); |
97 | |
} |
98 | |
} |
99 | |
|
100 | 0 | if (endpointProperties != null) |
101 | |
{ |
102 | 0 | muleEndpoint.getProperties().putAll(endpointProperties); |
103 | |
} |
104 | 0 | muleEndpoint.initialise(); |
105 | |
|
106 | |
} |
107 | 0 | catch (Exception e) |
108 | |
{ |
109 | 0 | throw new JBIException(e); |
110 | 0 | } |
111 | 0 | } |
112 | |
} |