From cea5f56ec59b00e21d813a7823238109a6f3042b Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Thu, 22 Aug 2002 21:33:13 +0000 Subject: [PATCH] tweak git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@757 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd-dcpd/etc/go.bat | 2 +- .../src/net/sourceforge/pmd/dcpd/DCPD.java | 9 +------ .../net/sourceforge/pmd/dcpd/DCPDWorker.java | 16 ++++++++++++ .../src/net/sourceforge/pmd/dcpd/Test.java | 8 +----- .../src/net/sourceforge/pmd/dcpd/Util.java | 26 +++++++++++++++++++ 5 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPDWorker.java create mode 100644 pmd-dcpd/src/net/sourceforge/pmd/dcpd/Util.java diff --git a/pmd-dcpd/etc/go.bat b/pmd-dcpd/etc/go.bat index 137d3faaed..2959f6f0a4 100755 --- a/pmd-dcpd/etc/go.bat +++ b/pmd-dcpd/etc/go.bat @@ -5,7 +5,7 @@ set CLASSPATH=%CLASSPATH%;c:\data\pmd\pmd-dcpd\lib\runtimeonly\reggie.jar set CLASSPATH=%CLASSPATH%;c:\data\pmd\pmd-dcpd\build set CLASSPATH=%CLASSPATH%;c:\data\pmd\pmd-dcpd\lib\pmd-0.9.jar -set MAIN=net.sourceforge.pmd.dcpd.Test +set MAIN=net.sourceforge.pmd.dcpd.DCPD set MEMORY_ARG=-Xms128M -Xmx384M set POLICY_ARG=-Djava.security.policy=c:\jini-1_2_1\policy\policy.all set SPACENAME_ARG=-Dcom.sun.jini.outrigger.spacename=JavaSpaces diff --git a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPD.java b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPD.java index 4971b16475..a2947dfad0 100644 --- a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPD.java +++ b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPD.java @@ -28,7 +28,7 @@ public class DCPD { public DCPD(String javaSpaceURL) { try { - space = getSpace(javaSpaceURL); + space = Util.findSpace("mordor"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("Couldn't connect to the space on " + javaSpaceURL); @@ -62,13 +62,6 @@ public class DCPD { tokenSets.add(ts); } - private JavaSpace getSpace(String javaSpaceServerName) throws ClassNotFoundException, MalformedURLException, IOException, RemoteException { - ServiceRegistrar registrar = (new LookupLocator(javaSpaceServerName)).getRegistrar(); - ServiceMatches sm = registrar.lookup(new ServiceTemplate(null, new Class[] {JavaSpace.class}, new Entry[] {}), 1); - return (JavaSpace)sm.items[0].service; - } - - public static void main(String[] args) { new DCPD("jini://mordor"); } diff --git a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPDWorker.java b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPDWorker.java new file mode 100644 index 0000000000..47b418608d --- /dev/null +++ b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/DCPDWorker.java @@ -0,0 +1,16 @@ +/* + * User: tom + * Date: Aug 22, 2002 + * Time: 5:13:14 PM + */ +package net.sourceforge.pmd.dcpd; + +public class DCPDWorker { + + public DCPDWorker() { + + } + public static void main(String[] args) { + new DCPDWorker(); + } +} diff --git a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Test.java b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Test.java index f5511589dd..c50c0a5062 100644 --- a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Test.java +++ b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Test.java @@ -22,7 +22,7 @@ public class Test { public Test() { try { - JavaSpace space = getSpace(); + JavaSpace space = Util.findSpace("mordor"); add("C:\\j2sdk1.4.0_01\\src\\java\\lang\\", true); Entry wrapper = new TokenSetsWrapper(tokenSets); @@ -59,12 +59,6 @@ public class Test { tokenSets.add(ts); } - private JavaSpace getSpace() throws Exception { - ServiceRegistrar registrar = (new LookupLocator("jini://mordor")).getRegistrar(); - ServiceMatches sm = registrar.lookup(new ServiceTemplate(null, new Class[] {JavaSpace.class}, new Entry[] {}), 1); - return (JavaSpace)sm.items[0].service; - } - public static void main(String[] args) { new Test(); } diff --git a/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Util.java b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Util.java new file mode 100644 index 0000000000..fe26973843 --- /dev/null +++ b/pmd-dcpd/src/net/sourceforge/pmd/dcpd/Util.java @@ -0,0 +1,26 @@ +/* + * User: tom + * Date: Aug 22, 2002 + * Time: 5:25:40 PM + */ +package net.sourceforge.pmd.dcpd; + +import net.jini.space.JavaSpace; +import net.jini.core.lookup.ServiceRegistrar; +import net.jini.core.lookup.ServiceMatches; +import net.jini.core.lookup.ServiceTemplate; +import net.jini.core.discovery.LookupLocator; +import net.jini.core.entry.Entry; + +import java.rmi.RemoteException; +import java.io.IOException; +import java.net.MalformedURLException; + +public class Util { + + public static JavaSpace findSpace(String serverName) throws ClassNotFoundException, MalformedURLException, IOException, RemoteException { + ServiceRegistrar registrar = (new LookupLocator("jini://" + serverName)).getRegistrar(); + ServiceMatches sm = registrar.lookup(new ServiceTemplate(null, new Class[] {JavaSpace.class}, new Entry[] {}), 1); + return (JavaSpace)sm.items[0].service; + } +}