KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.ArrayList JavaDoc;
27
28
29 /**
30  * Combined representation of diagnostic-service config elements in domain.xml
31  * and command line options provided by the user at the time of report
32  * generation.
33  * @author Manisha Umbarje
34  */

35 public class ReportConfig {
36
37     //CLI options
38
private CLIOptions options;
39     
40     //Represents the target for which report is being generated
41
private ReportTarget target;
42     
43     private ExecutionContext context;
44     
45     // Configurtion of diagnostic-service element
46
private List JavaDoc<ServiceConfig> configurations ;
47     
48     /**
49      * Creates new instance of ReportConfig object
50      */

51     public ReportConfig(CLIOptions cliOptions, ReportTarget target,
52             ExecutionContext context) throws DiagnosticException {
53         options = cliOptions;
54         this.target = target;
55         this.context = context;
56         initialize();
57     }
58     
59     /**
60      * Add diagnostic service configuration corresponding to a instance
61      * @param config diagnostic service config element from domain.xml
62      */

63     public void addInstanceSpecificConfig(ServiceConfig config) {
64         if(config != null) {
65             configurations.add(config);
66         }
67     }
68     
69     public void addInstanceConfigs(List JavaDoc<ServiceConfig> configs) {
70         if(configs != null) {
71             Iterator JavaDoc<ServiceConfig> iterator = configs.iterator();
72             while(iterator.hasNext()) {
73                 addInstanceSpecificConfig(iterator.next());
74             }
75         }
76     }
77
78     public ServiceConfig getInstanceConfigByName(String JavaDoc name){
79         ServiceConfig instanceConfig = null;
80         for(ServiceConfig config : configurations){
81             if(config.getInstanceName().equalsIgnoreCase(name)){
82                 instanceConfig = config;
83                 break;
84             }
85         }
86         return instanceConfig;
87     }
88     
89     /**
90      * returns ReportTarget
91      * @return target
92      */

93     public ReportTarget getTarget() {
94         return target;
95     }
96     
97     /**
98      * @return CLIOptons
99      */

100     public CLIOptions getCLIOptions() {
101         return options;
102     }
103     
104     /**
105      * Returns Execution context
106      */

107     public ExecutionContext getExecutionContext() {
108         return context;
109     }
110     /**
111      * In PE, only one configuration is returned.
112      * In SE/EE the report generation may be invoked for multiple instances
113      * @return list of configurations
114      */

115     public Iterator JavaDoc<ServiceConfig> getInstanceConfigurations() {
116          return configurations.iterator();
117     }
118  
119     public String JavaDoc toString() {
120         return options.toString() + target.toString() +
121                 context.toString() + configurations;
122     }
123     private void initialize() {
124         configurations = new ArrayList JavaDoc();
125     }
126 }
127
Popular Tags