Source Code Cross Referenced for BarracudaDiscRackEnhydra.java in  » J2EE » Enhydra-Demos » barracudaDiscRack » 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 » barracudaDiscRack 
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: BarracudaDiscRackEnhydra.java,v 1.1 2006-09-11 12:30:36 sinisa Exp $
022:         */
023:
024:        package barracudaDiscRack;
025:
026:        import com.lutris.appserver.server.*;
027:        import com.lutris.appserver.server.httpPresentation.*;
028:        import com.lutris.appserver.server.session.*;
029:        import com.lutris.util.*;
030:        import javax.servlet.*;
031:        import javax.servlet.http.*;
032:        import java.util.*;
033:        import java.io.*;
034:
035:        /**
036:         * The application object.
037:         *
038:         * Application-wide data would go here.
039:         */
040:        public class BarracudaDiscRackEnhydra extends StandardApplication {
041:
042:            /*
043:             *  A few methods you might want to add to.
044:             *  See StandardApplication for more details.
045:             */
046:            public void startup(Config appConfig) throws ApplicationException {
047:                super .startup(appConfig);
048:                //  Here is where you would read application-specific settings from
049:                //  your config file.
050:
051:                // setup the Disc Rack gateway to barracuda
052:                try {
053:                    // setup the init parameters for the gateway
054:                    // if present in the applications config file
055:                    // default to the standard config from multiserver/enhydra
056:                    ServletConfig servletConfig = this 
057:                            .getHttpPresentationManager().getServlet()
058:                            .getServletConfig();
059:                    Config gatewayConfig = appConfig.getConfig("InitGateway");
060:                    if (null != gatewayConfig) {
061:                        servletConfig = new ServletConfigWrapper(this 
062:                                .getHttpPresentationManager()
063:                                .getServletContext(), gatewayConfig,
064:                                servletConfig.getServletName());
065:                    }
066:
067:                    this .myDiscRackGateway = new DiscRackGateway();
068:                    this .myGatewayExtension = this .myDiscRackGateway
069:                            .getEventExtension();
070:                    this .myDiscRackGateway.init(servletConfig);
071:                } catch (ServletException ex) {
072:                    throw (new ApplicationException(
073:                            "Error initilising DiscRackGateway", ex));
074:                } catch (KeywordValueException ex) {
075:                    throw (new ApplicationException(
076:                            "Error initilising DiscRackGateway", ex));
077:                }
078:            }
079:
080:            /*
081:             * destroy Barracuda Disc Rack gateway
082:             */
083:            public void shutdown() {
084:                super .shutdown();
085:                this .myDiscRackGateway.destroy();
086:            }
087:
088:            /**
089:             * Default method used by <CODE>requestPreprocessor</CODE>
090:             * to ensure that a session exists and initialize the
091:             * <CODE>session</CODE> and <CODE>sessionData</CODE> fields
092:             * in the <CODE>HttpPresentationComms</CODE> object.
093:             * New sessions are only created on requests to presentation
094:             * objects, not requests for other types of files (such as gifs).
095:             * This avoids allocating multiple sessions when a browser makes
096:             * multiple requests for HREFs.  If the session already exist, it
097:             * is alwasy set in <CODE>comms</CODE><P>
098:             *
099:             * This normally looks up the session using a session key from
100:             * a cookie.
101:             *
102:             * @param comms
103:             *   Object containing request, response and redirect objects.
104:             * @exception ApplicationException
105:             *   If an error occurs setting up the session.
106:             */
107:            protected void ensureSession(HttpPresentationComms comms)
108:                    throws ApplicationException {
109:
110:                try {
111:                    boolean isOkForSession = presentationManager
112:                            .isPresentationRequest(comms.request)
113:                            || comms.request.getRequestURI().indexOf(
114:                                    this .myGatewayExtension) > -1;
115:
116:                    if (isOkForSession) {
117:                        // FIX - verify OK
118:                        comms.session = StandardAppUtil
119:                                .getRequestSession(comms);
120:                    }
121:                    if (comms.session != null
122:                            && sessionManager.sessionExists(comms.session
123:                                    .getSessionKey())) {
124:                        /*
125:                         * InitializeNewSession() sets up comms.sessionData, so
126:                         * that it may be used if an application defines it's own
127:                         * version of that method (after calling the super method,
128:                         * it has a normal comms object to work with).
129:                         * Therefore, if we did not call initializeNewSession(),
130:                         * we have to initialize comms.sessionData here.
131:                         */
132:                        comms.sessionData = comms.session.getSessionData();
133:                    } else {
134:
135:                        if (isOkForSession) {
136:                            initializeNewSession(comms);
137:                        }
138:                    }
139:                } catch (HttpPresentationException except) {
140:                    throw new ApplicationException(except);
141:                } catch (SessionException except) {
142:                    throw new ApplicationException(except);
143:                }
144:            }
145:
146:            public boolean requestPreprocessor(HttpPresentationComms comms)
147:                    throws Exception {
148:                boolean retVal = super .requestPreprocessor(comms);
149:                if (!retVal) {
150:                    String target = comms.request.getRequestURI();
151:                    // if has the event extension in the URI then treat it as a barracuda event
152:                    if (target.indexOf(this .myGatewayExtension) > -1) {
153:                        this .myDiscRackGateway.handleDefaultExt(comms.request
154:                                .getHttpServletRequest(), comms.response
155:                                .getHttpServletResponse(), comms);
156:                        retVal = true;
157:                    }
158:                }
159:                return retVal;
160:            }
161:
162:            /**
163:             * This is an optional function, used only by the Multiserver's graphical
164:             * administration. This bit of HTML appears in the status page for this
165:             * application. You could add extra status info, for example
166:             * a list of currently logged in users.
167:             *
168:             * @return HTML that is displayed in the status page of the Multiserver.
169:             */
170:            public String toHtml() {
171:                return "This is <I>DiscRack</I>";
172:            }
173:
174:            private DiscRackGateway myDiscRackGateway;
175:            private String myGatewayExtension;
176:        }
177:
178:        class ServletConfigWrapper implements  ServletConfig {
179:
180:            private ServletContext myContext;
181:            private Config myConfig;
182:            private String myName;
183:
184:            public ServletConfigWrapper(ServletContext context, Config config,
185:                    String name) {
186:                this .myContext = context;
187:                this .myConfig = config;
188:                this .myName = name;
189:            }
190:
191:            public ServletContext getServletContext() {
192:                return this .myContext;
193:            }
194:
195:            public String getInitParameter(String name) {
196:                String retVal = null;
197:                try {
198:                    retVal = this .myConfig.getString(name);
199:                } catch (KeywordValueException ex) {
200:                }
201:                return retVal;
202:            }
203:
204:            public Enumeration getInitParameterNames() {
205:                return (Collections.enumeration(Arrays.asList(this .myConfig
206:                        .keys())));
207:            }
208:
209:            public String getServletName() {
210:                return this.myName;
211:            }
212:
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.