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


001:        /**
002:         * $Id: PSConsoleMBeanServerConnectionWrapper.java
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.util;
014:
015:        import java.io.IOException;
016:        import java.util.Set;
017:        import java.util.logging.Level;
018:
019:        import javax.faces.context.FacesContext;
020:        import javax.faces.context.ExternalContext;
021:        import javax.management.*;
022:
023:        import com.sun.portal.admin.console.common.AuthCredentialBean;
024:        import com.sun.portal.admin.console.common.PSBaseBean;
025:
026:        /**
027:         * A pkg private implementation of javax.management.MBeanServerConnection
028:         * wrapper object that will terminate the current user session when
029:         * certain serious exceptions occur. Normally, this will also force
030:         * the current user to re-authenticate.
031:         */
032:        class PSConsoleMBeanServerConnectionWrapper implements 
033:                MBeanServerConnection {
034:
035:            private final MBeanServerConnection mbsc;
036:
037:            /** Creates a new instance of PSConsoleMBeanServerConnectionWrapper */
038:            public PSConsoleMBeanServerConnectionWrapper(
039:                    MBeanServerConnection mbsc) {
040:                this .mbsc = mbsc;
041:            }
042:
043:            /*
044:             * Does these things:
045:             * 1. close the client end of the JMX connection
046:             * 2. redirect to logout.jsp which internally invalidates
047:             *    the http session object and redirect to login
048:             */
049:            private void terminateSession() {
050:                AuthCredentialBean abean = AuthCredentialBean
051:                        .getCurrentInstance();
052:                if (abean != null) {
053:                    // close the JMX connection and reset the auth credential bean
054:                    try {
055:                        abean.closeConnection();
056:                        abean.resetAuthCredential();
057:                        FacesContext fc = FacesContext.getCurrentInstance();
058:                        if (fc != null) {
059:                            ExternalContext ec = fc.getExternalContext();
060:                            ec.redirect(ec.getRequestContextPath()
061:                                    + "/faces/common/Logout.jsp");
062:                        } else {
063:                            PSBaseBean
064:                                    .log(Level.SEVERE,
065:                                            "No faces instance found when expecting one");
066:                        }
067:                    } catch (IOException ioe) {
068:                        PSBaseBean.log(Level.SEVERE,
069:                                "Fail to terminate current user session.", ioe);
070:                    }
071:                }
072:            }
073:
074:            public void addNotificationListener(ObjectName name,
075:                    NotificationListener listener, NotificationFilter filter,
076:                    Object handback) throws InstanceNotFoundException,
077:                    IOException {
078:
079:                try {
080:                    mbsc.addNotificationListener(name, listener, filter,
081:                            handback);
082:                } catch (SecurityException se) {
083:                    PSBaseBean
084:                            .log(
085:                                    Level.SEVERE,
086:                                    "SecurityException caught in MBeanServerConnection operation.",
087:                                    se);
088:                    terminateSession();
089:                }
090:            }
091:
092:            // See javax.management.MBeanServer
093:            //
094:            public void addNotificationListener(ObjectName name,
095:                    ObjectName listener, NotificationFilter filter,
096:                    Object handback) throws InstanceNotFoundException,
097:                    IOException {
098:                try {
099:                    mbsc.addNotificationListener(name, listener, filter,
100:                            handback);
101:                } catch (SecurityException se) {
102:                    PSBaseBean
103:                            .log(
104:                                    Level.SEVERE,
105:                                    "SecurityException caught in MBeanServerConnection operation.",
106:                                    se);
107:                    terminateSession();
108:                }
109:            }
110:
111:            public ObjectInstance createMBean(String className, ObjectName name)
112:                    throws ReflectionException, InstanceAlreadyExistsException,
113:                    MBeanRegistrationException, MBeanException,
114:                    NotCompliantMBeanException, IOException {
115:                return createMBean(className, name, (Object[]) null,
116:                        (String[]) null);
117:            }
118:
119:            // See javax.management.MBeanServer
120:            //
121:            public ObjectInstance createMBean(String className,
122:                    ObjectName name, ObjectName loaderName)
123:                    throws ReflectionException, InstanceAlreadyExistsException,
124:                    MBeanRegistrationException, MBeanException,
125:                    NotCompliantMBeanException, InstanceNotFoundException,
126:                    IOException {
127:                return createMBean(className, name, loaderName,
128:                        (Object[]) null, (String[]) null);
129:            }
130:
131:            // See javax.management.MBeanServer
132:            //
133:            public ObjectInstance createMBean(String className,
134:                    ObjectName name, Object params[], String signature[])
135:                    throws ReflectionException, InstanceAlreadyExistsException,
136:                    MBeanRegistrationException, MBeanException,
137:                    NotCompliantMBeanException, IOException {
138:                ObjectInstance oi = null;
139:                try {
140:                    oi = mbsc.createMBean(className, name, params, signature);
141:                } catch (SecurityException se) {
142:                    PSBaseBean
143:                            .log(
144:                                    Level.SEVERE,
145:                                    "SecurityException caught in MBeanServerConnection operation.",
146:                                    se);
147:                    terminateSession();
148:                }
149:                return oi;
150:            }
151:
152:            // See javax.management.MBeanServer
153:            //
154:            public ObjectInstance createMBean(String className,
155:                    ObjectName name, ObjectName loaderName, Object params[],
156:                    String signature[]) throws ReflectionException,
157:                    InstanceAlreadyExistsException, MBeanRegistrationException,
158:                    MBeanException, NotCompliantMBeanException,
159:                    InstanceNotFoundException, IOException {
160:                ObjectInstance oi = null;
161:                try {
162:                    oi = mbsc.createMBean(className, name, loaderName, params,
163:                            signature);
164:                } catch (SecurityException se) {
165:                    PSBaseBean
166:                            .log(
167:                                    Level.SEVERE,
168:                                    "SecurityException caught in MBeanServerConnection operation.",
169:                                    se);
170:                    terminateSession();
171:                }
172:                return oi;
173:            }
174:
175:            public Object getAttribute(ObjectName name, String attribute)
176:                    throws MBeanException, AttributeNotFoundException,
177:                    InstanceNotFoundException, ReflectionException, IOException {
178:                Object obj = null;
179:                try {
180:                    obj = mbsc.getAttribute(name, attribute);
181:                } catch (SecurityException se) {
182:                    PSBaseBean
183:                            .log(
184:                                    Level.SEVERE,
185:                                    "SecurityException caught in MBeanServerConnection operation.",
186:                                    se);
187:                    terminateSession();
188:                }
189:                return obj;
190:            }
191:
192:            // See javax.management.MBeanServer
193:            //
194:            public AttributeList getAttributes(ObjectName name,
195:                    String[] attributes) throws InstanceNotFoundException,
196:                    ReflectionException, IOException {
197:                AttributeList al = null;
198:                try {
199:                    al = mbsc.getAttributes(name, attributes);
200:                } catch (SecurityException se) {
201:                    PSBaseBean
202:                            .log(
203:                                    Level.SEVERE,
204:                                    "SecurityException caught in MBeanServerConnection operation.",
205:                                    se);
206:                    terminateSession();
207:                }
208:                return al;
209:            }
210:
211:            public String getDefaultDomain() throws IOException {
212:                String dd = "";
213:                try {
214:                    dd = mbsc.getDefaultDomain();
215:                } catch (SecurityException se) {
216:                    PSBaseBean
217:                            .log(
218:                                    Level.SEVERE,
219:                                    "SecurityException caught in MBeanServerConnection operation.",
220:                                    se);
221:                    terminateSession();
222:                }
223:                return dd;
224:            }
225:
226:            // See javax.management.MBeanServer
227:            //
228:            //
229:            public String[] getDomains() throws IOException {
230:                String[] az = null;
231:                try {
232:                    az = mbsc.getDomains();
233:                } catch (SecurityException se) {
234:                    PSBaseBean
235:                            .log(
236:                                    Level.SEVERE,
237:                                    "SecurityException caught in MBeanServerConnection operation.",
238:                                    se);
239:                    terminateSession();
240:                }
241:                return az;
242:            }
243:
244:            public Integer getMBeanCount() throws IOException {
245:                Integer i = null;
246:                try {
247:                    i = mbsc.getMBeanCount();
248:                } catch (SecurityException se) {
249:                    PSBaseBean
250:                            .log(
251:                                    Level.SEVERE,
252:                                    "SecurityException caught in MBeanServerConnection operation.",
253:                                    se);
254:                    terminateSession();
255:                }
256:                return i;
257:            }
258:
259:            public MBeanInfo getMBeanInfo(ObjectName name)
260:                    throws InstanceNotFoundException, IntrospectionException,
261:                    ReflectionException, IOException {
262:                MBeanInfo info = null;
263:                try {
264:                    info = mbsc.getMBeanInfo(name);
265:                } catch (SecurityException se) {
266:                    PSBaseBean
267:                            .log(
268:                                    Level.SEVERE,
269:                                    "SecurityException caught in MBeanServerConnection operation.",
270:                                    se);
271:                    terminateSession();
272:                }
273:                return info;
274:            }
275:
276:            public ObjectInstance getObjectInstance(ObjectName name)
277:                    throws InstanceNotFoundException, IOException {
278:                ObjectInstance oi = null;
279:                try {
280:                    oi = mbsc.getObjectInstance(name);
281:                } catch (SecurityException se) {
282:                    PSBaseBean
283:                            .log(
284:                                    Level.SEVERE,
285:                                    "SecurityException caught in MBeanServerConnection operation.",
286:                                    se);
287:                    terminateSession();
288:                }
289:                return oi;
290:            }
291:
292:            public Object invoke(ObjectName name, String operationName,
293:                    Object params[], String signature[])
294:                    throws InstanceNotFoundException, MBeanException,
295:                    ReflectionException, IOException {
296:                Object obj = null;
297:                try {
298:                    obj = mbsc.invoke(name, operationName, params, signature);
299:                } catch (SecurityException se) {
300:                    PSBaseBean
301:                            .log(
302:                                    Level.SEVERE,
303:                                    "SecurityException caught in MBeanServerConnection operation.",
304:                                    se);
305:                    terminateSession();
306:                }
307:                return obj;
308:            }
309:
310:            public boolean isInstanceOf(ObjectName name, String className)
311:                    throws InstanceNotFoundException, IOException {
312:                boolean b = false;
313:                try {
314:                    b = mbsc.isInstanceOf(name, className);
315:                } catch (SecurityException se) {
316:                    PSBaseBean
317:                            .log(
318:                                    Level.SEVERE,
319:                                    "SecurityException caught in MBeanServerConnection operation.",
320:                                    se);
321:                    terminateSession();
322:                }
323:                return b;
324:            }
325:
326:            public boolean isRegistered(ObjectName name) throws IOException {
327:                boolean b = false;
328:                try {
329:                    b = mbsc.isRegistered(name);
330:                } catch (SecurityException se) {
331:                    PSBaseBean
332:                            .log(
333:                                    Level.SEVERE,
334:                                    "SecurityException caught in MBeanServerConnection operation.",
335:                                    se);
336:                    terminateSession();
337:                }
338:                return b;
339:            }
340:
341:            public Set queryMBeans(ObjectName name, QueryExp query)
342:                    throws IOException {
343:                Set s = null;
344:                try {
345:                    s = mbsc.queryMBeans(name, query);
346:                } catch (SecurityException se) {
347:                    PSBaseBean
348:                            .log(
349:                                    Level.SEVERE,
350:                                    "SecurityException caught in MBeanServerConnection operation.",
351:                                    se);
352:                    terminateSession();
353:                }
354:                return s;
355:            }
356:
357:            public Set queryNames(ObjectName name, QueryExp query)
358:                    throws IOException {
359:                Set s = null;
360:                try {
361:                    s = mbsc.queryNames(name, query);
362:                } catch (SecurityException se) {
363:                    PSBaseBean
364:                            .log(
365:                                    Level.SEVERE,
366:                                    "SecurityException caught in MBeanServerConnection operation.",
367:                                    se);
368:                    terminateSession();
369:                }
370:                return s;
371:            }
372:
373:            public void removeNotificationListener(ObjectName name,
374:                    NotificationListener listener)
375:                    throws InstanceNotFoundException,
376:                    ListenerNotFoundException, IOException {
377:                try {
378:                    mbsc.removeNotificationListener(name, listener);
379:                } catch (SecurityException se) {
380:                    PSBaseBean
381:                            .log(
382:                                    Level.SEVERE,
383:                                    "SecurityException caught in MBeanServerConnection operation.",
384:                                    se);
385:                    terminateSession();
386:                }
387:            }
388:
389:            // See javax.management.MBeanServer
390:            //
391:            //
392:            public void removeNotificationListener(ObjectName name,
393:                    NotificationListener listener, NotificationFilter filter,
394:                    Object handback) throws InstanceNotFoundException,
395:                    ListenerNotFoundException, IOException {
396:                try {
397:                    mbsc.removeNotificationListener(name, listener, filter,
398:                            handback);
399:                } catch (SecurityException se) {
400:                    PSBaseBean
401:                            .log(
402:                                    Level.SEVERE,
403:                                    "SecurityException caught in MBeanServerConnection operation.",
404:                                    se);
405:                    terminateSession();
406:                }
407:            }
408:
409:            // See javax.management.MBeanServer
410:            //
411:            public void removeNotificationListener(ObjectName name,
412:                    ObjectName listener) throws InstanceNotFoundException,
413:                    ListenerNotFoundException, IOException {
414:                try {
415:                    mbsc.removeNotificationListener(name, listener);
416:                } catch (SecurityException se) {
417:                    PSBaseBean
418:                            .log(
419:                                    Level.SEVERE,
420:                                    "SecurityException caught in MBeanServerConnection operation.",
421:                                    se);
422:                    terminateSession();
423:                }
424:            }
425:
426:            // See javax.management.MBeanServer
427:            //
428:            //
429:            public void removeNotificationListener(ObjectName name,
430:                    ObjectName listener, NotificationFilter filter,
431:                    Object handback) throws InstanceNotFoundException,
432:                    ListenerNotFoundException, IOException {
433:                try {
434:                    mbsc.removeNotificationListener(name, listener, filter,
435:                            handback);
436:                } catch (SecurityException se) {
437:                    PSBaseBean
438:                            .log(
439:                                    Level.SEVERE,
440:                                    "SecurityException caught in MBeanServerConnection operation.",
441:                                    se);
442:                    terminateSession();
443:                }
444:            }
445:
446:            public void setAttribute(ObjectName name, Attribute attribute)
447:                    throws InstanceNotFoundException,
448:                    AttributeNotFoundException, InvalidAttributeValueException,
449:                    MBeanException, ReflectionException, IOException {
450:                try {
451:                    mbsc.setAttribute(name, attribute);
452:                } catch (SecurityException se) {
453:                    PSBaseBean
454:                            .log(
455:                                    Level.SEVERE,
456:                                    "SecurityException caught in MBeanServerConnection operation.",
457:                                    se);
458:                    terminateSession();
459:                }
460:            }
461:
462:            public AttributeList setAttributes(ObjectName name,
463:                    AttributeList attributes) throws InstanceNotFoundException,
464:                    ReflectionException, IOException {
465:                AttributeList al = null;
466:                try {
467:                    al = mbsc.setAttributes(name, attributes);
468:                } catch (SecurityException se) {
469:                    PSBaseBean
470:                            .log(
471:                                    Level.SEVERE,
472:                                    "SecurityException caught in MBeanServerConnection operation.",
473:                                    se);
474:                    terminateSession();
475:                }
476:                return al;
477:            }
478:
479:            public void unregisterMBean(ObjectName name)
480:                    throws InstanceNotFoundException,
481:                    MBeanRegistrationException, IOException {
482:                try {
483:                    mbsc.unregisterMBean(name);
484:                } catch (SecurityException se) {
485:                    PSBaseBean
486:                            .log(
487:                                    Level.SEVERE,
488:                                    "SecurityException caught in MBeanServerConnection operation.",
489:                                    se);
490:                    terminateSession();
491:                }
492:            }
493:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.