|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.dsrg.sofa.deployment.zeroconf.ZeroConfServer
public class ZeroConfServer
Zero Configuration Server.
The configuration can be read from file/stream during construction. Later
it can be altered via the setProperty(String, String)
method.
After a call to listen(...)
the server is listening
on some port (given or default) for UDP configuration requests to which it
responds by sending UDP datagram containing the configuration.
Much of server's functionality can be made available through
JMX interface, see ZeroConfServerMBean
.
Server can be run as a standalone program or used within another program. For help on running as standalone program, run it with the -h option.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.objectweb.dsrg.sofa.deployment.zeroconf.ZeroConfServerMBean |
---|
ZeroConfServerMBean.LauncherInfo |
Field Summary | |
---|---|
static int |
DEFAULT_PORT
Default server port. |
Constructor Summary | |
---|---|
ZeroConfServer()
Creates a configuration server with empty initial configuration. |
|
ZeroConfServer(java.io.InputStream config)
Creates a configuration server with initial configuration read from an input stream. |
|
ZeroConfServer(java.io.Reader config)
Creates a configuration server with initial configuration read from a reader. |
|
ZeroConfServer(java.lang.String configFile)
Creates a configuration server with initial configuration read from a file. |
Method Summary | |
---|---|
protected void |
clearNotRespondingLaunchers()
|
ZeroConfServerMBean.LauncherInfo[] |
getLauncherInfos()
Returns the information about all the registered launchers. |
java.lang.String |
getProperty(java.lang.String name)
Returns the value of property name ,
or null if there is no property named name . |
boolean |
hangup(java.net.InetSocketAddress sa)
Stops listening on the given socket address. |
boolean |
hangup(int port)
Stops listening on port on local machine. |
boolean |
hangup(java.lang.String hostname,
int port)
Stops listening on hostname:port . |
void |
hangupAll()
Stops listening for requests on any sockets. |
void |
listen()
Starts listening for configuration requests on local machine and the default port. |
void |
listen(java.net.InetSocketAddress sa)
Starts listening for configuration requests on the given socket address. |
void |
listen(int port)
Starts listening for configuration requests on local machine and given port. |
void |
listen(java.lang.String hostname,
int port)
Starts listening for configuration requests on the given local host and port. |
java.lang.String[] |
listeningAddresses()
Returns a list of socket addresses on which the server is listening to requests. |
java.lang.String[] |
listProperties()
Returns an array of all set properties in property=value
format with special characters escaped as in
java.util.Properties stored in a file. |
java.lang.String[] |
listPropertyNames()
Returns an array of names of all set properties |
static void |
main(java.lang.String[] args)
Used to start the server from command line as a standalone process. |
void |
registerLauncher(java.lang.String url,
java.lang.String objectName)
Registers the launcher in the zeroconf server. |
java.lang.String |
setProperty(java.lang.String name,
java.lang.String value)
Sets the value of property name to value . |
void |
startJMX()
Starts the JMX interface, using default name of the MBean and RMI registry on the default port. |
void |
startJMX(java.lang.Integer rmiPort,
java.lang.String name)
Starts the JMX interface. |
void |
stop()
Stops listening for requests on any sockets and closes the JMX interface. |
boolean |
stopJMX()
Stops the JMX interface. |
protected boolean |
tryResponse(ZeroConfServerMBean.LauncherInfo l)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
Constructor Detail |
---|
public ZeroConfServer()
public ZeroConfServer(java.lang.String configFile) throws java.io.FileNotFoundException, java.io.IOException
configFile
- name of the file to read configuration from.
This file has a format of Properties
described in
Properties.load(Reader)
. UTF-8 encoding is assumed.
If you need to specify another encoding, use
ZeroConfServer(Reader)
instead.
java.io.FileNotFoundException
java.io.IOException
public ZeroConfServer(java.io.InputStream config) throws java.io.IOException
config
- input stream to read configuration from.
The input has a format of Properties
described in
Properties.load(Reader)
. UTF-8 encoding is assumed.
If you need to specify another encoding, use
ZeroConfServer(Reader)
instead.
java.io.IOException
public ZeroConfServer(java.io.Reader config) throws java.io.IOException
config
- reader to read configuration from.
The input has a format of Properties
described in
Properties.load(Reader)
.
java.io.IOException
Method Detail |
---|
public java.lang.String getProperty(java.lang.String name)
ZeroConfServerMBean
name
,
or null
if there is no property named name
.
getProperty
in interface ZeroConfServerMBean
public java.lang.String setProperty(java.lang.String name, java.lang.String value)
ZeroConfServerMBean
name
to value
.
setProperty
in interface ZeroConfServerMBean
name
,
or null
if none was set.public java.lang.String[] listPropertyNames()
ZeroConfServerMBean
listPropertyNames
in interface ZeroConfServerMBean
public java.lang.String[] listProperties()
ZeroConfServerMBean
property=value
format with special characters escaped as in
java.util.Properties
stored in a file.
listProperties
in interface ZeroConfServerMBean
public void listen() throws java.net.SocketException
ZeroConfServerMBean
listen
in interface ZeroConfServerMBean
java.net.SocketException
- if binding to the default port on local
machine fails.public void listen(int port) throws java.net.SocketException
ZeroConfServerMBean
listen
in interface ZeroConfServerMBean
port
- port to listen on
java.net.SocketException
- if binding to port
on local
machine fails.public void listen(java.lang.String hostname, int port) throws java.net.SocketException
ZeroConfServerMBean
listen
in interface ZeroConfServerMBean
hostname
- local host name to listen onport
- port to listen on
java.net.SocketException
- if binding to port
on the given
host machine fails.public void listen(java.net.InetSocketAddress sa) throws java.net.SocketException
java.net.SocketException
- if binding to sa
fails.public java.lang.String[] listeningAddresses()
ZeroConfServerMBean
listeningAddresses
in interface ZeroConfServerMBean
public void hangupAll()
ZeroConfServerMBean
hangupAll
in interface ZeroConfServerMBean
public boolean hangup(int port)
ZeroConfServerMBean
port
on local machine.
hangup
in interface ZeroConfServerMBean
false
if the server was not listening on
port
on local machine, true
otherwise.public boolean hangup(java.lang.String hostname, int port)
ZeroConfServerMBean
hostname:port
.
hangup
in interface ZeroConfServerMBean
false
if the server was not listening on
hostname:port
, true
otherwise.public boolean hangup(java.net.InetSocketAddress sa)
false
if the server was not listening on
sa
, true
otherwise.public void stop()
ZeroConfServerMBean
stop
in interface ZeroConfServerMBean
public void startJMX() throws java.io.IOException, javax.management.JMException
java.io.IOException
javax.management.JMException
startJMX(Integer, String)
public void startJMX(java.lang.Integer rmiPort, java.lang.String name) throws java.io.IOException, javax.management.JMException
The MBean is registered under name
ZeroConfServer:name=name
.
The connector will use the RMI registry on port rmiPort
.
On return, remote management will be available through
service:jmx:rmi:///jndi/rmi://<host>:rmiPort
/name
,
where <host> is a hostname of local machine.
A second call to startJMX()
without prior call to
stopJMX()
will result in an
IllegalStateException
.
rmiPort
- port on which RMI registry is running. If null
, default RMI registry port will be used. Remeber to make sure
that the RMI registry is running on this port.name
- Optional portion of the MBean's object name and service URL.
You need to specify your own name if you want to run more
ZeroConfServers
on the same machine. If null
,
defaults to "zeroconf"
.
java.io.IOException
- propagates any exception thrown during
creation or start of the connector server.
javax.management.JMException
- propagates exception thrown during MBean registration.public boolean stopJMX()
true
if JMX interface was started,
false
otherwise.public static void main(java.lang.String[] args) throws java.io.IOException, java.net.SocketException, javax.management.JMException
java.io.IOException
java.net.SocketException
javax.management.JMException
protected boolean tryResponse(ZeroConfServerMBean.LauncherInfo l)
protected void clearNotRespondingLaunchers()
public void registerLauncher(java.lang.String url, java.lang.String objectName)
ZeroConfServerMBean
registerLauncher
in interface ZeroConfServerMBean
url
- The jmx service url of the launcher.objectName
- The objectname of the launcher.public ZeroConfServerMBean.LauncherInfo[] getLauncherInfos()
ZeroConfServerMBean
getLauncherInfos
in interface ZeroConfServerMBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |