Source Code Cross Referenced for ProxyObjectGate.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:        /* ProxyObjectGate.java
002:         */
003:
004:        package org.ozoneDB.core.DbRemote;
005:
006:        import java.util.HashMap;
007:        import java.util.Iterator;
008:
009:        import org.ozoneDB.OzoneProxy;
010:        import org.ozoneDB.core.GarbageCollector;
011:        import org.ozoneDB.core.ObjectID;
012:
013:        /**
014:         A gate for Proxy objects. Every Proxy which leaves the Database should wander
015:         through a ProxyObjectGate to be registered (so that the objects referenced by such a Proxy
016:         are known to be referenced and thus reachable).
017:
018:         Every Proxy which left the Database, was registered and is now known to be unreachable should
019:         sign itself off exactly one time.
020:
021:         @author <A HREF="http://www.medium.net/">Medium.net</A>
022:         */
023:        public class ProxyObjectGate {
024:            /**
025:                This is a Mapping from {@link ObjectID} to Integer. It represents the
026:                count of references this client holds to the database object represented by the objectID.
027:
028:                Entries have to be added when returning {@link OzoneProxy}s directly or indirectly.
029:                Entries have to be removed if a {#link OzoneProxy} is finalize()d on the client side.
030:                This way, the ozoneDB always know which objects are referenced and thus have to be
031:                considered reachable, even if they were not reachable internally.
032:             */
033:            protected HashMap objectsReferencesByClient;
034:
035:            protected GarbageCollector garbageCollectorToBeNotifiedOfExportedReferences;
036:
037:            /**
038:                This is an Integer which represents the number "1".
039:             */
040:            protected final static Integer one = new Integer(1);
041:
042:            /**
043:                Creates a new ProxyObjectGate.
044:             */
045:            protected ProxyObjectGate() {
046:                objectsReferencesByClient = new HashMap();
047:            }
048:
049:            public void addObjectReferencedByClient(OzoneProxy proxy) {
050:                if (proxy != null) {
051:                    synchronized (objectsReferencesByClient) {
052:                        ObjectID id = proxy.remoteID();
053:
054:                        if (garbageCollectorToBeNotifiedOfExportedReferences != null) {
055:                            garbageCollectorToBeNotifiedOfExportedReferences
056:                                    .notifyDatabaseObjectIsAboutToBeExported(id);
057:                        }
058:
059:                        Object oldEntry = objectsReferencesByClient
060:                                .put(id, one);
061:
062:                        if (oldEntry != null) {
063:                            objectsReferencesByClient.put(id, new Integer(
064:                                    ((Integer) oldEntry).intValue() + 1));
065:                        }
066:                    }
067:                }
068:            }
069:
070:            protected void removeObjectReferencedByClient(OzoneProxy proxy) {
071:                removeObjectReferencedByClient(proxy.remoteID());
072:            }
073:
074:            protected void removeObjectReferencedByClient(ObjectID id) {
075:                synchronized (objectsReferencesByClient) {
076:                    Object oldEntry = objectsReferencesByClient.remove(id);
077:
078:                    if (oldEntry != null) {
079:                        if (oldEntry != one) {
080:                            int count = ((Integer) oldEntry).intValue();
081:
082:                            count--;
083:
084:                            if (count > 0) {
085:                                if (count > 1) {
086:                                    objectsReferencesByClient.put(id,
087:                                            new Integer(count));
088:                                } else {
089:                                    objectsReferencesByClient.put(id, one);
090:                                }
091:                            }
092:                        } else {
093:                            // The reference count was exactly one, now the reference is removed from the map.
094:                        }
095:                    } else {
096:                        // oldEntry never may be null. What should we do here?
097:                    }
098:                }
099:            }
100:
101:            /**
102:                Starts filtering references to database objects ({@link OzoneProxy}s) which
103:                are exported to the client.
104:                Every reference which is exported will be notified to the given GarbageCollector.
105:                Additionally, references which are known to be used by the client are notified to the
106:                given GarbageCollector within this call.
107:             */
108:            public void startFilterDatabaseObjectReferencesExports(
109:                    GarbageCollector garbageCollector) {
110:
111:                synchronized (objectsReferencesByClient) {
112:                    this .garbageCollectorToBeNotifiedOfExportedReferences = garbageCollector;
113:
114:                    Iterator i = objectsReferencesByClient.keySet().iterator();
115:
116:                    while (i.hasNext()) {
117:                        garbageCollector
118:                                .notifyDatabaseObjectIsExported((ObjectID) i
119:                                        .next());
120:                    }
121:                }
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.