public final class NSClientPeerFactory extends Object
NSClientAgentConfig
objects for specific
addresses. If an address cannot be located in the configuration then a
default peer instance is returned to the caller.
Note: Users of this class should make sure the
init() is called before calling any other method to ensure the
config is loaded before accessing other convenience methods.Constructor and Description |
---|
NSClientPeerFactory(InputStream stream)
Constructor for NSClientPeerFactory.
|
Modifier and Type | Method and Description |
---|---|
NSClientAgentConfig |
getAgentConfig(InetAddress agentInetAddress)
getAgentConfig
|
static NSClientPeerFactory |
getInstance()
Return the singleton instance of this factory.
|
Lock |
getReadLock() |
Lock |
getWriteLock() |
static void |
init()
Load the config from the default config file and create the singleton
instance of this factory.
|
static void |
reload()
Reload the config from the default config file
|
void |
saveCurrent()
Saves the current settings to disk
|
static void |
setInstance(NSClientPeerFactory singleton)
setInstance
|
public NSClientPeerFactory(InputStream stream) throws IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
Constructor for NSClientPeerFactory.
stream
- a InputStream
object.IOException
- if any.org.exolab.castor.xml.MarshalException
- if any.org.exolab.castor.xml.ValidationException
- if any.public Lock getReadLock()
public Lock getWriteLock()
public static void init() throws IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
IOException
- Thrown if the specified config file cannot be readorg.exolab.castor.xml.MarshalException
- Thrown if the file does not conform to the schema.org.exolab.castor.xml.ValidationException
- Thrown if the contents do not match the required schema.IOException
- if any.org.exolab.castor.xml.MarshalException
- if any.org.exolab.castor.xml.ValidationException
- if any.public static void reload() throws IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
IOException
- Thrown if the specified config file cannot be read/loadedorg.exolab.castor.xml.MarshalException
- Thrown if the file does not conform to the schema.org.exolab.castor.xml.ValidationException
- Thrown if the contents do not match the required schema.IOException
- if any.org.exolab.castor.xml.MarshalException
- if any.org.exolab.castor.xml.ValidationException
- if any.public void saveCurrent() throws Exception
Exception
- if any.public static NSClientPeerFactory getInstance()
IllegalStateException
- Thrown if the factory has not yet been initialized.public static void setInstance(NSClientPeerFactory singleton)
setInstance
singleton
- a NSClientPeerFactory
object.public NSClientAgentConfig getAgentConfig(InetAddress agentInetAddress)
getAgentConfig
agentInetAddress
- a InetAddress
object.NSClientAgentConfig
object.Copyright © 2017. All rights reserved.