KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.shark.corba.poa;
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 David Forslund
11  */

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