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