01: /*
02: * Copyright 1999,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.catalina.mbeans;
18:
19: import javax.management.InstanceNotFoundException;
20: import javax.management.MBeanException;
21: import javax.management.MBeanServer;
22: import javax.management.RuntimeOperationsException;
23: import org.apache.catalina.Server;
24: import org.apache.catalina.ServerFactory;
25: import org.apache.catalina.core.StandardServer;
26: import org.apache.commons.modeler.BaseModelMBean;
27:
28: /**
29: * <p>A <strong>ModelMBean</strong> implementation for the
30: * <code>org.apache.catalina.core.StandardServer</code> component.</p>
31: *
32: * @author Amy Roh
33: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:45 $
34: */
35:
36: public class StandardServerMBean extends BaseModelMBean {
37:
38: // ------------------------------------------------------- Static Variables
39:
40: /**
41: * The <code>MBeanServer</code> for this application.
42: */
43: private static MBeanServer mserver = MBeanUtils.createServer();
44:
45: // ----------------------------------------------------------- Constructors
46:
47: /**
48: * Construct a <code>ModelMBean</code> with default
49: * <code>ModelMBeanInfo</code> information.
50: *
51: * @exception MBeanException if the initializer of an object
52: * throws an exception
53: * @exception RuntimeOperationsException if an IllegalArgumentException
54: * occurs
55: */
56: public StandardServerMBean() throws MBeanException,
57: RuntimeOperationsException {
58:
59: super ();
60:
61: }
62:
63: // ------------------------------------------------------------- Attributes
64:
65: // ------------------------------------------------------------- Operations
66:
67: /**
68: * Write the configuration information for this entire <code>Server</code>
69: * out to the server.xml configuration file.
70: *
71: * @exception InstanceNotFoundException if the managed resource object
72: * cannot be found
73: * @exception MBeanException if the initializer of the object throws
74: * an exception, or persistence is not supported
75: * @exception RuntimeOperationsException if an exception is reported
76: * by the persistence mechanism
77: */
78: public synchronized void store() throws InstanceNotFoundException,
79: MBeanException, RuntimeOperationsException {
80:
81: Server server = ServerFactory.getServer();
82: if (server instanceof StandardServer) {
83: try {
84: ((StandardServer) server).storeConfig();
85: } catch (Exception e) {
86: throw new MBeanException(e,
87: "Error updating conf/server.xml");
88: }
89: }
90:
91: }
92:
93: }
|