KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > jndi > ns > AbsRegistry


1 /**
2  * Copyright (C) 2005 - Bull S.A.
3  *
4  * CAROL: Common Architecture for RMI ObjectWeb Layer
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  * --------------------------------------------------------------------------
22  * $Id: AbsRegistry.java,v 1.1 2005/03/10 12:21:46 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.carol.jndi.ns;
26
27 import java.util.Properties JavaDoc;
28
29
30 /**
31  * This abstract class implements common methods of a NameService
32  * Registry should extend this class.
33  * @author Florent Benoit
34  */

35 public abstract class AbsRegistry implements NameService {
36
37     /**
38      * port number
39      */

40     private int port = 0;
41
42     /**
43      * Hostname to use
44      */

45     private String JavaDoc host = null;
46
47
48     /**
49      * registry is started ?
50      */

51     private boolean isStarted = false;
52
53     /**
54      * Configuration properties (of carol.properties)
55      */

56     private Properties JavaDoc configurationProperties = null;
57
58
59     /**
60      * Build a new Registry
61      */

62     protected AbsRegistry() {
63
64     }
65
66     /**
67      * Build a new Registry with a given default port number
68      * @param defaultPortNumber the default port number
69      */

70     protected AbsRegistry(int defaultPortNumber) {
71         this.port = defaultPortNumber;
72     }
73
74
75     /**
76      * start Method, Start a new NameService or do nothing if the name service
77      * is all ready start
78      * @throws NameServiceException if a problem occure
79      */

80     public abstract void start() throws NameServiceException;
81
82     /**
83      * stop Method, Stop a NameService or do nothing if the name service is all
84      * ready stop
85      * @throws NameServiceException if a problem occure
86      */

87     public abstract void stop() throws NameServiceException;
88
89
90
91     /**
92      * isStarted Method, check if a name service is started
93      * @return boolean true if the name service is started
94      */

95     public boolean isStarted() {
96         return isStarted;
97     }
98
99     /**
100      * set port method, set the port for the name service
101      * @param p port number
102      */

103     public void setPort(int p) {
104         if (p <= 0) {
105             throw new IllegalArgumentException JavaDoc(
106                     "The number for the port is incorrect. It must be a value > 0. Value was '" + port + "'");
107         }
108         this.port = p;
109     }
110
111     /**
112      * Set the address to use for bind
113      * @param host hostname/ip address
114      */

115     public void setHost(String JavaDoc host) {
116         this.host = host;
117     }
118
119     /**
120      * @return hostname/ip to use
121      */

122     public String JavaDoc getHost() {
123         return host;
124     }
125
126     /**
127      * get port method, get the port for the name service
128      * @return int port number
129      */

130     public int getPort() {
131         return port;
132     }
133
134
135     /**
136      * Set the configuration properties of the protocol
137      * @param p configuration properties
138      */

139     public void setConfigProperties(Properties JavaDoc p) {
140         this.configurationProperties = p;
141     }
142
143
144     /**
145      * Registry is started
146      */

147     protected void setStarted() {
148         this.isStarted = true;
149     }
150
151     /**
152      * Registry is stopped
153      */

154     protected void resetStarted() {
155         this.isStarted = false;
156     }
157
158
159     /**
160      * @return the configuration properties.
161      */

162     protected Properties JavaDoc getConfigProperties() {
163         return configurationProperties;
164     }
165 }
166
Popular Tags