Source Code Cross Referenced for RCEnvironment.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » rc » 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 » Content Management System » apache lenya 2.0 » org.apache.lenya.cms.rc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        /* $Id: RCEnvironment.java 531479 2007-04-23 14:21:35Z andreas $  */
020:
021:        package org.apache.lenya.cms.rc;
022:
023:        import java.io.File;
024:        import java.io.IOException;
025:        import java.util.HashMap;
026:        import java.util.Map;
027:
028:        import org.apache.avalon.framework.configuration.Configurable;
029:        import org.apache.avalon.framework.configuration.Configuration;
030:        import org.apache.avalon.framework.configuration.ConfigurationException;
031:        import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
032:        import org.apache.avalon.framework.logger.AbstractLogEnabled;
033:        import org.apache.avalon.framework.logger.Logger;
034:        import org.xml.sax.SAXException;
035:
036:        /**
037:         * Helper class that holds the revision controller configuration
038:         */
039:        public class RCEnvironment extends AbstractLogEnabled implements 
040:                Configurable {
041:
042:            /**
043:             * <code>CONFIGURATION_FILE</code> The configuration file
044:             */
045:            public static final String CONFIGURATION_FILE = "lenya"
046:                    + File.separator + "config" + File.separator + "rc"
047:                    + File.separator + "revision-controller.xconf";
048:            /**
049:             * <code>RCML_DIRECTORY</code> The RCML directory
050:             */
051:            public static final String RCML_DIRECTORY = "rcml-directory";
052:            /**
053:             * <code>BACKUP_DIRECTORY</code> The backup directory
054:             */
055:            public static final String BACKUP_DIRECTORY = "backup-directory";
056:            private String rcmlDirectory;
057:            private String backupDirectory;
058:
059:            private static Map instances = new HashMap();
060:
061:            /**
062:             * Returns the singleton RC environment for this context path.
063:             * @param contextPath The context path (the Lenya webapp directory).
064:             * @param logger The logger.
065:             * @return An RC environment.
066:             */
067:            public static RCEnvironment getInstance(String contextPath,
068:                    Logger logger) {
069:                RCEnvironment instance = (RCEnvironment) instances
070:                        .get(contextPath);
071:                if (instance == null) {
072:                    instance = new RCEnvironment(contextPath, logger);
073:                    instances.put(contextPath, instance);
074:                }
075:                return instance;
076:            }
077:
078:            /**
079:             * Creates a new RCEnvironment object from the context path
080:             * @param contextPath The context path
081:             * @param logger The logger.
082:             */
083:            public RCEnvironment(String contextPath, Logger logger) {
084:                enableLogging(logger);
085:                getLogger().debug("context path:" + contextPath);
086:
087:                String configurationFilePath = contextPath + "/"
088:                        + CONFIGURATION_FILE;
089:                getLogger().debug(
090:                        "configuration file path:" + configurationFilePath);
091:
092:                File configurationFile = new File(configurationFilePath);
093:
094:                try {
095:                    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
096:                    Configuration configuration = builder
097:                            .buildFromFile(configurationFile);
098:                    configure(configuration);
099:                } catch (final ConfigurationException e) {
100:                    getLogger().error(
101:                            "Cannot load revision controller configuration! ",
102:                            e);
103:                } catch (final SAXException e) {
104:                    getLogger().error(
105:                            "Cannot load revision controller configuration! ",
106:                            e);
107:                } catch (final IOException e) {
108:                    getLogger().error(
109:                            "Cannot load revision controller configuration! ",
110:                            e);
111:                }
112:            }
113:
114:            /**
115:             @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)     
116:             */
117:            public void configure(
118:                    org.apache.avalon.framework.configuration.Configuration configuration)
119:                    throws ConfigurationException {
120:                // revision controller
121:                setRCMLDirectory(configuration.getChild("rcmlDirectory")
122:                        .getAttribute("href"));
123:                setBackupDirectory(configuration.getChild("backupDirectory")
124:                        .getAttribute("href"));
125:
126:                getLogger().debug(
127:                        "CONFIGURATION:\nRCML Directory: href="
128:                                + getRCMLDirectory());
129:                getLogger().debug(
130:                        "CONFIGURATION:\nBackup Directory: href="
131:                                + getBackupDirectory());
132:            }
133:
134:            /**
135:             * Get the RCML directory
136:             * @return The RCML directory
137:             */
138:            public String getRCMLDirectory() {
139:                return this .rcmlDirectory;
140:            }
141:
142:            /**
143:             * Set the rcml directory
144:             * @param rcmlDir the path to the rcml directory
145:             */
146:            protected void setRCMLDirectory(String rcmlDir) {
147:                this .rcmlDirectory = rcmlDir;
148:            }
149:
150:            /**
151:             * Get the backup directory
152:             * @return The backup directory
153:             */
154:            public String getBackupDirectory() {
155:                return this .backupDirectory;
156:            }
157:
158:            /**
159:             * Set the backup directory
160:             * @param backupDir path to the backup directory
161:             */
162:            protected void setBackupDirectory(String backupDir) {
163:                this.backupDirectory = backupDir;
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.