Source Code Cross Referenced for SerializableMethod.java in  » Ajax » zk » org » zkoss » lang » reflect » 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 » Ajax » zk » org.zkoss.lang.reflect 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* SerializableMethod.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Wed Jun 21 17:57:05     2006, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        }}IS_RIGHT
016:         */
017:        package org.zkoss.lang.reflect;
018:
019:        import java.lang.reflect.Method;
020:        import java.io.Serializable;
021:        import java.io.ObjectOutputStream;
022:        import java.io.ObjectInputStream;
023:        import java.io.IOException;
024:
025:        import org.zkoss.lang.Objects;
026:        import org.zkoss.lang.SystemException;
027:
028:        /**
029:         * A wrapper of java.lang.reflect.Method to make it serializable.
030:         *
031:         * @author tomyeh
032:         */
033:        public class SerializableMethod implements  Serializable, Cloneable {
034:            private static final long serialVersionUID = 20060622L;
035:            private transient Method _m;
036:
037:            public SerializableMethod(Method method) {
038:                _m = method;
039:            }
040:
041:            /** Returns the method being encapsulated.
042:             */
043:            public final Method getMethod() {
044:                return _m;
045:            }
046:
047:            //Serializable//
048:            //NOTE: they must be declared as private
049:            private synchronized void writeObject(ObjectOutputStream s)
050:                    throws IOException {
051:                s.defaultWriteObject();
052:
053:                if (_m == null) {
054:                    s.writeObject(null);
055:                } else {
056:                    s.writeObject(_m.getDeclaringClass());
057:                    s.writeObject(_m.getName());
058:
059:                    final Class[] argTypes = _m.getParameterTypes();
060:                    s.writeInt(argTypes.length);
061:                    for (int j = 0; j < argTypes.length; ++j)
062:                        s.writeObject(argTypes[j]);
063:                }
064:            }
065:
066:            private synchronized void readObject(ObjectInputStream s)
067:                    throws IOException, ClassNotFoundException {
068:                s.defaultReadObject();
069:
070:                final Class cls = (Class) s.readObject();
071:                if (cls != null) {
072:                    final String nm = (String) s.readObject();
073:                    final int sz = s.readInt();
074:                    final Class[] argTypes = new Class[sz];
075:                    for (int j = 0; j < sz; ++j)
076:                        argTypes[j] = (Class) s.readObject();
077:                    try {
078:                        _m = cls.getMethod(nm, argTypes);
079:                    } catch (NoSuchMethodException ex) {
080:                        throw new SystemException("Method not found: " + nm
081:                                + " with " + Objects.toString(argTypes));
082:                    }
083:                }
084:            }
085:
086:            //-- cloneable --//
087:            public Object clone() {
088:                try {
089:                    return super .clone();
090:                } catch (CloneNotSupportedException e) {
091:                    throw new InternalError();
092:                }
093:            }
094:
095:            //Object//
096:            public int hashCode() {
097:                return Objects.hashCode(_m);
098:            }
099:
100:            public boolean equals(Object o) {
101:                return (o instanceof  SerializableMethod)
102:                        && Objects.equals(_m, ((SerializableMethod) o)._m);
103:            }
104:
105:            public String toString() {
106:                return Objects.toString(_m);
107:            }
108:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.