Source Code Cross Referenced for FOM_WebContinuation.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » components » flow » javascript » fom » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.components.flow.javascript.fom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.components.flow.javascript.fom;
018:
019:        import java.util.Iterator;
020:        import java.util.List;
021:
022:        import org.apache.avalon.framework.service.ServiceManager;
023:        import org.apache.cocoon.components.flow.ContinuationsManager;
024:        import org.apache.cocoon.components.flow.WebContinuation;
025:        import org.mozilla.javascript.Context;
026:        import org.mozilla.javascript.Function;
027:        import org.mozilla.javascript.NativeArray;
028:        import org.mozilla.javascript.Scriptable;
029:        import org.mozilla.javascript.ScriptableObject;
030:        import org.mozilla.javascript.Undefined;
031:        import org.mozilla.javascript.Wrapper;
032:        import org.mozilla.javascript.continuations.Continuation;
033:
034:        /**
035:         *
036:         * @version CVS $Id: FOM_WebContinuation.java 433543 2006-08-22 06:22:54Z crossley $
037:         */
038:        public class FOM_WebContinuation extends ScriptableObject {
039:
040:            WebContinuation wk;
041:
042:            static class UserObject {
043:                boolean isBookmark;
044:                PageLocalScopeImpl pageLocal;
045:            }
046:
047:            static private boolean isBookmark(WebContinuation wk) {
048:                UserObject userObj = (UserObject) wk.getUserObject();
049:                if (userObj == null) {
050:                    return false;
051:                }
052:                return userObj.isBookmark;
053:            }
054:
055:            public FOM_WebContinuation() {
056:                this (null);
057:            }
058:
059:            public FOM_WebContinuation(WebContinuation wk) {
060:                this .wk = wk;
061:            }
062:
063:            // new FOM_WebContinuation([Continuation] continuation,
064:            //                         [FOM_WebContinuation] parent,
065:            //                         [Number] timeToLive)
066:            public static Object jsConstructor(Context cx, Object[] args,
067:                    Function ctorObj, boolean inNewExpr) throws Exception {
068:                FOM_WebContinuation result = null;
069:                if (args.length < 1) {
070:                    // error
071:                }
072:                Continuation c = (Continuation) unwrap(args[0]);
073:                FOM_WebContinuation parent = null;
074:                if (args.length > 1) {
075:                    parent = (FOM_WebContinuation) args[1];
076:                }
077:                int timeToLive = 0;
078:                if (args.length > 2) {
079:                    timeToLive = (int) org.mozilla.javascript.Context
080:                            .toNumber(args[2]);
081:                }
082:                WebContinuation wk;
083:                Scriptable scope = getTopLevelScope(c);
084:                FOM_Cocoon cocoon = (FOM_Cocoon) getProperty(scope, "cocoon");
085:                ServiceManager componentManager = cocoon.getServiceManager();
086:                ContinuationsManager contMgr = (ContinuationsManager) componentManager
087:                        .lookup(ContinuationsManager.ROLE);
088:                wk = contMgr.createWebContinuation(c, (parent == null ? null
089:                        : parent.getWebContinuation()), timeToLive, cocoon
090:                        .getInterpreterId(), null);
091:                result = new FOM_WebContinuation(wk);
092:                result.setParentScope(getTopLevelScope(scope));
093:                result.setPrototype(getClassPrototype(scope, result
094:                        .getClassName()));
095:                return result;
096:            }
097:
098:            public String getClassName() {
099:                return "FOM_WebContinuation";
100:            }
101:
102:            public Object jsFunction_getAttribute(String name) {
103:                return org.mozilla.javascript.Context.toObject(wk
104:                        .getAttribute(name), getParentScope());
105:            }
106:
107:            public void jsFunction_setAttribute(String name, Object value) {
108:                wk.setAttribute(name, unwrap(value));
109:            }
110:
111:            public void jsFunction_removeAttribute(String name) {
112:                wk.removeAttribute(name);
113:            }
114:
115:            public Object jsFunction_getAttributeNames() {
116:                return org.mozilla.javascript.Context.toObject(wk
117:                        .getAttributeNames(), getParentScope());
118:            }
119:
120:            public String jsGet_id() {
121:                return wk.getId();
122:            }
123:
124:            public Continuation jsGet_continuation() {
125:                return (Continuation) wk.getContinuation();
126:            }
127:
128:            public FOM_WebContinuation jsFunction_getParent() {
129:                WebContinuation parent = wk.getParentContinuation();
130:                if (parent == null) {
131:                    return null;
132:                }
133:
134:                FOM_WebContinuation pwk = new FOM_WebContinuation(parent);
135:                pwk.setParentScope(getParentScope());
136:                pwk.setPrototype(getClassPrototype(getParentScope(), pwk
137:                        .getClassName()));
138:                return pwk;
139:            }
140:
141:            public NativeArray jsFunction_getChildren() throws Exception {
142:                List list = wk.getChildren();
143:                NativeArray arr = (NativeArray) org.mozilla.javascript.Context
144:                        .getCurrentContext().newObject(getParentScope(),
145:                                "Array",
146:                                new Object[] { new Integer(list.size()) });
147:                Iterator iter = list.iterator();
148:                for (int i = 0; iter.hasNext(); i++) {
149:                    WebContinuation child = (WebContinuation) iter.next();
150:                    FOM_WebContinuation cwk = new FOM_WebContinuation(child);
151:                    cwk.setParentScope(getParentScope());
152:                    cwk.setPrototype(getClassPrototype(getParentScope(), cwk
153:                            .getClassName()));
154:                    arr.put(i, arr, cwk);
155:                }
156:                return arr;
157:            }
158:
159:            public void jsFunction_invalidate() throws Exception {
160:                ContinuationsManager contMgr = null;
161:                FOM_Cocoon cocoon = (FOM_Cocoon) getProperty(
162:                        getTopLevelScope(this ), "cocoon");
163:                ServiceManager componentManager = cocoon.getServiceManager();
164:                contMgr = (ContinuationsManager) componentManager
165:                        .lookup(ContinuationsManager.ROLE);
166:                contMgr.invalidateWebContinuation(wk);
167:            }
168:
169:            public void jsFunction_display() {
170:                wk.display();
171:            }
172:
173:            public WebContinuation getWebContinuation() {
174:                return wk;
175:            }
176:
177:            private static Object unwrap(Object obj) {
178:                if (obj instanceof  Wrapper) {
179:                    obj = ((Wrapper) obj).unwrap();
180:                } else if (obj == Undefined.instance) {
181:                    obj = null;
182:                }
183:                return obj;
184:            }
185:
186:            PageLocalScopeImpl getPageLocal() {
187:                UserObject userObj = (UserObject) wk.getUserObject();
188:                if (userObj == null)
189:                    return null;
190:                return userObj.pageLocal;
191:            }
192:
193:            void setPageLocal(PageLocalScopeImpl pageLocal) {
194:                UserObject userObj = (UserObject) wk.getUserObject();
195:                if (userObj == null) {
196:                    userObj = new UserObject();
197:                    wk.setUserObject(userObj);
198:                }
199:                userObj.pageLocal = pageLocal;
200:            }
201:
202:            public void jsFunction_setBookmark(boolean value) {
203:                UserObject userObj = (UserObject) wk.getUserObject();
204:                if (userObj == null) {
205:                    userObj = new UserObject();
206:                    wk.setUserObject(userObj);
207:                }
208:                userObj.isBookmark = value;
209:            }
210:
211:            public boolean jsGet_bookmark() {
212:                return isBookmark(wk);
213:            }
214:
215:            public boolean jsFunction_isBookmark() {
216:                return isBookmark(wk);
217:            }
218:
219:            public FOM_WebContinuation jsGet_previousBookmark() {
220:                WebContinuation c = wk.getParentContinuation();
221:                if (c == null) {
222:                    return null;
223:                }
224:
225:                // If this is a continuation of sendPageAndWait()
226:                // and the immediate parent is a bookmark, then
227:                // it is the bookmark for this page, so skip it.
228:                if (!isBookmark(wk) && isBookmark(c)) {
229:                    c = c.getParentContinuation();
230:                }
231:                while (c != null && !isBookmark(c)) {
232:                    c = c.getParentContinuation();
233:                }
234:                if (c == null) {
235:                    return null;
236:                }
237:
238:                FOM_WebContinuation pwk = new FOM_WebContinuation(c);
239:                pwk.setParentScope(getParentScope());
240:                pwk.setPrototype(getClassPrototype(getParentScope(), pwk
241:                        .getClassName()));
242:                return pwk;
243:            }
244:
245:            /**
246:             * Return text representation of the WebContinuation.
247:             */
248:            public String toString() {
249:                return "WC" + wk.getId();
250:            }
251:        }
w___ww_.__j__av_a__2__s__._c_om_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.