Source Code Cross Referenced for HandlerDefinition.java in  » IDE-Netbeans » visualweb.api.designer » com » sun » rave » web » ui » component » util » event » 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 » IDE Netbeans » visualweb.api.designer » com.sun.rave.web.ui.component.util.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package com.sun.rave.web.ui.component.util.event;
042:
043:        import java.lang.reflect.Method;
044:        import java.lang.reflect.Modifier;
045:        import java.util.ArrayList;
046:        import java.util.HashMap;
047:        import java.util.List;
048:        import java.util.Map;
049:
050:        /**
051:         *  <P>	A HandlerDefinition defines a "handler" that may be invoked in the
052:         *	process of executing an event.  A HandlerDefinition has an
053:         *	<strong>id</strong>, <strong>java method</strong>, <strong>input
054:         *	definitions</strong>, <strong>output definitions</strong>, and
055:         *	<strong>child handlers</strong>.</P>
056:         *
057:         *  <P>	The <strong>java method</strong> to be invoked must have the
058:         *	following method signature:</P>
059:         *
060:         *  <P> <BLOCKQUOTE></CODE>
061:         *	    public void beginDisplay(HandlerContext handlerCtx)
062:         *	</CODE></BLOCKQUOTE></P>
063:         *
064:         *  <P>	<code>void</code> above can return a value.  Depending on the type of
065:         *	event, return values may be handled differently.</P>
066:         *
067:         *  @author Ken Paulsen	(ken.paulsen@sun.com)
068:         */
069:        public class HandlerDefinition implements  java.io.Serializable {
070:
071:            /**
072:             *	Constructor
073:             */
074:            public HandlerDefinition(String id) {
075:                _id = id;
076:            }
077:
078:            /**
079:             *	This method returns the id for this handler.
080:             */
081:            public String getId() {
082:                return _id;
083:            }
084:
085:            /**
086:             *	For future tool support
087:             */
088:            public String getDescription() {
089:                return _description;
090:            }
091:
092:            /**
093:             *	For future tool support
094:             */
095:            public void setDescription(String desc) {
096:                _description = desc;
097:            }
098:
099:            /**
100:             *	<P> This method sets the event handler (method) to be invoked.  The
101:             *	    method should be public and accept a prameter of type
102:             *	    "HandlerContext"  Example:</P>
103:             *
104:             *	<P> <BLOCKQUOTE>
105:             *		public void beginDisplay(HandlerContext handlerCtx)
106:             *	    </BLOCKQUOTE></P>
107:             *
108:             *	@param cls	    The full class name containing method
109:             *	@param methodName   The method name of the handler within class
110:             */
111:            public void setHandlerMethod(String cls, String methodName) {
112:                if ((cls == null) || (methodName == null)) {
113:                    throw new IllegalArgumentException(
114:                            "Class name and method name must be non-null!");
115:                }
116:                _methodClass = cls;
117:                _methodName = methodName;
118:            }
119:
120:            /**
121:             *
122:             */
123:            public void setHandlerMethod(Method method) {
124:                if (method != null) {
125:                    _methodName = method.getName();
126:                    _methodClass = method.getDeclaringClass().getName();
127:                } else {
128:                    _methodName = null;
129:                    _methodClass = null;
130:                }
131:                _method = method;
132:            }
133:
134:            /**
135:             *	<p> This method determines if the handler is static.</p>
136:             */
137:            public boolean isStatic() {
138:                if (_static == null) {
139:                    _static = Boolean.valueOf(Modifier
140:                            .isStatic(getHandlerMethod().getModifiers()));
141:                }
142:                return _static.booleanValue();
143:            }
144:
145:            /**
146:             *
147:             */
148:            public Method getHandlerMethod() {
149:                if (_method != null) {
150:                    // return cached Method
151:                    return _method;
152:                }
153:
154:                // See if we have the info to find it
155:                if ((_methodClass != null) && (_methodName != null)) {
156:                    // Find the class
157:                    Class clzz = null;
158:                    try {
159:                        clzz = Class.forName(_methodClass);
160:                    } catch (ClassNotFoundException ex) {
161:                        throw new RuntimeException("'" + _methodClass
162:                                + "' not found!", ex);
163:                    }
164:
165:                    // Find the method on the class
166:                    Method method = null;
167:                    try {
168:                        method = clzz.getMethod(_methodName, EVENT_ARGS);
169:                    } catch (NoSuchMethodException ex) {
170:                        throw new RuntimeException("Method '" + _methodName
171:                                + "' not found!", ex);
172:                    }
173:
174:                    // Cache the _method
175:                    _method = method;
176:                }
177:
178:                // Return the Method if there is one
179:                return _method;
180:            }
181:
182:            /**
183:             *	This method adds an IODescriptor to the list of input descriptors.
184:             *	These descriptors define the input parameters to this handler.
185:             *
186:             *	@param desc	The input IODescriptor to add
187:             */
188:            public void addInputDef(IODescriptor desc) {
189:                _inputDefs.put(desc.getName(), desc);
190:            }
191:
192:            /**
193:             *	This method sets the input IODescriptors for this handler.
194:             *
195:             *	@param inputDefs	The Map of IODescriptors
196:             */
197:            public void setInputDefs(Map inputDefs) {
198:                if (inputDefs == null) {
199:                    throw new IllegalArgumentException(
200:                            "inputDefs cannot be null!");
201:                }
202:                _inputDefs = inputDefs;
203:            }
204:
205:            /**
206:             *	This method retrieves the Map of input IODescriptors.
207:             *
208:             *	@return The Map of IODescriptors
209:             */
210:            public Map getInputDefs() {
211:                return _inputDefs;
212:            }
213:
214:            /**
215:             *	This method returns the requested IODescriptor, null if not found.
216:             */
217:            public IODescriptor getInputDef(String name) {
218:                return (IODescriptor) _inputDefs.get(name);
219:            }
220:
221:            /**
222:             *	This method adds an IODescriptor to the list of output descriptors.
223:             *	These descriptors define the output parameters to this handler.
224:             *
225:             *	@param desc	The IODescriptor to add
226:             */
227:            public void addOutputDef(IODescriptor desc) {
228:                _outputDefs.put(desc.getName(), desc);
229:            }
230:
231:            /**
232:             *	This method sets the output IODescriptors for this handler.
233:             *
234:             *	@param outputDefs    The Map of output IODescriptors
235:             */
236:            public void setOutputDefs(Map outputDefs) {
237:                if (outputDefs == null) {
238:                    throw new IllegalArgumentException(
239:                            "outputDefs cannot be null!");
240:                }
241:                _outputDefs = outputDefs;
242:            }
243:
244:            /**
245:             *	This method retrieves the Map of output IODescriptors.
246:             *
247:             *	@return The Map of output IODescriptors
248:             */
249:            public Map getOutputDefs() {
250:                return _outputDefs;
251:            }
252:
253:            /**
254:             *	This method returns the requested IODescriptor, null if not found.
255:             */
256:            public IODescriptor getOutputDef(String name) {
257:                return (IODescriptor) _outputDefs.get(name);
258:            }
259:
260:            /**
261:             *	This method adds a Handler to the list of child handlers.  Child
262:             *	Handlers are executed PRIOR to this handler executing.
263:             *
264:             *	@param desc	The Handler to add
265:             */
266:            public void addChildHandler(Handler desc) {
267:                _childHandlers.add(desc);
268:            }
269:
270:            /**
271:             *	This method sets the List of child Handlers for this HandlerDefinition.
272:             *
273:             *	@param childHandlers	The List of child Handler objects
274:             */
275:            public void setChildHandlers(List childHandlers) {
276:                if (childHandlers == null) {
277:                    throw new IllegalArgumentException(
278:                            "childHandlers cannot be null!");
279:                }
280:                _childHandlers = childHandlers;
281:            }
282:
283:            /**
284:             *	This method retrieves the List of child Handler.
285:             *
286:             *	@return The List of child Handler for this handler.
287:             */
288:            public List getChildHandlers() {
289:                return _childHandlers;
290:            }
291:
292:            public static final Class[] EVENT_ARGS = new Class[] { HandlerContext.class };
293:
294:            private String _id = null;
295:            private String _description = null;
296:            private String _methodClass = null;
297:            private String _methodName = null;
298:            private transient Method _method = null;
299:            private Map _inputDefs = new HashMap(5);
300:            private Map _outputDefs = new HashMap(5);
301:            private List _childHandlers = new ArrayList(5);
302:            private transient Boolean _static = null;
303:
304:            private static final long serialVersionUID = 0xA8B7C6D5E4F30211L;
305:        }
w___w_w__.___ja__v__a___2s___.co___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.