01: package net.xoetrope.optional.service;
02:
03: import java.util.Hashtable;
04:
05: /**
06: * The basis of each element in the service proxy stack.
07: * <p>Copyright (c) Xoetrope Ltd. 2001-2003</p>
08: * $Revision: 1.1 $
09: */
10: public abstract class ServiceProxy {
11: public static final int OK = 0;
12: public static final int STARTED = 1;
13: public static final int PENDING = 2;
14: public static final int COMPLETE = 3;
15: public static final int FAILED = 4;
16:
17: protected String routeName;
18: protected String serviceName;
19: protected int status = OK;
20: protected ServiceProxy nextProxy;
21:
22: /**
23: * Calls call( null, null, null )
24: * @return the result of the service call
25: * @throws ServiceProxyException
26: */
27: public Object call() throws ServiceProxyException {
28: try {
29: return call(null, null, null);
30: } catch (ServiceProxyException e) {
31: throw (e);
32: }
33: }
34:
35: public abstract Object call(String method, String[] argNames,
36: Object[] arguments) throws ServiceProxyException;
37:
38: public int getStatus() {
39: return status;
40: }
41:
42: protected String getRouteName() {
43: return routeName;
44: }
45:
46: public void setRouteName(String route) {
47: routeName = route;
48: }
49:
50: protected String getServiceName() {
51: return serviceName;
52: }
53:
54: public void setServiceName(String name) {
55: serviceName = name;
56: }
57:
58: public void setNextProxy(ServiceProxy sp) {
59: nextProxy = sp;
60: }
61:
62: /**
63: * Set the attributes for this service proxy.
64: * @param t
65: */
66: public void setAttributes(Hashtable t) {
67: }
68:
69: public int getParamIndex(String name, String argNames[]) {
70: for (int i = 0; i < argNames.length; i++) {
71: if (argNames[i].compareTo(name) == 0)
72: return i;
73: }
74: return 0;
75: }
76:
77: public Object getParam(String name, String argNames[],
78: Object argValues[]) {
79: return argValues[getParamIndex(name, argNames)];
80: }
81:
82: }
|