Source Code Cross Referenced for Carol.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » ant » jonasbase » 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.jonasbase 
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
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: Florent BENOIT
022:         * --------------------------------------------------------------------------
023:         * $Id: Carol.java 7895 2006-01-18 06:53:55Z pelletib $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.ant.jonasbase;
026:
027:        import org.objectweb.jonas.ant.JOnASBaseTask;
028:
029:        /**
030:         * Defines properties for carol.properties
031:         * @author Florent Benoit
032:         */
033:        public class Carol extends Tasks {
034:
035:            /**
036:             * Info for the logger
037:             */
038:            private static final String INFO = "[Carol] ";
039:
040:            /**
041:             * Protocols property
042:             */
043:            private static final String PROTOCOLS_PROPERTY = "carol.protocols";
044:
045:            /**
046:             * Default protocols
047:             */
048:            private static final String DEFAULT_PROTOCOLS = "jrmp";
049:
050:            /**
051:             * Default Host
052:             */
053:            private static final String DEFAULT_HOST = "localhost";
054:
055:            /**
056:             * Default protocol header
057:             */
058:            private static final String PROTOCOL_HEADER = "://";
059:
060:            /**
061:             * Default jrmp port number
062:             */
063:            private static final String DEFAULT_JRMP_PORT = "1099";
064:
065:            /**
066:             * Default jeremie port number
067:             */
068:            private static final String DEFAULT_JEREMIE_PORT = "2000";
069:
070:            /**
071:             * Default iiop port number
072:             */
073:            private static final String DEFAULT_IIOP_PORT = "2001";
074:
075:            /**
076:             * Default cmi port number
077:             */
078:            private static final String DEFAULT_CMI_PORT = "2002";
079:
080:            /**
081:             * Default irmi port number
082:             */
083:            private static final String DEFAULT_IRMI_PORT = "1098";
084:
085:            /**
086:             * Default cmi mcast addr
087:             */
088:            private static final String DEFAULT_CMI_MCASTADDR = "224.0.0.35";
089:
090:            /**
091:             * Default cmi mcast port
092:             */
093:            private static final String DEFAULT_CMI_MCASTPORT = "35467";
094:
095:            /**
096:             * Optimization
097:             */
098:            private static final String OPTIMIZATION_PROPERTY = "carol.jvm.rmi.local.call=";
099:
100:            /**
101:             * Optimization (off)
102:             */
103:            private static final String OPTIMIZATION_OFF = OPTIMIZATION_PROPERTY
104:                    + "false";
105:
106:            /**
107:             * Optimization (on)
108:             */
109:            private static final String OPTIMIZATION_ON = OPTIMIZATION_PROPERTY
110:                    + "true";
111:
112:            /**
113:             * CMI mcast addr attribut
114:             */
115:            private static final String CMI_MCASTADDR_ATTR = "mcast_addr";
116:
117:            /**
118:             * CMI mcast port attribut
119:             */
120:            private static final String CMI_MCASTPORT_ATTR = "mcast_port";
121:
122:            /**
123:             * Default constructor
124:             */
125:            public Carol() {
126:                super ();
127:            }
128:
129:            /**
130:             * Set the port for a protocol
131:             * @param protocolName name of the protocol
132:             * @param hostName for the protocol
133:             * @param portNumber port for a given protocol
134:             * @param protocolUrl URL for the protocol (if any)
135:             * @param token of the protocol to replace
136:             */
137:            private void setURL(String protocolName, String hostName,
138:                    String portNumber, String protocolUrl, String token) {
139:                String url = null;
140:
141:                // Token to replace
142:                token = protocolName + PROTOCOL_HEADER + DEFAULT_HOST + ":"
143:                        + token;
144:
145:                if (protocolUrl != null) {
146:                    url = protocolUrl;
147:                } else {
148:                    url = protocolName + PROTOCOL_HEADER + hostName + ":"
149:                            + portNumber;
150:                }
151:                JReplace propertyReplace = new JReplace();
152:                propertyReplace.setLogInfo(INFO + "Setting URL for protocol '"
153:                        + protocolName + "' to : " + url);
154:                propertyReplace
155:                        .setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE);
156:                propertyReplace.setToken(token);
157:                propertyReplace.setValue(url);
158:                addTask(propertyReplace);
159:            }
160:
161:            /**
162:             * Set the port for JRMP
163:             * @param portNumber port for JRMP
164:             */
165:            public void setJrmpPort(String portNumber) {
166:                setURL("rmi", DEFAULT_HOST, portNumber, null, DEFAULT_JRMP_PORT);
167:            }
168:
169:            /**
170:             * Set the port for JEREMIE
171:             * @param portNumber port for JEREMIE
172:             */
173:            public void setJeremiePort(String portNumber) {
174:                setURL("jrmi", DEFAULT_HOST, portNumber, null,
175:                        DEFAULT_JEREMIE_PORT);
176:            }
177:
178:            /**
179:             * Set the port for IIOP
180:             * @param portNumber port for IIOP
181:             */
182:            public void setIiopPort(String portNumber) {
183:                setURL("iiop", DEFAULT_HOST, portNumber, null,
184:                        DEFAULT_IIOP_PORT);
185:            }
186:
187:            /**
188:             * Set the port for CMI
189:             * @param portNumber port for CMI
190:             */
191:            public void setCmiPort(String portNumber) {
192:                setURL("cmi", DEFAULT_HOST, portNumber, null, DEFAULT_CMI_PORT);
193:            }
194:
195:            /**
196:             * Set the port for IRMI
197:             * @param portNumber port for IRMI
198:             */
199:            public void setIrmiPort(String portNumber) {
200:                setURL("rmi", DEFAULT_HOST, portNumber, null, DEFAULT_IRMI_PORT);
201:            }
202:
203:            /**
204:             * Set mcastAddr for CMI
205:             * @param mcastAddr multicast address
206:             */
207:            public void setCmiMcastAddr(String mcastAddr) {
208:
209:                // Token to replace the multicast addr
210:                String token = CMI_MCASTADDR_ATTR + "=" + "\""
211:                        + DEFAULT_CMI_MCASTADDR + "\"";
212:                String value = CMI_MCASTADDR_ATTR + "=" + "\"" + mcastAddr
213:                        + "\"";
214:                JReplace mcastAddrReplace = new JReplace();
215:                mcastAddrReplace.setLogInfo(INFO
216:                        + "Setting mcastaddr for protocol cmi");
217:                mcastAddrReplace
218:                        .setConfigurationFile(JOnASBaseTask.JGROUPS_CMI_CONF_FILE);
219:                mcastAddrReplace.setToken(token);
220:                mcastAddrReplace.setValue(value);
221:                addTask(mcastAddrReplace);
222:            }
223:
224:            /**
225:             * Set mcastPort for CMI
226:             * @param mcastPort multicast port
227:             */
228:            public void setCmiMcastPort(String mcastPort) {
229:
230:                // Token to replace the multicast port
231:                String token = CMI_MCASTPORT_ATTR + "=" + "\""
232:                        + DEFAULT_CMI_MCASTPORT + "\"";
233:                String value = CMI_MCASTPORT_ATTR + "=" + "\"" + mcastPort
234:                        + "\"";
235:                JReplace mcastPortReplace = new JReplace();
236:                mcastPortReplace.setLogInfo(INFO
237:                        + "Setting mcastport for protocol cmi");
238:                mcastPortReplace
239:                        .setConfigurationFile(JOnASBaseTask.JGROUPS_CMI_CONF_FILE);
240:                mcastPortReplace.setToken(token);
241:                mcastPortReplace.setValue(value);
242:                addTask(mcastPortReplace);
243:
244:            }
245:
246:            /**
247:             * Set the port for all protocols
248:             * @param portNumber port for all protocols
249:             */
250:            public void setDefaultPort(String portNumber) {
251:                setJrmpPort(portNumber);
252:                setJeremiePort(portNumber);
253:                setIiopPort(portNumber);
254:                setCmiPort(portNumber);
255:                setIrmiPort(portNumber);
256:            }
257:
258:            /**
259:             * Set the initial protocols when JOnAS start
260:             * @param protocols comma separated list of protocols
261:             */
262:            public void setProtocols(String protocols) {
263:                JReplace propertyReplace = new JReplace();
264:                propertyReplace
265:                        .setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE);
266:                propertyReplace.setToken(PROTOCOLS_PROPERTY + "="
267:                        + DEFAULT_PROTOCOLS);
268:                propertyReplace.setValue(PROTOCOLS_PROPERTY + "=" + protocols);
269:                propertyReplace.setLogInfo(INFO + "Setting protocols to : "
270:                        + protocols);
271:                addTask(propertyReplace);
272:            }
273:
274:            /**
275:             * Enable or disable optimization
276:             * @param enabled (true or false)
277:             */
278:            public void setJrmpOptimization(boolean enabled) {
279:                // Change only if needed
280:                if (!enabled) {
281:                    return;
282:                }
283:                JReplace propertyReplace = new JReplace();
284:                propertyReplace
285:                        .setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE);
286:                propertyReplace.setToken(OPTIMIZATION_OFF);
287:                propertyReplace.setValue(OPTIMIZATION_ON);
288:                propertyReplace.setLogInfo(INFO + "Enable JRMP optimization");
289:                addTask(propertyReplace);
290:            }
291:
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.