forked from I2P_Developers/i2p.i2p
* Fixed the FIXME in createInstance where the method failed to ensures that there will be only one naming service instance.
This commit is contained in:
@ -31,6 +31,8 @@ public abstract class NamingService {
|
|||||||
protected final Set<NamingServiceListener> _listeners;
|
protected final Set<NamingServiceListener> _listeners;
|
||||||
protected final Set<NamingServiceUpdater> _updaters;
|
protected final Set<NamingServiceUpdater> _updaters;
|
||||||
|
|
||||||
|
private static NamingService instance;
|
||||||
|
|
||||||
/** what classname should be used as the naming service impl? */
|
/** what classname should be used as the naming service impl? */
|
||||||
public static final String PROP_IMPL = "i2p.naming.impl";
|
public static final String PROP_IMPL = "i2p.naming.impl";
|
||||||
private static final String DEFAULT_IMPL = "net.i2p.client.naming.BlockfileNamingService";
|
private static final String DEFAULT_IMPL = "net.i2p.client.naming.BlockfileNamingService";
|
||||||
@ -451,10 +453,11 @@ public abstract class NamingService {
|
|||||||
* choose the implementation from the "i2p.naming.impl" system
|
* choose the implementation from the "i2p.naming.impl" system
|
||||||
* property.
|
* property.
|
||||||
*
|
*
|
||||||
* FIXME Actually, it doesn't ensure that. Only call this once!!!
|
|
||||||
*/
|
*/
|
||||||
public static final synchronized NamingService createInstance(I2PAppContext context) {
|
public static final synchronized NamingService createInstance(I2PAppContext context) {
|
||||||
NamingService instance = null;
|
if (instance instanceof NamingService) {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
String impl = context.getProperty(PROP_IMPL, DEFAULT_IMPL);
|
String impl = context.getProperty(PROP_IMPL, DEFAULT_IMPL);
|
||||||
try {
|
try {
|
||||||
Class cls = Class.forName(impl);
|
Class cls = Class.forName(impl);
|
||||||
|
Reference in New Issue
Block a user