1
2
3
4
5
6
7
8
9
10 package org.mule.transport.jms;
11
12 import org.mule.endpoint.ResourceNameEndpointURIBuilder;
13 import org.mule.api.endpoint.MalformedEndpointException;
14
15 import java.util.Properties;
16 import java.net.URI;
17 import java.net.URISyntaxException;
18
19
20
21
22 public class JmsEndpointURIBuilder extends ResourceNameEndpointURIBuilder
23 {
24 @Override
25 protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException
26 {
27 super.setEndpoint(uri, props);
28
29 String oldUri = uri.toString();
30
31 String newUri = null;
32 if (uri.getScheme().equals("topic"))
33 {
34 props.setProperty(RESOURCE_INFO_PROPERTY, "topic");
35 newUri = uri.toString().replace("topic://", "jms://");
36 }
37 else if (uri.getScheme().equals("queue"))
38 {
39 newUri = uri.toString().replace("queue://", "jms://");
40 }
41 else if (oldUri.startsWith("jms://queue://"))
42 {
43 newUri = uri.toString().replace("jms://queue://", "jms://queue:");
44 }
45 else if (oldUri.startsWith("jms://temp-queue://"))
46 {
47 newUri = uri.toString().replace("jms://temp-queue://", "jms://temp-queue:");
48 }
49 else if (oldUri.startsWith("jms://topic://"))
50 {
51 props.setProperty(RESOURCE_INFO_PROPERTY, "topic");
52 newUri = uri.toString().replace("jms://topic://", "jms://topic:");
53 }
54
55 try
56 {
57 if (newUri != null)
58 {
59 rewriteURI(new URI(newUri));
60 }
61 }
62 catch (URISyntaxException e)
63 {
64 throw new MalformedEndpointException(e);
65 }
66 }
67 }