Source Code Cross Referenced for DataPersisterFactory.java in  » RSS-RDF » curn » org » clapper » curn » 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 » RSS RDF » curn » org.clapper.curn 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*---------------------------------------------------------------------------*\
002:         $Id: DataPersisterFactory.java 6548 2006-11-03 03:40:07Z bmc $
003:        \*---------------------------------------------------------------------------*/
004:
005:        package org.clapper.curn;
006:
007:        import org.clapper.util.classutil.ClassUtil;
008:        import org.clapper.util.classutil.ClassUtilException;
009:        import org.clapper.util.config.ConfigurationException;
010:
011:        /**
012:         * Class that's used to create a {@link DataPersister}. This class is
013:         * implemented as a plug-in, so that <i>curn</i>'s plug-in discovery
014:         * mechanism will find it and automatically configure it. The factory
015:         * methods, though, are static; the plug-in logic merely sets up the data
016:         * structures that are used by the static methods.
017:         *
018:         * @see PlugIn
019:         * @see DataPersister
020:         *
021:         * @version <tt>$Revision: 6548 $</tt>
022:         */
023:        public final class DataPersisterFactory implements 
024:                MainConfigItemPlugIn, PostConfigPlugIn {
025:            /*----------------------------------------------------------------------*\
026:                                       Private Constants
027:            \*----------------------------------------------------------------------*/
028:
029:            private static final String CFG_VAR_PERSISTER_CLASS = "DataPersisterClass";
030:            private static final String DEF_DATA_PERSISTER_CLASS_NAME = "org.clapper.curn.XMLDataPersister";
031:
032:            /*----------------------------------------------------------------------*\
033:                                     Private Instance Data
034:            \*----------------------------------------------------------------------*/
035:
036:            /**
037:             * The data persister class name.
038:             */
039:            private static String dataPersisterClassName = DEF_DATA_PERSISTER_CLASS_NAME;
040:
041:            /**
042:             * The data persister object to use.
043:             */
044:            private static DataPersister dataPersisterInstance = null;
045:
046:            /*----------------------------------------------------------------------*\
047:                                           Constructor
048:            \*----------------------------------------------------------------------*/
049:
050:            /**
051:             * Creates a new instance of DataPersisterFactory
052:             */
053:            public DataPersisterFactory() {
054:            }
055:
056:            /*----------------------------------------------------------------------*\
057:                                        Public Methods
058:            \*----------------------------------------------------------------------*/
059:
060:            /**
061:             * Get the configured data persister object.
062:             *
063:             * @return the configured data persister.
064:             */
065:            public static DataPersister getInstance() {
066:                return dataPersisterInstance;
067:            }
068:
069:            /**
070:             * Initialize the plug-in. This method is called before any of the
071:             * plug-in methods are called.
072:             *
073:             * @throws CurnException on error
074:             */
075:            public void initPlugIn() throws CurnException {
076:            }
077:
078:            /**
079:             * Get a displayable name for the plug-in.
080:             *
081:             * @return the name
082:             */
083:            public String getPlugInName() {
084:                return null; // "invisible" plug-in
085:            }
086:
087:            /**
088:             * Get the sort key for this plug-in.
089:             *
090:             * @return the sort key string.
091:             */
092:            public String getPlugInSortKey() {
093:                return ClassUtil.getShortClassName(getClass().getName());
094:            }
095:
096:            /**
097:             * Called immediately after <i>curn</i> has read and processed a
098:             * configuration item in the main [curn] configuration section. All
099:             * configuration items are passed, one by one, to each loaded plug-in.
100:             * If a plug-in class is not interested in a particular configuration
101:             * item, this method should simply return without doing anything. Note
102:             * that some configuration items may simply be variable assignment;
103:             * there's no real way to distinguish a variable assignment from a
104:             * blessed configuration item.
105:             *
106:             * @param sectionName  the name of the configuration section where
107:             *                     the item was found
108:             * @param paramName    the name of the parameter
109:             * @param config       the {@link CurnConfig} object
110:             *
111:             * @throws CurnException on error
112:             *
113:             * @see CurnConfig
114:             */
115:            public void runMainConfigItemPlugIn(String sectionName,
116:                    String paramName, CurnConfig config) throws CurnException {
117:                try {
118:                    if (paramName.equals(CFG_VAR_PERSISTER_CLASS)) {
119:                        dataPersisterClassName = config.getConfigurationValue(
120:                                sectionName, paramName);
121:                    }
122:                }
123:
124:                catch (ConfigurationException ex) {
125:                    throw new CurnException(ex);
126:                }
127:            }
128:
129:            /**
130:             * Called after the entire configuration has been read and parsed, but
131:             * before any feeds are processed. Intercepting this event is useful
132:             * for plug-ins that want to adjust the configuration. For instance,
133:             * the <i>curn</i> command-line wrapper intercepts this plug-in event
134:             * so it can adjust the configuration to account for command line
135:             * options.
136:             *
137:             * @param config  the parsed {@link CurnConfig} object
138:             *
139:             * @throws CurnException on error
140:             *
141:             * @see CurnConfig
142:             */
143:            public void runPostConfigPlugIn(CurnConfig config)
144:                    throws CurnException {
145:                synchronized (DEF_DATA_PERSISTER_CLASS_NAME) {
146:                    if (dataPersisterInstance == null) {
147:                        try {
148:                            // Try to load and instantiate the data persister class.
149:
150:                            dataPersisterInstance = (DataPersister) ClassUtil
151:                                    .instantiateClass(dataPersisterClassName);
152:                            dataPersisterInstance.init(config);
153:                        }
154:
155:                        catch (ClassUtilException ex) {
156:                            throw new CurnException("Can't instantiate data "
157:                                    + "persister class "
158:                                    + dataPersisterClassName, ex);
159:                        }
160:                    }
161:                }
162:            }
163:
164:            /*----------------------------------------------------------------------*\
165:                                       Protected Methods
166:            \*----------------------------------------------------------------------*/
167:
168:            /*----------------------------------------------------------------------*\
169:                                        Private Methods
170:            \*----------------------------------------------------------------------*/
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.