Source Code Cross Referenced for DefaultJmsTopicResolver.java in  » ESB » mule » org » mule » transport » jms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » mule » org.mule.transport.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DefaultJmsTopicResolver.java 10489 2008-01-23 17:53:38Z dfeist $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.transport.jms;
012:
013:        import org.mule.api.endpoint.ImmutableEndpoint;
014:        import org.mule.util.MapUtils;
015:        import org.mule.util.StringMessageUtils;
016:
017:        import javax.jms.Destination;
018:        import javax.jms.Queue;
019:        import javax.jms.Topic;
020:
021:        import org.apache.commons.logging.Log;
022:        import org.apache.commons.logging.LogFactory;
023:
024:        /**
025:         * A default implementation of the resolver uses endpoint's
026:         * resource info and Java's {@code instanceof} operator to
027:         * detect JMS topics.
028:         */
029:        public class DefaultJmsTopicResolver implements  JmsTopicResolver {
030:            /**
031:             * logger used by this class
032:             */
033:            protected static final Log logger = LogFactory
034:                    .getLog(DefaultJmsTopicResolver.class);
035:
036:            /**
037:             * Connector back-reference.
038:             */
039:            private JmsConnector connector;
040:
041:            /**
042:             * Create an instance of the resolver.
043:             * @param connector owning connector
044:             */
045:            public DefaultJmsTopicResolver(final JmsConnector connector) {
046:                this .connector = connector;
047:            }
048:
049:            /**
050:             * Getter for property 'connector'.
051:             *
052:             * @return Value for property 'connector'.
053:             */
054:            public JmsConnector getConnector() {
055:                return connector;
056:            }
057:
058:            /**
059:             * Will use endpoint's resource info to detect a topic,
060:             * as in {@code jms://topic:trade.PriceUpdatesTopic}. This
061:             * method will call {@link #isTopic(org.mule.api.endpoint.ImmutableEndpoint, boolean)}
062:             * with fallback flag set to <strong>true</false>.
063:             * <p/>
064:             * <strong>NOTE:</strong> When using topics, use the '.' (dot) symbol for subcontext separation,
065:             * as opposed to '/'. Otherwise the resource info may not get properly translated for the
066:             * topic endpoint due to the way URI's are parsed. 
067:             * @param endpoint endpoint to test
068:             * @return true if the endpoint has a topic configuration
069:             * @see #isTopic(org.mule.api.endpoint.ImmutableEndpoint, boolean) 
070:             */
071:            public boolean isTopic(ImmutableEndpoint endpoint) {
072:                return isTopic(endpoint, true);
073:            }
074:
075:            /** {@inheritDoc} */
076:            public boolean isTopic(ImmutableEndpoint endpoint,
077:                    boolean fallbackToEndpointProperties) {
078:                final String resourceInfo = endpoint.getEndpointURI()
079:                        .getResourceInfo();
080:                boolean topic = JmsConstants.TOPIC_PROPERTY
081:                        .equalsIgnoreCase(resourceInfo);
082:                if (!topic && fallbackToEndpointProperties) {
083:                    topic = MapUtils.getBooleanValue(endpoint.getProperties(),
084:                            JmsConstants.TOPIC_PROPERTY, false);
085:                }
086:
087:                return topic;
088:            }
089:
090:            /**
091:             * Will use an {@code instanceof} operator. Keep in mind
092:             * that may fail for JMS systems implementing both a
093:             * {@code javax.jms.Topic} and {@code javax.jms.Queue} in
094:             * a single destination class implementation.
095:             * @param destination a jms destination to test
096:             * @return {@code true} if the destination is a topic
097:             */
098:            public boolean isTopic(Destination destination) {
099:                checkInvariants(destination);
100:
101:                return destination instanceof  Topic;
102:            }
103:
104:            /**
105:             * Perform some sanity checks, will complain in the log.
106:             * @param destination destination to test
107:             */
108:            protected void checkInvariants(final Destination destination) {
109:                if (destination instanceof  Topic
110:                        && destination instanceof  Queue
111:                        && connector.getJmsSupport() instanceof  Jms102bSupport) {
112:                    logger
113:                            .error(StringMessageUtils
114:                                    .getBoilerPlate("Destination implements both Queue and Topic "
115:                                            + "while complying with JMS 1.0.2b specification. "
116:                                            + "Please report your application server or JMS vendor name and version "
117:                                            + "to dev<_at_>mule.codehaus.org or http://www.mulesource.org/jira"));
118:                }
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.