1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.module.cxf.support; |
12 | |
|
13 | |
import org.mule.api.endpoint.EndpointNotFoundException; |
14 | |
|
15 | |
import java.io.IOException; |
16 | |
import java.util.List; |
17 | |
|
18 | |
import org.apache.cxf.endpoint.Endpoint; |
19 | |
import org.apache.cxf.interceptor.Interceptor; |
20 | |
import org.apache.cxf.message.Message; |
21 | |
import org.apache.cxf.phase.PhaseInterceptor; |
22 | |
import org.apache.cxf.service.model.EndpointInfo; |
23 | |
import org.apache.cxf.transport.ChainInitiationObserver; |
24 | |
import org.apache.cxf.transport.Destination; |
25 | |
import org.apache.cxf.transport.DestinationFactory; |
26 | |
import org.apache.cxf.transport.MessageObserver; |
27 | |
|
28 | 0 | public final class CxfUtils |
29 | |
{ |
30 | |
|
31 | |
@SuppressWarnings("unchecked") |
32 | |
public static void removeInterceptor(List<Interceptor<? extends Message>> inInterceptors, String name) { |
33 | |
|
34 | 0 | for (Interceptor<?> i : inInterceptors) { |
35 | 0 | if (i instanceof PhaseInterceptor) { |
36 | 0 | PhaseInterceptor<Message> p = (PhaseInterceptor<Message>)i; |
37 | |
|
38 | 0 | if (p.getId().equals(name)) { |
39 | 0 | inInterceptors.remove(p); |
40 | 0 | return; |
41 | |
} |
42 | 0 | } |
43 | |
} |
44 | 0 | } |
45 | |
|
46 | |
public static Endpoint getEndpoint(DestinationFactory df, String uri) |
47 | |
throws IOException, EndpointNotFoundException |
48 | |
{ |
49 | 0 | int idx = uri.indexOf('?'); |
50 | 0 | if (idx != -1) |
51 | |
{ |
52 | 0 | uri = uri.substring(0, idx); |
53 | |
} |
54 | |
|
55 | 0 | EndpointInfo ei = new EndpointInfo(); |
56 | 0 | ei.setAddress(uri); |
57 | |
|
58 | 0 | Destination d = df.getDestination(ei); |
59 | 0 | if (d.getMessageObserver() == null) |
60 | |
{ |
61 | |
|
62 | 0 | throw new EndpointNotFoundException(uri); |
63 | |
} |
64 | |
|
65 | 0 | MessageObserver mo = d.getMessageObserver(); |
66 | 0 | if (!(mo instanceof ChainInitiationObserver)) |
67 | |
{ |
68 | 0 | throw new EndpointNotFoundException(uri); |
69 | |
} |
70 | |
|
71 | 0 | ChainInitiationObserver co = (ChainInitiationObserver) mo; |
72 | 0 | return co.getEndpoint(); |
73 | |
} |
74 | |
|
75 | |
} |