01: package org.drools.agent;
02:
03: import java.io.IOException;
04: import java.net.URL;
05:
06: import org.drools.rule.Package;
07:
08: /**
09: * A nicely mockable Http client interface.
10: *
11: * IM IN YR HTTP MOCKIN UR CLEINT
12: *
13: * @author Michael Neale
14: *
15: */
16: public interface IHttpClient {
17:
18: public LastUpdatedPing checkLastUpdated(URL url) throws IOException;
19:
20: public Package fetchPackage(URL url) throws IOException,
21: ClassNotFoundException;
22:
23: }
24:
25: /**
26: * This is returned when pinging for changes.
27: *
28: * @author Michael Neale
29: */
30: class LastUpdatedPing {
31: public long lastUpdated = -1;
32: public String responseMessage;
33:
34: public boolean isError() {
35: if (lastUpdated == -1)
36: return true;
37: if (responseMessage == null)
38: return true;
39: if (responseMessage.indexOf("200 OK") == -1)
40: return true;
41: return false;
42: }
43:
44: public String toString() {
45: return "Last updated: " + lastUpdated + "\n"
46: + "Reponse header: " + responseMessage;
47: }
48:
49: }
|