class MulticastDNSService extends BasicModule {

    private static final Logger Log = LoggerFactory.getLogger(MulticastDNSService.class);

    private JmDNS jmdns;

    public MulticastDNSService() {
        super("Multicast DNS Service");

        PropertyEventDispatcher.addListener(new PropertyEventListener() {

            @Override
            public void propertySet(String property, Map params) {
                // Restart the service if component settings changes.
                if (property.equals("xmpp.component.socket.active") ||
                        property.equals(" xmpp.component.socket.port"))
                {
                    stop();
                    start();
                }
            }

            @Override
            public void propertyDeleted(String property, Map params) {
                // Restart the service if component settings changes.
                if (property.equals("xmpp.component.socket.active") ||
                        property.equals(" xmpp.component.socket.port"))
                {
                    stop();
                    start();
                }
            }

            @Override
            public void xmlPropertySet(String property, Map params) {
            }

            @Override
            public void xmlPropertyDeleted(String property, Map params) {
            }
        });
    }

    @Override
    public void initialize(XMPPServer server) {
       
    }

    @Override
    public void start() throws IllegalStateException {
        // If the service isn't enabled, return.
        if (!JiveGlobals.getBooleanProperty("multicastDNS.enabled", false) ) {
            return;     
        }
        TimerTask startService = new TimerTask() {
            @Override
            public void run() {<FILL_FUNCTION_BODY>}
        };
        // Schedule the task to run in 5 seconds, to give Openfire time to start the ports.
        TaskEngine.getInstance().schedule(startService, Duration.ofSeconds(5));
    }


    @Override
    public void stop() {
        if (jmdns != null) {
            try {
                jmdns.close();
            }
            catch (Exception e) {
                // Ignore.
            }
        }
    }

    @Override
    public void destroy() {
        if (jmdns != null) {
            jmdns = null;
        }
    }
}

                int clientPortNum = -1;
                int componentPortNum = -1;
                final ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
                if ( connectionManager != null )
                {
                    clientPortNum = connectionManager.getPort( ConnectionType.SOCKET_C2S, false );
                    componentPortNum = connectionManager.getPort( ConnectionType.COMPONENT, false);
                }
                try {
                    if (jmdns == null) {
                        jmdns = new JmDNS();
                    }
                    String serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();

                    if (clientPortNum != -1) {
                        ServiceInfo clientService = new ServiceInfo("_xmpp-client._tcp.local.",
                                serverName + "._xmpp-client._tcp.local.", clientPortNum, "XMPP Server");
                        jmdns.registerService(clientService);
                    }
                    if (componentPortNum != -1) {
                        ServiceInfo componentService = new ServiceInfo("_xmpp-component._tcp.local.",
                                serverName +  "._xmpp-component._tcp.local.", componentPortNum, "XMPP Component Server");
                        jmdns.registerService(componentService);
                    }
                }
                 catch (IOException ioe) {
                    Log.error(ioe.getMessage(), ioe);
                }
            
<methods>public void <init>(java.lang.String) ,public void destroy() ,public java.lang.String getName() ,public void initialize(org.jivesoftware.openfire.XMPPServer) ,public void start() throws java.lang.IllegalStateException,public void stop() <variables>private java.lang.String name