1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.jms;
12
13 import org.mule.umo.endpoint.UMOImmutableEndpoint;
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 (UMOImmutableEndpoint endpoint)
75 {
76 return isTopic(endpoint, true);
77 }
78
79
80 public boolean isTopic (UMOImmutableEndpoint endpoint, boolean fallbackToEndpointProperties)
81 {
82 final String resourceInfo = endpoint.getEndpointURI().getResourceInfo();
83 boolean topic = JmsConstants.TOPIC_PROPERTY.equalsIgnoreCase(resourceInfo);
84 if (!topic && fallbackToEndpointProperties)
85 {
86 topic = MapUtils.getBooleanValue(endpoint.getProperties(), JmsConstants.TOPIC_PROPERTY, false);
87 }
88
89 return topic;
90 }
91
92
93
94
95
96
97
98
99
100 public boolean isTopic (Destination destination)
101 {
102 checkInvariants(destination);
103
104 return destination instanceof Topic;
105 }
106
107
108
109
110
111 protected void checkInvariants (final Destination destination)
112 {
113 if (destination instanceof Topic && destination instanceof Queue
114 && connector.getJmsSupport() instanceof Jms102bSupport)
115 {
116 logger.error(StringMessageUtils.getBoilerPlate(
117 "Destination implements both Queue and Topic "
118 + "while complying with JMS 1.0.2b specification. "
119 + "Please report your application server or JMS vendor name and version "
120 + "to dev<_at_>mule.codehaus.org or http://www.mulesource.org/jira"));
121 }
122 }
123 }