1
2
3
4
5
6
7
8
9
10 package org.mule.endpoint;
11
12 import org.mule.api.MuleContext;
13 import org.mule.api.endpoint.EndpointException;
14 import org.mule.api.endpoint.EndpointURI;
15 import org.mule.api.endpoint.ImmutableEndpoint;
16 import org.mule.api.transport.Connector;
17 import org.mule.transport.AbstractConnector;
18 import org.mule.util.BeanUtils;
19
20 import java.util.Map;
21
22
23
24
25
26 public abstract class AbstractMetaEndpointBuilder extends EndpointURIEndpointBuilder
27 {
28 protected AbstractMetaEndpointBuilder()
29 {
30 }
31
32 protected AbstractMetaEndpointBuilder(EndpointURIEndpointBuilder global)
33 throws EndpointException
34 {
35 super(global);
36 }
37
38 protected AbstractMetaEndpointBuilder(URIBuilder builder)
39 {
40 super(builder);
41 }
42
43 protected AbstractMetaEndpointBuilder(String address, MuleContext muleContext)
44 {
45 super(address, muleContext);
46 }
47
48 protected AbstractMetaEndpointBuilder(EndpointURI endpointURI)
49 {
50 super(endpointURI);
51 }
52
53 protected AbstractMetaEndpointBuilder(ImmutableEndpoint source)
54 {
55 super(source);
56 }
57
58 @Override
59 public void setProperties(Map<Object, Object> properties)
60 {
61
62 for (Map.Entry<Object, Object> entry : properties.entrySet())
63 {
64 try
65 {
66 BeanUtils.setProperty(this, entry.getKey().toString(), entry.getValue());
67 }
68 catch (Exception e)
69 {
70
71 }
72 }
73 properties.remove("connector");
74 super.setProperties(properties);
75 }
76
77 @Override
78 protected String getScheme()
79 {
80 return uriBuilder.getEndpoint().getScheme();
81 }
82
83 public static String getEndpointAddressWithoutMetaScheme(String string)
84 {
85 int idx = string.indexOf(':');
86 if (idx != -1)
87 {
88 string = string.substring(idx+1);
89 }
90 return string;
91 }
92
93 @Override
94 protected Connector getConnector() throws EndpointException
95 {
96 AbstractConnector c = (AbstractConnector) super.getConnector();
97 EndpointURI endpointURI = uriBuilder.getEndpoint();
98 if(!c.supportsProtocol(endpointURI.getFullScheme()))
99 {
100 c.registerSupportedMetaProtocol(endpointURI.getSchemeMetaInfo());
101 }
102 return c;
103 }
104 }