Source Code Cross Referenced for DefaultReplyToHandler.java in  » ESB » mule » org » mule » transport » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DefaultReplyToHandler.java 11373 2008-03-15 05:03:10Z 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;
012:
013:        import org.mule.DefaultMuleEvent;
014:        import org.mule.RegistryContext;
015:        import org.mule.api.MuleEvent;
016:        import org.mule.api.MuleException;
017:        import org.mule.api.MuleMessage;
018:        import org.mule.api.config.MuleProperties;
019:        import org.mule.api.endpoint.EndpointBuilder;
020:        import org.mule.api.endpoint.EndpointFactory;
021:        import org.mule.api.endpoint.OutboundEndpoint;
022:        import org.mule.api.transport.DispatchException;
023:        import org.mule.api.transport.ReplyToHandler;
024:        import org.mule.config.i18n.CoreMessages;
025:
026:        import java.util.HashMap;
027:        import java.util.List;
028:        import java.util.Map;
029:
030:        import org.apache.commons.logging.Log;
031:        import org.apache.commons.logging.LogFactory;
032:
033:        /**
034:         * <code>DefaultReplyToHandler</code> is responsible for processing a message
035:         * replyTo header.
036:         */
037:
038:        public class DefaultReplyToHandler implements  ReplyToHandler {
039:            /**
040:             * logger used by this class
041:             */
042:            protected static final Log logger = LogFactory
043:                    .getLog(DefaultReplyToHandler.class);
044:
045:            private volatile List transformers;
046:            private final Map endpointCache = new HashMap();
047:
048:            public DefaultReplyToHandler(List transformers) {
049:                this .transformers = transformers;
050:            }
051:
052:            public void processReplyTo(MuleEvent event,
053:                    MuleMessage returnMessage, Object replyTo)
054:                    throws MuleException {
055:                if (logger.isDebugEnabled()) {
056:                    logger.debug("sending reply to: "
057:                            + returnMessage.getReplyTo());
058:                }
059:
060:                String replyToEndpoint = replyTo.toString();
061:
062:                // get the endpoint for this url
063:                OutboundEndpoint endpoint = getEndpoint(event, replyToEndpoint);
064:
065:                // make sure remove the replyTo property as not cause a a forever
066:                // replyto loop
067:                returnMessage
068:                        .removeProperty(MuleProperties.MULE_REPLY_TO_PROPERTY);
069:
070:                // Create the replyTo event asynchronous
071:                MuleEvent replyToEvent = new DefaultMuleEvent(returnMessage,
072:                        endpoint, event.getSession(), false);
073:
074:                // dispatch the event
075:                try {
076:                    endpoint.dispatch(replyToEvent);
077:                    if (logger.isInfoEnabled()) {
078:                        logger.info("reply to sent: " + endpoint);
079:                    }
080:                    event.getService().getComponent().getStatistics()
081:                            .incSentReplyToEvent();
082:                } catch (Exception e) {
083:                    throw new DispatchException(CoreMessages
084:                            .failedToDispatchToReplyto(endpoint), replyToEvent
085:                            .getMessage(), replyToEvent.getEndpoint(), e);
086:                }
087:
088:            }
089:
090:            protected synchronized OutboundEndpoint getEndpoint(
091:                    MuleEvent event, String endpointUri) throws MuleException {
092:                OutboundEndpoint endpoint = (OutboundEndpoint) endpointCache
093:                        .get(endpointUri);
094:                if (endpoint == null) {
095:                    EndpointFactory endpointFactory = RegistryContext
096:                            .getRegistry().lookupEndpointFactory();
097:                    EndpointBuilder endpointBuilder = endpointFactory
098:                            .getEndpointBuilder(endpointUri);
099:                    if (transformers == null) {
100:                        endpointBuilder.setTransformers(event.getEndpoint()
101:                                .getResponseTransformers());
102:                    }
103:                    endpoint = endpointFactory
104:                            .getOutboundEndpoint(endpointBuilder);
105:                    endpointCache.put(endpointUri, endpoint);
106:                }
107:                return endpoint;
108:            }
109:
110:            public List getTransformers() {
111:                return transformers;
112:            }
113:
114:            public void setTransformers(List transformers) {
115:                this.transformers = transformers;
116:            }
117:
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.