Source Code Cross Referenced for DatasetPoolManager.java in  » GIS » GeoTools-2.4.1 » it » geosolutions » imageio » plugins » jhdf » pool » 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 » GIS » GeoTools 2.4.1 » it.geosolutions.imageio.plugins.jhdf.pool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package it.geosolutions.imageio.plugins.jhdf.pool;
002:
003:        import it.geosolutions.imageio.plugins.jhdf.pool.DatasetPool.DatasetCopy;
004:
005:        import java.io.File;
006:        import java.util.TreeMap;
007:        import java.util.logging.Logger;
008:
009:        /**
010:         * This class provides to manage different dataset pools (A dataset pool for
011:         * each (sub)dataset contained within the originating source. An ImageReader
012:         * should ask t
013:         * 
014:         * 
015:         * @author Romagnoli Daniele
016:         * @author Giannecchini Simone
017:         * 
018:         */
019:
020:        public class DatasetPoolManager {
021:
022:            private static final Logger LOGGER = org.geotools.util.logging.Logging
023:                    .getLogger("it.geosolutions.imageio.plugins.jhdf.pool");
024:
025:            /** Hashmap containing couples (key,DatasetPool). */
026:            // protected Map pooledDatasetsMap = Collections.synchronizedMap(new
027:            // HashMap(
028:            // 10));
029:            /** Map to associate keys to index */
030:            // protected TreeMap indexToKeyMap = new TreeMap();
031:            protected TreeMap indexToPoolMap = new TreeMap();
032:
033:            /**
034:             * The number of pooled Datasets. If a HDF file contains 4 subdatasets, this *
035:             * variable may assume as value, atmost 4. The number of copies of the same
036:             * dataset within a pool is not related with this value.
037:             */
038:            private int differentPooledDatasets;
039:
040:            /** The number of subdatasets contained within the source file */
041:            private int subdatasetNumber;
042:
043:            private File originatingFile;
044:
045:            // public DatasetCopy getDatasetCopy(final int datasetIndex) {
046:            // return getDatasetCopy(getKeyFromIndex(datasetIndex));
047:            // }
048:            //
049:            // // TODO: I need to set a proper type for the search key within the
050:            // hashmap.
051:            // // Maybe "String" is not the proper one.
052:            // private DatasetCopy getDatasetCopy(final String key) {
053:            // DatasetCopy dsc = null;
054:            // synchronized (pooledDatasetsMap) {
055:            // if (pooledDatasetsMap == null
056:            // || key==null || !pooledDatasetsMap.containsKey(key)){
057:            // // populate the pool
058:            // ;
059:            //				
060:            // }
061:            //				
062:            //
063:            // if (pooledDatasetsMap.containsKey(key)) {
064:            // DatasetPool pool = (DatasetPool) pooledDatasetsMap.get(key);
065:            // synchronized (pool) {
066:            // if (pool.hasAvailableDatasets()) {
067:            // dsc = pool.getDatasetCopy();
068:            // }
069:            // }
070:            // }
071:            // }
072:            // return dsc;
073:            // }
074:            //
075:            // public void getBackDatasetCopy(final int datasetIndex,
076:            // final int copyID, final boolean hasBeenModified) {
077:            // getBackDatasetCopy(getKeyFromIndex(datasetIndex), copyID,
078:            // hasBeenModified);
079:            // }
080:            //
081:            // private void getBackDatasetCopy(final String key, final int copyID,
082:            // final boolean hasBeenModified) {
083:            // synchronized (pooledDatasetsMap) {
084:            // if (pooledDatasetsMap.containsKey(key)) {
085:            // DatasetPool pool = (DatasetPool) pooledDatasetsMap.get(key);
086:            // synchronized (pool) {
087:            // pool.getBackDatasetCopy(copyID, hasBeenModified);
088:            // }
089:            // }
090:            // }
091:            // }
092:            //
093:            // /**
094:            // * A simple method providing to retrieve the key which is related to a
095:            // * dataset from dataset index.
096:            // *
097:            // * @param datasetIndex
098:            // * @return
099:            // */
100:            // protected String getKeyFromIndex(final int datasetIndex) {
101:            // String key = null;
102:            // synchronized (indexToKeyMap) {
103:            // if (indexToKeyMap != null && !indexToKeyMap.isEmpty()
104:            // && indexToKeyMap.containsKey(datasetIndex))
105:            // key = (String) indexToKeyMap.get(datasetIndex);
106:            // }
107:            // return key;
108:            // }
109:
110:            public DatasetCopy getDatasetCopy(int imageIndex) {
111:                DatasetCopy dsc = null;
112:                System.out.print("Entering synchronized map-->");
113:                synchronized (indexToPoolMap) {
114:                    // TODO: REMOVE this MESSAGE
115:                    System.out.print("ENTERED... ->");
116:                    System.out.print("MANAGER: getting DatasetCopy ");
117:                    if (indexToPoolMap == null
118:                            || !indexToPoolMap.containsKey(Integer
119:                                    .valueOf(imageIndex))) {
120:                        // populate the pool
121:                        indexToPoolMap.put(Integer.valueOf(imageIndex),
122:                                new DatasetPool(imageIndex, originatingFile));
123:                        differentPooledDatasets++;
124:                    }
125:                    if (indexToPoolMap.containsKey(Integer.valueOf(imageIndex))) {
126:                        DatasetPool pool = (DatasetPool) indexToPoolMap
127:                                .get(Integer.valueOf(imageIndex));
128:                        //				synchronized (pool) {
129:                        dsc = pool.getDatasetCopy();
130:                        //				}
131:                    }
132:                }
133:                // TODO: REMOVE this MESSAGE
134:                System.out.print(dsc.getCopyID() + "\n");
135:                return dsc;
136:            }
137:
138:            public void getBackDatasetCopy(final int key, final int copyID,
139:                    final boolean hasBeenModified) {
140:                synchronized (indexToPoolMap) {
141:                    // TODO: REMOVE this MESSAGE
142:                    System.out.print("MANAGER: getting back DatasetCopy "
143:                            + String.valueOf(copyID) + "\n");
144:                    if (indexToPoolMap.containsKey(Integer.valueOf(key))) {
145:                        DatasetPool pool = (DatasetPool) indexToPoolMap
146:                                .get(Integer.valueOf(key));
147:                        //				synchronized (pool) {
148:                        pool.getBackDatasetCopy(copyID, hasBeenModified);
149:                        //				}
150:                    }
151:                }
152:            }
153:
154:            public File getOriginatingFile() {
155:                return originatingFile;
156:            }
157:
158:            public void setOriginatingFile(File originatingFile) {
159:                this.originatingFile = originatingFile;
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.