13742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman/**
23742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman *
33742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman */
43742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanpackage javax.jmdns;
53742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
63742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanimport java.io.Closeable;
73742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanimport java.io.IOException;
83742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanimport java.net.InetAddress;
93742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanimport java.util.Map;
103742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanimport java.util.concurrent.atomic.AtomicReference;
113742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
123742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanimport javax.jmdns.impl.JmmDNSImpl;
133742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
143742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman/**
153742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * <p>
163742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * Java Multihomed Multicast DNS
173742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * </p>
183742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * Uses an underlying {@link JmDNS} instance for each {@link InetAddress} found on this computer.<br/>
193742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * This class will monitor network topology changes, and will create or destroy JmDNS instances as required. It is your responsibility to maintain services registration (hint: use a {@link NetworkTopologyListener}).<br/>
203742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * Most of this class methods have no notion of transaction: if an Exception is raised in the middle of execution, you may be in an incoherent state.
213742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * <p>
223742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * <b>Note:</b> This API is experimental and may change in the future please let us know what work and what does not work in you application.
233742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * </p>
243742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman *
253742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman * @author C&eacute;drik Lime, Pierre Frisch
263742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman */
273742d9db8b6edb10627b0f89336cca5249f1d15aManuel Romanpublic interface JmmDNS extends Closeable {
283742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
293742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
303742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * JmmDNS.Factory enable the creation of new instance of JmmDNS.
313742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
323742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public static final class Factory {
333742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        private static volatile JmmDNS _instance;
343742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
353742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        /**
363742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * This interface defines a delegate to the EOClassDescriptionRegister class to enable subclassing.
373742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         */
383742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        public static interface ClassDelegate {
393742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
403742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            /**
413742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman             * Allows the delegate the opportunity to construct and return a different JmmDNS.
423742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman             *
433742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman             * @return Should return a new JmmDNS.
443742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman             * @see #classDelegate()
453742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman             * @see #setClassDelegate(ClassDelegate anObject)
463742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman             */
473742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            public JmmDNS newJmmDNS();
483742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
493742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        }
503742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
513742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        private static final AtomicReference<ClassDelegate> _databaseClassDelegate = new AtomicReference<ClassDelegate>();
523742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
533742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        private Factory() {
543742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            super();
553742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        }
563742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
573742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        /**
583742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * Assigns <code>delegate</code> as JmmDNS's class delegate. The class delegate is optional.
593742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         *
603742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @param delegate
613742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         *            The object to set as JmmDNS's class delegate.
623742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @see #classDelegate()
633742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @see JmmDNS.Factory.ClassDelegate
643742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         */
653742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        public static void setClassDelegate(ClassDelegate delegate) {
663742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            _databaseClassDelegate.set(delegate);
673742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        }
683742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
693742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        /**
703742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * Returns JmmDNS's class delegate.
713742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         *
723742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @return JmmDNS's class delegate.
733742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @see #setClassDelegate(ClassDelegate anObject)
743742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @see JmmDNS.Factory.ClassDelegate
753742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         */
763742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        public static ClassDelegate classDelegate() {
773742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            return _databaseClassDelegate.get();
783742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        }
793742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
803742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        /**
813742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * Returns a new instance of JmmDNS using the class delegate if it exists.
823742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         *
833742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @return new instance of JmmDNS
843742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         */
853742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        protected static JmmDNS newJmmDNS() {
863742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            JmmDNS dns = null;
873742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            ClassDelegate delegate = _databaseClassDelegate.get();
883742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            if (delegate != null) {
893742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman                dns = delegate.newJmmDNS();
903742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            }
913742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            return (dns != null ? dns : new JmmDNSImpl());
923742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        }
933742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
943742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        /**
953742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * Return the instance of the Multihommed Multicast DNS.
963742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         *
973742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         * @return the JmmDNS
983742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman         */
993742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        public static JmmDNS getInstance() {
1003742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            if (_instance == null) {
1013742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman                synchronized (Factory.class) {
1023742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman                    if (_instance == null) {
1033742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman                        _instance = JmmDNS.Factory.newJmmDNS();
1043742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman                    }
1053742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman                }
1063742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            }
1073742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman            return _instance;
1083742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman        }
1093742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    }
1103742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1113742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1123742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Return the names of the JmDNS instances.
1133742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1143742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of name of the JmDNS
1153742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getName()
1163742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1173742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract String[] getNames();
1183742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1193742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1203742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Return the list HostName associated with this JmmDNS instance.
1213742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1223742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of host names
1233742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getHostName()
1243742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1253742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract String[] getHostNames();
1263742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1273742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1283742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Return the list of addresses of the interface to which this instance of JmmDNS is bound.
1293742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1303742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of Internet Address
1313742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @exception IOException
1323742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getInetAddress()
1333742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1343742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract InetAddress[] getInetAddresses() throws IOException;
1353742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1363742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1373742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Return the list of addresses of the interface to which this instance of JmmDNS is bound.
1383742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1393742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of Internet Address
1403742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @exception IOException
1413742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getInterface()
1423742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @deprecated do not use this implementation yields unpredictable results use {@link #getInetAddresses()}
1433742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1443742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    @Deprecated
1453742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract InetAddress[] getInterfaces() throws IOException;
1463742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1473742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1483742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Get service information. If the information is not cached, the method will block until updated information is received on all DNS.
1493742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * <p/>
1503742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Usage note: Do not call this method from the AWT event dispatcher thread. You will make the user interface unresponsive.
1513742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1523742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
1533742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            fully qualified service type, such as <code>_http._tcp.local.</code> .
1543742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
1553742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
1563742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of service info. If no service info is found the list is empty.
1573742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getServiceInfo(java.lang.String, java.lang.String)
1583742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1593742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract ServiceInfo[] getServiceInfos(String type, String name);
1603742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1613742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1623742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Get service information. If the information is not cached, the method will block until updated information is received on all DNS.
1633742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * <p/>
1643742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Usage note: If you call this method from the AWT event dispatcher thread, use a small timeout, or you will make the user interface unresponsive.
1653742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1663742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
1673742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
1683742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
1693742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
1703742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param timeout
1713742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            timeout in milliseconds. Typical timeout should be 5s.
1723742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of service info. If no service info is found the list is empty.
1733742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getServiceInfo(java.lang.String, java.lang.String, long)
1743742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1753742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract ServiceInfo[] getServiceInfos(String type, String name, long timeout);
1763742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1773742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1783742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Get service information. If the information is not cached, the method will block until updated information is received on all DNS.
1793742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * <p/>
1803742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Usage note: If you call this method from the AWT event dispatcher thread, use a small timeout, or you will make the user interface unresponsive.
1813742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1823742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
1833742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
1843742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
1853742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
1863742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param persistent
1873742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            if <code>true</code> ServiceListener.resolveService will be called whenever new new information is received.
1883742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of service info. If no service info is found the list is empty.
1893742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getServiceInfo(java.lang.String, java.lang.String, boolean)
1903742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
1913742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract ServiceInfo[] getServiceInfos(String type, String name, boolean persistent);
1923742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
1933742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
1943742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Get service information. If the information is not cached, the method will block until updated information is received on all DNS.
1953742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * <p/>
1963742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Usage note: If you call this method from the AWT event dispatcher thread, use a small timeout, or you will make the user interface unresponsive.
1973742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
1983742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
1993742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
2003742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
2013742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
2023742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param timeout
2033742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            timeout in milliseconds. Typical timeout should be 5s.
2043742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param persistent
2053742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            if <code>true</code> ServiceListener.resolveService will be called whenever new new information is received.
2063742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of service info. If no service info is found the list is empty.
2073742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#getServiceInfo(java.lang.String, java.lang.String, boolean, long)
2083742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2093742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract ServiceInfo[] getServiceInfos(String type, String name, boolean persistent, long timeout);
2103742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2113742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2123742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.
2133742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2143742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
2153742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
2163742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
2173742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
2183742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#requestServiceInfo(java.lang.String, java.lang.String)
2193742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2203742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void requestServiceInfo(String type, String name);
2213742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2223742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2233742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.
2243742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2253742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
2263742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
2273742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
2283742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
2293742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param persistent
2303742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            if <code>true</code> ServiceListener.resolveService will be called whenever new new information is received.
2313742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#requestServiceInfo(java.lang.String, java.lang.String, boolean)
2323742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2333742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void requestServiceInfo(String type, String name, boolean persistent);
2343742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2353742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2363742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.
2373742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2383742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
2393742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
2403742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
2413742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
2423742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param timeout
2433742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            timeout in milliseconds
2443742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#requestServiceInfo(java.lang.String, java.lang.String, long)
2453742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2463742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void requestServiceInfo(String type, String name, long timeout);
2473742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2483742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2493742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Request service information. The information about the service is requested and the ServiceListener.resolveService method is called as soon as it is available.
2503742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2513742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
2523742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code> .
2533742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param name
2543742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            unqualified service name, such as <code>foobar</code> .
2553742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param persistent
2563742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            if <code>true</code> ServiceListener.resolveService will be called whenever new new information is received.
2573742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param timeout
2583742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            timeout in milliseconds
2593742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#requestServiceInfo(java.lang.String, java.lang.String, boolean, long)
2603742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2613742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void requestServiceInfo(String type, String name, boolean persistent, long timeout);
2623742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2633742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2643742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Listen for service types.
2653742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2663742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param listener
2673742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            listener for service types
2683742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @exception IOException
2693742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#addServiceTypeListener(javax.jmdns.ServiceTypeListener)
2703742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2713742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void addServiceTypeListener(ServiceTypeListener listener) throws IOException;
2723742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2733742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2743742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Remove listener for service types.
2753742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2763742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param listener
2773742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            listener for service types
2783742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#removeServiceTypeListener(javax.jmdns.ServiceTypeListener)
2793742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2803742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void removeServiceTypeListener(ServiceTypeListener listener);
2813742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2823742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2833742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Listen for services of a given type. The type has to be a fully qualified type name such as <code>_http._tcp.local.</code>.
2843742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2853742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
2863742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code>.
2873742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param listener
2883742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            listener for service updates
2893742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#addServiceListener(java.lang.String, javax.jmdns.ServiceListener)
2903742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
2913742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void addServiceListener(String type, ServiceListener listener);
2923742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
2933742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
2943742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Remove listener for services of a given type.
2953742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
2963742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
2973742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code>.
2983742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param listener
2993742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            listener for service updates
3003742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#removeServiceListener(java.lang.String, javax.jmdns.ServiceListener)
3013742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3023742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void removeServiceListener(String type, ServiceListener listener);
3033742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3043742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3053742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Register a service. The service is registered for access by other jmdns clients. The name of the service may be changed to make it unique.<br>
3063742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * <b>Note</b> the Service info is cloned for each network interface.
3073742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3083742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param info
3093742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            service info to register
3103742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @exception IOException
3113742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#registerService(javax.jmdns.ServiceInfo)
3123742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3133742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void registerService(ServiceInfo info) throws IOException;
3143742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3153742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3163742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Unregister a service. The service should have been registered.
3173742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3183742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param info
3193742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            service info to remove
3203742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#unregisterService(javax.jmdns.ServiceInfo)
3213742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3223742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void unregisterService(ServiceInfo info);
3233742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3243742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3253742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Unregister all services.
3263742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3273742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#unregisterAllServices()
3283742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3293742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void unregisterAllServices();
3303742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3313742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3323742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Register a service type. If this service type was not already known, all service listeners will be notified of the new service type. Service types are automatically registered as they are discovered.
3333742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3343742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
3353742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            full qualified service type, such as <code>_http._tcp.local.</code>.
3363742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#registerServiceType(java.lang.String)
3373742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3383742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void registerServiceType(String type);
3393742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3403742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3413742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Returns a list of service infos of the specified type.
3423742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3433742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
3443742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            Service type name, such as <code>_http._tcp.local.</code>.
3453742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return An array of service instance.
3463742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#list(java.lang.String)
3473742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3483742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract ServiceInfo[] list(String type);
3493742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3503742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3513742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Returns a list of service infos of the specified type.
3523742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3533742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
3543742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            Service type name, such as <code>_http._tcp.local.</code>.
3553742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param timeout
3563742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            timeout in milliseconds. Typical timeout should be 6s.
3573742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return An array of service instance.
3583742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#list(java.lang.String, long)
3593742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3603742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract ServiceInfo[] list(String type, long timeout);
3613742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3623742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3633742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Returns a list of service infos of the specified type sorted by subtype. Any service that do not register a subtype is listed in the empty subtype section.
3643742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3653742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
3663742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            Service type name, such as <code>_http._tcp.local.</code>.
3673742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return A dictionary of service info by subtypes.
3683742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#listBySubtype(java.lang.String)
3693742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3703742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract Map<String, ServiceInfo[]> listBySubtype(String type);
3713742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3723742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3733742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Returns a list of service infos of the specified type sorted by subtype. Any service that do not register a subtype is listed in the empty subtype section.
3743742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3753742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param type
3763742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            Service type name, such as <code>_http._tcp.local.</code>.
3773742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param timeout
3783742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            timeout in milliseconds. Typical timeout should be 6s.
3793742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return A dictionary of service info by subtypes.
3803742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @see javax.jmdns.JmDNS#listBySubtype(java.lang.String, long)
3813742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3823742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract Map<String, ServiceInfo[]> listBySubtype(String type, long timeout);
3833742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3843742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3853742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Listen to network changes.
3863742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3873742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param listener
3883742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            listener for network changes
3893742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3903742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void addNetworkTopologyListener(NetworkTopologyListener listener);
3913742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
3923742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
3933742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Remove listener for network changes.
3943742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
3953742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @param listener
3963742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *            listener for network changes
3973742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
3983742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract void removeNetworkTopologyListener(NetworkTopologyListener listener);
3993742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
4003742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    /**
4013742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * Returns list of network change listeners
4023742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     *
4033742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     * @return list of network change listeners
4043742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman     */
4053742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman    public abstract NetworkTopologyListener[] networkListeners();
4063742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman
4073742d9db8b6edb10627b0f89336cca5249f1d15aManuel Roman}
408