Source Code Cross Referenced for SafeDelegatingCheckRunner.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » tools » checks » 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 » uPortal_rel 2 6 1 GA » org.jasig.portal.tools.checks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2005 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.tools.checks;
007:
008:        import java.util.ArrayList;
009:        import java.util.Iterator;
010:        import java.util.List;
011:
012:        import org.apache.commons.logging.Log;
013:        import org.apache.commons.logging.LogFactory;
014:        import org.jasig.portal.spring.PortalApplicationContextFacade;
015:
016:        /**
017:         * SafeDelegatingCheckRunner safely attempts to delegate to a Spring-configured
018:         * ICheckRunner.  Even if Spring isn't present or that ICheckRunner is misconfigured
019:         * or broken, instances of this class will still implement the ICheckRunner API - that is,
020:         * they will express this failure as a return value from the interface method.
021:         * 
022:         * @version $Revision: 35833 $ $Date: 2005-05-19 18:51:40 -0700 (Thu, 19 May 2005) $
023:         * @since uPortal 2.5
024:         */
025:        public class SafeDelegatingCheckRunner implements  ICheckRunner {
026:
027:            private Log log = LogFactory.getLog(getClass());
028:
029:            /**
030:             * The name of the Spring bean we expect will be an instance of ICheckRunner
031:             * to which we will be delegating.
032:             */
033:            public static final String CHECKS_KEY = "checkRunner";
034:
035:            public List doChecks() {
036:
037:                // check our own dependencies
038:
039:                // List of checks for our own dependencies
040:                List localChecks = new ArrayList();
041:                localChecks.add(new SpringPresenceCheck());
042:                localChecks.add(new SpringBeanCheck(CHECKS_KEY,
043:                        ICheckRunner.class.getName()));
044:
045:                BasicCheckRunner localCheckRunner = new BasicCheckRunner();
046:                localCheckRunner.setChecks(localChecks);
047:
048:                List results = localCheckRunner.doChecks();
049:
050:                if (!containsFailedCheck(results)) {
051:
052:                    try {
053:                        // great, local dependencies look good, let's try to run the
054:                        // Spring configured ICheckRunner.
055:
056:                        ICheckRunner configuredDelegate = (ICheckRunner) PortalApplicationContextFacade
057:                                .getPortalApplicationContext().getBean(
058:                                        SafeDelegatingCheckRunner.CHECKS_KEY,
059:                                        ICheckRunner.class);
060:                        results.addAll(configuredDelegate.doChecks());
061:
062:                    } catch (Throwable t) {
063:                        log.error(
064:                                "Failed to obtain Spring-configured ICheckRunner named ["
065:                                        + CHECKS_KEY + "].", t);
066:                        CheckResult delegateFailedResult = CheckResult
067:                                .createFailure(
068:                                        "The Spring-configured ICheckRunner threw an exception: "
069:                                                + t,
070:                                        "Examine the configuration of the Spring bean named ["
071:                                                + SafeDelegatingCheckRunner.CHECKS_KEY
072:                                                + "]");
073:                        CheckAndResult delegateFailedCheckAndResult = new CheckAndResult(
074:                                "Check that the configured ICheckRunner delegate did not throw any Throwable.",
075:                                delegateFailedResult);
076:                        results.add(delegateFailedCheckAndResult);
077:                    }
078:
079:                }
080:
081:                return results;
082:            }
083:
084:            /**
085:             * Return true if any CheckAndResult in the list of results is not a success.
086:             * @param results a List of CheckAndResult instances.
087:             * @return true if any failures, false otherwise
088:             */
089:            private boolean containsFailedCheck(List results) {
090:                for (Iterator iter = results.iterator(); iter.hasNext();) {
091:                    CheckAndResult checkAndResult = (CheckAndResult) iter
092:                            .next();
093:                    if (!checkAndResult.isSuccess()) {
094:                        return true;
095:                    }
096:                }
097:                return false;
098:            }
099:
100:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.