Source Code Cross Referenced for ListSettingsBean.java in  » Portal » Open-Portal » com » sun » portal » admin » console » monitoring » settings » 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.admin.console.monitoring.settings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: ListSettingsBean.java,v 1.3 2006/03/24 08:37:35 pa157442 Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.console.monitoring.settings;
014:
015:        import java.util.List;
016:        import java.util.LinkedList;
017:        import java.util.Set;
018:        import java.util.Iterator;
019:        import java.util.ListIterator;
020:        import java.util.ArrayList;
021:        import java.util.logging.Level;
022:
023:        import java.io.IOException;
024:
025:        import javax.management.AttributeNotFoundException;
026:        import javax.management.MBeanException;
027:        import javax.management.InstanceNotFoundException;
028:        import javax.management.ReflectionException;
029:        import javax.management.MalformedObjectNameException;
030:        import javax.management.MBeanServerConnection;
031:        import javax.management.ObjectName;
032:        import javax.management.QueryExp;
033:        import javax.management.Attribute;
034:
035:        import javax.faces.event.ValueChangeEvent;
036:
037:        import com.sun.portal.admin.common.util.AdminUtil;
038:        import com.sun.portal.admin.common.util.AdminClientUtil;
039:        import com.sun.portal.admin.console.common.PSBaseBean;
040:        import com.sun.web.ui.component.Checkbox;
041:
042:        import com.sun.data.provider.DataProvider;
043:        import com.sun.data.provider.impl.ObjectListDataProvider;
044:
045:        import com.sun.portal.admin.console.common.PortalBaseBean;
046:
047:        /**
048:         *
049:         * @author pa157442
050:         */
051:        public class ListSettingsBean extends PSBaseBean {
052:
053:            private Boolean selectedEnable = Boolean.TRUE;
054:            private Boolean selectedDisable = Boolean.FALSE;
055:
056:            private ObjectName objectName;
057:            private Set mbeanNames;
058:            private MBeanServerConnection mbsc;
059:            private String defaultDomain;
060:            private DataProvider settings;
061:
062:            public static final String MONITORINGCONFIGURATION = "MonitoringConfiguration";
063:            public static final String MONITORING = "Monitoring";
064:
065:            private ObjectListDataProvider getNewObjectListDataProvider() {
066:                // Has to be initialized as Lockhart does not like it to be null.
067:                List list = new LinkedList();
068:                ObjectListDataProvider dataProvider = new ObjectListDataProvider(
069:                        list);
070:                dataProvider.setObjectType(SettingsBean.class);
071:                return dataProvider;
072:            }
073:
074:            /** Creates a new instance of SettingsBean */
075:            public ListSettingsBean() {
076:
077:            }
078:
079:            public void listMonitoringStatus() {
080:                String portalId = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
081:
082:                settings = getNewObjectListDataProvider();
083:
084:                ObjectName pattern = null;
085:                Set instanceNames = null;
086:
087:                PortalBaseBean portalBean = new PortalBaseBean();
088:                try {
089:                    instanceNames = portalBean.getInstanceObjectNames(portalId);
090:                } catch (IOException ie) {
091:                    log(Level.SEVERE,
092:                            "ListSettingsBean.listMonitoringStatus()", ie);
093:                } catch (Exception e) {
094:                    log(Level.SEVERE, e.getMessage(), e);
095:                }
096:
097:                PSBaseBean psBean = new PSBaseBean();
098:
099:                LinkedList statisticsList = new LinkedList();
100:
101:                for (Iterator counter = instanceNames.iterator(); counter
102:                        .hasNext();) {
103:                    ObjectName instanceName = (ObjectName) counter.next();
104:                    String instanceId = (String) psBean.getAttribute(
105:                            (ObjectName) instanceName, "ID");
106:                    //MBean path of Monitoring
107:                    LinkedList path = new LinkedList();
108:                    path.addFirst(getDomain());
109:                    path.addFirst(portalId);
110:                    path.addFirst(instanceId);
111:                    path.addFirst(MONITORING);
112:
113:                    try {
114:                        //Object Name of Monitoring
115:                        objectName = AdminClientUtil
116:                                .getResourceMBeanObjectName(
117:                                        AdminUtil.MONITORING_MBEAN_TYPE, path);
118:                    } catch (MalformedObjectNameException mone) {
119:                        log(Level.SEVERE,
120:                                "ListSettingsBean.listMonitoringStatus()", mone);
121:                    }
122:
123:                    mbsc = getMBeanServerConnection();
124:
125:                    Boolean connected = Boolean.FALSE;
126:                    boolean instanceDown = false;
127:
128:                    try {
129:
130:                        try {
131:                            mbsc.invoke(objectName, "connect", null, null);
132:                            connected = Boolean.TRUE;
133:                        } catch (ReflectionException re) {
134:                            log(Level.SEVERE,
135:                                    "ListSettingsBean.listMonitoringStatus()",
136:                                    re);
137:                        } catch (IOException ie) {
138:                            log(Level.SEVERE,
139:                                    "ListSettingsBean.listMonitoringStatus()",
140:                                    ie);
141:                        } catch (InstanceNotFoundException infe) {
142:                            log(Level.SEVERE,
143:                                    "ListSettingsBean.listMonitoringStatus()",
144:                                    infe);
145:                        } catch (MBeanException mbe) {
146:                            log(Level.SEVERE,
147:                                    "ListSettingsBean.listMonitoringStatus()",
148:                                    mbe);
149:                            boolean io = mbe.getCause() instanceof  IOException;
150:                            if (io) {
151:                                instanceDown = true;
152:                            }
153:                        }
154:
155:                        if (!instanceDown) {
156:                            try {
157:                                defaultDomain = (String) mbsc.getAttribute(
158:                                        objectName, "DefaultDomain");
159:                            } catch (MBeanException mbe) {
160:                                log(
161:                                        Level.SEVERE,
162:                                        "ListSettingsBean.listMonitoringStatus()",
163:                                        mbe);
164:                            } catch (AttributeNotFoundException anfe) {
165:                                log(
166:                                        Level.SEVERE,
167:                                        "ListSettingsBean.listMonitoringStatus()",
168:                                        anfe);
169:                            } catch (InstanceNotFoundException infe) {
170:                                log(
171:                                        Level.SEVERE,
172:                                        "ListSettingsBean.listMonitoringStatus()",
173:                                        infe);
174:                            } catch (ReflectionException re) {
175:                                log(
176:                                        Level.SEVERE,
177:                                        "ListSettingsBean.listMonitoringStatus()",
178:                                        re);
179:                            } catch (IOException ie) {
180:                                log(
181:                                        Level.SEVERE,
182:                                        "ListSettingsBean.listMonitoringStatus()",
183:                                        ie);
184:                            }
185:
186:                            try {
187:                                pattern = new ObjectName(defaultDomain
188:                                        + ":type=" + MONITORINGCONFIGURATION);
189:                            } catch (MalformedObjectNameException mone) {
190:                                log(
191:                                        Level.SEVERE,
192:                                        "ListSettingsBean.listMonitoringStatus()",
193:                                        mone);
194:                            }
195:
196:                            try {
197:                                mbeanNames = (Set) mbsc.invoke(objectName,
198:                                        "queryNames", new Object[] { pattern,
199:                                                null }, new String[] {
200:                                                ObjectName.class.getName(),
201:                                                QueryExp.class.getName() });
202:                            } catch (IOException ie) {
203:                                log(
204:                                        Level.SEVERE,
205:                                        "ListSettingsBean.listMonitoringStatus()",
206:                                        ie);
207:                            } catch (InstanceNotFoundException infe) {
208:                                log(
209:                                        Level.SEVERE,
210:                                        "ListSettingsBean.listMonitoringStatus()",
211:                                        infe);
212:                            } catch (ReflectionException re) {
213:                                log(
214:                                        Level.SEVERE,
215:                                        "ListSettingsBean.listMonitoringStatus()",
216:                                        re);
217:                            } catch (MBeanException mbe) {
218:                                log(
219:                                        Level.SEVERE,
220:                                        "ListSettingsBean.listMonitoringStatus()",
221:                                        mbe);
222:                            }
223:
224:                            if (mbeanNames != null && mbeanNames.size() > 0) {
225:                                for (Iterator iterator = mbeanNames.iterator(); iterator
226:                                        .hasNext();) {
227:
228:                                    ObjectName mBeanName = (ObjectName) iterator
229:                                            .next();
230:
231:                                    String param = "Disable";
232:                                    Boolean status = Boolean.TRUE;
233:                                    String monitoringStatus = "Disabled";
234:
235:                                    try {
236:
237:                                        status = (Boolean) mbsc
238:                                                .invoke(
239:                                                        objectName,
240:                                                        "getAttribute",
241:                                                        new Object[] {
242:                                                                mBeanName,
243:                                                                param },
244:                                                        new String[] {
245:                                                                ObjectName.class
246:                                                                        .getName(),
247:                                                                String.class
248:                                                                        .getName() });
249:                                    } catch (InstanceNotFoundException infe) {
250:                                        log(
251:                                                Level.SEVERE,
252:                                                "ListSettingsBean.listMonitoringStatus()",
253:                                                infe);
254:                                    } catch (ReflectionException re) {
255:                                        log(
256:                                                Level.SEVERE,
257:                                                "ListSettingsBean.listMonitoringStatus()",
258:                                                re);
259:                                    } catch (IOException ie) {
260:                                        log(
261:                                                Level.SEVERE,
262:                                                "ListSettingsBean.listMonitoringStatus()",
263:                                                ie);
264:                                    } catch (MBeanException mbe) {
265:                                        log(
266:                                                Level.SEVERE,
267:                                                "ListSettingsBean.listMonitoringStatus()",
268:                                                mbe);
269:                                    }
270:
271:                                    if (status.equals(Boolean.FALSE)) {
272:                                        monitoringStatus = "Enabled";
273:                                    }
274:
275:                                    statisticsList.add(new SettingsBean(
276:                                            instanceId, monitoringStatus,
277:                                            Boolean.FALSE));
278:
279:                                }
280:                            }
281:                        } else {
282:                            statisticsList.add(new SettingsBean(instanceId,
283:                                    "Not Available", Boolean.TRUE));
284:                        }
285:                        settings = new ObjectListDataProvider(statisticsList);
286:                    } finally {
287:                        if (connected.booleanValue()) {
288:                            try {
289:                                mbsc.invoke(objectName, "disconnect", null,
290:                                        null);
291:                            } catch (ReflectionException re) {
292:                                log(
293:                                        Level.SEVERE,
294:                                        "ListSettingsBean.listMonitoringStatus()",
295:                                        re);
296:                            } catch (InstanceNotFoundException infe) {
297:                                log(
298:                                        Level.SEVERE,
299:                                        "ListSettingsBean.listMonitoringStatus()",
300:                                        infe);
301:                            } catch (IOException ie) {
302:                                log(
303:                                        Level.SEVERE,
304:                                        "ListSettingsBean.listMonitoringStatus()",
305:                                        ie);
306:                            } catch (MBeanException me) {
307:                                log(
308:                                        Level.SEVERE,
309:                                        "ListSettingsBean.listMonitoringStatus()",
310:                                        me);
311:                            }
312:                        }
313:
314:                    }
315:
316:                }
317:            }
318:
319:            public void enableDisableMonitoring(Boolean flag,
320:                    ArrayList instanceNames) {
321:
322:                String portalId = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
323:
324:                Boolean connected = Boolean.FALSE;
325:                ObjectName pattern = null;
326:
327:                for (ListIterator counter = instanceNames.listIterator(); counter
328:                        .hasNext();) {
329:                    String instanceId = (String) counter.next();
330:
331:                    //MBean path of Monitoring
332:                    LinkedList path = new LinkedList();
333:                    path.addFirst(getDomain());
334:                    path.addFirst(portalId);
335:                    path.addFirst(instanceId);
336:                    path.addFirst(MONITORING);
337:
338:                    try {
339:                        //Object Name of Monitoring
340:                        objectName = AdminClientUtil
341:                                .getResourceMBeanObjectName(
342:                                        AdminUtil.MONITORING_MBEAN_TYPE, path);
343:                    } catch (MalformedObjectNameException mone) {
344:                        log(Level.SEVERE,
345:                                "ListSettingsBean.enableDisableMonitoring()",
346:                                mone);
347:                    }
348:
349:                    mbsc = getMBeanServerConnection();
350:
351:                    try {
352:
353:                        try {
354:                            mbsc.invoke(objectName, "connect", null, null);
355:                            connected = Boolean.TRUE;
356:                        } catch (ReflectionException re) {
357:                            log(
358:                                    Level.SEVERE,
359:                                    "ListSettingsBean.enableDisableMonitoring()",
360:                                    re);
361:                        } catch (IOException ie) {
362:                            log(
363:                                    Level.SEVERE,
364:                                    "ListSettingsBean.enableDisableMonitoring()",
365:                                    ie);
366:                        } catch (InstanceNotFoundException infe) {
367:                            log(
368:                                    Level.SEVERE,
369:                                    "ListSettingsBean.enableDisableMonitoring()",
370:                                    infe);
371:                        } catch (MBeanException mbe) {
372:                            log(
373:                                    Level.SEVERE,
374:                                    "ListSettingsBean.enableDisableMonitoring()",
375:                                    mbe);
376:
377:                        }
378:
379:                        try {
380:                            defaultDomain = (String) mbsc.getAttribute(
381:                                    objectName, "DefaultDomain");
382:                        } catch (MBeanException mbe) {
383:                            log(
384:                                    Level.SEVERE,
385:                                    "ListSettingsBean.enableDisableMonitoring()",
386:                                    mbe);
387:                        } catch (AttributeNotFoundException anfe) {
388:                            log(
389:                                    Level.SEVERE,
390:                                    "ListSettingsBean.enableDisableMonitoring()",
391:                                    anfe);
392:                        } catch (InstanceNotFoundException infe) {
393:                            log(
394:                                    Level.SEVERE,
395:                                    "ListSettingsBean.enableDisableMonitoring()",
396:                                    infe);
397:                        } catch (ReflectionException re) {
398:                            log(
399:                                    Level.SEVERE,
400:                                    "ListSettingsBean.enableDisableMonitoring()",
401:                                    re);
402:                        } catch (IOException ie) {
403:                            log(
404:                                    Level.SEVERE,
405:                                    "ListSettingsBean.enableDisableMonitoring()",
406:                                    ie);
407:                        }
408:
409:                        try {
410:                            pattern = new ObjectName(defaultDomain + ":type="
411:                                    + MONITORINGCONFIGURATION);
412:                        } catch (MalformedObjectNameException mone) {
413:                            log(
414:                                    Level.SEVERE,
415:                                    "ListSettingsBean.enableDisableMonitoring()",
416:                                    mone);
417:                        }
418:
419:                        try {
420:                            mbeanNames = (Set) mbsc.invoke(objectName,
421:                                    "queryNames",
422:                                    new Object[] { pattern, null },
423:                                    new String[] { ObjectName.class.getName(),
424:                                            QueryExp.class.getName() });
425:                        } catch (IOException ie) {
426:                            log(
427:                                    Level.SEVERE,
428:                                    "ListSettingsBean.enableDisableMonitoring()",
429:                                    ie);
430:                        } catch (InstanceNotFoundException infe) {
431:                            log(
432:                                    Level.SEVERE,
433:                                    "ListSettingsBean.enableDisableMonitoring()",
434:                                    infe);
435:                        } catch (ReflectionException re) {
436:                            log(
437:                                    Level.SEVERE,
438:                                    "ListSettingsBean.enableDisableMonitoring()",
439:                                    re);
440:                        } catch (MBeanException mbe) {
441:                            log(
442:                                    Level.SEVERE,
443:                                    "ListSettingsBean.enableDisableMonitoring()",
444:                                    mbe);
445:                        }
446:
447:                        if (mbeanNames != null && mbeanNames.size() > 0) {
448:                            for (Iterator iterator = mbeanNames.iterator(); iterator
449:                                    .hasNext();) {
450:
451:                                ObjectName mBeanName = (ObjectName) iterator
452:                                        .next();
453:
454:                                Boolean attribute = flag;
455:
456:                                Attribute attr = new Attribute("Disable",
457:                                        attribute);
458:
459:                                try {
460:                                    mbsc
461:                                            .invoke(
462:                                                    objectName,
463:                                                    "setAttribute",
464:                                                    new Object[] { mBeanName,
465:                                                            attr },
466:                                                    new String[] {
467:                                                            ObjectName.class
468:                                                                    .getName(),
469:                                                            Attribute.class
470:                                                                    .getName() });
471:                                } catch (InstanceNotFoundException infe) {
472:                                    log(
473:                                            Level.SEVERE,
474:                                            "ListSettingsBean.enableDisableMonitoring()",
475:                                            infe);
476:                                } catch (ReflectionException re) {
477:                                    log(
478:                                            Level.SEVERE,
479:                                            "ListSettingsBean.enableDisableMonitoring()",
480:                                            re);
481:                                } catch (IOException ie) {
482:                                    log(
483:                                            Level.SEVERE,
484:                                            "ListSettingsBean.enableDisableMonitoring()",
485:                                            ie);
486:                                } catch (MBeanException mbe) {
487:                                    log(
488:                                            Level.SEVERE,
489:                                            "ListSettingsBean.enableDisableMonitoring()",
490:                                            mbe);
491:                                }
492:
493:                            }
494:                        }
495:
496:                    } finally {
497:                        if (connected.booleanValue()) {
498:                            try {
499:                                mbsc.invoke(objectName, "disconnect", null,
500:                                        null);
501:                            } catch (ReflectionException re) {
502:                                log(
503:                                        Level.SEVERE,
504:                                        "ListSettingsBean.enableDisableMonitoring()",
505:                                        re);
506:                            } catch (InstanceNotFoundException infe) {
507:                                log(
508:                                        Level.SEVERE,
509:                                        "ListSettingsBean.enableDisableMonitoring()",
510:                                        infe);
511:                            } catch (IOException ie) {
512:                                log(
513:                                        Level.SEVERE,
514:                                        "ListSettingsBean.enableDisableMonitoring()",
515:                                        ie);
516:                            } catch (MBeanException me) {
517:                                log(
518:                                        Level.SEVERE,
519:                                        "ListSettingsBean.enableDisableMonitoring()",
520:                                        me);
521:                            }
522:                        }
523:
524:                    }
525:                }
526:
527:            }
528:
529:            public String enableMonitoring() {
530:
531:                ArrayList instanceNames = Checkbox.getSelected("cb");
532:                enableDisableMonitoring(Boolean.FALSE, instanceNames);
533:                return "success";
534:
535:            }
536:
537:            public String disableMonitoring() {
538:
539:                ArrayList instanceNames = Checkbox.getSelected("cb");
540:                enableDisableMonitoring(Boolean.TRUE, instanceNames);
541:                return "success";
542:
543:            }
544:
545:            public DataProvider getSettings() {
546:                listMonitoringStatus();
547:                return settings;
548:            }
549:
550:            public void setSettings(DataProvider settings) {
551:                this.settings = settings;
552:            }
553:
554:        }
w_w_w.__j__av___a2s.co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.