Source Code Cross Referenced for DefinitionsFactoryConfig.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » tiles » 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 » Web Framework » struts 1.3.8 » org.apache.struts.tiles 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DefinitionsFactoryConfig.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        package org.apache.struts.tiles;
023:
024:        import java.io.Serializable;
025:        import java.lang.reflect.InvocationTargetException;
026:        import java.util.HashMap;
027:        import java.util.Iterator;
028:        import java.util.Map;
029:        import java.util.Set;
030:
031:        import org.apache.commons.beanutils.BeanUtils;
032:
033:        /**
034:         * A TilesFactoryConfig object hold configuration attributes for a tile
035:         * definition factory.
036:         *
037:         * @since Struts 1.1
038:         * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
039:         */
040:        public class DefinitionsFactoryConfig implements  Serializable {
041:
042:            /**
043:             * Fully qualified classname of the factory to create.
044:             * If no classname is set, a default factory is created
045:             * (of class "org.apache.struts.tiles.xmlDefinition.I18nFactorySet").
046:             */
047:            protected String factoryClassname = "org.apache.struts.tiles.xmlDefinition.I18nFactorySet";
048:
049:            /**
050:             * Specifies whether the parser will validate configuration files.
051:             * Default value is true.
052:             */
053:            protected boolean parserValidate = true;
054:
055:            /**
056:             * Definition configuration file specified by user.
057:             */
058:            protected String definitionConfigFiles = null;
059:
060:            /**
061:             * Specifies whether the factory is "module-aware".
062:             */
063:            protected boolean moduleAware = true;
064:
065:            /**
066:             * The name associated to this factory.
067:             * <br>
068:             * With Struts 1.1, this name is the module name to which this factory
069:             * belong. It is set by the system.
070:             * <br>
071:             * In prior versions, this property is not used.
072:             */
073:            protected String factoryName;
074:
075:            /**
076:             * Alternate name for parser debug details properties in configuration file.
077:             * @deprecated This will be removed in a release after Struts 1.2.
078:             */
079:            public static final String PARSER_DETAILS_PARAMETER_NAME = "definitions-parser-details";
080:
081:            /**
082:             * Alternate name for parser validate properties in configuration file.
083:             */
084:            public static final String PARSER_VALIDATE_PARAMETER_NAME = "definitions-parser-validate";
085:
086:            /**
087:             * Alternate name for factory classname properties in configuration file.
088:             */
089:            public static final String FACTORY_CLASSNAME_PARAMETER_NAME = "definitions-factory-class";
090:
091:            /**
092:             * Alternate name for definition files properties in configuration file.
093:             */
094:            public static final String DEFINITIONS_CONFIG_PARAMETER_NAME = "definitions-config";
095:
096:            /**
097:             * Alternate name for definition debug details properties in configuration file.
098:             * @deprecated This will be removed in a release after Struts 1.2.
099:             */
100:            public static final String TILES_DETAILS_PARAMETER_NAME = "definitions-debug";
101:
102:            /**
103:             * Map of extra attribute available.
104:             */
105:            private Map extraAttributes = new HashMap();
106:
107:            /**
108:             * Default constructor.
109:             */
110:            public DefinitionsFactoryConfig() {
111:                super ();
112:            }
113:
114:            /**
115:             * Constructor.
116:             * Create configuration object, and initialize it with parameters from Map.
117:             * Parameters corresponding to an attribute are filtered and stored in appropriate
118:             * attribute.
119:             * @param initParameters Map.
120:             */
121:            public DefinitionsFactoryConfig(Map initParameters) {
122:                super ();
123:            }
124:
125:            /**
126:             * Get the module aware flag.
127:             * @return <code>true</code>: user wants a single factory instance,
128:             * <code>false</code>: user wants multiple factory instances (one per module with Struts)
129:             */
130:            public boolean isModuleAware() {
131:                return moduleAware;
132:            }
133:
134:            /**
135:             * Set the module aware flag.
136:             * @param moduleAware <code>true</code>: user wants a single factory instance,
137:             * <code>false</code>: user wants multiple factory instances (one per module with Struts)
138:             */
139:            public void setModuleAware(boolean moduleAware) {
140:                this .moduleAware = moduleAware;
141:            }
142:
143:            /**
144:             * Get the classname of the factory.
145:             * @return Classname.
146:             */
147:            public String getFactoryClassname() {
148:                return factoryClassname;
149:            }
150:
151:            /**
152:             * Set the classname of the factory..
153:             * @param aFactoryClassname Classname of the factory.
154:             */
155:            public void setFactoryClassname(String aFactoryClassname) {
156:                factoryClassname = aFactoryClassname;
157:            }
158:
159:            /**
160:             * Determines if the parser is validating.
161:             * @return <code>true<code> when in validating mode.
162:             */
163:            public boolean getParserValidate() {
164:                return parserValidate;
165:            }
166:
167:            /**
168:             * Set the validating mode for the parser.
169:             * @param aParserValidate <code>true</code> for validation, <code>false</code> otherwise
170:             */
171:            public void setParserValidate(boolean aParserValidate) {
172:                parserValidate = aParserValidate;
173:            }
174:
175:            /**
176:             * Get the definition config files.
177:             * @return Defition config files.
178:             */
179:            public String getDefinitionConfigFiles() {
180:                return definitionConfigFiles;
181:            }
182:
183:            /**
184:             * Set the definition config files.
185:             * @param aDefinitionConfigFiles Definition config files.
186:             */
187:            public void setDefinitionConfigFiles(String aDefinitionConfigFiles) {
188:                definitionConfigFiles = aDefinitionConfigFiles;
189:            }
190:
191:            /**
192:             * Set value of an additional attribute.
193:             * @param name Name of the attribute.
194:             * @param value Value of the attribute.
195:             */
196:            public void setAttribute(String name, Object value) {
197:                extraAttributes.put(name, value);
198:            }
199:
200:            /**
201:             * Get value of an additional attribute.
202:             * @param name Name of the attribute.
203:             * @return Value of the attribute, or null if not found.
204:             */
205:            public Object getAttribute(String name) {
206:                return extraAttributes.get(name);
207:            }
208:
209:            /**
210:             * Get additional attributes as a Map.
211:             * @return Map A Map containing attribute name - value pairs.
212:             */
213:            public Map getAttributes() {
214:                Map map = new HashMap(extraAttributes);
215:                // Add property attributes using old names
216:                /*
217:                  map.put(DEFINITIONS_CONFIG_PARAMETER_NAME, getDefinitionConfigFiles());
218:                  map.put(TILES_DETAILS_PARAMETER_NAME, Integer.toString(getDebugLevel()) );
219:                  map.put(PARSER_DETAILS_PARAMETER_NAME, Integer.toString(getParserDebugLevel()) );
220:                  map.put(PARSER_VALIDATE_PARAMETER_NAME, new Boolean(getParserValidate()).toString() );
221:
222:                  if( ! "org.apache.struts.tiles.xmlDefinition.I18nFactorySet".equals(getFactoryClassname()) )
223:                  map.put(FACTORY_CLASSNAME_PARAMETER_NAME, getFactoryClassname());
224:                 */
225:                return map;
226:            }
227:
228:            /**
229:             * Populate this config object from properties map, based on
230:             * the specified name/value pairs.  This method uses the populate() method from
231:             * org.apache.commons.beanutils.BeanUtil.
232:             * <p>
233:             * Properties keys are scanned for old property names, and linked to the new name
234:             * if necessary. This modifies the properties map.
235:             * <p>
236:             * The particular setter method to be called for each property is
237:             * determined using the usual JavaBeans introspection mechanisms.  Thus,
238:             * you may identify custom setter methods using a BeanInfo class that is
239:             * associated with the class of the bean itself.  If no such BeanInfo
240:             * class is available, the standard method name conversion ("set" plus
241:             * the capitalized name of the property in question) is used.
242:             * <p>
243:             * <strong>NOTE</strong>:  It is contrary to the JavaBeans Specification
244:             * to have more than one setter method (with different argument
245:             * signatures) for the same property.
246:             *
247:             * @param properties Map keyed by property name, with the
248:             *  corresponding (String or String[]) value(s) to be set.
249:             *
250:             * @exception IllegalAccessException if the caller does not have
251:             *  access to the property accessor method.
252:             * @exception InvocationTargetException if the property accessor method
253:             *  throws an exception.
254:             * @see org.apache.commons.beanutils.BeanUtils
255:             */
256:            public void populate(Map properties) throws IllegalAccessException,
257:                    InvocationTargetException {
258:
259:                // link old parameter names for backward compatibility
260:                linkOldPropertyNames(properties);
261:                BeanUtils.populate(this , properties);
262:            }
263:
264:            /**
265:             * Link old property names to new property names.
266:             * This modifies the map.
267:             * @param properties Map keyed by property name, with the
268:             *  corresponding (String or String[]) value(s) to be set.
269:             */
270:            static public void linkOldPropertyNames(Map properties) {
271:                Set entries = properties.entrySet();
272:                Map toAdd = new HashMap();
273:                Iterator i = entries.iterator();
274:                while (i.hasNext()) {
275:                    Map.Entry entry = (Map.Entry) i.next();
276:
277:                    if (DEFINITIONS_CONFIG_PARAMETER_NAME
278:                            .equals(entry.getKey())) {
279:                        toAdd.put("definitionConfigFiles", entry.getValue());
280:
281:                    } else if (FACTORY_CLASSNAME_PARAMETER_NAME.equals(entry
282:                            .getKey())) {
283:                        toAdd.put("factoryClassname", entry.getValue());
284:
285:                    } else if (PARSER_DETAILS_PARAMETER_NAME.equals(entry
286:                            .getKey())) {
287:                        toAdd.put("parserDebugLevel", entry.getValue());
288:
289:                    } else if (PARSER_VALIDATE_PARAMETER_NAME.equals(entry
290:                            .getKey())) {
291:                        toAdd.put("parserValidate", entry.getValue());
292:
293:                    } else if (TILES_DETAILS_PARAMETER_NAME.equals(entry
294:                            .getKey())) {
295:                        toAdd.put("debugLevel", entry.getValue());
296:                    }
297:                }
298:
299:                if (toAdd.size() > 0) {
300:                    properties.putAll(toAdd);
301:                }
302:            }
303:
304:            /**
305:             * Get the factory name.
306:             */
307:            public String getFactoryName() {
308:                return factoryName;
309:            }
310:
311:            /**
312:             * Set the factory name.
313:             * @param factoryName Name of the factory.
314:             */
315:            public void setFactoryName(String factoryName) {
316:                this.factoryName = factoryName;
317:            }
318:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.