1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl.endpoint;
12
13 import org.mule.umo.endpoint.MalformedEndpointException;
14 import org.mule.util.StringUtils;
15
16 import java.net.URI;
17 import java.util.Properties;
18
19
20
21
22
23
24 public class ResourceNameEndpointBuilder extends AbstractEndpointBuilder
25 {
26 public static final String RESOURCE_INFO_PROPERTY = "resourceInfo";
27
28 protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException
29 {
30 address = StringUtils.EMPTY;
31 if (uri.getHost() != null && !"localhost".equals(uri.getHost()))
32 {
33 address = uri.getHost();
34 }
35
36 if (uri.getPath() != null && uri.getPath().length() != 0)
37 {
38 if (address.length() > 0)
39 {
40 address += "/";
41 }
42 address += uri.getPath().substring(1);
43 }
44 else if (uri.getAuthority() != null && !uri.getAuthority().equals(address))
45 {
46 address += uri.getAuthority();
47 }
48
49 int y = address.indexOf("@");
50 if (y > -1)
51 {
52 this.userInfo = address.substring(0, y);
53 }
54
55 y++;
56
57 int x = address.indexOf(":", y);
58 if (x > -1)
59 {
60 String resourceInfo = address.substring(y, x);
61 props.setProperty("resourceInfo", resourceInfo);
62 address = address.substring(x + 1);
63 }
64 }
65 }