1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.cxf.support; |
12 | |
|
13 | |
import org.mule.api.endpoint.EndpointNotFoundException; |
14 | |
|
15 | |
import java.io.IOException; |
16 | |
|
17 | |
import org.apache.cxf.endpoint.Endpoint; |
18 | |
import org.apache.cxf.service.model.EndpointInfo; |
19 | |
import org.apache.cxf.transport.ChainInitiationObserver; |
20 | |
import org.apache.cxf.transport.Destination; |
21 | |
import org.apache.cxf.transport.DestinationFactory; |
22 | |
import org.apache.cxf.transport.MessageObserver; |
23 | |
|
24 | 0 | public final class CxfUtils |
25 | |
{ |
26 | |
|
27 | |
public static Endpoint getEndpoint(DestinationFactory df, String uri) |
28 | |
throws IOException, EndpointNotFoundException |
29 | |
{ |
30 | 0 | int idx = uri.indexOf('?'); |
31 | 0 | if (idx != -1) |
32 | |
{ |
33 | 0 | uri = uri.substring(0, idx); |
34 | |
} |
35 | |
|
36 | 0 | EndpointInfo ei = new EndpointInfo(); |
37 | 0 | ei.setAddress(uri); |
38 | |
|
39 | 0 | Destination d = df.getDestination(ei); |
40 | 0 | if (d.getMessageObserver() == null) |
41 | |
{ |
42 | |
|
43 | 0 | throw new EndpointNotFoundException(uri); |
44 | |
} |
45 | |
|
46 | 0 | MessageObserver mo = d.getMessageObserver(); |
47 | 0 | if (!(mo instanceof ChainInitiationObserver)) |
48 | |
{ |
49 | 0 | throw new EndpointNotFoundException(uri); |
50 | |
} |
51 | |
|
52 | 0 | ChainInitiationObserver co = (ChainInitiationObserver) mo; |
53 | 0 | return co.getEndpoint(); |
54 | |
} |
55 | |
|
56 | |
} |