KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > ant > jonasbase > Jms


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: Jms.java,v 1.1 2004/06/11 09:27:47 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant.jonasbase;
28
29 import java.util.StringTokenizer JavaDoc;
30
31 import org.objectweb.jonas.ant.JOnASBaseTask;
32
33 /**
34  * Allow to configure the JMS service
35  * @author Florent Benoit
36  */

37 public class Jms extends Tasks {
38
39     /**
40      * Info for the logger
41      */

42     private static final String JavaDoc INFO = "[JMS] ";
43
44     /**
45      * Default port number
46      */

47     private static final String JavaDoc DEFAULT_PORT = "16010";
48
49     /**
50      * Default initial topics
51      */

52     private static final String JavaDoc DEFAULT_TOPIC = "sampleTopic";
53
54     /**
55      * Name of the property for the Topics
56      */

57     private static final String JavaDoc TOPIC_PROPERTY = "Topic";
58
59     /**
60      * Name of the property for the Queues
61      */

62     private static final String JavaDoc QUEUE_PROPERTY = "Queue";
63
64     /**
65      * Default initial queues
66      */

67     private static final String JavaDoc DEFAULT_QUEUE = "sampleQueue";
68
69     /**
70      * Default constructor
71      */

72     public Jms() {
73         super();
74     }
75
76     /**
77      * Set the port number for Joram
78      * @param portNumber the port for Joram
79      */

80     public void setPort(String JavaDoc portNumber) {
81
82         // For JMS
83
JReplace propertyReplace = new JReplace();
84         propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_CONF_FILE);
85         propertyReplace.setToken(DEFAULT_PORT);
86         propertyReplace.setValue(portNumber);
87         propertyReplace.setLogInfo(INFO + "Setting Joram port number to : " + portNumber + " in "
88                 + JOnASBaseTask.JORAM_CONF_FILE + " file.");
89         addTask(propertyReplace);
90
91         // for RAR file
92
propertyReplace = new JReplace();
93         propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE);
94         propertyReplace.setToken(DEFAULT_PORT);
95         propertyReplace.setValue(portNumber);
96         propertyReplace.setLogInfo(INFO + "Setting Joram port number to : " + portNumber + " in "
97                 + JOnASBaseTask.JORAM_ADMIN_CONF_FILE + " file.");
98         addTask(propertyReplace);
99     }
100
101     /**
102      * Set the initial topics when JOnAS start
103      * @param initialTopics comma separated list of topics
104      */

105     public void setInitialTopics(String JavaDoc initialTopics) {
106         JReplace propertyReplace = new JReplace();
107         propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE);
108         propertyReplace.setToken(DEFAULT_TOPIC);
109         String JavaDoc tokenValue = "";
110         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(initialTopics, ",");
111
112         while (st.hasMoreTokens()) {
113             String JavaDoc topic = st.nextToken();
114             if (st.hasMoreTokens()) {
115                 tokenValue += topic + "\n" + TOPIC_PROPERTY + " ";
116             } else {
117                 tokenValue += topic;
118             }
119         }
120
121         propertyReplace.setValue(tokenValue);
122         propertyReplace.setLogInfo(INFO + "Setting initial topics to : " + initialTopics);
123         addTask(propertyReplace);
124     }
125
126     /**
127      * Set the initial queues when JOnAS start
128      * @param initialQueues comma separated list of topics
129      */

130     public void setInitialQueues(String JavaDoc initialQueues) {
131         JReplace propertyReplace = new JReplace();
132         propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE);
133         propertyReplace.setToken(DEFAULT_QUEUE);
134
135         String JavaDoc tokenValue = "";
136         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(initialQueues, ",");
137
138         while (st.hasMoreTokens()) {
139             String JavaDoc topic = st.nextToken();
140             if (st.hasMoreTokens()) {
141                 tokenValue += topic + "\n" + QUEUE_PROPERTY + " ";
142             } else {
143                 tokenValue += topic;
144             }
145         }
146
147         propertyReplace.setValue(tokenValue);
148         propertyReplace.setLogInfo(INFO + "Setting initial queues to : " + initialQueues);
149         addTask(propertyReplace);
150     }
151 }
Popular Tags