KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > CacheAdminCORBA


1 package org.enhydra.shark.corba;
2
3 import org.omg.WfBase.*;
4 import org.enhydra.shark.corba.WorkflowService.*;
5
6
7 /**
8  * The implementation of client interface through which client can
9  * configure shark's caches.
10  * @author Sasa Bojanic
11  */

12 public class CacheAdminCORBA extends _CacheAdministrationImplBase {
13    private SharkCORBAServer myServer;
14
15    private String JavaDoc userId;
16    private boolean connected=false;
17
18    org.enhydra.shark.api.client.wfservice.CacheAdministration myCacheAdmin;
19
20    CacheAdminCORBA (SharkCORBAServer server,org.enhydra.shark.api.client.wfservice.CacheAdministration ca) {
21       this.myServer=server;
22       this.myCacheAdmin=ca;
23    }
24
25    public void connect(String JavaDoc userId, String JavaDoc password, String JavaDoc engineName, String JavaDoc scope) throws BaseException, ConnectFailed {
26       this.userId=userId;
27
28       try {
29          if (!myServer.validateUser(userId,password)) {
30             throw new ConnectFailed("Connection failed, invalid username or password");
31          }
32          connected=true;
33          myCacheAdmin.connect(userId);
34       } catch (ConnectFailed cf) {
35          throw cf;
36       } catch (Exception JavaDoc ex) {
37          throw new BaseException();
38       }
39    }
40
41    public void disconnect() throws BaseException, NotConnected {
42       if (!connected) {
43          throw new NotConnected("The connection is not established...");
44       }
45       connected=false;
46       this._orb().disconnect(this);
47    }
48
49
50    public int getProcessCacheSize () throws BaseException, NotConnected {
51       if (!connected) {
52          throw new NotConnected("The connection is not established...");
53       }
54       try {
55          return myCacheAdmin.getProcessCacheSize();
56       } catch (Exception JavaDoc e) {
57          throw new BaseException();
58       }
59    }
60
61    public void setProcessCacheSize (int size) throws BaseException, NotConnected {
62       if (!connected) {
63          throw new NotConnected("The connection is not established...");
64       }
65       try {
66          myCacheAdmin.setProcessCacheSize(size);
67       } catch (Exception JavaDoc e) {
68          throw new BaseException();
69       }
70    }
71
72    public int howManyCachedProcesses() throws BaseException, NotConnected {
73       if (!connected) {
74          throw new NotConnected("The connection is not established...");
75       }
76       try {
77          return myCacheAdmin.howManyCachedProcesses();
78       } catch (Exception JavaDoc e) {
79          throw new BaseException();
80       }
81    }
82
83    public void clearProcessCache () throws BaseException, NotConnected {
84       if (!connected) {
85          throw new NotConnected("The connection is not established...");
86       }
87       try {
88          myCacheAdmin.clearProcessCache();
89       } catch (Exception JavaDoc e) {
90          throw new BaseException();
91       }
92    }
93
94
95    public int getResourceCacheSize () throws BaseException, NotConnected {
96       if (!connected) {
97          throw new NotConnected("The connection is not established...");
98       }
99       try {
100          return myCacheAdmin.getResourceCacheSize();
101       } catch (Exception JavaDoc e) {
102          throw new BaseException();
103       }
104    }
105
106    public void setResourceCacheSize(int size) throws BaseException, NotConnected {
107       if (!connected) {
108          throw new NotConnected("The connection is not established...");
109       }
110       try {
111          myCacheAdmin.setResourceCacheSize(size);
112       } catch (Exception JavaDoc e) {
113          throw new BaseException();
114       }
115    }
116
117    public int howManyCachedResources() throws BaseException, NotConnected {
118       if (!connected) {
119          throw new NotConnected("The connection is not established...");
120       }
121       try {
122          return myCacheAdmin.howManyCachedResources();
123       } catch (Exception JavaDoc e) {
124          throw new BaseException();
125       }
126    }
127
128    public void clearResourceCache () throws BaseException, NotConnected {
129       if (!connected) {
130          throw new NotConnected("The connection is not established...");
131       }
132       try {
133          myCacheAdmin.clearResourceCache();
134       } catch (Exception JavaDoc e) {
135          throw new BaseException();
136       }
137    }
138
139 }
140
Popular Tags