Source Code Cross Referenced for BarracudaConfig.java in  » J2EE » Enhydra-Demos » org » enhydra » barracuda » config » 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 » J2EE » Enhydra Demos » org.enhydra.barracuda.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         * 
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site (http://www.enhydra.org/).
008:         * 
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         * 
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         * 
019:         * Contributor(s):
020:         * 
021:         * $Id: BarracudaConfig.java,v 1.1 2006-09-11 12:30:02 sinisa Exp $
022:         */
023:        package org.enhydra.barracuda.config;
024:
025:        import java.io.*;
026:        import java.util.*;
027:        import java.lang.ref.*;
028:        import java.net.*;
029:        import javax.servlet.*;
030:        import javax.servlet.http.*;
031:
032:        import org.apache.log4j.*;
033:        import org.w3c.dom.*;
034:        import org.w3c.dom.html.*;
035:
036:        import org.enhydra.barracuda.config.events.*;
037:        import org.enhydra.barracuda.config.xmlc.*;
038:        import org.barracudamvc.core.comp.*;
039:        import org.barracudamvc.core.event.*;
040:        import org.barracudamvc.core.event.helper.*;
041:        import org.barracudamvc.core.forms.*;
042:        import org.barracudamvc.core.helper.servlet.*;
043:        import org.barracudamvc.core.util.dom.*; //import org.barracudamvc.core.util.dom.io.*;
044:        import org.enhydra.xml.io.*;
045:        import org.barracudamvc.core.util.http.*;
046:        import org.barracudamvc.core.view.*;
047:        import org.barracudamvc.plankton.data.*;
048:
049:        /**
050:         * This mini-app is can be used to configure the core Barracuda 
051:         * classes. This class contains event handlers (both Controller 
052:         * and View) for the Config screen (which is the only screen)
053:         */
054:        public class BarracudaConfig extends DefaultEventGateway {
055:
056:            //public constants
057:            protected static final Logger logger = Logger
058:                    .getLogger(BarracudaConfig.class.getName());
059:
060:            public static final String MASTER_SCREEN = BarracudaConfig.class
061:                    .getName()
062:                    + ".MasterScreen";
063:            public static final String FORM = BarracudaConfig.class.getName()
064:                    + ".Form";
065:            public static final String ERR = BarracudaConfig.class.getName()
066:                    + ".Errors";
067:
068:            //this defines the various event handlers
069:            private ListenerFactory getConfigFactory = new DefaultListenerFactory() {
070:                public BaseEventListener getInstance() {
071:                    return new GetConfigHandler();
072:                }
073:
074:                public String getListenerID() {
075:                    return getID(GetConfigHandler.class);
076:                }
077:            };
078:            private ListenerFactory getNextConfigFactory = new DefaultListenerFactory() {
079:                public BaseEventListener getInstance() {
080:                    return new GetNextConfigHandler();
081:                }
082:
083:                public String getListenerID() {
084:                    return getID(GetConfigHandler.class);
085:                }
086:            };
087:            private ListenerFactory renderConfigFactory = new DefaultListenerFactory() {
088:                public BaseEventListener getInstance() {
089:                    return new RenderConfigHandler();
090:                }
091:
092:                public String getListenerID() {
093:                    return getID(RenderConfigHandler.class);
094:                }
095:            };
096:
097:            //------------------- BarracudaConfig ------------------------
098:            /**
099:             * Public constructor
100:             */
101:            public BarracudaConfig() {
102:                //specify who's interested in what
103:                specifyLocalEventInterests(getConfigFactory, GetBConfig.class);
104:                specifyLocalEventInterests(getNextConfigFactory,
105:                        GetNextBConfig.class);
106:                specifyLocalEventInterests(renderConfigFactory,
107:                        RenderBConfig.class);
108:
109:                //add in sub-gateways
110:                this .add(new CompConfig());
111:                this .add(new DataConfig());
112:                this .add(new DomConfig());
113:                this .add(new EventConfig());
114:                this .add(new FormsConfig());
115:                this .add(new UtilConfig());
116:                this .add(new ViewConfig());
117:                this .add(new MasterConfig());
118:            }
119:
120:            //------------------------------------------------------------
121:            //             Model 2 - Controller Event Handlers
122:            //------------------------------------------------------------
123:            /**
124:             * GetConfigHandler - handle the request to get the config 
125:             * screen.
126:             */
127:            class GetConfigHandler extends DefaultBaseEventListener {
128:                public void handleControlEvent(ControlEventContext context)
129:                        throws EventException, ServletException, IOException {
130:                    //get the appropriate screen for the desired context and locale
131:                    Locale locale = context.getViewCapabilities()
132:                            .getClientLocale();
133:                    MasterScreen screen = new MasterScreenFactory()
134:                            .getInstance(BarracudaConfig.this , context, locale);
135:
136:                    //make sure the proper tab is selected (get curtab from session)
137:                    HttpSession session = SessionServices.getSession(context
138:                            .getRequest());
139:                    String curtab = (String) session
140:                            .getAttribute(TabsModel.CUR_TAB);
141:                    screen.tabsModel.setCurrentTab(curtab);
142:
143:                    //place the screen in the context (so the renderer can access it)
144:                    context.putState(MASTER_SCREEN, screen);
145:
146:                    //forward control to the renderer
147:                    context.getQueue().addEvent(new RenderBConfig());
148:                }
149:            }
150:
151:            /**
152:             * GetNextConfigHandler - get the next barracuda config screen (expects 
153:             * a TabsModel.CUR_TAB parameter in the request
154:             */
155:            class GetNextConfigHandler extends DefaultBaseEventListener {
156:                public void handleControlEvent(ControlEventContext context)
157:                        throws EventException, ServletException, IOException {
158:                    //get the curtab parameter
159:                    String curtab = context.getRequest().getParameter(
160:                            TabsModel.CUR_TAB);
161:
162:                    //place it in the session (so it'll be available when we handle
163:                    //the get event request)
164:                    HttpSession session = SessionServices.getSession(context
165:                            .getRequest());
166:                    session.setAttribute(TabsModel.CUR_TAB, curtab);
167:
168:                    //now redirect to the main get event
169:                    throw new ClientSideRedirectException(new GetBConfig());
170:                }
171:            }
172:
173:            //------------------------------------------------------------
174:            //                Model 2 - View Event Handlers
175:            //------------------------------------------------------------
176:            /**
177:             * RenderConfigHandler - handle the request to render the config 
178:             * screen
179:             */
180:            class RenderConfigHandler extends DefaultBaseEventListener {
181:                public void handleViewEvent(ViewEventContext context)
182:                        throws EventException, ServletException, IOException {
183:                    //get the screen from context
184:                    MasterScreen screen = (MasterScreen) context
185:                            .getState(MASTER_SCREEN);
186:
187:                    //TODO: note we really should be calling the initCycle and destroyCycle methods 
188:                    //on this component hierarchy (not here of course, but it does need to be done)
189:
190:                    //grab the component hierarchy and render it
191:                    ViewContext vc = new DefaultViewContext(context);
192:                    try {
193:                        screen.bcRoot.render(vc);
194:                    } catch (RenderException e) {
195:                        logger.debug("Error rendering views:", e);
196:                    }
197:
198:                    //csc_112901.2            
199:                    //now adjust the outgoing page (this is critical to make sure we
200:                    //can accurately detect client scripting)
201:                    ScriptDetector.prepareClientResp(screen.dom, vc);
202:
203:                    //now render the DOM
204:                    //06_19_2001_Jacob_Kjome_start - hoju@visi.com
205:                    //get the output options
206:                    OutputOptions oo = DefaultDOMWriter
207:                            .getDefaultOutputOptions(screen.dom
208:                                    .getOwnerDocument());
209:
210:                    //add doctype - need to do here because XMLC can't yet add the one embedded in the html to the DOM
211:                    oo.setOmitDocType(false);
212:                    oo.setPublicId("-//W3C//DTD HTML 4.01 Transitional//EN");
213:                    oo.setSystemId("http://www.w3.org/TR/html401/loose.dtd");
214:
215:                    //now render the DOM
216:                    //            new DefaultDOMWriter().write(screen.dom, context.getResponse());
217:                    new DefaultDOMWriter(oo).write(screen.dom, context
218:                            .getResponse());
219:                    //06_19_2001_Jacob_Kjome_end
220:                }
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.