/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined(_MSC_VER) #pragma warning ( disable: 4231 4251 4275 4786 ) #endif #include #include #include #include #include #include #include #if !defined(LOG4CXX) #define LOG4CXX 1 #endif #include #include #include #include #include #include #include #if defined(WIN32) || defined(_WIN32) #if !defined(_WIN32_WCE) #include #endif #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace log4cxx; using namespace log4cxx::helpers; using namespace log4cxx::net; using namespace log4cxx::filter; using namespace log4cxx::xml; using namespace log4cxx::rolling; Class::Class() { } Class::~Class() { } LogString Class::toString() const { return getName(); } ObjectPtr Class::newInstance() const { throw InstantiationException(LOG4CXX_STR("Cannot create new instances of Class.")); #if LOG4CXX_RETURN_AFTER_THROW return 0; #endif } Class::ClassMap& Class::getRegistry() { static ClassMap registry; return registry; } const Class& Class::forName(const LogString& className) { LogString lowerName(StringHelper::toLowerCase(className)); // // check registry using full class name // const Class* clazz = getRegistry()[lowerName]; if (clazz == 0) { LogString::size_type pos = className.find_last_of(LOG4CXX_STR(".$")); if (pos != LogString::npos) { LogString terminalName(lowerName, pos + 1, LogString::npos); clazz = getRegistry()[terminalName]; if (clazz == 0) { registerClasses(); clazz = getRegistry()[lowerName]; if (clazz == 0) { clazz = getRegistry()[terminalName]; } } } else { registerClasses(); clazz = getRegistry()[lowerName]; } } if (clazz == 0) { throw ClassNotFoundException(className); } return *clazz; } bool Class::registerClass(const Class& newClass) { getRegistry()[StringHelper::toLowerCase(newClass.getName())] = &newClass; return true; } void Class::registerClasses() { #if APR_HAS_THREADS AsyncAppender::registerClass(); #endif ConsoleAppender::registerClass(); FileAppender::registerClass(); log4cxx::db::ODBCAppender::registerClass(); #if (defined(WIN32) || defined(_WIN32)) #if !defined(_WIN32_WCE) log4cxx::nt::NTEventLogAppender::registerClass(); #endif log4cxx::nt::OutputDebugStringAppender::registerClass(); #endif log4cxx::RollingFileAppender::registerClass(); SMTPAppender::registerClass(); SocketAppender::registerClass(); #if APR_HAS_THREADS SocketHubAppender::registerClass(); #endif SyslogAppender::registerClass(); #if APR_HAS_THREADS TelnetAppender::registerClass(); #endif XMLSocketAppender::registerClass(); DateLayout::registerClass(); HTMLLayout::registerClass(); PatternLayout::registerClass(); SimpleLayout::registerClass(); TTCCLayout::registerClass(); XMLLayout::registerClass(); LevelMatchFilter::registerClass(); LevelRangeFilter::registerClass(); StringMatchFilter::registerClass(); log4cxx::RollingFileAppender::registerClass(); log4cxx::rolling::RollingFileAppender::registerClass(); DailyRollingFileAppender::registerClass(); log4cxx::rolling::SizeBasedTriggeringPolicy::registerClass(); log4cxx::rolling::TimeBasedRollingPolicy::registerClass(); log4cxx::rolling::ManualTriggeringPolicy::registerClass(); log4cxx::rolling::FixedWindowRollingPolicy::registerClass(); log4cxx::rolling::FilterBasedTriggeringPolicy::registerClass(); log4cxx::xml::DOMConfigurator::registerClass(); log4cxx::PropertyConfigurator::registerClass(); }