KickJava   Java API By Example, From Geeks To Geeks.

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


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: Db.java,v 1.2 2004/07/01 16:19:19 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant.jonasbase;
28
29 import java.io.File JavaDoc;
30
31 import org.apache.tools.ant.BuildException;
32
33 import org.objectweb.jonas.ant.JOnASBaseTask;
34
35 /**
36  * Allow to configure the DB service
37  * @author Florent Benoit
38  */

39 public class Db extends JTask implements BaseTaskItf {
40
41     /**
42      * Info for the logger
43      */

44     private static final String JavaDoc INFO = "[DB] ";
45
46     /**
47      * Name of the property for changing the port.
48      */

49     private static final String JavaDoc PORT_PROPERTY = "jonas.service.db.port";
50
51     /**
52      * Port number
53      */

54     private String JavaDoc portNumber = null;
55
56     /**
57      * Default constructor
58      */

59     public Db() {
60         super();
61     }
62
63     /**
64      * Set the port number for the Db service
65      * @param portNumber the port for the Db service
66      */

67     public void setPort(String JavaDoc portNumber) {
68             this.portNumber = portNumber;
69     }
70
71
72     /**
73      * Check the properties
74      */

75     private void checkProperties() {
76         if (portNumber == null) {
77             throw new BuildException(INFO + "Property 'portNumber' is missing.");
78         }
79     }
80
81     /**
82      * Execute this task
83      */

84     public void execute() {
85         checkProperties();
86
87         // Path to JONAS_BASE
88
String JavaDoc jBaseConf = getDestDir().getPath() + File.separator + "conf";
89
90         changeValueForKey(INFO, jBaseConf, JOnASBaseTask.JONAS_CONF_FILE,
91                 PORT_PROPERTY, portNumber, false);
92
93
94     }
95 }
Popular Tags