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


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 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: EditEjbAction.java 9680 2006-10-06 12:08:33Z danesa $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.webapp.jonasadmin.service.ejb;
025:
026:        import java.util.ArrayList;
027:        import java.util.Collection;
028:        import java.util.HashMap;
029:        import java.util.Map;
030:
031:        import javax.management.MalformedObjectNameException;
032:        import javax.management.ObjectName;
033:        import javax.servlet.http.HttpServletRequest;
034:        import javax.servlet.http.HttpServletResponse;
035:
036:        import org.apache.struts.action.ActionForm;
037:        import org.apache.struts.action.ActionForward;
038:        import org.apache.struts.action.ActionMapping;
039:        import org.objectweb.jonas.jmx.JonasManagementRepr;
040:        import org.objectweb.jonas.jmx.JonasObjectName;
041:        import org.objectweb.jonas.jmx.JoramObjectName;
042:        import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
043:        import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
044:        import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
045:        import org.objectweb.jonas.webapp.jonasadmin.joramplatform.EditJoramBaseAction;
046:        import org.objectweb.jonas.webapp.jonasadmin.service.container.ContainerForm;
047:
048:        /**
049:         * @author Michel-Ange ANTON
050:         */
051:
052:        public abstract class EditEjbAction extends JonasBaseAction {
053:
054:            /**
055:             * The EJB's OBJECT_NAME (the stringified ObjetName)
056:             */
057:            private String ejbObjectName = null;
058:
059:            // --------------------------------------------------------- Public Methods
060:            /**
061:             * Execute a action.
062:             *
063:             * @param pMapping <code>ActionForward</code> instance
064:             * @param pForm <code>ActionForm</code> instance
065:             * @param pRequest <code>HttpServletRequest</code> instance
066:             * @param pResponse <code>HttpServletResponse</code> instance
067:             * @return <code>ActionForward</code> instance
068:             */
069:            public ActionForward executeAction(ActionMapping pMapping,
070:                    ActionForm pForm, HttpServletRequest pRequest,
071:                    HttpServletResponse pResponse) {
072:
073:                // Current server
074:                WhereAreYou oWhere = (WhereAreYou) pRequest.getSession()
075:                        .getAttribute(WhereAreYou.SESSION_NAME);
076:                String serverName = oWhere.getCurrentJonasServerName();
077:
078:                // setForm is used specifically when this action is invoked as a result of invalid input in editEjbSession*.jsp.
079:                EjbForm setForm = (EjbForm) m_Session.getAttribute("ejbForm");
080:                // Determine the EJB's ObjectName
081:                String sObjectName = pRequest.getParameter("select");
082:                if (sObjectName == null) {
083:                    // Accept request attribute forced by a EditEjbAction
084:                    sObjectName = (String) pRequest.getAttribute("select");
085:                }
086:
087:                if (sObjectName == null) {
088:                    // Use the objectname specified in the cached input form before invalid data was submitted by user.
089:                    sObjectName = (setForm != null && setForm.getObjectName() != null) ? setForm
090:                            .getObjectName()
091:                            : null;
092:                }
093:
094:                ObjectName oObjectName = null;
095:                if (sObjectName != null) {
096:                    try {
097:                        oObjectName = ObjectName.getInstance(sObjectName);
098:                    } catch (Throwable t) {
099:                        addGlobalError(t);
100:                        saveErrors(pRequest, m_Errors);
101:                        return (pMapping.findForward("Global Error"));
102:                    }
103:                }
104:
105:                // Form used
106:                EjbForm oForm = getEjbForm();
107:                ejbObjectName = sObjectName;
108:                String msParamType = oObjectName.getKeyProperty("j2eeType");
109:                String msParamName = oObjectName.getKeyProperty("name");
110:                String msParamFile = getStringAttribute(oObjectName, "fileName");
111:
112:                // Put global properties
113:                oForm.setType(msParamType);
114:                oForm.setName(msParamName);
115:                oForm.setObjectName(ejbObjectName);
116:                oForm.setFile(msParamFile);
117:                if (msParamType != null) {
118:                    String sFullType = m_Resources.getMessage("ejb.fulltype."
119:                            + msParamType);
120:                    oForm.setFullType(sFullType);
121:                }
122:
123:                // Force the node selected in tree
124:                //m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
125:                // DEPTH_SERVER is not good in case the currently selected node do no belongs to the Server JOnAS node
126:                // this situation can be found when the selected node is a JMS destination managed by Joram and
127:                // when trying to navigate through the EJBs used by a JMS destination
128:                String serverNodeName = "domain" + WhereAreYou.NODE_SEPARATOR
129:                        + m_WhereAreYou.getCurrentJonasServerName();
130:
131:                m_WhereAreYou.selectNameNode(serverNodeName
132:                        + WhereAreYou.NODE_SEPARATOR + "services"
133:                        + WhereAreYou.NODE_SEPARATOR + "ejbContainers"
134:                        + WhereAreYou.NODE_SEPARATOR
135:                        + JonasAdminJmx.extractFilename(oForm.getFile())
136:                        + WhereAreYou.NODE_SEPARATOR + oForm.getName(), true);
137:
138:                try {
139:                    // Fill Ejb infos
140:                    fillEjbInfo(oForm, oObjectName, serverName);
141:                    // Fill Ejb dependencies (Datasource, JMS, ...)
142:                    fillEjbDependencies(oForm, oObjectName, serverName);
143:                } catch (Throwable t) {
144:                    addGlobalError(t);
145:                    saveErrors(pRequest, m_Errors);
146:                    return (pMapping.findForward("Global Error"));
147:                }
148:
149:                if (setForm != null && oForm.getObjectName() == null) {
150:                    sObjectName = setForm.getObjectName();
151:                    oForm = setForm;
152:                }
153:                pRequest.setAttribute("select", sObjectName);
154:
155:                m_Session.setAttribute("ejbForm", oForm);
156:
157:                // Ejb Forward
158:                String sForward = getEjbForward();
159:
160:                // Control if the Container in session is the parent of the current Ejb
161:                ContainerForm oContForm = (ContainerForm) m_Session
162:                        .getAttribute("containerForm");
163:                boolean bChangeForward = false;
164:                if (oContForm == null) {
165:                    bChangeForward = true;
166:                } else {
167:                    if (!oContForm.getPath().equals(oForm.getFile())) {
168:                        bChangeForward = true;
169:                    }
170:                }
171:                // Change enabled
172:                if (bChangeForward) {
173:                    // Next forward in EditContainerAction
174:                    pRequest.setAttribute("NextForward", sForward);
175:                    //p_Request.setAttribute("selectedEjb", sObjectName);
176:                    // Change the forward to Edit the container
177:                    sForward = "ActionEditContainer";
178:                }
179:
180:                // Forward to the jsp or the action
181:                return (pMapping.findForward(sForward));
182:            }
183:
184:            // --------------------------------------------------------- Protected Methods
185:
186:            /**
187:             * The global forward to go.
188:             *
189:             * @return Forward
190:             */
191:            protected abstract String getEjbForward();
192:
193:            /**
194:             * Return a <code>EjbForm</code> instance associate to the EJB.
195:             *
196:             * @return A form instance
197:             */
198:            protected abstract EjbForm getEjbForm();
199:
200:            /**
201:             * Fill all infos of EJB in the <code>EjbForm</code> instance.
202:             *
203:             * @param pForm Instance to fill
204:             * @param pObjectName Instance to get infos
205:             * @throws Exception Could not fill info
206:             */
207:            protected abstract void fillEjbInfo(EjbForm pForm,
208:                    ObjectName pObjectName, String serverName) throws Exception;
209:
210:            /**
211:             * Get a <code>ObjectName</code> instance for the Ejb given with the parameters of the HTPP request.
212:             *
213:             * @return The ObjectName instance
214:             * @throws Exception Could not construct ObjectName
215:             */
216:            protected ObjectName getEjbObjectName() throws Exception {
217:                return ObjectName.getInstance(ejbObjectName);
218:            }
219:
220:            /**
221:             * Fill all global infos of EJB in the <code>EjbForm</code> instance.
222:             *
223:             * @param pForm Instance to fill
224:             * @param pObjectName Instance to get infos
225:             */
226:            protected void fillEjbGlobalInfo(EjbForm pForm,
227:                    ObjectName pObjectName) {
228:                pForm
229:                        .setCacheSize(getIntegerAttribute(pObjectName,
230:                                "cacheSize"));
231:                pForm.setMaxCacheSize(getIntegerAttribute(pObjectName,
232:                        "maxCacheSize"));
233:                pForm.setMinPoolSize(getIntegerAttribute(pObjectName,
234:                        "minPoolSize"));
235:                pForm.setPoolSize(getIntegerAttribute(pObjectName, "poolSize"));
236:                pForm.setDisplayName(getStringAttribute(pObjectName,
237:                        "displayName"));
238:                pForm.setEjbClass(getStringAttribute(pObjectName, "ejbClass"));
239:                pForm
240:                        .setEjbFileName(getStringAttribute(pObjectName,
241:                                "fileName"));
242:                pForm.setEjbName(pObjectName.getKeyProperty("name"));
243:                pForm
244:                        .setHomeClass(getStringAttribute(pObjectName,
245:                                "homeClass"));
246:                pForm.setJndiName(getStringAttribute(pObjectName, "jndiName"));
247:                pForm.setLocalClass(getStringAttribute(pObjectName,
248:                        "localClass"));
249:                pForm.setLocalHomeClass(getStringAttribute(pObjectName,
250:                        "localHomeClass"));
251:                pForm.setRemoteClass(getStringAttribute(pObjectName,
252:                        "remoteClass"));
253:            }
254:
255:            /**
256:             * Fill all dependencies of EJB in the <code>EjbForm</code> instance.
257:             *
258:             * @param pForm Instance to fill
259:             * @param pObjectName Instance to get infos
260:             */
261:            protected void fillEjbDependencies(EjbForm pForm,
262:                    ObjectName pObjectName, String serverName) {
263:                // Dependency with Datasource service
264:                pForm.setDatabaseServiceActivated(JonasManagementRepr
265:                        .isRegistered(JonasObjectName.databaseService(),
266:                                serverName));
267:                pForm.setResourceServiceActivated(JonasManagementRepr
268:                        .isRegistered(JonasObjectName.resourceService(),
269:                                serverName));
270:                HashMap hDataSources = new HashMap((Map) JonasManagementRepr
271:                        .getAttribute(pObjectName, "allDataSourceName",
272:                                serverName));
273:                HashMap hJdbcRAs = new HashMap((Map) JonasManagementRepr
274:                        .getAttribute(pObjectName,
275:                                "allJdbcResourceAdapterName", serverName));
276:                if (hDataSources.size() > 0) {
277:                    pForm.setDataSource(true);
278:                    pForm.setDataSources(hDataSources);
279:                }
280:                if (hJdbcRAs.size() > 0) {
281:                    pForm.setDataSource(true);
282:                    pForm.setJdbcRas(hJdbcRAs);
283:                }
284:                // Dependency with JMS service or Joram resource
285:                pForm.setJmsServiceActivated(JonasManagementRepr.isRegistered(
286:                        JonasObjectName.jmsService(), serverName));
287:                ObjectName jormamPlatformObjectName = null;
288:                try {
289:                    jormamPlatformObjectName = JoramObjectName.joramPlatform();
290:                    pForm
291:                            .setJoramResourceLoaded(JonasManagementRepr
292:                                    .isRegistered(jormamPlatformObjectName,
293:                                            serverName));
294:                } catch (MalformedObjectNameException e) {
295:                    pForm.setJoramResourceLoaded(false);
296:                }
297:                ArrayList alJmsConnections = new ArrayList(
298:                        (Collection) JonasManagementRepr.getAttribute(
299:                                pObjectName, "allJMSConnectionFactoryName",
300:                                serverName));
301:                if (alJmsConnections.size() > 0) {
302:                    pForm.setJmsConnection(true);
303:                    pForm.setJmsConnections(alJmsConnections);
304:                }
305:                ArrayList alJmsDestinations = new ArrayList(
306:                        (Collection) JonasManagementRepr.getAttribute(
307:                                pObjectName, "allJMSDestinationName",
308:                                serverName));
309:                if (alJmsDestinations.size() > 0) {
310:                    pForm.setJmsDestination(true);
311:                    if (pForm.isJoramResourceLoaded()) {
312:                        // for each destination, look for the Joram destination MBean
313:                        ArrayList jmsDestinationItems = new ArrayList();
314:                        EjbDependency depItem = null;
315:                        for (int i = 0; i < alJmsDestinations.size(); i++) {
316:                            String name = (String) alJmsDestinations.get(i);
317:                            try {
318:                                ObjectName topicObjectName = JoramObjectName
319:                                        .joramTopic(name);
320:                                if (JonasManagementRepr.isRegistered(
321:                                        topicObjectName, serverName)) {
322:                                    String agentId = (String) JonasManagementRepr
323:                                            .getAttribute(topicObjectName,
324:                                                    "Name", serverName);
325:                                    String serverId = EditJoramBaseAction
326:                                            .currentServerId(agentId);
327:                                    depItem = new EjbDependency(name, "topic",
328:                                            serverId);
329:                                } else {
330:                                    ObjectName queueObjectName = JoramObjectName
331:                                            .joramQueue(name);
332:                                    if (JonasManagementRepr.isRegistered(
333:                                            queueObjectName, serverName)) {
334:                                        String agentId = (String) JonasManagementRepr
335:                                                .getAttribute(queueObjectName,
336:                                                        "Name", serverName);
337:                                        String serverId = EditJoramBaseAction
338:                                                .currentServerId(agentId);
339:                                        depItem = new EjbDependency(name,
340:                                                "queue", serverId);
341:                                    } else {
342:                                        depItem = new EjbDependency(name, null,
343:                                                "0");
344:                                    }
345:                                }
346:                            } catch (MalformedObjectNameException e) {
347:                                depItem = new EjbDependency(name, null, "0");
348:                            }
349:                            jmsDestinationItems.add(depItem);
350:                        }
351:                        pForm.setJmsDestinations(jmsDestinationItems);
352:                    } else {
353:                        pForm.setJmsDestinations(alJmsDestinations);
354:                    }
355:                }
356:                // Dependency with Mail service
357:                pForm.setMailServiceActivated(JonasManagementRepr.isRegistered(
358:                        JonasObjectName.mailService(), serverName));
359:                HashMap hMailSessions = new HashMap((Map) JonasManagementRepr
360:                        .getAttribute(pObjectName, "allMailFactorySName",
361:                                serverName));
362:                if (hMailSessions.size() > 0) {
363:                    pForm.setMailSession(true);
364:                    pForm.setMailSessions(hMailSessions);
365:                }
366:                HashMap hMailMimes = new HashMap((Map) JonasManagementRepr
367:                        .getAttribute(pObjectName, "allMailFactoryMName",
368:                                serverName));
369:                if (hMailMimes.size() > 0) {
370:                    pForm.setMailMime(true);
371:                    pForm.setMailMimes(hMailMimes);
372:                }
373:                // Detect one dependency
374:                pForm.setDependency(pForm.isDataSource()
375:                        || pForm.isJmsConnection() || pForm.isJmsDestination()
376:                        || pForm.isMailSession() || pForm.isMailMime());
377:            }
378:        }
www_._ja_v__a_2s___.__c__o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.