forked from phoedos/pmd
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:
@ -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\build
|
||||||
set CLASSPATH=%CLASSPATH%;c:\data\pmd\pmd-dcpd\lib\pmd-0.9.jar
|
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 MEMORY_ARG=-Xms128M -Xmx384M
|
||||||
set POLICY_ARG=-Djava.security.policy=c:\jini-1_2_1\policy\policy.all
|
set POLICY_ARG=-Djava.security.policy=c:\jini-1_2_1\policy\policy.all
|
||||||
set SPACENAME_ARG=-Dcom.sun.jini.outrigger.spacename=JavaSpaces
|
set SPACENAME_ARG=-Dcom.sun.jini.outrigger.spacename=JavaSpaces
|
||||||
|
@ -11,6 +11,7 @@ import net.jini.core.lookup.ServiceMatches;
|
|||||||
import net.jini.core.lookup.ServiceTemplate;
|
import net.jini.core.lookup.ServiceTemplate;
|
||||||
import net.jini.core.discovery.LookupLocator;
|
import net.jini.core.discovery.LookupLocator;
|
||||||
import net.jini.core.entry.Entry;
|
import net.jini.core.entry.Entry;
|
||||||
|
import net.jini.core.lease.Lease;
|
||||||
import net.sourceforge.pmd.cpd.*;
|
import net.sourceforge.pmd.cpd.*;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -29,20 +30,20 @@ public class DCPD {
|
|||||||
public DCPD(String javaSpaceURL) {
|
public DCPD(String javaSpaceURL) {
|
||||||
try {
|
try {
|
||||||
space = Util.findSpace("mordor");
|
space = Util.findSpace("mordor");
|
||||||
|
space.write(new Job("test"), null, Lease.FOREVER);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException("Couldn't connect to the space on " + javaSpaceURL);
|
throw new RuntimeException("Couldn't connect to the space on " + javaSpaceURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
add("C:\\j2sdk1.4.0_01\\src\\java\\lang\\", true);
|
add("C:\\j2sdk1.4.0_01\\src\\java\\lang\\", true);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
throw new RuntimeException("Couldn't load the files");
|
throw new RuntimeException("Couldn't load the files");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
Entry wrapper = new TokenSetsWrapper(tokenSets);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(String dir, boolean recurse) throws IOException {
|
private void add(String dir, boolean recurse) throws IOException {
|
||||||
|
@ -5,12 +5,45 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.pmd.dcpd;
|
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 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() {
|
public DCPDWorker() {
|
||||||
// get space
|
try {
|
||||||
// register self listener for TokenSetsWrapper objects
|
space = Util.findSpace("mordor");
|
||||||
// wait
|
space.notify(new Job("test"), null, new MyListener(), Lease.FOREVER, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
18
pmd-dcpd/src/net/sourceforge/pmd/dcpd/Job.java
Normal file
18
pmd-dcpd/src/net/sourceforge/pmd/dcpd/Job.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user