View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      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  package org.apache.logging.log4j.core.jmx;
18  
19  import java.io.IOException;
20  import java.net.URI;
21  import java.net.URISyntaxException;
22  import java.util.Map;
23  
24  /**
25   * The MBean interface for monitoring and managing a {@code LoggerContext}.
26   */
27  public interface LoggerContextAdminMBean {
28      /** ObjectName pattern for LoggerContextAdmin MBeans. */
29      String PATTERN = "org.apache.logging.log4j2:type=LoggerContext,ctx=%s";
30  
31      /**
32       * Notification that the {@code Configuration} of the instrumented
33       * {@code LoggerContext} has been reconfigured. Notifications of this type
34       * do not carry a message or user data.
35       */
36      String NOTIF_TYPE_RECONFIGURED = "com.apache.logging.log4j.core.jmx.config.reconfigured";
37  
38      /**
39       * Returns the status of the instrumented {@code LoggerContext}.
40       * 
41       * @return the LoggerContext status.
42       */
43      String getStatus();
44  
45      /**
46       * Returns the name of the instrumented {@code LoggerContext}.
47       * 
48       * @return the name of the instrumented {@code LoggerContext}.
49       */
50      String getName();
51  
52      /**
53       * Returns the configuration location URI as a String.
54       * 
55       * @return the configuration location
56       */
57      String getConfigLocationURI();
58  
59      /**
60       * Sets the configuration location to the specified URI. This will cause the
61       * instrumented {@code LoggerContext} to reconfigure.
62       * 
63       * @param configLocationURI location of the configuration file in
64       *            {@link URI} format.
65       * @throws URISyntaxException if the format of the specified
66       *             configLocationURI is incorrect
67       * @throws IOException if an error occurred reading the specified location
68       */
69      void setConfigLocationURI(String configLocation) throws URISyntaxException,
70              IOException;
71  
72      /**
73       * Returns the configuration text, which may be the contents of the
74       * configuration file or the text that was last set with a call to
75       * {@code setConfigText}.
76       * 
77       * @return the configuration text
78       */
79      String getConfigText() throws IOException;
80  
81      /**
82       * Sets the configuration text. This does not replace the contents of the
83       * configuration file, but <em>does</em> cause the instrumented
84       * {@code LoggerContext} to be reconfigured with the specified text.
85       * 
86       * @param configText the configuration text in XML or JSON format
87       * @param charsetName name of the {@code Charset} used to convert the
88       *            specified configText to bytes
89       * @throws IllegalArgumentException if a problem occurs configuring from the
90       *             specified text
91       */
92      void setConfigText(String configText, String charsetName);
93  
94      /**
95       * Returns the name of the Configuration of the instrumented LoggerContext.
96       * 
97       * @return the Configuration name
98       */
99      String getConfigName();
100 
101     /**
102      * Returns the class name of the {@code Configuration} of the instrumented
103      * LoggerContext.
104      * 
105      * @return the class name of the {@code Configuration}.
106      */
107     String getConfigClassName();
108 
109     /**
110      * Returns a string description of all Filters configured in the
111      * {@code Configuration} of the instrumented LoggerContext.
112      * 
113      * @return a string description of all Filters configured
114      */
115     String getConfigFilter();
116 
117     /**
118      * Returns the class name of the object that is monitoring the configuration
119      * file for modifications.
120      * 
121      * @return the class name of the object that is monitoring the configuration
122      *         file for modifications
123      */
124     String getConfigMonitorClassName();
125 
126     /**
127      * Returns a map with configured properties.
128      * 
129      * @return a map with configured properties.
130      */
131     Map<String, String> getConfigProperties();
132 
133 }