source: pacpusframework/branches/2.0-beta1/3rd/apache-log4cxx/include/log4cxx/xml/domconfigurator.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 13.6 KB
Line 
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
18#ifndef _LOG4CXX_XML_DOM_CONFIGURATOR_H
19#define _LOG4CXX_XML_DOM_CONFIGURATOR_H
20
21#if defined(_MSC_VER)
22#pragma warning (push)
23#pragma warning ( disable: 4231 4251 4275 4786 )
24#endif
25
26
27
28#include <log4cxx/logstring.h>
29#include <map>
30#include <log4cxx/appender.h>
31#include <log4cxx/layout.h>
32#include <log4cxx/logger.h>
33#include <log4cxx/helpers/properties.h>
34#include <log4cxx/spi/configurator.h>
35#include <log4cxx/helpers/charsetdecoder.h>
36#include <log4cxx/spi/filter.h>
37#include <log4cxx/rolling/triggeringpolicy.h>
38#include <log4cxx/rolling/rollingpolicy.h>
39#include <log4cxx/file.h>
40#include <log4cxx/config/propertysetter.h>
41
42extern "C" {
43 struct apr_xml_doc;
44 struct apr_xml_elem;
45}
46
47namespace log4cxx
48{
49
50 namespace xml
51 {
52
53 /**
54 Use this class to initialize the log4cxx environment using a DOM tree.
55
56 <p>Sometimes it is useful to see how log4cxx is reading configuration
57 files. You can enable log4cxx internal logging by setting the
58 <code>debug</code> attribute in the
59 <code>log4cxx</code> element. As in
60 <pre>
61 &lt;log4j:configuration <b>debug="true"</b> xmlns:log4j="http://jakarta.apache.org/log4j/">
62 ...
63 &lt;/log4j:configuration>
64 </pre>
65
66 <p>There are sample XML files included in the package.
67 */
68 class LOG4CXX_EXPORT DOMConfigurator :
69 virtual public spi::Configurator,
70 virtual public helpers::ObjectImpl
71 {
72 protected:
73 typedef std::map<LogString, AppenderPtr> AppenderMap;
74 /**
75 Used internally to parse appenders by IDREF name.
76 */
77 AppenderPtr findAppenderByName(
78 log4cxx::helpers::Pool& p,
79 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
80 apr_xml_elem* elem,
81 apr_xml_doc* doc,
82 const LogString& appenderName,
83 AppenderMap& appenders);
84
85 /**
86 Used internally to parse appenders by IDREF element.
87 */
88 AppenderPtr findAppenderByReference(
89 log4cxx::helpers::Pool& p,
90 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
91 apr_xml_elem* appenderRef,
92 apr_xml_doc* doc,
93 AppenderMap& appenders);
94
95 /**
96 Used internally to parse an appender element.
97 */
98 AppenderPtr parseAppender(
99 log4cxx::helpers::Pool& p,
100 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
101 apr_xml_elem* appenderElement,
102 apr_xml_doc* doc,
103 AppenderMap& appenders);
104
105 /**
106 Used internally to parse an {@link spi::ErrorHandler ErrorHandler } element.
107 */
108 void parseErrorHandler(
109 log4cxx::helpers::Pool& p,
110 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
111 apr_xml_elem* element,
112 AppenderPtr& appender,
113 apr_xml_doc* doc,
114 AppenderMap& appenders);
115
116 /**
117 Used internally to parse a filter element.
118 */
119 void parseFilters(
120 log4cxx::helpers::Pool& p,
121 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
122 apr_xml_elem* element,
123 std::vector<log4cxx::spi::FilterPtr>& filters);
124
125 /**
126 Used internally to parse a logger element.
127 */
128 void parseLogger(
129 log4cxx::helpers::Pool& p,
130 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
131 apr_xml_elem* loggerElement,
132 apr_xml_doc* doc,
133 AppenderMap& appenders);
134
135 /**
136 Used internally to parse the logger factory element.
137 */
138 void parseLoggerFactory(
139 log4cxx::helpers::Pool& p,
140 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
141 apr_xml_elem* factoryElement);
142
143 /**
144 Used internally to parse the logger factory element.
145 */
146 log4cxx::helpers::ObjectPtr parseTriggeringPolicy(
147 log4cxx::helpers::Pool& p,
148 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
149 apr_xml_elem* factoryElement);
150
151 /**
152 Used internally to parse the logger factory element.
153 */
154 log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
155 log4cxx::helpers::Pool& p,
156 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
157 apr_xml_elem* factoryElement);
158
159 /**
160 Used internally to parse the root logger element.
161 */
162 void parseRoot(log4cxx::helpers::Pool& p,
163 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
164 apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
165
166 /**
167 Used internally to parse the children of a logger element.
168 */
169 void parseChildrenOfLoggerElement(
170 log4cxx::helpers::Pool& p,
171 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
172 apr_xml_elem* catElement,
173 LoggerPtr logger, bool isRoot,
174 apr_xml_doc* doc,
175 AppenderMap& appenders);
176
177 /**
178 Used internally to parse a layout element.
179 */
180 LayoutPtr parseLayout(
181 log4cxx::helpers::Pool& p,
182 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
183 apr_xml_elem* layout_element);
184
185 /**
186 Used internally to parse a level element.
187 */
188 void parseLevel(
189 log4cxx::helpers::Pool& p,
190 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
191 apr_xml_elem* element,
192 LoggerPtr logger, bool isRoot);
193
194 void setParameter(
195 log4cxx::helpers::Pool& p,
196 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
197 apr_xml_elem* elem,
198 log4cxx::config::PropertySetter& propSetter);
199
200 /**
201 Used internally to configure the log4cxx framework from
202 an in-memory representation of an XML document.
203 */
204 void parse(
205 log4cxx::helpers::Pool& p,
206 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
207 apr_xml_elem* element,
208 apr_xml_doc* doc,
209 AppenderMap& appenders);
210
211 public:
212 DOMConfigurator();
213
214 DECLARE_LOG4CXX_OBJECT(DOMConfigurator)
215 BEGIN_LOG4CXX_CAST_MAP()
216 LOG4CXX_CAST_ENTRY(spi::Configurator)
217 END_LOG4CXX_CAST_MAP()
218
219 DOMConfigurator(log4cxx::helpers::Pool& p);
220
221 void addRef() const;
222 void releaseRef() const;
223
224 /**
225 A static version of #doConfigure.
226 */
227 static void configure(const std::string& filename);
228#if LOG4CXX_WCHAR_T_API
229 static void configure(const std::wstring& filename);
230#endif
231#if LOG4CXX_UNICHAR_API
232 static void configure(const std::basic_string<UniChar>& filename);
233#endif
234#if LOG4CXX_CFSTRING_API
235 static void configure(const CFStringRef& filename);
236#endif
237 /**
238 Like #configureAndWatch(const std::string& configFilename, long delay)
239 except that the default delay as defined by
240 log4cxx::helpers::FileWatchdog#DEFAULT_DELAY is used.
241 @param configFilename A log4j configuration file in XML format.
242 */
243 static void configureAndWatch(const std::string& configFilename);
244#if LOG4CXX_WCHAR_T_API
245 static void configureAndWatch(const std::wstring& configFilename);
246#endif
247#if LOG4CXX_UNICHAR_API
248 static void configureAndWatch(const std::basic_string<UniChar>& configFilename);
249#endif
250#if LOG4CXX_CFSTRING_API
251 static void configureAndWatch(const CFStringRef& configFilename);
252#endif
253 /**
254 Read the configuration file <code>configFilename</code> if it
255 exists. Moreover, a thread will be created that will periodically
256 check if <code>configFilename</code> has been created or
257 modified. The period is determined by the <code>delay</code>
258 argument. If a change or file creation is detected, then
259 <code>configFilename</code> is read to configure log4cxx.
260
261 @param configFilename A log4j configuration file in XML format.
262 @param delay The delay in milliseconds to wait between each check.
263 */
264 static void configureAndWatch(const std::string& configFilename,
265 long delay);
266#if LOG4CXX_WCHAR_T_API
267 static void configureAndWatch(const std::wstring& configFilename,
268 long delay);
269#endif
270#if LOG4CXX_UNICHAR_API
271 static void configureAndWatch(const std::basic_string<UniChar>& configFilename,
272 long delay);
273#endif
274#if LOG4CXX_CFSTRING_API
275 static void configureAndWatch(const CFStringRef& configFilename,
276 long delay);
277#endif
278
279 /**
280 Interpret the XML file pointed by <code>filename</code> and set up
281 log4cxx accordingly.
282 <p>The configuration is done relative to the hierarchy parameter.
283 @param filename The file to parse.
284 @param repository The hierarchy to operation upon.
285 */
286 void doConfigure(const File& filename,
287 spi::LoggerRepositoryPtr& repository);
288
289 protected:
290 static LogString getAttribute(
291 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
292 apr_xml_elem*,
293 const std::string& attrName);
294
295 LogString subst(const LogString& value);
296
297 protected:
298 helpers::Properties props;
299 spi::LoggerRepositoryPtr repository;
300 spi::LoggerFactoryPtr loggerFactory;
301
302 private:
303 // prevent assignment or copy statements
304 DOMConfigurator(const DOMConfigurator&);
305 DOMConfigurator& operator=(const DOMConfigurator&);
306
307 };
308 LOG4CXX_PTR_DEF(DOMConfigurator);
309 } // namespace xml
310} // namespace log4cxx
311
312#if defined(_MSC_VER)
313#pragma warning (pop)
314#endif
315
316#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
Note: See TracBrowser for help on using the repository browser.