Source Code Cross Referenced for CallbackFactory.java in  » Scripting » jruby » org » jruby » runtime » 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 » Scripting » jruby » org.jruby.runtime 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***** BEGIN LICENSE BLOCK *****
002:         * Version: CPL 1.0/GPL 2.0/LGPL 2.1
003:         *
004:         * The contents of this file are subject to the Common Public
005:         * License Version 1.0 (the "License"); you may not use this file
006:         * except in compliance with the License. You may obtain a copy of
007:         * the License at http://www.eclipse.org/legal/cpl-v10.html
008:         *
009:         * Software distributed under the License is distributed on an "AS
010:         * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
011:         * implied. See the License for the specific language governing
012:         * rights and limitations under the License.
013:         *
014:         * Copyright (C) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de>
015:         * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr>
016:         * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se>
017:         * Copyright (C) 2004 Charles O Nutter <headius@headius.com>
018:         * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
019:         * 
020:         * Alternatively, the contents of this file may be used under the terms of
021:         * either of the GNU General Public License Version 2 or later (the "GPL"),
022:         * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
023:         * in which case the provisions of the GPL or the LGPL are applicable instead
024:         * of those above. If you wish to allow use of your version of this file only
025:         * under the terms of either the GPL or the LGPL, and not to allow others to
026:         * use your version of this file under the terms of the CPL, indicate your
027:         * decision by deleting the provisions above and replace them with the notice
028:         * and other provisions required by the GPL or the LGPL. If you do not delete
029:         * the provisions above, a recipient may use your version of this file under
030:         * the terms of any one of the CPL, the GPL or the LGPL.
031:         ***** END LICENSE BLOCK *****/package org.jruby.runtime;
032:
033:        import org.jruby.Ruby;
034:        import org.jruby.runtime.callback.Callback;
035:        import org.jruby.runtime.callback.ReflectionCallbackFactory;
036:        import org.jruby.runtime.callback.InvocationCallbackFactory;
037:        import org.jruby.runtime.callback.DumpingInvocationCallbackFactory;
038:        import org.jruby.util.JRubyClassLoader;
039:
040:        /**
041:         * Helper class to build Callback method.
042:         * This impements method corresponding to the signature of method most often found in
043:         * the Ruby library, for methods with other signature the appropriate Callback object
044:         * will need to be explicitly created.
045:         **/
046:        public abstract class CallbackFactory {
047:            public static final Class[] NULL_CLASS_ARRAY = new Class[0];
048:
049:            /**
050:             * gets an instance method with no arguments.
051:             * @param method name of the method
052:             * @return a CallBack object corresponding to the appropriate method
053:             **/
054:            public abstract Callback getMethod(String method);
055:
056:            public abstract Callback getFastMethod(String method);
057:
058:            /**
059:             * gets an instance method with 1 argument.
060:             * @param method name of the method
061:             * @param arg1 the class of the only argument for this method
062:             * @return a CallBack object corresponding to the appropriate method
063:             **/
064:            public abstract Callback getMethod(String method, Class arg1);
065:
066:            public abstract Callback getFastMethod(String method, Class arg1);
067:
068:            /**
069:             * gets an instance method with two arguments.
070:             * @param method name of the method
071:             * @param arg1 the java class of the first argument for this method
072:             * @param arg2 the java class of the second argument for this method
073:             * @return a CallBack object corresponding to the appropriate method
074:             **/
075:            public abstract Callback getMethod(String method, Class arg1,
076:                    Class arg2);
077:
078:            public abstract Callback getFastMethod(String method, Class arg1,
079:                    Class arg2);
080:
081:            /**
082:             * gets an instance method with two arguments.
083:             * @param method name of the method
084:             * @param arg1 the java class of the first argument for this method
085:             * @param arg2 the java class of the second argument for this method
086:             * @param arg3 the java class of the second argument for this method
087:             * @return a CallBack object corresponding to the appropriate method
088:             **/
089:            public abstract Callback getMethod(String method, Class arg1,
090:                    Class arg2, Class arg3);
091:
092:            public abstract Callback getFastMethod(String method, Class arg1,
093:                    Class arg2, Class arg3);
094:
095:            /**
096:             * gets a singleton (class) method without arguments.
097:             * @param method name of the method
098:             * @return a CallBack object corresponding to the appropriate method
099:             **/
100:            public abstract Callback getSingletonMethod(String method);
101:
102:            public abstract Callback getFastSingletonMethod(String method);
103:
104:            /**
105:             * gets a singleton (class) method with 1 argument.
106:             * @param method name of the method
107:             * @param arg1 the class of the only argument for this method
108:             * @return a CallBack object corresponding to the appropriate method
109:             **/
110:            public abstract Callback getSingletonMethod(String method,
111:                    Class arg1);
112:
113:            public abstract Callback getFastSingletonMethod(String method,
114:                    Class arg1);
115:
116:            /**
117:             * gets a singleton (class) method with 2 arguments.
118:             * @param method name of the method
119:             * @return a CallBack object corresponding to the appropriate method
120:             **/
121:            public abstract Callback getSingletonMethod(String method,
122:                    Class arg1, Class arg2);
123:
124:            public abstract Callback getFastSingletonMethod(String method,
125:                    Class arg1, Class arg2);
126:
127:            /**
128:             * gets a singleton (class) method with 3 arguments.
129:             * @param method name of the method
130:             * @return a CallBack object corresponding to the appropriate method
131:             **/
132:            public abstract Callback getSingletonMethod(String method,
133:                    Class arg1, Class arg2, Class arg3);
134:
135:            public abstract Callback getFastSingletonMethod(String method,
136:                    Class arg1, Class arg2, Class arg3);
137:
138:            public abstract Callback getBlockMethod(String method);
139:
140:            public abstract CompiledBlockCallback getBlockCallback(String method);
141:
142:            /**
143:             * gets a singleton (class) method with no mandatory argument and some optional arguments.
144:             * @param method name of the method
145:             * @return a CallBack object corresponding to the appropriate method
146:             **/
147:            public abstract Callback getOptSingletonMethod(String method);
148:
149:            public abstract Callback getFastOptSingletonMethod(String method);
150:
151:            /**
152:             * gets an instance method with no mandatory argument and some optional arguments.
153:             * @param method name of the method
154:             * @return a CallBack object corresponding to the appropriate method
155:             **/
156:            public abstract Callback getOptMethod(String method);
157:
158:            public abstract Callback getFastOptMethod(String method);
159:
160:            private static boolean reflection = false;
161:            private static boolean dumping = false;
162:            private static String dumpingPath = null;
163:
164:            static {
165:                if (Ruby.isSecurityRestricted())
166:                    reflection = true;
167:                else {
168:                    if (System.getProperty("jruby.reflection") != null
169:                            && Boolean.getBoolean("jruby.reflection")) {
170:                        reflection = true;
171:                    }
172:                    if (System.getProperty("jruby.dump_invocations") != null) {
173:                        dumping = true;
174:                        dumpingPath = System.getProperty(
175:                                "jruby.dump_invocations").toString();
176:                    }
177:                }
178:            }
179:
180:            public static CallbackFactory createFactory(Ruby runtime, Class type) {
181:                if (reflection) {
182:                    return new ReflectionCallbackFactory(type);
183:                } else if (dumping) {
184:                    return new DumpingInvocationCallbackFactory(runtime, type,
185:                            dumpingPath);
186:                } else {
187:                    return new InvocationCallbackFactory(runtime, type, runtime
188:                            .getJRubyClassLoader());
189:                }
190:            }
191:
192:            public static CallbackFactory createFactory(Ruby runtime,
193:                    Class type, ClassLoader classLoader) {
194:                if (reflection) {
195:                    return new ReflectionCallbackFactory(type);
196:                } else if (dumping) {
197:                    return new DumpingInvocationCallbackFactory(runtime, type,
198:                            dumpingPath);
199:                } else {
200:                    // FIXME: No, I don't like it.
201:                    return new InvocationCallbackFactory(runtime, type,
202:                            (JRubyClassLoader) classLoader);
203:                }
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.