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