now callback works
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@774 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -10,7 +10,6 @@ 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
|
||||
set GROUP_ARG=-Dcom.sun.jini.lookup.groups=public
|
||||
rem set CODEBASE=-Djava.rmi.server.codebase=http://mordor:8081/space-examples-dl.jar
|
||||
set CODEBASE=-Djava.rmi.server.codebase=http://mordor:8081/dcpd.jar
|
||||
|
||||
java %MEMORY_ARG% %POLICY_ARG% %SPACENAME_ARG% %GROUP_ARG% -cp %CLASSPATH% %CODEBASE% %MAIN%
|
||||
|
@ -21,12 +21,16 @@ public class DCPDWorker {
|
||||
public DCPDWorker() {
|
||||
try {
|
||||
space = Util.findSpace("mordor");
|
||||
space.notify(new Job("test"), null, new JobAddedListener(space), Lease.FOREVER, null);
|
||||
space.notify(new Job("test"), null, new JobAddedListener(space, this), Lease.FOREVER, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void jobAdded(Job job) {
|
||||
System.out.println("GOT A JOB NAMED " + job.name);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new DCPDWorker();
|
||||
}
|
||||
|
@ -15,27 +15,20 @@ import java.rmi.server.UnicastRemoteObject;
|
||||
|
||||
public class JobAddedListener extends UnicastRemoteObject implements RemoteEventListener {
|
||||
|
||||
public JavaSpace space;
|
||||
protected JavaSpace space;
|
||||
protected DCPDWorker worker;
|
||||
|
||||
public JobAddedListener() throws RemoteException {}
|
||||
|
||||
public JobAddedListener(JavaSpace space) throws RemoteException {
|
||||
public JobAddedListener(JavaSpace space, DCPDWorker worker) throws RemoteException {
|
||||
this.space = space;
|
||||
this.worker = worker;
|
||||
}
|
||||
|
||||
public void notify(RemoteEvent event) throws UnknownEventException, RemoteException {
|
||||
System.out.println("HOWDY!");
|
||||
try {
|
||||
if (space == null) {
|
||||
System.out.println("SPACE IS NULL");
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Job job = (Job)space.take(new Job("test"), null, 1000);
|
||||
worker.jobAdded(job);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Reference in New Issue
Block a user