KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > system > metadata > ServiceValueContext


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.system.metadata;
23
24 import javax.management.MBeanAttributeInfo JavaDoc;
25 import javax.management.MBeanServer JavaDoc;
26
27 import org.jboss.kernel.Kernel;
28 import org.jboss.kernel.spi.dependency.KernelController;
29 import org.jboss.system.ServiceController;
30
31 /**
32  * ServiceValueContext.
33  *
34  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
35  * @version $Revision: 1.1 $
36  */

37 public class ServiceValueContext
38 {
39    /** The MBeanServer */
40    private MBeanServer JavaDoc server;
41    
42    /** The service controller */
43    private ServiceController controller;
44    
45    /** The MBeanAttributeInfo */
46    private MBeanAttributeInfo JavaDoc attributeInfo;
47    
48    /** The ClassLoader */
49    private ClassLoader JavaDoc classloader;
50    
51    /** Whether to trim */
52    private boolean trim;
53    
54    /** Whether to replace */
55    private boolean replace;
56
57    /**
58     * Create a new ServiceValueContext.
59     */

60    public ServiceValueContext()
61    {
62    }
63
64    /**
65     * Create a new ServiceValueContext.
66     *
67     * @param server the server
68     * @param controller the service controller
69     * @param classloader the classloader
70     */

71    public ServiceValueContext(MBeanServer JavaDoc server, ServiceController controller, ClassLoader JavaDoc classloader)
72    {
73       this.server = server;
74       this.controller = controller;
75       this.classloader = classloader;
76    }
77
78    /**
79     * Create a new ServiceValueContext.
80     *
81     * @param server the server
82     * @param controller the service controller
83     * @param attributeInfo the attribute info
84     * @param classloader the classloader
85     */

86    public ServiceValueContext(MBeanServer JavaDoc server, ServiceController controller, MBeanAttributeInfo JavaDoc attributeInfo, ClassLoader JavaDoc classloader)
87    {
88       this.server = server;
89       this.controller = controller;
90       this.attributeInfo = attributeInfo;
91       this.classloader = classloader;
92    }
93
94    /**
95     * Get the attributeInfo.
96     *
97     * @return the attributeInfo.
98     */

99    public MBeanAttributeInfo JavaDoc getAttributeInfo()
100    {
101       return attributeInfo;
102    }
103
104    /**
105     * Set the attributeInfo.
106     *
107     * @param attributeInfo the attributeInfo.
108     */

109    public void setAttributeInfo(MBeanAttributeInfo JavaDoc attributeInfo)
110    {
111       this.attributeInfo = attributeInfo;
112    }
113
114    /**
115     * Get the classloader.
116     *
117     * @return the classloader.
118     */

119    public ClassLoader JavaDoc getClassloader()
120    {
121       return classloader;
122    }
123
124    /**
125     * Set the classloader.
126     *
127     * @param classloader the classloader.
128     */

129    public void setClassloader(ClassLoader JavaDoc classloader)
130    {
131       this.classloader = classloader;
132    }
133
134    /**
135     * Get the replace.
136     *
137     * @return the replace.
138     */

139    public boolean isReplace()
140    {
141       return replace;
142    }
143
144    /**
145     * Set the replace.
146     *
147     * @param replace the replace.
148     */

149    public void setReplace(boolean replace)
150    {
151       this.replace = replace;
152    }
153
154    /**
155     * Get the server.
156     *
157     * @return the server.
158     */

159    public MBeanServer JavaDoc getServer()
160    {
161       if (server == null)
162       {
163          if (controller == null)
164             throw new IllegalStateException JavaDoc("No MBeanServer");
165          else
166             return controller.getMBeanServer();
167       }
168       return server;
169    }
170
171    /**
172     * Set the server.
173     *
174     * @param server the server.
175     */

176    public void setServer(MBeanServer JavaDoc server)
177    {
178       this.server = server;
179    }
180
181    /**
182     * Get the service controller.
183     *
184     * @return the controller.
185     */

186    public ServiceController getServiceController()
187    {
188       if (controller == null)
189          throw new IllegalStateException JavaDoc("No ServiceController");
190       return controller;
191    }
192
193    /**
194     * Set the service controller.
195     *
196     * @param controller the controller.
197     */

198    public void setServiceController(ServiceController controller)
199    {
200       this.controller = controller;
201    }
202
203    /**
204     * Get the trim.
205     *
206     * @return the trim.
207     */

208    public boolean isTrim()
209    {
210       return trim;
211    }
212
213    /**
214     * Set the trim.
215     *
216     * @param trim the trim.
217     */

218    public void setTrim(boolean trim)
219    {
220       this.trim = trim;
221    }
222    
223    /**
224     * Get the kernel
225     *
226     * @return the kernel
227     */

228    public Kernel getKernel()
229    {
230       return getServiceController().getKernel();
231    }
232    
233    /**
234     * Get the controller
235     *
236     * @return the controller
237     */

238    public KernelController getController()
239    {
240       return getKernel().getController();
241    }
242 }
243
Popular Tags