This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new 7ae36285 Simplify the config::PropertySetter interface in the next ABI
version (#673)
7ae36285 is described below
commit 7ae36285c792f44933b36f2d768b08ac3e734c7e
Author: Stephen Webb <[email protected]>
AuthorDate: Sat May 16 12:20:14 2026 +1000
Simplify the config::PropertySetter interface in the next ABI version (#673)
---
src/main/cpp/domconfigurator.cpp | 16 +++----
src/main/cpp/propertyconfigurator.cpp | 13 ++----
src/main/cpp/propertysetter.cpp | 58 ++++++++++++++++--------
src/main/include/log4cxx/config/propertysetter.h | 40 ++++++++++------
src/test/cpp/net/telnetappendertestcase.cpp | 7 ++-
5 files changed, 82 insertions(+), 52 deletions(-)
diff --git a/src/main/cpp/domconfigurator.cpp b/src/main/cpp/domconfigurator.cpp
index 0f7352e9..715ef200 100644
--- a/src/main/cpp/domconfigurator.cpp
+++ b/src/main/cpp/domconfigurator.cpp
@@ -410,7 +410,7 @@ AppenderPtr
DOMConfigurator::DOMConfiguratorPrivate::parseAppender(apr_xml_elem*
}
}
- propSetter.activate(p);
+ propSetter.activate();
appenders[appender->getName()].activated = true;
return appender;
}
@@ -503,7 +503,7 @@ void
DOMConfigurator::DOMConfiguratorPrivate::parseErrorHandler(apr_xml_elem* el
}
}
- propSetter.activate(p);
+ propSetter.activate();
if (auto appSkeleton =
LOG4CXX_NS::cast<AppenderSkeleton>(appender))
appSkeleton->setErrorHandler(eh);
}
@@ -546,7 +546,7 @@ FilterStore
DOMConfigurator::DOMConfiguratorPrivate::parseFilters(apr_xml_elem*
}
}
- propSetter.activate(p);
+ propSetter.activate();
result.push_back(filter);
}
return result;
@@ -720,7 +720,7 @@ void
DOMConfigurator::DOMConfiguratorPrivate::parseChildrenOfLoggerElement(apr_x
logger->replaceAppenders(newappenders);
this->appenderAdded = true;
}
- propSetter.activate(p);
+ propSetter.activate();
}
/**
@@ -762,7 +762,7 @@ LayoutPtr
DOMConfigurator::DOMConfiguratorPrivate::parseLayout(apr_xml_elem* lay
}
}
- propSetter.activate(p);
+ propSetter.activate();
return layout;
}
catch (Exception& oops)
@@ -821,7 +821,7 @@ ObjectPtr
DOMConfigurator::DOMConfiguratorPrivate::parseTriggeringPolicy(apr_xml
}
}
- propSetter.activate(p);
+ propSetter.activate();
return instance;
}
catch (Exception& oops)
@@ -869,7 +869,7 @@ RollingPolicyPtr
DOMConfigurator::DOMConfiguratorPrivate::parseRollingPolicy(apr
}
}
- propSetter.activate(p);
+ propSetter.activate();
return LOG4CXX_NS::cast<RollingPolicy>(instance);
}
catch (Exception& oops)
@@ -958,7 +958,7 @@ void
DOMConfigurator::DOMConfiguratorPrivate::setParameter(apr_xml_elem* elem, P
LogString name(subst(getAttribute(elem, NAME_ATTR)));
LogString value(subst(getAttribute(elem, VALUE_ATTR)));
value = subst(value);
- propSetter.setProperty(name, value, p);
+ propSetter.setProperty(name, value);
}
spi::ConfigurationStatus DOMConfigurator::doConfigure
diff --git a/src/main/cpp/propertyconfigurator.cpp
b/src/main/cpp/propertyconfigurator.cpp
index bd244535..9d4c28a4 100644
--- a/src/main/cpp/propertyconfigurator.cpp
+++ b/src/main/cpp/propertyconfigurator.cpp
@@ -286,8 +286,7 @@ void
PropertyConfigurator::configureLoggerFactory(helpers::Properties& props)
);
m_priv->loggerFactory = LOG4CXX_NS::cast<LoggerFactory>(
instance );
- Pool p;
- PropertySetter::setProperties(m_priv->loggerFactory, props,
LOG4CXX_STR("log4j.factory."), p);
+ PropertySetter::setProperties(m_priv->loggerFactory, props,
LOG4CXX_STR("log4j.factory."));
}
}
@@ -509,8 +508,6 @@ AppenderPtr PropertyConfigurator::parseAppender(
if (appender->instanceof(OptionHandler::getStaticClass()))
{
- Pool p;
-
if (appender->requiresLayout())
{
LayoutPtr layout;
@@ -528,7 +525,7 @@ AppenderPtr PropertyConfigurator::parseAppender(
+ LOG4CXX_STR(" options for [")
+ appenderName + LOG4CXX_STR("]"));
}
- PropertySetter::setProperties(layout, props,
layoutPrefix + LOG4CXX_STR("."), p);
+ PropertySetter::setProperties(layout, props,
layoutPrefix + LOG4CXX_STR("."));
if (LogLog::isDebugEnabled())
{
LogLog::debug((LogString)
LOG4CXX_STR("End of parsing for [")
@@ -557,7 +554,7 @@ AppenderPtr PropertyConfigurator::parseAppender(
LogLog::debug((LogString)
LOG4CXX_STR("Parsing ") + RollingPolicy::getStaticClass().getName()
+ LOG4CXX_STR(" options
for [") + appenderName + LOG4CXX_STR("]"));
}
-
PropertySetter::setProperties(rollingPolicy, props, rollingPolicyKey +
LOG4CXX_STR("."), p);
+
PropertySetter::setProperties(rollingPolicy, props, rollingPolicyKey +
LOG4CXX_STR("."));
}
}
@@ -578,12 +575,12 @@ AppenderPtr PropertyConfigurator::parseAppender(
LogLog::debug((LogString)
LOG4CXX_STR("Parsing ") + TriggeringPolicy::getStaticClass().getName()
+ LOG4CXX_STR(" options
for [") + appenderName + LOG4CXX_STR("]"));
}
-
PropertySetter::setProperties(triggeringPolicy, props, triggeringPolicyKey +
LOG4CXX_STR("."), p);
+
PropertySetter::setProperties(triggeringPolicy, props, triggeringPolicyKey +
LOG4CXX_STR("."));
}
}
}
- PropertySetter::setProperties(appender, props, prefix +
LOG4CXX_STR("."), p);
+ PropertySetter::setProperties(appender, props, prefix +
LOG4CXX_STR("."));
if (LogLog::isDebugEnabled())
{
LogLog::debug((LogString) LOG4CXX_STR("Parsed [")
diff --git a/src/main/cpp/propertysetter.cpp b/src/main/cpp/propertysetter.cpp
index e8866669..7147ded4 100644
--- a/src/main/cpp/propertysetter.cpp
+++ b/src/main/cpp/propertysetter.cpp
@@ -15,16 +15,13 @@
* limitations under the License.
*/
-#include <log4cxx/logstring.h>
#include <log4cxx/config/propertysetter.h>
-#include <log4cxx/helpers/object.h>
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/helpers/optionconverter.h>
#include <log4cxx/spi/optionhandler.h>
#include <log4cxx/helpers/properties.h>
#include <log4cxx/appender.h>
-#include <log4cxx/layout.h>
-#include <log4cxx/helpers/pool.h>
+
using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::helpers;
@@ -35,24 +32,19 @@ PropertySetter::PropertySetter(const helpers::ObjectPtr&
obj1) : obj(obj1)
{
}
-void PropertySetter::setProperties(const helpers::ObjectPtr& obj,
- helpers::Properties& properties,
- const LogString& prefix,
- Pool& p)
+void PropertySetter::setProperties(const helpers::ObjectPtr& obj,
helpers::Properties& properties, const LogString& prefix)
{
- PropertySetter(obj).setProperties(properties, prefix, p);
+ PropertySetter(obj).setProperties(properties, prefix);
}
-void PropertySetter::setProperties(helpers::Properties& properties,
- const LogString& prefix,
- Pool& p)
+void PropertySetter::setProperties(helpers::Properties& properties, const
LogString& prefix)
{
size_t len = prefix.length();
for (auto key : properties.propertyNames())
{
- // handle only properties that start with the desired frefix.
+ // handle only properties that start with the desired prefix.
if (key.find(prefix) == 0)
{
// ignore key if it contains dots after the prefix
@@ -71,16 +63,14 @@ void PropertySetter::setProperties(helpers::Properties&
properties,
continue;
}
- setProperty(key, value, p);
+ setProperty(key, value);
}
}
- activate(p);
+ activate();
}
-void PropertySetter::setProperty(const LogString& option,
- const LogString& value,
- Pool&)
+void PropertySetter::setProperty(const LogString& option, const LogString&
value)
{
if (value.empty())
{
@@ -99,7 +89,7 @@ void PropertySetter::setProperty(const LogString& option,
}
}
-void PropertySetter::activate(Pool& p)
+void PropertySetter::activate()
{
if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass()))
{
@@ -107,3 +97,33 @@ void PropertySetter::activate(Pool& p)
handler->activateOptions();
}
}
+
+#if LOG4CXX_ABI_VERSION <= 15
+void PropertySetter::setProperties(const helpers::ObjectPtr& obj,
+ helpers::Properties& properties,
+ const LogString& prefix,
+ Pool&)
+{
+ PropertySetter(obj).setProperties(properties, prefix);
+}
+
+
+void PropertySetter::setProperties(helpers::Properties& properties,
+ const LogString& prefix,
+ Pool&)
+{
+ setProperties(properties, prefix);
+}
+
+void PropertySetter::setProperty(const LogString& option,
+ const LogString& value,
+ Pool&)
+{
+ setProperty(option, value);
+}
+
+void PropertySetter::activate(Pool& p)
+{
+ activate();
+}
+#endif
diff --git a/src/main/include/log4cxx/config/propertysetter.h
b/src/main/include/log4cxx/config/propertysetter.h
index 072a3278..28926a6b 100644
--- a/src/main/include/log4cxx/config/propertysetter.h
+++ b/src/main/include/log4cxx/config/propertysetter.h
@@ -81,20 +81,14 @@ class LOG4CXX_EXPORT PropertySetter
@param obj The object to configure.
@param properties A java.util.Properties containing keys and
values.
@param prefix Only keys having the specified prefix will be set.
- @param p pool to use for any allocations required during call.
*/
- static void setProperties(const helpers::ObjectPtr& obj,
- helpers::Properties& properties,
- const LogString& prefix,
- LOG4CXX_NS::helpers::Pool& p);
+ static void setProperties(const helpers::ObjectPtr& obj,
helpers::Properties& properties, const LogString& prefix);
/**
Set the properites for the object that match the
<code>prefix</code> passed as parameter.
*/
- void setProperties(helpers::Properties& properties,
- const LogString& prefix,
- LOG4CXX_NS::helpers::Pool& p);
+ void setProperties(helpers::Properties& properties, const
LogString& prefix);
/**
Set a property on this PropertySetter's Object. If the
underlying
@@ -103,13 +97,33 @@ class LOG4CXX_EXPORT PropertySetter
@param option name of the property
@param value String value of the property
- @param p pool to use for any allocations required during call.
*/
- void setProperty(const LogString& option,
- const LogString& value,
- LOG4CXX_NS::helpers::Pool& p);
+ void setProperty(const LogString& option, const LogString&
value);
- void activate(LOG4CXX_NS::helpers::Pool& p);
+ void activate();
+
+#if LOG4CXX_ABI_VERSION <= 15
+ /**
+ @deprecated The \c pool parameter is not used and will be
removed in a future version.
+ */
+ [[deprecated("Use setProperties() without a Pool parameter
instead")]]
+ static void setProperties(const helpers::ObjectPtr& obj,
helpers::Properties& properties, const LogString& prefix, helpers::Pool& p);
+ /**
+ @deprecated The \c pool parameter is not used and will be
removed in a future version.
+ */
+ [[deprecated("Use setProperties() without a Pool parameter
instead")]]
+ void setProperties(helpers::Properties& properties, const
LogString& prefix, helpers::Pool& p);
+ /**
+ @deprecated The \c pool parameter is not used and will be
removed in a future version.
+ */
+ [[deprecated("Use setProperty() without a Pool parameter
instead")]]
+ void setProperty(const LogString& option, const LogString&
value, helpers::Pool& p);
+ /**
+ @deprecated The \c pool parameter is not used and will be
removed in a future version.
+ */
+ [[deprecated("Use activate() without a Pool parameter
instead")]]
+ void activate(helpers::Pool& p);
+#endif
}; // class PropertySetter
} // namespace config;
} // namespace log4cxx
diff --git a/src/test/cpp/net/telnetappendertestcase.cpp
b/src/test/cpp/net/telnetappendertestcase.cpp
index f5b513f6..270465df 100644
--- a/src/test/cpp/net/telnetappendertestcase.cpp
+++ b/src/test/cpp/net/telnetappendertestcase.cpp
@@ -140,16 +140,15 @@ class TelnetAppenderTestCase : public
AppenderSkeletonTestCase
void testInvalidMaxConnectionsOptionFallsBack()
{
- Pool p;
auto appender = std::make_shared<TelnetAppender>();
config::PropertySetter setter(appender);
- setter.setProperty(LOG4CXX_STR("MaxConnections"),
LOG4CXX_STR("9999999999999999999999"), p);
+ setter.setProperty(LOG4CXX_STR("MaxConnections"),
LOG4CXX_STR("9999999999999999999999"));
LOGUNIT_ASSERT_EQUAL(20, appender->getMaxConnections());
- setter.setProperty(LOG4CXX_STR("MaxConnections"),
LOG4CXX_STR("-2147483649"), p);
+ setter.setProperty(LOG4CXX_STR("MaxConnections"),
LOG4CXX_STR("-2147483649"));
LOGUNIT_ASSERT_EQUAL(20, appender->getMaxConnections());
- setter.setProperty(LOG4CXX_STR("MaxConnections"),
LOG4CXX_STR("16"), p);
+ setter.setProperty(LOG4CXX_STR("MaxConnections"),
LOG4CXX_STR("16"));
LOGUNIT_ASSERT_EQUAL(16, appender->getMaxConnections());
}