Methods Summary |
---|
public Service[] | Lookup(java.lang.String stype)Return the current list of services as an array
if (!registry.containsKey(stype)) return new Service[] {};
Vector list = (Vector)registry.get(stype);
Service[] result = new Service[list.size()];
list.copyInto(result);
return result;
|
public java.lang.String | LookupAsString(java.lang.String stype)
Service[] services = Lookup(stype);
String result = "";
for (int i=0; i<services.length; i++) {
Service service = services[i];
result += service.getServiceName() + "\t" +
service.getServiceUrl() + "\t" +
service.getServiceType() + "\t" +
service.getServiceWsdl() + "\n";
}
return result;
|
public void | Register(java.lang.String name, java.lang.String url, java.lang.String stype, java.lang.String wsdl)Register a new serivce
Vector list = (Vector)registry.get(stype);
if (list == null) registry.put(stype, list=new Vector());
Service service = find(list, name);
if (service==null)
list.add(service=new Service());
service.setServiceName(name);
service.setServiceUrl(url);
service.setServiceType(stype);
service.setServiceWsdl(wsdl);
save();
|
public void | Unregister(java.lang.String name)Unregister a serivce
Enumeration e1 = registry.keys();
while (e1.hasMoreElements()) {
Vector list = (Vector) registry.get(e1.nextElement());
Enumeration e2 = list.elements();
while (e2.hasMoreElements()) {
Service s = (Service) e2.nextElement();
if (s.getServiceName().equals(name)) {
list.remove(s);
save();
}
}
}
|
private Service | find(java.util.Vector list, java.lang.String name)
Enumeration e = list.elements();
while (e.hasMoreElements()) {
Service s = (Service) e.nextElement();
if (s.getServiceName().equals(name)) return s;
}
return null;
|
public void | load()
try {
FileInputStream fis = new FileInputStream("bid.reg");
ObjectInputStream ois = new ObjectInputStream( fis );
registry = (Hashtable) ois.readObject();
ois.close();
fis.close();
} catch(java.io.FileNotFoundException fnfe){
// nop
} catch(Exception e){
e.printStackTrace();
}
|
public void | save()
try {
FileOutputStream fos = new FileOutputStream("bid.reg");
ObjectOutputStream oos = new ObjectOutputStream( fos );
oos.writeObject( registry );
oos.close();
fos.close();
} catch(Exception e){
e.printStackTrace();
}
|