You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Marco Ferretti <ma...@gmail.com> on 2005/06/01 12:04:03 UTC
Re: correct way of using NotificationListener
Hi Daniel,
sorry for bugging you, but I am trying to use the approach that you suggested
in the previous post on this topic :
#########################################
#### Test.java
#########################################
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.webdav.lib.NotificationListener;
import org.apache.webdav.lib.methods.DepthSupport;
public class Test {
public static void main ( String args[] ){
Test.testListener();
}
static void testListener() {
NotificationListener listener = null;
mySubscriber subscriber = null;
try{
String root = "/slide";
String resource = "files/test.log";
listener = new NotificationListener("",0,"127.0.0.1",8080,
Protocol.getProtocol("http"), new
UsernamePasswordCredentials("root","root"),
root,30000,false);
subscriber = new mySubscriber();
listener.subscribe("Update",root+"/" +
resource,DepthSupport.DEPTH_INFINITY,
600,1,subscriber,new
UsernamePasswordCredentials("root","root"));
listener.subscribe("Delete",root+"/" +
resource,DepthSupport.DEPTH_INFINITY,
600,1,subscriber,new
UsernamePasswordCredentials("root","root"));
listener.subscribe("Update/newmember",root+"/" +
resource,DepthSupport.DEPTH_INFINITY,
600,1,subscriber,new
UsernamePasswordCredentials("root","root"));
listener.subscribe("Move",root+"/" +
resource,DepthSupport.DEPTH_INFINITY,
600,1,subscriber,new
UsernamePasswordCredentials("root","root"));
} catch ( Throwable t ) {
t.printStackTrace();
}
}
}
#########################################
#### mySubscriber.java
#########################################
import java.util.Iterator;
import java.util.Map;
import org.apache.webdav.lib.Subscriber;
public class mySubscriber implements Subscriber {
public void notify( String arg0, Map arg1 ) {
System.out.println( "mySubscriber.notify()" );
System.out.println("arg0 : " + arg0);
Iterator it = arg1.keySet().iterator();
String key = null;
System.out.println("arg1 : " + arg1);
while( it.hasNext() ){
System.out.println("key : " + arg1.get(key));
}
}
}
##############################################
I then try to update the properties of the resource and delete the resource
but I got no notification ( non sysouts from mySubscriber ) .
What's the bit I am missing ?
TIA
Marco
On Thursday 12 May 2005 17:48, Daniel Florey wrote:
> I don't understand.
> You create the NotificationListener pointing to the webdav-domain (e.g.
> /exchange oder /slide or whatever the root of your webdav server is). Then
> you can subscribe to as many resources as you like.
>
> Cheers,
> Daniel
>
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-user-help@jakarta.apache.org