Scone also may contain SconePlugin objects and offers them the following services:
This package also includes the Retriever class. This class can be used to fetch any document from the internet. It is designed especially for fetching and analyzing HTML documents.
example:
plugins.ini:
//leave exactly one space after plugin: !
plugin: scone.ObserverTest
scone/ObserverTest.java:
package scone;
import java.util.*;
import scone.netobjects.*;
import scone.proxy.*;
public class ObserverTest implements Observer, SconePluginInterface{
public ObserverTest(){}
//diese Methode ruft Scone bei allen plugins auf!
public void init(Scone scone){
//diesen Observer anmelden
NetNodeCache.putObserver(this);
HtmlNodeCache.putObserver(this);
//alle 30 sekunden notifien
HtmlNodeCache.setObservePeriod(1000*30);
}
//wir koennen davon ausgehen, dass o irgendein cache ist
//und arg eine enumeration von netobjects...
public void update(Observable o, Object arg){
System.out.println("ObserverTest!");
//yes, the NetNodeCache notifies us!
if(o instanceof NetNodeCache){
//just print all new NetNode objects to the screen
for (Enumeration e = (Enumeration)arg; e.hasMoreElements() ;) {
System.out.println("New NetNode: "+((NetNode)e.nextElement()).getUri());
}
}else{
if(o instanceof HtmlNodeCache){
//just print all new HtmlNode objects to the screen
for (Enumeration e = (Enumeration)arg; e.hasMoreElements() ;) {
System.out.println("New HtmlNode: "+((HtmlNode)e.nextElement()).getTitle());
}
}
}
}
}