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


001:        /*
002:         * $Id: UdpConnector.java 10961 2008-02-22 19:01:02Z 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.udp;
012:
013:        import org.mule.api.MuleException;
014:        import org.mule.api.endpoint.ImmutableEndpoint;
015:        import org.mule.api.endpoint.InboundEndpoint;
016:        import org.mule.api.lifecycle.InitialisationException;
017:        import org.mule.api.service.Service;
018:        import org.mule.transport.AbstractConnector;
019:
020:        import java.net.DatagramSocket;
021:
022:        import org.apache.commons.pool.impl.GenericKeyedObjectPool;
023:
024:        /**
025:         * <code>UdpConnector</code> can send and receive Mule events as Datagram packets.
026:         */
027:        public class UdpConnector extends AbstractConnector {
028:
029:            public static final String UDP = "udp";
030:            public static final int DEFAULT_SOCKET_TIMEOUT = INT_VALUE_NOT_SET;
031:            public static final int DEFAULT_BUFFER_SIZE = 1024 * 16;
032:            public static final String KEEP_SEND_SOCKET_OPEN_PROPERTY = "keepSendSocketOpen";
033:
034:            protected int sendTimeout = DEFAULT_SOCKET_TIMEOUT;
035:            protected int receiveTimeout = DEFAULT_SOCKET_TIMEOUT;
036:            protected int sendBufferSize = DEFAULT_BUFFER_SIZE;
037:            protected int receiveBufferSize = DEFAULT_BUFFER_SIZE;
038:            protected boolean keepSendSocketOpen = true;
039:            protected boolean broadcast;
040:            protected GenericKeyedObjectPool dispatcherSocketsPool = new GenericKeyedObjectPool();
041:
042:            protected void doInitialise() throws InitialisationException {
043:                dispatcherSocketsPool.setFactory(new UdpSocketFactory());
044:                dispatcherSocketsPool.setTestOnBorrow(true);
045:                dispatcherSocketsPool.setTestOnReturn(true);
046:                //There should only be one pooled instance per socket (key)
047:                dispatcherSocketsPool.setMaxActive(1);
048:            }
049:
050:            protected void doDispose() {
051:                try {
052:                    dispatcherSocketsPool.close();
053:                } catch (Exception e) {
054:                    logger.warn("Failed to close dispatcher socket pool: "
055:                            + e.getMessage());
056:                }
057:            }
058:
059:            protected void doConnect() throws Exception {
060:                // template method
061:            }
062:
063:            protected void doDisconnect() throws Exception {
064:                dispatcherSocketsPool.clear();
065:            }
066:
067:            protected void doStart() throws MuleException {
068:                // template method
069:            }
070:
071:            protected void doStop() throws MuleException {
072:                // template method
073:            }
074:
075:            public String getProtocol() {
076:                return UDP;
077:            }
078:
079:            public int getSendTimeout() {
080:                return this .sendTimeout;
081:            }
082:
083:            public void setSendTimeout(int timeout) {
084:                if (timeout < 0) {
085:                    timeout = DEFAULT_SOCKET_TIMEOUT;
086:                }
087:                this .sendTimeout = timeout;
088:            }
089:
090:            public int getReceiveTimeout() {
091:                return receiveTimeout;
092:            }
093:
094:            public void setReceiveTimeout(int timeout) {
095:                if (timeout < 0) {
096:                    timeout = DEFAULT_SOCKET_TIMEOUT;
097:                }
098:                this .receiveTimeout = timeout;
099:            }
100:
101:            public int getSendBufferSize() {
102:                return sendBufferSize;
103:            }
104:
105:            public void setSendBufferSize(int sendBufferSize) {
106:                if (sendBufferSize < 1) {
107:                    sendBufferSize = DEFAULT_BUFFER_SIZE;
108:                }
109:                this .sendBufferSize = sendBufferSize;
110:            }
111:
112:            public int getReceiveBufferSize() {
113:                return receiveBufferSize;
114:            }
115:
116:            public void setReceiveBufferSize(int receiveBufferSize) {
117:                if (receiveBufferSize < 1) {
118:                    receiveBufferSize = DEFAULT_BUFFER_SIZE;
119:                }
120:                this .receiveBufferSize = receiveBufferSize;
121:            }
122:
123:            public boolean isBroadcast() {
124:                return broadcast;
125:            }
126:
127:            public void setBroadcast(boolean broadcast) {
128:                this .broadcast = broadcast;
129:            }
130:
131:            public boolean isKeepSendSocketOpen() {
132:                return keepSendSocketOpen;
133:            }
134:
135:            public void setKeepSendSocketOpen(boolean keepSendSocketOpen) {
136:                this .keepSendSocketOpen = keepSendSocketOpen;
137:            }
138:
139:            /**
140:             * Lookup a socket in the list of dispatcher sockets but don't create a new
141:             * socket
142:             *
143:             * @param endpoint
144:             * @return
145:             */
146:            DatagramSocket getSocket(ImmutableEndpoint endpoint)
147:                    throws Exception {
148:                return (DatagramSocket) dispatcherSocketsPool
149:                        .borrowObject(endpoint);
150:            }
151:
152:            void releaseSocket(DatagramSocket socket, ImmutableEndpoint endpoint)
153:                    throws Exception {
154:                dispatcherSocketsPool.returnObject(endpoint, socket);
155:            }
156:
157:            protected Object getReceiverKey(Service service,
158:                    InboundEndpoint endpoint) {
159:                return endpoint.getEndpointURI().getAddress() + "/"
160:                        + service.getName();
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.