Source Code Cross Referenced for PersistencePluginAdapter.java in  » Science » Cougaar12_4 » org » cougaar » core » persist » 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 » Science » Cougaar12_4 » org.cougaar.core.persist 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.core.persist;
028:
029:        import org.cougaar.bootstrap.SystemProperties;
030:        import org.cougaar.core.adaptivity.OMCRange;
031:        import org.cougaar.core.adaptivity.OMCRangeList;
032:        import org.cougaar.util.log.Logger;
033:
034:        /**
035:         * Adapter to simplify writing {@link PersistencePlugin} implementations.
036:         * Implements several methods in the PersistencePlugin API that often
037:         * need not be specialized in individual implementaions.
038:         */
039:        public abstract class PersistencePluginAdapter implements 
040:                PersistenceNames {
041:            protected static final String[] emptyStringArray = new String[0];
042:            protected static final OMCRangeList emptyOMCRangeList = new OMCRangeList(
043:                    new OMCRange[0]);
044:            protected static String[] controlNames = { PERSISTENCE_ARCHIVE_COUNT_NAME };
045:            protected PersistencePluginSupport pps;
046:
047:            protected String name;
048:            protected String[] params;
049:            protected int archiveCount; // The number of archives to keep
050:            protected int consolidationPeriod;
051:            protected long persistenceInterval;
052:            protected boolean writable = true;
053:
054:            protected void init(PersistencePluginSupport pps, String name,
055:                    String[] params) {
056:                this .pps = pps;
057:                this .name = name;
058:                this .params = params;
059:                archiveCount = SystemProperties
060:                        .getInt(
061:                                PERSISTENCE_ARCHIVE_COUNT_PROP,
062:                                (SystemProperties
063:                                        .getBoolean("org.cougaar.core.persistence.archivingDisabled") ? 0
064:                                        : Integer.MAX_VALUE));
065:                Logger logger = pps.getLogger();
066:                for (int i = 0; i < params.length; i++) {
067:                    String param = params[i];
068:                    try {
069:                        if (param.startsWith(PERSISTENCE_ARCHIVE_COUNT_PREFIX)) {
070:                            archiveCount = Integer.parseInt(param
071:                                    .substring(PERSISTENCE_ARCHIVE_COUNT_PREFIX
072:                                            .length()));
073:                            if (logger.isDebugEnabled())
074:                                logger.debug("archiveCount=" + archiveCount);
075:                            continue;
076:                        }
077:                        if (param.startsWith(PERSISTENCE_INTERVAL_PREFIX)) {
078:                            persistenceInterval = Long.parseLong(param
079:                                    .substring(PERSISTENCE_INTERVAL_PREFIX
080:                                            .length()));
081:                            if (logger.isDebugEnabled())
082:                                logger.debug("persistenceInterval="
083:                                        + persistenceInterval);
084:                            continue;
085:                        }
086:                        if (param
087:                                .startsWith(PERSISTENCE_CONSOLIDATION_PERIOD_PREFIX)) {
088:                            consolidationPeriod = Integer
089:                                    .parseInt(param
090:                                            .substring(PERSISTENCE_CONSOLIDATION_PERIOD_PREFIX
091:                                                    .length()));
092:                            if (logger.isDebugEnabled())
093:                                logger.debug("consolidationPeriod="
094:                                        + consolidationPeriod);
095:                            continue;
096:                        }
097:                        if (param.startsWith(PERSISTENCE_DISABLE_WRITE_PREFIX)) {
098:                            writable = !"true".equals(param
099:                                    .substring(PERSISTENCE_DISABLE_WRITE_PREFIX
100:                                            .length()));
101:                            if (logger.isDebugEnabled())
102:                                logger.debug("writable=" + writable);
103:                            continue;
104:                        }
105:                        handleParameter(param);
106:                    } catch (Exception e) {
107:                        pps.getLogger().error("Parse error " + param);
108:                    }
109:                }
110:            }
111:
112:            protected abstract void handleParameter(String param);
113:
114:            protected String parseParamValue(String param, String key) {
115:                if (param.startsWith(key)) {
116:                    return param.substring(key.length());
117:                }
118:                return null;
119:            }
120:
121:            public String getName() {
122:                return name;
123:            }
124:
125:            public boolean isWritable() {
126:                return writable;
127:            }
128:
129:            public void setWritable(boolean newWritable) {
130:                writable = newWritable;
131:            }
132:
133:            public long getPersistenceInterval() {
134:                return persistenceInterval;
135:            }
136:
137:            public void setPersistenceInterval(long newInterval) {
138:                persistenceInterval = newInterval;
139:            }
140:
141:            public int getConsolidationPeriod() {
142:                return consolidationPeriod;
143:            }
144:
145:            public void setConsolidationPeriod(int newPeriod) {
146:                consolidationPeriod = newPeriod;
147:            }
148:
149:            public int getParamCount() {
150:                return params.length;
151:            }
152:
153:            public String getParam(int i) {
154:                return params[i];
155:            }
156:
157:            public String[] getControlNames() {
158:                return controlNames;
159:            }
160:
161:            public OMCRangeList getControlValues(String controlName) {
162:                if (PERSISTENCE_ARCHIVE_COUNT_NAME.equals(controlName)) {
163:                    return new OMCRangeList(new Integer(0), new Integer(
164:                            Integer.MAX_VALUE));
165:                }
166:                return emptyOMCRangeList; // Should never be called
167:            }
168:
169:            public void setControl(String controlName, Comparable newValue) {
170:                if (PERSISTENCE_ARCHIVE_COUNT_NAME.equals(controlName)) {
171:                    archiveCount = ((Integer) newValue).intValue();
172:                }
173:            }
174:
175:            public java.sql.Connection getDatabaseConnection(Object locker) {
176:                throw new UnsupportedOperationException(
177:                        "FilePersistence.getDatabaseConnection not supported");
178:            }
179:
180:            public void releaseDatabaseConnection(Object locker) {
181:                throw new UnsupportedOperationException(
182:                        "FilePersistence.releaseDatabaseConnection not supported");
183:            }
184:
185:            public boolean checkOwnership() throws PersistenceException {
186:                return true;
187:            }
188:
189:            public void lockOwnership() throws PersistenceException {
190:            }
191:
192:            public void unlockOwnership() throws PersistenceException {
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.