1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jms;
12
13 import org.mule.api.endpoint.ImmutableEndpoint;
14 import org.mule.util.MapUtils;
15 import org.mule.util.StringMessageUtils;
16
17 import javax.jms.Destination;
18 import javax.jms.Queue;
19 import javax.jms.Topic;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24
25
26
27
28
29 public class DefaultJmsTopicResolver implements JmsTopicResolver
30 {
31
32
33
34 protected static final Log logger = LogFactory.getLog(DefaultJmsTopicResolver.class);
35
36
37
38
39 private JmsConnector connector;
40
41
42
43
44
45 public DefaultJmsTopicResolver (final JmsConnector connector)
46 {
47 this.connector = connector;
48 }
49
50
51
52
53
54
55
56 public JmsConnector getConnector ()
57 {
58 return connector;
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 public boolean isTopic (ImmutableEndpoint endpoint)
75 {
76 return isTopic(endpoint, true);
77 }
78
79
80 public boolean isTopic (ImmutableEndpoint endpoint, boolean fallbackToEndpointProperties)
81 {
82 String resourceInfo = endpoint.getEndpointURI().getResourceInfo();
83
84 boolean topic = JmsConstants.TOPIC_PROPERTY.equalsIgnoreCase(resourceInfo) ||
85 endpoint.getEndpointURI().toString().contains(JmsConstants.TOPIC_PROPERTY + ":");
86 if (!topic && fallbackToEndpointProperties)
87 {
88 topic = MapUtils.getBooleanValue(endpoint.getProperties(), JmsConstants.TOPIC_PROPERTY, false);
89 }
90
91 return topic;
92 }
93
94
95
96
97
98
99
100
101
102 public boolean isTopic (Destination destination)
103 {
104 checkInvariants(destination);
105
106 return destination instanceof Topic;
107 }
108
109
110
111
112
113 protected void checkInvariants (final Destination destination)
114 {
115 if (destination instanceof Topic && destination instanceof Queue
116 && connector.getJmsSupport() instanceof Jms102bSupport)
117 {
118 logger.error(StringMessageUtils.getBoilerPlate(
119 "Destination implements both Queue and Topic "
120 + "while complying with JMS 1.0.2b specification. "
121 + "Please report your application server or JMS vendor name and version "
122 + "to dev<_at_>mule.codehaus.org or http://www.mulesoft.org/jira"));
123 }
124 }
125 }