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


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2005-2006 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: Benoit Pelletier
022:         * --------------------------------------------------------------------------
023:         * $Id: Director.java 7936 2006-01-25 17:00:15Z sauthieg $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.ant.cluster;
026:
027:        import java.io.File;
028:        import java.util.ArrayList;
029:        import java.util.Iterator;
030:        import java.util.List;
031:
032:        import org.objectweb.jonas.ant.jonasbase.JEcho;
033:        import org.objectweb.jonas.ant.jonasbase.JMkdir;
034:        import org.objectweb.jonas.ant.jonasbase.JTouch;
035:        import org.objectweb.jonas.ant.jonasbase.Tasks;
036:
037:        /**
038:         * Allow to configure the director Load Balancer for Apache
039:         * @author Benoit Pelletier
040:         */
041:        public class Director extends Tasks {
042:
043:            /**
044:             * Info for the logger
045:             */
046:            private static final String INFO = "[Director] ";
047:
048:            /**
049:             * Name of the director conf file
050:             */
051:            private static final String DIRECTOR_FILE = "enhydra_director.conf";
052:
053:            /**
054:             * Configuration file
055:             */
056:            private File configurationFile = null;
057:
058:            /**
059:             * Application Server list
060:             */
061:            private List appServerList = null;
062:
063:            /**
064:             * sticky session
065:             */
066:            private boolean stickySession = false;
067:
068:            /**
069:             * Default constructor
070:             */
071:            public Director() {
072:                super ();
073:                appServerList = new ArrayList();
074:            }
075:
076:            /**
077:             * Creation of the Director file
078:             * @param destDir destination directory
079:             */
080:            public void createFile(String destDir) {
081:                JMkdir mkdir = new JMkdir();
082:                mkdir.setDestDir(new File(destDir));
083:                addTask(mkdir);
084:
085:                JTouch touchWorker = new JTouch();
086:                configurationFile = new File(destDir + "/" + DIRECTOR_FILE);
087:                touchWorker.setDestDir(configurationFile);
088:                addTask(touchWorker);
089:
090:            }
091:
092:            /**
093:             * Add an application server
094:             * @param portNumber port number
095:             * @param lbFactor load balancing factor
096:             */
097:            public void addAppServer(String portNumber, String lbFactor) {
098:                AppServer appServer = new AppServer();
099:                appServer.setPortNumber(portNumber);
100:                appServer.setLbFactor(lbFactor);
101:                appServerList.add(appServer);
102:            }
103:
104:            /**
105:             * get app server definition
106:             * @param appServer application server to define
107:             * @return definition of the application server
108:             */
109:            private String getAppServerDef(AppServer appServer) {
110:                String appServerDef = "\n"
111:                        + "      <AppServer host= \"localhost\" port=\""
112:                        + appServer.getPortNumber() + "\" weight=\""
113:                        + appServer.getLbFactor() + "\" />";
114:                return appServerDef;
115:            }
116:
117:            /**
118:             * creation of the AppServer file
119:             */
120:            private void flushAppServerFile() {
121:                JEcho echo = new JEcho();
122:                echo.setDestDir(configurationFile);
123:                String appServersDefs = "";
124:                int ind = 1;
125:                for (Iterator it = this .appServerList.iterator(); it.hasNext();) {
126:                    AppServer appServer = (AppServer) it.next();
127:                    appServer.setName("appServer" + ind);
128:                    appServersDefs = appServersDefs
129:                            + getAppServerDef(appServer);
130:                    ind++;
131:                }
132:
133:                String contentFile = "\n"
134:                        + "<?xml version=\"1.0\"?>"
135:                        + "\n"
136:                        + "<!DOCTYPE EnhydraDirectorConfig SYSTEM \"EnhydraDirectorConfig.dtd\">"
137:                        + "\n" + "<EnhydraDirectorConfig>" + "\n"
138:                        + "   <Application prefix=\"/sampleCluster2/\">"
139:                        + appServersDefs + "\n" + "   </Application>" + "\n"
140:                        + "   <Status prefix=\"/status\">" + "\n"
141:                        + "      <Restrict server=\"127.0.0.1\" />" + "\n"
142:                        + "      <Restrict client=\"127.0.0.1\" />" + "\n"
143:                        + "   </Status>" + "\n" + "</EnhydraDirectorConfig>";
144:
145:                echo.setMessage(contentFile);
146:                echo.setLogInfo(INFO + "Flushing AppServer Configuration in '"
147:                        + configurationFile + "'");
148:                addTask(echo);
149:            }
150:
151:            /**
152:             * Generation of the config files
153:             */
154:            public void flushFile() {
155:                flushAppServerFile();
156:            }
157:
158:            /**
159:             * Set sticky Session
160:             * @param stickySession to set
161:             **/
162:            public void setStickySession(boolean stickySession) {
163:                this .stickySession = stickySession;
164:            }
165:
166:            /**
167:             * Define an inner class for application servers
168:             * @author Benoit Pelletier
169:             */
170:            public class AppServer {
171:
172:                /**
173:                 * port number
174:                 */
175:                private String portNumber = null;
176:
177:                /**
178:                 * load balancing factor
179:                 */
180:                private String lbFactor = null;
181:
182:                /**
183:                 * name
184:                 */
185:                private String name = null;
186:
187:                /**
188:                 * get port number
189:                 * @return port number
190:                 */
191:                public String getPortNumber() {
192:                    return portNumber;
193:                }
194:
195:                /**
196:                 * set port number
197:                 * @param portNumber port number
198:                 */
199:                public void setPortNumber(String portNumber) {
200:                    this .portNumber = portNumber;
201:                }
202:
203:                /**
204:                 * get load balancing factor
205:                 * @return load balancing factor
206:                 */
207:                public String getLbFactor() {
208:                    return lbFactor;
209:                }
210:
211:                /**
212:                 * set load balancing factor
213:                 * @param lbFactor load balancing factor
214:                 */
215:                public void setLbFactor(String lbFactor) {
216:                    this .lbFactor = lbFactor;
217:                }
218:
219:                /**
220:                 * get name
221:                 * @return name
222:                 */
223:                public String getName() {
224:                    return name;
225:                }
226:
227:                /**
228:                 * set name
229:                 * @param name name to set
230:                 */
231:                public void setName(String name) {
232:                    this.name = name;
233:                }
234:            }
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.