From: <fte...@us...> - 2007-03-04 16:20:16
|
Revision: 78 http://trivial.svn.sourceforge.net/trivial/?rev=78&view=rev Author: fterrier Date: 2007-03-04 08:20:17 -0800 (Sun, 04 Mar 2007) Log Message: ----------- presence service not working Modified Paths: -------------- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 15:41:26 UTC (rev 77) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/PresenceServiceImpl.java 2007-03-04 16:20:17 UTC (rev 78) @@ -1,17 +1,23 @@ package net.sf.trivial.easypaste.internal.pi.presence; import java.io.IOException; +import java.net.InetAddress; +import javax.jmdns.JmDNS; + import net.sf.trivial.easypaste.internal.presence.AbstractPresenceService; import net.sf.trivial.easypaste.internal.presence.ServiceBrowser; import net.sf.trivial.easypaste.internal.presence.ServiceRegistrer; public class PresenceServiceImpl extends AbstractPresenceService { + private final JmDNS jmdns; + public PresenceServiceImpl(int port, String serviceName) throws IOException { super(port, serviceName); - this.serviceBrowser = new ServiceBrowserImpl(this); - this.serviceRegistrer = new ServiceRegistrerImpl(); + this.jmdns = createJmDNS(); + this.serviceBrowser = new ServiceBrowserImpl(jmdns,this); + this.serviceRegistrer = new ServiceRegistrerImpl(jmdns); } private final ServiceRegistrerImpl serviceRegistrer; @@ -27,4 +33,8 @@ return serviceRegistrer; } + private JmDNS createJmDNS() throws IOException { + return new JmDNS(InetAddress.getLocalHost()); + } + } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 15:41:26 UTC (rev 77) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceBrowserImpl.java 2007-03-04 16:20:17 UTC (rev 78) @@ -1,6 +1,7 @@ package net.sf.trivial.easypaste.internal.pi.presence; import java.io.IOException; +import java.net.InetAddress; import javax.jmdns.JmDNS; import javax.jmdns.ServiceEvent; @@ -29,8 +30,8 @@ null,event.getInfo().getInetAddress(),event.getInfo().getPort())); } - public ServiceBrowserImpl(PresenceServiceImpl presenceService) throws IOException { - this.jmdns = new JmDNS(); + public ServiceBrowserImpl(JmDNS jmdns, PresenceServiceImpl presenceService) { + this.jmdns = jmdns; this.presenceService = presenceService; } @@ -38,13 +39,7 @@ private final JmDNS jmdns; public void browse(String proto) { - try { - JmDNS jmdns = new JmDNS(); - jmdns.addServiceListener(proto, this); - } - catch (IOException e) { - // TODO - } + jmdns.addServiceListener(proto, this); } public void stop() { Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java 2007-03-04 15:41:26 UTC (rev 77) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/pi/presence/ServiceRegistrerImpl.java 2007-03-04 16:20:17 UTC (rev 78) @@ -1,26 +1,33 @@ package net.sf.trivial.easypaste.internal.pi.presence; import java.io.IOException; +import java.net.InetAddress; import javax.jmdns.JmDNS; import javax.jmdns.ServiceInfo; +import net.sf.trivial.easypaste.launcher.EasyStart; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + public class ServiceRegistrerImpl implements net.sf.trivial.easypaste.internal.presence.ServiceRegistrer { - public ServiceRegistrerImpl() throws IOException { - this.jmdns = new JmDNS(); + private static Log log = LogFactory.getLog(ServiceRegistrerImpl.class); + + public ServiceRegistrerImpl(JmDNS jmdns) { + this.jmdns = jmdns; } private final JmDNS jmdns; public void register(String name, String proto, int port) { try { - JmDNS jmdns = new JmDNS(); - ServiceInfo info = new ServiceInfo(proto, name, 1268, 0, 0, ""); + ServiceInfo info = new ServiceInfo(proto, name, port, ""); jmdns.registerService(info); } catch (IOException e) { - e.printStackTrace(); + log.error("Could not register",e); } } Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 15:41:26 UTC (rev 77) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/internal/presence/AbstractPresenceService.java 2007-03-04 16:20:17 UTC (rev 78) @@ -61,8 +61,7 @@ private final int port; private final String serviceName; - static final int WAIT = 15000; - static final String PROTO = "_easypaste._tcp"; + static final String PROTO = "_easypaste._tcp."; public AbstractPresenceService(int port, String serviceName) { this.port = port; Modified: trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java =================================================================== --- trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java 2007-03-04 15:41:26 UTC (rev 77) +++ trunk/eclipse/easypaste/src/net/sf/trivial/easypaste/launcher/EasyStart.java 2007-03-04 16:20:17 UTC (rev 78) @@ -10,6 +10,7 @@ public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException { String os = System.getProperty("os.name"); log.debug("os.name=" + os); + os = "Linux"; if ("Mac OS X".equals(os)) { log.info("Detected Mac OS X"); Class.forName("net.sf.trivial.easypaste.launcher.mac.EasyController").newInstance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |