KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > jmx > ProjectControllerMBeanDescription


1 /********************************************************************************
2  * CruiseControl, a Continuous Integration Toolkit
3  * Copyright (c) 2001, ThoughtWorks, Inc.
4  * 651 W Washington Ave. Suite 600
5  * Chicago, IL 60661 USA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * + Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * + Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  *
20  * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
21  * names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior
23  * written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  ********************************************************************************/

37 package net.sourceforge.cruisecontrol.jmx;
38
39 import java.lang.reflect.Method JavaDoc;
40 import java.util.HashMap JavaDoc;
41 import java.util.Map JavaDoc;
42
43 import mx4j.MBeanDescriptionAdapter;
44
45 /**
46  * @author <a HREF="mailto:joriskuipers@xs4all.nl">Joris Kuipers</a>
47  */

48 public class ProjectControllerMBeanDescription extends MBeanDescriptionAdapter {
49
50     private static final Map JavaDoc METHOD_DESCRIPTIONS;
51     
52     static {
53         METHOD_DESCRIPTIONS = new HashMap JavaDoc();
54
55         METHOD_DESCRIPTIONS.put("pause", "Pauses the project");
56         METHOD_DESCRIPTIONS.put("resume", "Resumes the project when it's paused");
57         METHOD_DESCRIPTIONS.put("build", "Forces a build of the project");
58         METHOD_DESCRIPTIONS.put("buildWithTarget", "Forces a build of the project using the given target");
59         METHOD_DESCRIPTIONS.put("serialize", "Persists the state of the project to disk");
60     }
61     
62     private static final Map JavaDoc ATTR_DESCRIPTIONS;
63     
64     static {
65         ATTR_DESCRIPTIONS = new HashMap JavaDoc();
66         ATTR_DESCRIPTIONS.put("ConfigFileName",
67                               "The name of the config file this project reads its settings from");
68
69         ATTR_DESCRIPTIONS.put("Label", "The current build label");
70
71         ATTR_DESCRIPTIONS.put("LabelIncrementer",
72                               "The classname of the LabelIncrementer used to determine the build label. "
73                             + "Changes to this attribute are not persisted");
74
75         ATTR_DESCRIPTIONS.put("LastBuild",
76                               "Time of the last build, using the format 'yyyyMMddHHmmss'");
77
78         ATTR_DESCRIPTIONS.put("LastSuccessfulBuild",
79                               "Time of the last successful build, using the format 'yyyyMMddHHmmss'");
80
81         ATTR_DESCRIPTIONS.put("LogDir",
82                               "The directory where the log files for this project are written to. "
83                             + "Changes to this attribute are not persisted");
84
85         ATTR_DESCRIPTIONS.put("ProjectName", "The name of this project");
86
87         ATTR_DESCRIPTIONS.put("BuildInterval",
88                               "The build interval in milliseconds. Changes to this attribute are not persisted");
89
90         ATTR_DESCRIPTIONS.put("Status", "The current status of the project");
91
92         ATTR_DESCRIPTIONS.put("Paused", "Indicates if the project is paused");
93
94         ATTR_DESCRIPTIONS.put("BuildStartTime",
95                               "Start Time of the last build, using the format 'yyyyMMddHHmmss'");
96     }
97     
98     public String JavaDoc getOperationDescription(Method JavaDoc method) {
99         String JavaDoc methodName = method.getName();
100         if (METHOD_DESCRIPTIONS.containsKey(methodName)) {
101             return (String JavaDoc) METHOD_DESCRIPTIONS.get(methodName);
102         }
103         return super.getOperationDescription(method);
104     }
105     
106     public String JavaDoc getAttributeDescription(String JavaDoc attr) {
107         if (ATTR_DESCRIPTIONS.containsKey(attr)) {
108             return (String JavaDoc) ATTR_DESCRIPTIONS.get(attr);
109         }
110         return super.getAttributeDescription(attr);
111     }
112
113     public String JavaDoc getMBeanDescription() {
114         return "Controller for a CruiseControl project";
115     }
116 }
117
Popular Tags