KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > diagnostics > PEDiagnosticAgent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.diagnostics;
24
25
26
27 import com.sun.enterprise.diagnostics.collect.Collector;
28 import com.sun.enterprise.diagnostics.collect.DomainXMLHelper;
29 import com.sun.enterprise.diagnostics.report.html.HTMLReportWriter;
30 import com.sun.logging.LogDomains;
31
32 import java.util.zip.ZipFile JavaDoc;
33 import java.util.List JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.io.File JavaDoc;
36 import java.util.logging.Logger JavaDoc;
37 import java.util.logging.Level JavaDoc;
38 /**
39  * DiagnosticAgent provides the main entry point to Diagnostic Service Back End.
40  *
41  * @author mu125243
42  */

43 public class PEDiagnosticAgent implements DiagnosticAgent {
44     
45     private static Logger JavaDoc logger = LogDomains.getLogger(LogDomains.ADMIN_LOGGER);
46     
47     /** Creates a new instance of DiagnosticAgent */
48     public PEDiagnosticAgent() {
49     }
50     
51     
52
53     /**
54      * Generates Diagnostic Report
55      * @param clioptions cli options specified by the user
56      * @return absolute path of zip containing diagnostic report
57      * @throw DiagnosticException
58      */

59     public String JavaDoc generateReport(Map JavaDoc options) throws DiagnosticException {
60         if(options != null) {
61             BackendObjectFactory objectFactory = getBackendObjectFactory(options);
62             ReportGenerator generator = objectFactory.createReportGenerator();
63             return generator.generate().getName();
64         }
65         throw new DiagnosticException(" Null Input for report generation");
66     }
67     
68     /**
69      * Generates Diagnostic Report
70      * @param clioptions cli options specified by the user
71      * @instances list of instance names for which report generation is invoked
72      * @targetType type of the target for which report is being generated
73      * @return absolute path of zip containing diagnostic report
74      * @throw DiagnosticException
75      */

76     public String JavaDoc generateReport(Map JavaDoc clioptions, List JavaDoc<String JavaDoc> instances,
77             String JavaDoc targetType) throws DiagnosticException {
78         throw new DiagnosticException("Unsupported operation");
79     }
80             
81
82     /**
83      * @param repositoryDir absolute path of central repository
84      * @return list of attributes being masked with ****
85      * @throw DiagnosticException
86      */

87     public List JavaDoc<String JavaDoc> getConfidentialProperties(String JavaDoc repositoryDir)
88     throws DiagnosticException {
89        return new DomainXMLHelper(repositoryDir).getAttrs();
90     }
91     
92     /**
93      * Delete report specified by the fileName
94      * @fileName absolute path of the report to be deleted
95      * @throw DiagnosticException
96      */

97     public void deleteReport(String JavaDoc fileName) throws DiagnosticException {
98         if (fileName != null) {
99             File JavaDoc file = new File JavaDoc(fileName);
100             if(file.exists()) {
101                 file.delete();
102             }
103         }
104     }
105     /**
106      * Returns BavkendObjectFactory
107      */

108     protected BackendObjectFactory getBackendObjectFactory(Map JavaDoc input) {
109         return new PEBackendObjectFactory(input);
110     }
111     
112     private Logger JavaDoc getLogger() {
113         return logger;
114     }
115 }
116
Popular Tags