Source Code Cross Referenced for SRADesktop.java in  » Portal » Open-Portal » com » sun » portal » sra » desktop » 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 » Portal » Open Portal » com.sun.portal.sra.desktop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.sra.desktop;
002:
003:        import java.io.File;
004:        import java.io.IOException;
005:        import java.io.PrintWriter;
006:        import java.util.HashMap;
007:        import java.util.Iterator;
008:
009:        import javax.servlet.RequestDispatcher;
010:        import javax.servlet.ServletConfig;
011:        import javax.servlet.ServletException;
012:        import javax.servlet.http.HttpServlet;
013:        import javax.servlet.http.HttpServletRequest;
014:        import javax.servlet.http.HttpServletResponse;
015:        import javax.xml.parsers.ParserConfigurationException;
016:
017:        import org.xml.sax.SAXException;
018:
019:        import com.sun.portal.sra.config.CommandList;
020:        import com.sun.portal.sra.config.SAX2Reader;
021:        import com.sun.portal.sra.config.SraDesktop;
022:        import com.sun.portal.sra.desktop.commands.Command;
023:        import com.sun.portal.sra.desktop.commands.CommandExecutionException;
024:
025:        public class SRADesktop extends HttpServlet {
026:            private static final String CONTENT_TYPE = "text/html";
027:            private static final String FIRST_PAGE = "/index.jsp";
028:            private static ServletConfig _config;
029:            private static HashMap _commandMap;
030:            private static HashMap _nextViewMap;
031:            private static HashMap _providerMap;
032:            private static SAX2Reader _sax;
033:
034:            /**
035:             * @web.servlet display-name="SRA Desktop Servlet" load-on-startup="1"
036:             * name="SRADesktop" @web.servlet-init-param name="CONFIG_FILE"
037:             * value="config.xml" @web.servlet-init-param name="NETLET_PROVIDER_CLASS"
038:             * value="SOME VALUE HERE" To change the template for this generated type
039:             * comment go to Window - Preferences - Java - Code Generation - Code and
040:             * Comments
041:             */
042:
043:            public void init(ServletConfig config) throws ServletException {
044:                super .init(config);
045:                _config = config;
046:
047:                try {
048:                    _sax = new SAX2Reader();
049:                    _commandMap = new HashMap();
050:                    _nextViewMap = new HashMap();
051:                    _providerMap = new HashMap();
052:
053:                    String configFile = _config.getServletContext()
054:                            .getRealPath(
055:                                    _config.getInitParameter("CONFIG_FILE"));
056:
057:                    getAllProviders();
058:
059:                    SraDesktop sdesk = (SraDesktop) _sax.parse(new File(
060:                            configFile));
061:                    CommandList command_list = sdesk.getCommandList();
062:                    Iterator iter = command_list.iterator();
063:
064:                    while (iter.hasNext()) {
065:                        com.sun.portal.sra.config.Command command = (com.sun.portal.sra.config.Command) iter
066:                                .next();
067:                        _commandMap.put(command.getName().getPCData(), command
068:                                .getCommandclass().getPCData());
069:                        _nextViewMap.put(command.getName().getPCData(), command
070:                                .getView().getPCData());
071:                    }
072:
073:                } catch (Exception e) {
074:                    throw new ServletException(e.toString());
075:                }
076:
077:            }
078:
079:            /**
080:             * 
081:             */
082:            private void getAllProviders() {
083:                _providerMap.put("SRA_PROXYLET_PROVIDER", _config
084:                        .getServletContext().getInitParameter(
085:                                "SRA_PROXYLET_PROVIDER"));
086:                _providerMap.put("SRA_SEPARATION_PROVIDER", _config
087:                        .getServletContext().getInitParameter(
088:                                "SRA_SEPARATION_PROVIDER"));
089:
090:            }
091:
092:            public void doGet(HttpServletRequest request,
093:                    HttpServletResponse response) throws ServletException,
094:                    IOException {
095:                try {
096:                    doGetPost(request, response);
097:                } catch (CommandExecutionException e) {
098:                    //e.printStackTrace();
099:                    System.out.println(e.returnStackTrace().toString());
100:
101:                }
102:            }
103:
104:            public void doPost(HttpServletRequest request,
105:                    HttpServletResponse response) throws ServletException,
106:                    IOException {
107:                try {
108:                    doGetPost(request, response);
109:                } catch (CommandExecutionException e) {
110:                    System.out.println(e.returnStackTrace().toString());
111:                }
112:            }
113:
114:            public void doPut(HttpServletRequest request,
115:                    HttpServletResponse response) throws ServletException,
116:                    IOException {
117:            }
118:
119:            public void doDelete(HttpServletRequest request,
120:                    HttpServletResponse response) throws ServletException,
121:                    IOException {
122:            }
123:
124:            private Command getCommand(String command)
125:                    throws ClassNotFoundException, IllegalAccessException,
126:                    InstantiationException {
127:                String nextCommand = (String) _commandMap.get(command);
128:
129:                return (Command) (Class.forName(nextCommand).newInstance());
130:            }
131:
132:            private String getNextView(String command) {
133:                String nextView = (String) _nextViewMap.get(command);
134:                if (nextView == null)
135:                    nextView = FIRST_PAGE;
136:
137:                return nextView;
138:            }
139:
140:            public void doGetPost(HttpServletRequest request,
141:                    HttpServletResponse response) throws ServletException,
142:                    IOException, CommandExecutionException {
143:                PrintWriter out = response.getWriter();
144:                out
145:                        .println("<html><body>The value for the provider is "
146:                                + (String) _providerMap.get("NETLET_PROVIDER")
147:                                + "<br>");
148:
149:                String comm = request.getParameter("action") == null ? "getDefault"
150:                        : request.getParameter("action");
151:
152:                try {
153:                    //Get the new command and next view which will generate the HTML
154:                    // fragment
155:                    Command command = getCommand(comm);
156:                    String nextView = getNextView(comm);
157:
158:                    request.setAttribute("DSAME_LOGOUT_URL", _config
159:                            .getServletContext().getInitParameter(
160:                                    "DSAME_LOGOUT_URL"));
161:                    request.setAttribute("staticContext", _config
162:                            .getServletContext().getInitParameter(
163:                                    "staticContext"));
164:
165:                    executeRequestedCommand(request, response, command);
166:
167:                    // Forward processing to the next view.
168:                    out.println("Next View is " + nextView + "<br>");
169:                    RequestDispatcher dispatcher = _config.getServletContext()
170:                            .getRequestDispatcher(nextView);
171:
172:                    if (dispatcher != null)
173:                        dispatcher.forward(request, response);
174:                    else
175:                        out.println("No Dispatcher Found for next view "
176:                                + nextView);
177:                } catch (Exception e) {
178:                    e.printStackTrace();
179:                    throw new CommandExecutionException(e);
180:                }
181:
182:                out.println("</body></html>");
183:            }
184:
185:            private void executeRequestedCommand(HttpServletRequest request,
186:                    HttpServletResponse response, Command command)
187:                    throws IOException, CommandExecutionException {
188:                // Execute the command associated and get the outout HTML and put it in
189:                // the request session.
190:                command.execute(request, response, _providerMap);
191:
192:            }
193:
194:            public void destroy() {
195:                _commandMap.clear();
196:                _nextViewMap.clear();
197:                _providerMap.clear();
198:            }
199:
200:            public static void main(String[] args)
201:                    throws ParserConfigurationException, SAXException,
202:                    IOException {
203:                String configFile = "D:\\SunProjects\\SRAWeb\\Web Root\\WEB-INF\\config.xml";
204:
205:                SAX2Reader _sax = new SAX2Reader();
206:                SraDesktop sdesk = (SraDesktop) _sax
207:                        .parse(new File(configFile));
208:                CommandList command_list = sdesk.getCommandList();
209:                Iterator iter = command_list.iterator();
210:
211:                while (iter.hasNext()) {
212:                    com.sun.portal.sra.config.Command command = (com.sun.portal.sra.config.Command) iter
213:                            .next();
214:                    System.out.println("|" + command.getName().getPCData()
215:                            + "|:::|" + command.getCommandclass().getPCData()
216:                            + "|");
217:                    System.out.println("|" + command.getName().getPCData()
218:                            + "|:::|" + command.getView().getPCData() + "|");
219:                }
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.