KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > rmi > server > RmiConnectionServerSide


1 package com.daffodilwoods.rmi.server;
2
3 import java.rmi.*;
4 import java.rmi.server.*;
5 import java.util.*;
6
7 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*;
8 import com.daffodilwoods.daffodildb.server.serversystem.*;
9 import com.daffodilwoods.daffodildb.server.sql99.dml.*;
10 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*;
11 import com.daffodilwoods.database.general.*;
12 import com.daffodilwoods.database.resource.*;
13 import com.daffodilwoods.rmi.interfaces.*;
14
15 public class RmiConnectionServerSide extends UnicastRemoteObject implements _RmiConnection, java.rmi.server.Unreferenced JavaDoc {
16
17    _Connection connection_interface;
18    WeakHashMap selectIteratorMap;
19    RmiPreparedStatementFactory statementFactory;
20    String JavaDoc client = null;
21    public RmiConnectionServerSide(_Connection connection_interface) throws RemoteException {
22       this(connection_interface, new RmiPreparedStatementFactory());
23    }
24
25    public RmiConnectionServerSide(_Connection connection_interface,
26                                   RmiPreparedStatementFactory statementFactory0) throws RemoteException {
27       super();
28       this.connection_interface = connection_interface;
29       selectIteratorMap = new WeakHashMap();
30       statementFactory = statementFactory0;
31    }
32
33    public void setTransactionIsolation(int level) throws DException,
34        RemoteException {
35       connection_interface.setTransactionIsolation(level);
36    }
37
38    public Object JavaDoc[] executeBatch(String JavaDoc query) throws DException, RemoteException {
39       return connection_interface.executeBatch(query);
40    }
41
42    public void setAutoCommit(boolean autoCommit) throws DException,
43        RemoteException {
44       connection_interface.setAutoCommit(autoCommit);
45    }
46
47    public Object JavaDoc executeUpdate(String JavaDoc query, int queryTimeOut) throws DException,
48        RemoteException {
49       return connection_interface.executeUpdate(query, queryTimeOut);
50    }
51
52    public void setCurrentCatalog(String JavaDoc catalog) throws DException,
53        RemoteException {
54       connection_interface.setCurrentCatalog(catalog);
55    }
56
57    public void rollback() throws DException, RemoteException {
58       connection_interface.rollback();
59    }
60
61    public void commit() throws DException, RemoteException {
62       connection_interface.commit();
63    }
64
65    public void finalize() {
66        try {
67            RmiServerServerSide.RmiClientHelper.getInstance().performAction(
68                    client, false , null);
69
70        } catch (Exception JavaDoc ex) {
71        }
72    }
73
74    public void close() throws DException, RemoteException {
75        connection_interface.close();
76        UnicastRemoteObject.unexportObject(this, true);
77        try {
78            RmiServerServerSide.RmiClientHelper.getInstance().performAction(
79                    client, false,null);
80        } catch (Exception JavaDoc ex) {
81        }
82    }
83
84    public String JavaDoc getDatabaseURL() throws DException, RemoteException {
85       return connection_interface.getDatabaseURL();
86    }
87
88    public String JavaDoc getCurrentUser() throws DException, RemoteException {
89       return connection_interface.getCurrentUser();
90    }
91
92    public String JavaDoc getCurrentCatalog() throws DException, RemoteException {
93       return connection_interface.getCurrentCatalog();
94    }
95
96    public Object JavaDoc getSessionConstant() throws DException, RemoteException {
97       return connection_interface.getSessionConstant();
98    }
99
100    public _RmiConnection getSystemConnection() throws DException,
101        RemoteException {
102       return new RmiConnectionServerSide(connection_interface.getSystemConnection(),
103                                          statementFactory);
104    }
105
106    public int getIsolationLevel() throws DException, RemoteException {
107       return connection_interface.getIsolationLevel();
108    }
109
110    public Object JavaDoc[] createDeepRecordCopy(QualifiedIdentifier tableName,
111                                         Object JavaDoc[] keys) throws DException,
112        RemoteException {
113       return connection_interface.createDeepRecordCopy(tableName, keys);
114    }
115
116    public boolean isDataModified() throws DException, RemoteException {
117       return connection_interface.isDataModified();
118    }
119
120    public void unreferenced() {
121    }
122
123    public _RmiPreparedStatement getPreparedStatement(String JavaDoc query, int type) throws
124        DException, RemoteException {
125       RmiPreparedStatementServerSide preparedStatement = statementFactory.getStatement();
126       preparedStatement.initialize(connection_interface.
127                                    getPreparedStatement(query, type), this, statementFactory);
128       preparedStatement.setQuery(query);
129       preparedStatement.setConnection(connection_interface);
130       return preparedStatement;
131    }
132
133    public Object JavaDoc execute(String JavaDoc query, int queryTimeOut, int type) throws
134        DException, RemoteException {
135
136       Object JavaDoc result = connection_interface.execute(query, queryTimeOut, type);
137       if (result instanceof _SelectIterator) {
138          RmiSelectIteratorServerSide tableRetriever = new RmiSelectIteratorServerSide( (
139              _SelectIterator) result, this);
140          tableRetriever.setConnection(connection_interface);
141          return tableRetriever;
142       }
143       return result;
144
145    }
146
147    public Object JavaDoc executeQuery(String JavaDoc query, int queryTimeOut, int type) throws
148        DException, RemoteException {
149       Object JavaDoc result = connection_interface.executeQuery(query, queryTimeOut, type);
150       RmiSelectIteratorServerSide tableRetriever = new RmiSelectIteratorServerSide( (
151           _SelectIterator) result, this);
152       tableRetriever.setConnection(connection_interface);
153       return tableRetriever;
154
155    }
156
157    public void commitSavePoint() throws DException, RemoteException {
158       connection_interface.commitSavePoint();
159    }
160
161    public void rollbackSavePoint(String JavaDoc savepoint) throws DException, RemoteException {
162       connection_interface.rollbackSavePoint(savepoint);
163    }
164
165    public void releaseSavePoint(String JavaDoc savepoint) throws DException, RemoteException {
166       connection_interface.releaseSavePoint(savepoint);
167    }
168
169    public void setSavePoint(String JavaDoc savepoint) throws DException, RemoteException {
170       connection_interface.setSavePoint(savepoint);
171    }
172
173    public String JavaDoc setSavePoint() throws DException, RemoteException {
174       return connection_interface.setSavePoint();
175    }
176
177    public boolean getAutoCommit() throws DException, RemoteException {
178       return connection_interface.getAutoCommit();
179    }
180
181    public _RmiPreparedStatement getPreparedStatement(String JavaDoc query, int type, int autoGeneratedType, Object JavaDoc autoGenetatedValues) throws DException, RemoteException {
182       RmiPreparedStatementServerSide preparedStatement = statementFactory.getStatement();
183       preparedStatement.initialize(connection_interface.
184                                    getPreparedStatement(query, type, autoGeneratedType, autoGenetatedValues), this, statementFactory);
185       preparedStatement.setQuery(query);
186       preparedStatement.setConnection(connection_interface);
187       return preparedStatement;
188
189    }
190
191    public Object JavaDoc execute(String JavaDoc query, int queryTimeOut, int type, int queryType, int autoGeneratedType, Object JavaDoc autoGenetatedValues) throws DException, RemoteException {
192       Object JavaDoc result = connection_interface.execute(query, queryTimeOut, type, queryType, autoGeneratedType, autoGenetatedValues);
193       if (result instanceof _SelectIterator) {
194          RmiSelectIteratorServerSide tableRetriever = new RmiSelectIteratorServerSide( (
195              _SelectIterator) result, this);
196          tableRetriever.setConnection(connection_interface);
197          return tableRetriever;
198       } else if (result instanceof DMLResult) {
199         _ColumnCharacteristics cc = (_ColumnCharacteristics) ( (DMLResult) result).getColumnCharacteristics();
200          if (cc != null && (cc instanceof RmiSelectColumnCharacteristics)== false) {
201             int columnCount = cc.getColumnCount();
202             ColumnInfo[] ci = new ColumnInfo[columnCount];
203             for (int i = 1; i <= columnCount; i++) {
204                ci[i-1]= new ColumnInfo(cc.getTableName(i), cc.getCatalogName(i), cc.getSchemaName(i),
205                    cc.getColumnName(i), cc.getColumnType(i), cc.getSize(i), cc.getPrecision(i),
206                    cc.getScale(i), cc.isNullable(i), cc.getColumnLabel(i), cc.getQualifiedTableName(i), cc.isAutoIncrement(i));
207
208             }
209             ( (DMLResult) result).setColumnCharacteristics(new RmiSelectColumnCharacteristics(ci));
210          }
211       }
212       return result;
213    }
214
215
216    public boolean isClosed() throws DException, RemoteException {
217       return connection_interface.isClosed();
218    }
219    public void setClient(String JavaDoc client){
220     this.client = client;
221 }
222
223 }
224
Popular Tags