Source Code Cross Referenced for ApplyCatalinaAccessLoggerAction.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » webapp » jonasadmin » logging » 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 » JOnAS 4.8.6 » org.objectweb.jonas.webapp.jonasadmin.logging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2003-2005 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: ApplyCatalinaAccessLoggerAction.java 9680 2006-10-06 12:08:33Z danesa $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.webapp.jonasadmin.logging;
025:
026:        import java.io.IOException;
027:
028:        import javax.management.ObjectName;
029:        import javax.servlet.ServletException;
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:
033:        import org.apache.struts.action.ActionMessage;
034:        import org.apache.struts.action.ActionForm;
035:        import org.apache.struts.action.ActionForward;
036:        import org.apache.struts.action.ActionMapping;
037:        import org.objectweb.jonas.jmx.JonasManagementRepr;
038:        import org.objectweb.jonas.jmx.CatalinaObjectName;
039:        import org.objectweb.jonas.webapp.jonasadmin.JonasAdminException;
040:        import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
041:
042:        /**
043:         * @author Michel-Ange ANTON
044:         * @author Adriana Danes
045:         */
046:        public class ApplyCatalinaAccessLoggerAction extends BaseLoggerAction {
047:
048:            /**
049:             * Signature for the <code>createStandardConnector</code> operation.
050:             */
051:            private String sa_CreateAccessLogger[] = { "java.lang.String" };
052:
053:            private static String sDefaultForward = "ActionEditWebAppCatalina";
054:
055:            // --------------------------------------------------------- Protected Variables
056:
057:            // --------------------------------------------------------- Public Methods
058:            /**
059:             * Execute CatalinaAccessLogger action
060:             * @param pForm The current form
061:             * @param pMapping The current mapping
062:             * @param pRequest The current request
063:             * @param pResponse The response to the current request
064:             * @return The forward to go to the next page
065:             * @throws Exception
066:             */
067:            public ActionForward executeAction(ActionMapping pMapping,
068:                    ActionForm pForm, HttpServletRequest pRequest,
069:                    HttpServletResponse pResponse) throws IOException,
070:                    ServletException {
071:
072:                // Default forward
073:                ActionForward oForward = null;
074:
075:                // Form used
076:                CatalinaAccessLogValveForm oForm = (CatalinaAccessLogValveForm) pForm;
077:
078:                // Populate
079:                try {
080:                    if ("create".equals(oForm.getAction())) {
081:                        oForward = createAccessLogger(oForm, pMapping, pRequest);
082:                    } else if ("edit".equals(oForm.getAction())) {
083:                        // Save in memory the new datas
084:                        oForward = populateMbean(oForm, pMapping
085:                                .findForward("ActionEditCatalinaAccessLogger"),
086:                                pMapping, pRequest);
087:                    }
088:                } catch (JonasAdminException e) {
089:                    // Build error
090:                    m_Errors.add("logger.catalina.access", new ActionMessage(e
091:                            .getId()));
092:                    saveErrors(pRequest, m_Errors);
093:                    // Return to the current page
094:                    oForward = new ActionForward(pMapping.getInput());
095:                } catch (Throwable t) {
096:                    addGlobalError(t);
097:                    saveErrors(pRequest, m_Errors);
098:                    oForward = pMapping.findForward("Global Error");
099:                }
100:
101:                // Next Forward
102:                return oForward;
103:            }
104:
105:            /**
106:             * Create a new access logger.
107:             * @param pForm The current form
108:             * @param pMapping The current mapping
109:             * @param pRequest The current request
110:             * @return The forward to go to the next page
111:             * @throws Exception
112:             */
113:            protected ActionForward createAccessLogger(
114:                    CatalinaAccessLogValveForm pForm, ActionMapping pMapping,
115:                    HttpServletRequest pRequest) throws Exception {
116:                Object values[] = null;
117:                // Look up the Catalina MBeanFactory
118:                ObjectName onFactory = CatalinaObjectName.catalinaFactory();
119:                // Create a new Access Logger Valve object
120:                values = new Object[1];
121:                String domainName = m_WhereAreYou
122:                        .getCurrentCatalinaDomainName();
123:                // Determine container type
124:                String containerType = pForm.getContainerType();
125:                if (containerType.equals(m_Resources
126:                        .getMessage("label.loggers.container.engine"))) {
127:                    ObjectName onEngine = CatalinaObjectName
128:                            .catalinaEngine(domainName);
129:                    values[0] = (onEngine).toString();
130:                } else if (containerType.equals(m_Resources
131:                        .getMessage("label.loggers.container.host"))) {
132:                    ObjectName onHost = CatalinaObjectName.catalinaHost(
133:                            domainName, pForm.getContainerName());
134:                    values[0] = (onHost).toString();
135:                }
136:                WhereAreYou oWhere = (WhereAreYou) pRequest.getSession()
137:                        .getAttribute(WhereAreYou.SESSION_NAME);
138:                String jonasServerName = oWhere.getCurrentJonasServerName();
139:                Object onValve = JonasManagementRepr.invoke(onFactory,
140:                        "createAccessLoggerValve", values,
141:                        sa_CreateAccessLogger, jonasServerName);
142:                pForm.setObjectName((String) onValve);
143:                // Populate
144:                ActionForward oForward = populateMbean(pForm, pMapping
145:                        .findForward("ActionListLoggers"), pMapping, pRequest);
146:
147:                // refresh tree
148:                refreshTree(pRequest);
149:                // Force the node selected in tree
150:                m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
151:                        + WhereAreYou.NODE_SEPARATOR + "logging"
152:                        + WhereAreYou.NODE_SEPARATOR
153:                        + LoggerItem.LOGGER_CATALINA_ACCESS_HOST, true);
154:
155:                // Return the next forward
156:                return oForward;
157:            }
158:
159:            /**
160:             * Populate the Mbean Access Logger.
161:             * @param p_Form The current form
162:             * @param p_Forward The current forward
163:             * @param p_Mapping The current mapping
164:             * @param p_Request The current request
165:             * @return If 'save' is requested then return the new forward to save
166:             * else return the current forward
167:             * @throws Exception Failed to populate Mbean
168:             */
169:            protected ActionForward populateMbean(
170:                    CatalinaAccessLogValveForm p_Form, ActionForward p_Forward,
171:                    ActionMapping p_Mapping, HttpServletRequest p_Request)
172:                    throws Exception {
173:                ActionForward oForward = p_Forward;
174:                // Access logger
175:                ObjectName on = new ObjectName(p_Form.getObjectName());
176:                setStringAttribute(on, "directory", p_Form.getDirectory());
177:                setStringAttribute(on, "prefix", p_Form.getPrefix());
178:                setStringAttribute(on, "suffix", p_Form.getSuffix());
179:                setBooleanAttribute(on, "resolveHosts", p_Form.isResolveHosts());
180:                setBooleanAttribute(on, "rotatable", p_Form.isRotatable());
181:                setStringAttribute(on, "pattern", p_Form.getPattern());
182:                // Save in configuration file
183:                if (p_Form.isSave()) {
184:                    //ObjectName onServer = CatalinaObjectName.catalinaServer();
185:                    //JonasManagementRepr.invoke(onServer, "store", null, null);
186:                    p_Form.setSave(false);
187:                    p_Request.setAttribute("forward", p_Forward.getName());
188:                    oForward = p_Mapping.findForward("ActionEditServletServer");
189:                }
190:                return oForward;
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.