Source Code Cross Referenced for SWFFlowExecutorImpl.java in  » Web-Framework » RSF » uk » org » ponder » rsf » swf » support » 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 » Web Framework » RSF » uk.org.ponder.rsf.swf.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 13 Sep 2007
003:         */
004:        package uk.org.ponder.rsf.swf.support;
005:
006:        import org.springframework.webflow.context.ExternalContext;
007:        import org.springframework.webflow.context.ExternalContextHolder;
008:        import org.springframework.webflow.core.FlowException;
009:        import org.springframework.webflow.execution.FlowExecution;
010:        import org.springframework.webflow.execution.ViewSelection;
011:        import org.springframework.webflow.execution.repository.FlowExecutionKey;
012:        import org.springframework.webflow.execution.repository.FlowExecutionLock;
013:        import org.springframework.webflow.execution.repository.FlowExecutionRepository;
014:        import org.springframework.webflow.executor.FlowExecutorImpl;
015:        import org.springframework.webflow.executor.ResponseInstruction;
016:
017:        /**
018:         * A mirror of the builtin SWF "FlowExecutorImpl" construct, modified marginally
019:         * to supply a "work payload" represented by a Runnable to be executed before
020:         * the flow is closed. The implementation "operate" is a composite of the
021:         * "resume" and "refresh" functions of the original Executor, since the event
022:         * identity or even whether there is an event will not be known until the
023:         * supplied "StringGetter" has executed within the context of the opened flow.
024:         * </p>
025:         * Within RSF, this Executor takes place as an "AlterationWrapper".
026:         * 
027:         * @author Antranig Basman (antranig@caret.cam.ac.uk)
028:         * 
029:         */
030:
031:        public class SWFFlowExecutorImpl {
032:
033:            private FlowExecutionRepository executionRepository;
034:
035:            public void setFlowExecutorImpl(FlowExecutorImpl flowExecutorImpl) {
036:                executionRepository = flowExecutorImpl.getExecutionRepository();
037:            }
038:
039:            public void operate(String flowExecutionKey,
040:                    SWFExecutionPayload payload, final ExternalContext context)
041:                    throws FlowException {
042:                // expose external context as a thread-bound service
043:                ExternalContextHolder.setExternalContext(context);
044:                try {
045:                    final FlowExecutionKey key = executionRepository
046:                            .parseFlowExecutionKey(flowExecutionKey);
047:                    FlowExecutionLock lock = executionRepository.getLock(key);
048:                    // make sure we're the only one manipulating the flow execution
049:                    lock.lock();
050:                    try {
051:                        final FlowExecution flowExecution = executionRepository
052:                                .getFlowExecution(key);
053:                        payload.executeInRequest(flowExecution,
054:                                new ResponseInstructionGetter() {
055:                                    public ResponseInstruction getResponse(
056:                                            String eventId) {
057:                                        if (eventId != null) {
058:                                            ViewSelection selectedView = flowExecution
059:                                                    .signalEvent(eventId,
060:                                                            context);
061:
062:                                            if (flowExecution.isActive()) {
063:                                                // execution still active => store it in the repository
064:                                                FlowExecutionKey innerkey = executionRepository
065:                                                        .getNextKey(
066:                                                                flowExecution,
067:                                                                key);
068:                                                executionRepository
069:                                                        .putFlowExecution(
070:                                                                innerkey,
071:                                                                flowExecution);
072:                                                return new ResponseInstruction(
073:                                                        innerkey.toString(),
074:                                                        flowExecution,
075:                                                        selectedView);
076:                                            } else {
077:                                                // execution ended => remove it from the repository
078:                                                executionRepository
079:                                                        .removeFlowExecution(key);
080:                                                return new ResponseInstruction(
081:                                                        flowExecution,
082:                                                        selectedView);
083:                                            }
084:                                        } else {
085:                                            ViewSelection selectedView = flowExecution
086:                                                    .refresh(context);
087:                                            // don't generate a new key for a refresh, just update
088:                                            // the flow execution with it's existing key
089:                                            executionRepository
090:                                                    .putFlowExecution(key,
091:                                                            flowExecution);
092:                                            return new ResponseInstruction(key
093:                                                    .toString(), flowExecution,
094:                                                    selectedView);
095:                                        }
096:                                    }
097:                                });
098:
099:                    } finally {
100:                        lock.unlock();
101:                    }
102:                } finally {
103:                    ExternalContextHolder.setExternalContext(null);
104:                }
105:            }
106:
107:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.