Source Code Cross Referenced for DbLocalClient.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » core » DbRemote » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » Ozone 1.1 » org.ozoneDB.core.DbRemote 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Core License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: DbLocalClient.java,v 1.2 2002/06/08 00:49:38 mediumnet Exp $
008:
009:        package org.ozoneDB.core.DbRemote;
010:
011:        import java.io.*;
012:        import org.ozoneDB.DxLib.*;
013:        import org.ozoneDB.DxLib.net.DxClient;
014:        import org.ozoneDB.*;
015:        import org.ozoneDB.core.*;
016:        import org.ozoneDB.util.*;
017:
018:        /**
019:         * Note: the entire connection is synchronized when ExternalDatabase is sending
020:         * a command through; so synchronization of send/receive is not strictly needed
021:         *
022:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
023:         * @version $Revision: 1.2 $Date: 2002/06/08 00:49:38 $
024:         */
025:        public class DbLocalClient extends DbClient {
026:
027:            protected Env env;
028:
029:            protected User user;
030:
031:            protected DbCommand currentCommand = null;
032:
033:            protected ByteArrayOutputStream copyStream;
034:
035:            protected ProxyObjectGate proxyObjectGate;
036:
037:            public DbLocalClient(ExternalDatabase _db, Env _env, String _user)
038:                    throws Exception {
039:                super (_db, _user);
040:                env = _env;
041:
042:                user = env.userManager.userForName(_user);
043:                if (user == null) {
044:                    throw new PermissionDeniedExc("No such user.");
045:                }
046:
047:                copyStream = new ByteArrayOutputStream(4 * 1024);
048:
049:                proxyObjectGate = new ProxyObjectGate();
050:
051:                env.getLocalClientTracker().addClient(this );
052:            }
053:
054:            public synchronized void send(Object obj) throws IOException {
055:                try {
056:                    copyStream.reset();
057:
058:                    // FIXME: copy only args of DbInvoke
059:                    currentCommand = (DbCommand) copyObject(obj, false);
060:                    currentCommand.env = env;
061:                    currentCommand.setProxyObjectGate(getProxyObjectGate());
062:                    env.transactionManager
063:                            .handleCommand(currentCommand, user/*this*/);
064:                } catch (Exception e) {
065:                    throw new IOException(e.toString());
066:                }
067:            }
068:
069:            public synchronized Object receive() throws IOException,
070:                    ClassNotFoundException {
071:                if (currentCommand == null) {
072:                    throw new IllegalStateException(
073:                            "Attempt to receive() without prior send().");
074:                }
075:                Object result = copyObject(currentCommand.result, true);
076:                currentCommand = null;
077:                return result;
078:            }
079:
080:            /**
081:             * Copy the given object using ByteArrayStreams so all streamable
082:             * objects (all database objects) can be copied.
083:             */
084:            protected synchronized Object copyObject(Object obj,
085:                    boolean updateLinks) throws IOException {
086:                ObjectInputStream in = null;
087:                try {
088:                    copyStream.reset();
089:
090:                    ObjectOutputStream out = new ObjectOutputStream(copyStream);
091:                    out.writeObject(obj);
092:                    out.close();
093:
094:                    in = new ObjectInputStream(new ByteArrayInputStream(
095:                            copyStream.toByteArray()));
096:
097:                    // remove in finally clause
098:                    if (updateLinks) {
099:                        OzoneProxy.linkTable.addForKey(db, in);
100:                    }
101:
102:                    Object result = in.readObject();
103:
104:                    return result;
105:                } catch (Exception e) {
106:                    throw new IOException(e.toString());
107:                } finally {
108:                    if (updateLinks && in != null) {
109:                        OzoneProxy.linkTable.removeForKey(in);
110:                    }
111:                }
112:
113:            }
114:
115:            public boolean objectAvailable() {
116:                throw new RuntimeException("Method not implemented.");
117:            }
118:
119:            public void close() throws IOException {
120:            }
121:
122:            public void onConnect() throws IOException {
123:                throw new RuntimeException("Method not implemented.");
124:            }
125:
126:            public void onDeconnect() throws IOException {
127:                throw new RuntimeException("Method not implemented.");
128:            }
129:
130:            public ObjectInputStream inputStream() {
131:                throw new RuntimeException("Method not implemented.");
132:            }
133:
134:            public ObjectOutputStream outputStream() {
135:                throw new RuntimeException("Method not implemented.");
136:            }
137:
138:            /**
139:                Returns the ProxyObjectGate for this Client.
140:             */
141:            public ProxyObjectGate getProxyObjectGate() {
142:                return proxyObjectGate;
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.