Source Code Cross Referenced for DiscoveryClient.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » discovery » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.discovery 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or modify it
007:         * under the terms of the GNU Lesser General Public License as published by the
008:         * Free Software Foundation; either version 2.1 of the License, or any later
009:         * version.
010:         *
011:         * This library is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
014:         * for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public License
017:         * along with this library; if not, write to the Free Software Foundation,
018:         * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
019:         *
020:         */package org.objectweb.jonas.discovery;
021:
022:        import java.net.UnknownHostException;
023:
024:        import javax.management.MBeanRegistration;
025:        import javax.management.MBeanServer;
026:        import javax.management.ObjectName;
027:
028:        import org.objectweb.jonas.common.Log;
029:        import org.objectweb.jonas.common.NetUtils;
030:
031:        import org.objectweb.util.monolog.api.BasicLevel;
032:        import org.objectweb.util.monolog.api.Logger;
033:
034:        /**
035:         * The DiscoveryClient is in charge of sending discovery messages on the LAN to
036:         * discover resources. It waits during a Timeout period of time for the
037:         * discovery answers (discovery messages containing a response).
038:         *
039:         * @author <a href="mailto:Takoua.Abdellatif@inria.fr">Takoua Abdellatif </a>
040:         * @version 1.0
041:         */
042:        public class DiscoveryClient implements  DiscoveryClientMBean,
043:                MBeanRegistration {
044:            /**
045:             * Source port of the sent discovery message
046:             */
047:            private int sourcePort;
048:            /**
049:             * Source IP of the sent discovery message (address of the local host)
050:             */
051:            private String sourceIp;
052:            /**
053:             * My ObjectName
054:             */
055:            private ObjectName myOn;
056:            /**
057:             * Runnable object that sends a discovery message and than listens for
058:             * response of servers in the management domain
059:             */
060:            private DiscoveryClientListener dcl = null;
061:            /**
062:             * Thread associated to dcl
063:             */
064:            private Thread discoveryClientListener = null;
065:            private int ttl = 1;
066:            /**
067:             * Time to wait for a response
068:             */
069:            private int timeout = 1000;
070:            private int listeningPort;
071:            private String listeningIp;
072:            private static Logger logger = Log
073:                    .getLogger(Log.JONAS_DISCOVERY_PREFIX);
074:
075:            public DiscoveryClient(int listeningPort, String listeningIP,
076:                    int sourcePort) {
077:                this .listeningIp = listeningIP;
078:                this .listeningPort = listeningPort;
079:                this .sourcePort = sourcePort;
080:            }
081:
082:            /**
083:             *
084:             * @see org.objectweb.jonas.server.discovery.DiscoveryClientMBean#getTimeOut()
085:             */
086:            public int getTimeout() {
087:                return timeout;
088:            }
089:
090:            /**
091:             *
092:             * @see org.objectweb.jonas.server.discovery.DiscoveryClientMBean#setTimeout(int)
093:             */
094:            public void setTimeout(int timeout) {
095:                this .timeout = timeout;
096:            }
097:
098:            /**
099:             *
100:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#getListeningPort()
101:             */
102:            public int getListeningPort() {
103:                return listeningPort;
104:            }
105:
106:            /**
107:             *
108:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#setListeningPort(int)
109:             */
110:            public void setListeningPort(int listeningPort) {
111:                this .listeningPort = listeningPort;
112:
113:            }
114:
115:            /**
116:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#getListeningIp()
117:             */
118:            public String getListeningIp() {
119:                return listeningIp;
120:            }
121:
122:            /**
123:             *
124:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#setListeningIP(java.lang.String)
125:             */
126:            public void setListeningIp(String ipAddress) {
127:                this .listeningIp = ipAddress;
128:
129:            }
130:
131:            /**
132:             * @see org.objectweb.jonas.server.discovery.DiscoveryClientMBean#getSourcePort()
133:             */
134:            public int getSourcePort() {
135:                return sourcePort;
136:            }
137:
138:            /**
139:             * @see org.objectweb.jonas.server.discovery.DiscoveryClientMBean#setSourcePort(int)
140:             */
141:            public void setSourcePort(int sourcePort) {
142:                this .sourcePort = sourcePort;
143:
144:            }
145:
146:            /**
147:             * @see org.objectweb.jonas.server.discovery.DiscoveryClientMBean#getSourceIp()
148:             */
149:            public String getSourceIp() {
150:                return sourceIp;
151:            }
152:
153:            /**
154:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#getTimeToLive()
155:             */
156:            public int getTimeToLive() {
157:                return ttl;
158:            }
159:
160:            /**
161:             * @see org.objectweb.jonas.server.discovery.DiscoveryClientMBean#setSourceIp(java.lang.String)
162:             */
163:            public void setSourceIp(String sourceIp) {
164:                this .sourceIp = sourceIp;
165:
166:            }
167:
168:            /**
169:             *
170:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#setTimeToLive(int)
171:             */
172:            public void setTimeToLive(int ttl) {
173:                this .ttl = ttl;
174:
175:            }
176:
177:            /**
178:             *
179:             * @see org.objectweb.jonas.server.discovery.EnrollerMBean#start()
180:             */
181:            public void start() {
182:                // create the thread in charge of sending the discovery message and waiting
183:                // for the responses
184:                // creates an instance of the DiscoveryClientListener class
185:                try {
186:                    this .setSourceIp(NetUtils.getLocalAddress());
187:                } catch (UnknownHostException e) {
188:                    logger.log(BasicLevel.ERROR,
189:                            "Unable to create a localhost.", e);
190:                }
191:                dcl = new DiscoveryClientListener(this );
192:
193:                if (discoveryClientListener == null) {
194:                    discoveryClientListener = new Thread(dcl,
195:                            "discoveryClientListener");
196:                }
197:                discoveryClientListener.start();
198:
199:            }
200:
201:            public void stop() {
202:
203:            }
204:
205:            /**
206:             *
207:             * @see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer,
208:             *      javax.management.ObjectName)
209:             */
210:            public ObjectName preRegister(MBeanServer mbeanServer, ObjectName on) {
211:                this .myOn = on;
212:                return myOn;
213:            }
214:
215:            /**
216:             *
217:             * @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)
218:             */
219:            public void postRegister(Boolean arg0) {
220:                start();
221:            }
222:
223:            /**
224:             *
225:             * @see javax.management.MBeanRegistration#preDeregister()
226:             */
227:            public void preDeregister() throws Exception {
228:                dcl.stop();
229:
230:            }
231:
232:            /**
233:             *
234:             * @see javax.management.MBeanRegistration#postDeregister()
235:             */
236:            public void postDeregister() {
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.