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


001:        /*
002:         * Copyright (c) 2002-2006 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.xwork.util;
006:
007:        import ognl.MethodFailedException;
008:        import ognl.ObjectMethodAccessor;
009:        import ognl.OgnlContext;
010:        import ognl.OgnlRuntime;
011:        import ognl.PropertyAccessor;
012:
013:        import java.beans.PropertyDescriptor;
014:        import java.util.Collection;
015:        import java.util.Map;
016:
017:        /**
018:         * Allows methods to be executed under normal cirumstances, except when {@link #DENY_METHOD_EXECUTION}
019:         * is in the action context with a value of true.
020:         *
021:         * @author Patrick Lightbody
022:         */
023:        public class XWorkMethodAccessor extends ObjectMethodAccessor {
024:
025:            public static final String DENY_METHOD_EXECUTION = "xwork.MethodAccessor.denyMethodExecution";
026:            public static final String DENY_INDEXED_ACCESS_EXECUTION = "xwork.IndexedPropertyAccessor.denyMethodExecution";
027:
028:            public Object callMethod(Map context, Object object, String string,
029:                    Object[] objects) throws MethodFailedException {
030:
031:                //Collection property accessing
032:                //this if statement ensures that ognl
033:                //statements of the form someBean.mySet('keyPropVal')
034:                //return the set element with value of the keyProp given
035:
036:                if (objects.length == 1 && context instanceof  OgnlContext) {
037:                    try {
038:                        OgnlContext ogContext = (OgnlContext) context;
039:                        if (OgnlRuntime.hasSetProperty(ogContext, object,
040:                                string)) {
041:                            PropertyDescriptor descriptor = OgnlRuntime
042:                                    .getPropertyDescriptor(object.getClass(),
043:                                            string);
044:                            Class propertyType = descriptor.getPropertyType();
045:                            if ((Collection.class)
046:                                    .isAssignableFrom(propertyType)) {
047:                                //go directly through OgnlRuntime here
048:                                //so that property strings are not cleared
049:                                //i.e. OgnlUtil should be used initially, OgnlRuntime
050:                                //thereafter
051:
052:                                Object propVal = OgnlRuntime.getProperty(
053:                                        ogContext, object, string);
054:                                //use the Collection property accessor instead of the individual property accessor, because 
055:                                //in the case of Lists otherwise the index property could be used
056:                                PropertyAccessor accessor = OgnlRuntime
057:                                        .getPropertyAccessor(Collection.class);
058:                                OgnlContextState.setGettingByKeyProperty(
059:                                        ogContext, true);
060:                                return accessor.getProperty(ogContext, propVal,
061:                                        objects[0]);
062:                            }
063:                        }
064:                    } catch (Exception oe) {
065:                        //this exception should theoretically never happen
066:                        //log it
067:                        oe.printStackTrace();
068:                    }
069:
070:                }
071:
072:                //HACK - we pass indexed method access i.e. setXXX(A,B) pattern
073:                if ((objects.length == 2 && string.startsWith("set"))
074:                        || (objects.length == 1 && string.startsWith("get"))) {
075:                    Boolean exec = (Boolean) context
076:                            .get(DENY_INDEXED_ACCESS_EXECUTION);
077:                    boolean e = ((exec == null) ? false : exec.booleanValue());
078:                    if (!e) {
079:                        return super .callMethod(context, object, string,
080:                                objects);
081:                    }
082:                }
083:                Boolean exec = (Boolean) context.get(DENY_METHOD_EXECUTION);
084:                boolean e = ((exec == null) ? false : exec.booleanValue());
085:
086:                if (!e) {
087:                    return super .callMethod(context, object, string, objects);
088:                } else {
089:                    return null;
090:                }
091:            }
092:
093:            public Object callStaticMethod(Map context, Class aClass,
094:                    String string, Object[] objects)
095:                    throws MethodFailedException {
096:                Boolean exec = (Boolean) context.get(DENY_METHOD_EXECUTION);
097:                boolean e = ((exec == null) ? false : exec.booleanValue());
098:
099:                if (!e) {
100:                    return super.callStaticMethod(context, aClass, string,
101:                            objects);
102:                } else {
103:                    return null;
104:                }
105:            }
106:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.