moving slowly ahead towards event notification

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@767 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-08-23 21:21:28 +00:00
parent 49fe00a067
commit ff450e8982
4 changed files with 59 additions and 7 deletions

View File

@ -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.DCPD
set MAIN=net.sourceforge.pmd.dcpd.%1
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

View File

@ -11,6 +11,7 @@ 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 net.jini.core.lease.Lease;
import net.sourceforge.pmd.cpd.*;
import java.net.MalformedURLException;
@ -29,20 +30,20 @@ public class DCPD {
public DCPD(String javaSpaceURL) {
try {
space = Util.findSpace("mordor");
space.write(new Job("test"), null, Lease.FOREVER);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Couldn't connect to the space on " + javaSpaceURL);
}
/*
try {
add("C:\\j2sdk1.4.0_01\\src\\java\\lang\\", true);
} catch (IOException ioe) {
ioe.printStackTrace();
throw new RuntimeException("Couldn't load the files");
}
Entry wrapper = new TokenSetsWrapper(tokenSets);
*/
}
private void add(String dir, boolean recurse) throws IOException {

View File

@ -5,12 +5,45 @@
*/
package net.sourceforge.pmd.dcpd;
import net.jini.space.JavaSpace;
import net.jini.core.lease.Lease;
import net.jini.core.event.RemoteEventListener;
import net.jini.core.event.RemoteEvent;
import net.jini.core.event.UnknownEventException;
import java.rmi.RemoteException;
import java.rmi.MarshalledObject;
public class DCPDWorker {
public class MyListener implements RemoteEventListener {
public MyListener() {}
public void notify(RemoteEvent event) throws UnknownEventException, RemoteException {
System.out.println("HOWDY!");
try {
Job job = (Job)space.take(new Job("test"), null, 1000);
if (job == null) {
System.out.println("No job found");
} else {
System.out.println("job = " + job.name);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private JavaSpace space;
public DCPDWorker() {
// get space
// register self listener for TokenSetsWrapper objects
// wait
try {
space = Util.findSpace("mordor");
space.notify(new Job("test"), null, new MyListener(), Lease.FOREVER, null);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {

View File

@ -0,0 +1,18 @@
/*
* User: tom
* Date: Aug 23, 2002
* Time: 3:06:21 PM
*/
package net.sourceforge.pmd.dcpd;
import net.jini.core.entry.Entry;
public class Job implements Entry {
public String name;
public Job() {}
public Job(String name) {
this.name = name;
}
}