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