00001 package javax.jmdns; 00002 00003 import java.net.InetAddress; 00004 import java.net.NetworkInterface; 00005 import java.util.concurrent.atomic.AtomicReference; 00006 00007 import javax.jmdns.impl.NetworkTopologyDiscoveryImpl; 00008 00051 public interface NetworkTopologyDiscovery { 00052 00056 public static final class Factory { 00057 private static volatile NetworkTopologyDiscovery _instance; 00058 00062 public static interface ClassDelegate { 00063 00071 public NetworkTopologyDiscovery newNetworkTopologyDiscovery(); 00072 } 00073 00074 private static final AtomicReference<Factory.ClassDelegate> _databaseClassDelegate = new AtomicReference<Factory.ClassDelegate>(); 00075 00076 private Factory() { 00077 super(); 00078 } 00079 00088 public static void setClassDelegate(Factory.ClassDelegate delegate) { 00089 _databaseClassDelegate.set(delegate); 00090 } 00091 00099 public static Factory.ClassDelegate classDelegate() { 00100 return _databaseClassDelegate.get(); 00101 } 00102 00108 protected static NetworkTopologyDiscovery newNetworkTopologyDiscovery() { 00109 NetworkTopologyDiscovery instance = null; 00110 Factory.ClassDelegate delegate = _databaseClassDelegate.get(); 00111 if (delegate != null) { 00112 instance = delegate.newNetworkTopologyDiscovery(); 00113 } 00114 return (instance != null ? instance : new NetworkTopologyDiscoveryImpl()); 00115 } 00116 00122 public static NetworkTopologyDiscovery getInstance() { 00123 if (_instance == null) { 00124 synchronized (NetworkTopologyDiscovery.Factory.class) { 00125 if (_instance == null) { 00126 _instance = NetworkTopologyDiscovery.Factory.newNetworkTopologyDiscovery(); 00127 } 00128 } 00129 } 00130 return _instance; 00131 } 00132 } 00133 00139 public abstract InetAddress[] getInetAddresses(); 00140 00148 public boolean useInetAddress(NetworkInterface networkInterface, InetAddress interfaceAddress); 00149 00155 public void lockInetAddress(InetAddress interfaceAddress); 00156 00162 public void unlockInetAddress(InetAddress interfaceAddress); 00163 00164 }