Source Code Cross Referenced for BSFEventProcessorReturningEventInfos.java in  » Scripting » bsf-2.4.0 » org » apache » bsf » 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 » Scripting » bsf 2.4.0 » org.apache.bsf.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This software consists of voluntary contributions made by many individuals
003:         * on behalf of the Apache Software Foundation and was originally created by
004:         * Sanjiva Weerawarana and others at International Business Machines
005:         * Corporation. For more information on the Apache Software Foundation,
006:         * please see <http://www.apache.org/>.
007:         */
008:
009:        package org.apache.bsf.util;
010:
011:        import java.util.Vector;
012:
013:        import org.apache.bsf.BSFEngine;
014:        import org.apache.bsf.BSFException;
015:        import org.apache.bsf.BSFManager;
016:        import org.apache.bsf.util.event.EventProcessor;
017:
018:        /*
019:         * Copyright (C) 2001-2006 Rony G. Flatscher
020:         * 
021:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
022:         * use this file except in compliance with the License. You may obtain a copy of
023:         * the License at
024:         * 
025:         * <a
026:         * href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
027:         * 
028:         * Unless required by applicable law or agreed to in writing, software
029:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
030:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
031:         * License for the specific language governing permissions and limitations under
032:         * the License.
033:         * 
034:         */
035:
036:        /**
037:         * 
038:         * This is used to support binding scripts to be run when an event occurs,
039:         * forwarding the arguments supplied to the event listener. It is an adapted
040:         * version of org.apache.bsf.util.BSFEventProcessor.
041:         * 
042:         * @author Rony G. Flatscher, but most of the code copied from
043:         *         org.apache.bsf.util.BSFEventProcessor by Sanjiva Weerawarana
044:         */
045:        public class BSFEventProcessorReturningEventInfos implements 
046:                EventProcessor {
047:            BSFEngine engine;
048:
049:            BSFManager manager;
050:
051:            String filter;
052:
053:            String source;
054:
055:            int lineNo;
056:
057:            int columnNo;
058:
059:            Object script;
060:
061:            Object dataFromScriptingEngine; // ---rgf, 2006-02-24: data coming from the
062:
063:            // script engine, could be
064:
065:            // e.g. an object reference to forward event with received arguments to
066:
067:            /**
068:             * Package-protected constructor makes this class unavailable for public
069:             * use.
070:             * 
071:             * @param dataFromScriptingEngine
072:             *            this contains any object supplied by the scripting engine and
073:             *            gets sent back with the supplied script. This could be used
074:             *            e.g. for indicating which scripting engine object should be
075:             *            ultimately informed of the event occurrence.
076:             */
077:            BSFEventProcessorReturningEventInfos(BSFEngine engine,
078:                    BSFManager manager, String filter, String source,
079:                    int lineNo, int columnNo, Object script,
080:                    Object dataFromScriptingEngine) throws BSFException {
081:                this .engine = engine;
082:                this .manager = manager;
083:                this .filter = filter;
084:                this .source = source;
085:                this .lineNo = lineNo;
086:                this .columnNo = columnNo;
087:                this .script = script;
088:                this .dataFromScriptingEngine = dataFromScriptingEngine;
089:            }
090:
091:            // ////////////////////////////////////////////////////////////////////////
092:            //
093:            // event is delegated to me by the adapters using this. inFilter is
094:            // in general the name of the method via which the event was received
095:            // at the adapter. For prop/veto change events, inFilter is the name
096:            // of the property. In any case, in the event processor, I only forward
097:            // those events if for which the filters match (if one is specified).
098:
099:            public void processEvent(String inFilter, Object[] evtInfo) {
100:                try {
101:                    processExceptionableEvent(inFilter, evtInfo);
102:                } catch (RuntimeException re) {
103:                    // rethrow this .. I don't want to intercept run-time stuff
104:                    // that can in fact occur legit
105:                    throw re;
106:                } catch (Exception e) {
107:                    // should not occur
108:                    System.err
109:                            .println("BSFError: non-exceptionable event delivery "
110:                                    + "threw exception (that's not nice): " + e);
111:                    e.printStackTrace();
112:                }
113:            }
114:
115:            // ////////////////////////////////////////////////////////////////////////
116:            //
117:            // same as above, but used when the method event method may generate
118:            // an exception which must go all the way back to the source (as in
119:            // the vetoableChange case)
120:
121:            public void processExceptionableEvent(String inFilter,
122:                    Object[] evtInfo) throws Exception {
123:
124:                // System.err.println(this+": inFilter=["+inFilter+"],
125:                // filter=["+filter+"]");
126:                if ((filter != null) && !filter.equals(inFilter)) {
127:                    // ignore this event
128:                    return;
129:                }
130:
131:                // run the script
132:                // engine.exec (source, lineNo, columnNo, script);
133:
134:                // create the parameter vectors for engine.apply()
135:                Vector paramNames = new Vector(), paramValues = new Vector();
136:
137:                // parameter # 1
138:                // supply the parameters as an array object as sent to the event object
139:                // listener
140:                // (usually the first entry is the sent event object)
141:                paramNames.add("eventParameters");
142:                paramValues.add(evtInfo);
143:
144:                // parameter # 2
145:                // supply the data object received from the scripting engine to be sent
146:                // with the event
147:                paramNames.add("dataFromScriptingEngine");
148:                paramValues.add(this .dataFromScriptingEngine); // can be null as well
149:
150:                // parameter # 3
151:                // event filter in place
152:                paramNames.add("inFilter");
153:                paramValues.add(inFilter); // event name that has occurred
154:
155:                // parameter # 4
156:                // event filter in place
157:                paramNames.add("eventFilter");
158:                paramValues.add(this .filter); // can be null as well
159:
160:                // parameter # 5
161:                // BSF manager instance (e.g. allows access to its registry)
162:                paramNames.add("BSFManager");
163:                paramValues.add(this.manager);
164:
165:                engine.apply(source, lineNo, columnNo, this.script, paramNames,
166:                        paramValues);
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.