Source Code Cross Referenced for DelegatingConfiguration.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » config » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.config;
006:
007:        import java.util.HashSet;
008:        import java.util.Iterator;
009:        import java.util.Set;
010:
011:        /**
012:         * A Configuration implementation which stores an internal list of configuration objects. Each time
013:         * a config method is called (get, set, list, etc..) this class will go through the list of configurations
014:         * and call the method until successful.
015:         *
016:         * @author Rickard Öberg
017:         * @author Jason Carreira
018:         * @author Bill Lynch (docs)
019:         */
020:        public class DelegatingConfiguration extends Configuration {
021:
022:            Configuration[] configList;
023:
024:            /**
025:             * Creates a new DelegatingConfiguration object given a list of {@link Configuration} implementations.
026:             *
027:             * @param aConfigList a list of Configuration implementations.
028:             */
029:            public DelegatingConfiguration(Configuration[] aConfigList) {
030:                configList = aConfigList;
031:            }
032:
033:            /**
034:             * Sets the given property - calls setImpl(String, Object) method on config objects in the config
035:             * list until successful.
036:             *
037:             * @see #set(String, Object)
038:             */
039:            public void setImpl(String name, Object value)
040:                    throws IllegalArgumentException,
041:                    UnsupportedOperationException {
042:                // Determine which config to use by using get
043:                // Delegate to the other configurations
044:                IllegalArgumentException e = null;
045:
046:                for (int i = 0; i < configList.length; i++) {
047:                    try {
048:                        configList[i].getImpl(name);
049:
050:                        // Found it, now try setting
051:                        configList[i].setImpl(name, value);
052:
053:                        // Worked, now return
054:                        return;
055:                    } catch (IllegalArgumentException ex) {
056:                        e = ex;
057:
058:                        // Try next config
059:                    }
060:                }
061:
062:                throw e;
063:            }
064:
065:            /**
066:             * Gets the specified property - calls getImpl(String) method on config objects in config list
067:             * until successful.
068:             *
069:             * @see #get(String)
070:             */
071:            public Object getImpl(String name) throws IllegalArgumentException {
072:                // Delegate to the other configurations
073:                IllegalArgumentException e = null;
074:
075:                for (int i = 0; i < configList.length; i++) {
076:                    try {
077:                        return configList[i].getImpl(name);
078:                    } catch (IllegalArgumentException ex) {
079:                        e = ex;
080:
081:                        // Try next config
082:                    }
083:                }
084:
085:                throw e;
086:            }
087:
088:            /**
089:             * Determines if a paramter has been set - calls the isSetImpl(String) method on each config object
090:             * in config list. Returns <tt>true</tt> when one of the config implementations returns true. Returns
091:             * <tt>false</tt> otherwise.
092:             *
093:             * @see #isSet(String)
094:             */
095:            public boolean isSetImpl(String aName) {
096:                for (int i = 0; i < configList.length; i++) {
097:                    if (configList[i].isSetImpl(aName)) {
098:                        return true;
099:                    }
100:                }
101:
102:                return false;
103:            }
104:
105:            /**
106:             * Returns a list of all property names - returns a list of all property names in all config
107:             * objects in config list.
108:             *
109:             * @see #list()
110:             */
111:            public Iterator listImpl() {
112:                boolean workedAtAll = false;
113:
114:                Set settingList = new HashSet();
115:                UnsupportedOperationException e = null;
116:
117:                for (int i = 0; i < configList.length; i++) {
118:                    try {
119:                        Iterator list = configList[i].listImpl();
120:
121:                        while (list.hasNext()) {
122:                            settingList.add(list.next());
123:                        }
124:
125:                        workedAtAll = true;
126:                    } catch (UnsupportedOperationException ex) {
127:                        e = ex;
128:
129:                        // Try next config
130:                    }
131:                }
132:
133:                if (!workedAtAll) {
134:                    throw (e == null) ? new UnsupportedOperationException() : e;
135:                } else {
136:                    return settingList.iterator();
137:                }
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.