WW-5293 Update deprecations

This commit is contained in:
Kusal Kithul-Godage
2023-03-07 14:23:05 +11:00
parent 960682ae8a
commit 6aee0eb20d
3 changed files with 58 additions and 18 deletions
@@ -88,7 +88,7 @@ import static org.apache.commons.lang3.StringUtils.trimToNull;
/**
* Looks in the classpath for an XML file, "xwork.xml" by default,
* Looks in the classpath for an XML file, "struts.xml" by default,
* and uses it for the XWork configuration.
*
* @author tmjee
@@ -117,15 +117,19 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider
private ValueSubstitutor valueSubstitutor;
public XmlConfigurationProvider() {
this("struts.xml", true);
this("struts.xml");
}
public XmlConfigurationProvider(String filename) {
this(filename, true);
this.configFileName = filename;
}
/**
* @deprecated since 6.2.0, use {@link #XmlConfigurationProvider(String)}
*/
@Deprecated
public XmlConfigurationProvider(String filename, @Deprecated boolean notUsed) {
this.configFileName = filename;
this(filename);
}
public void setThrowExceptionOnDuplicateBeans(boolean val) {
@@ -487,7 +491,15 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider
name, packageContext.getName(), actionConfig);
}
/**
* @deprecated since 6.2.0, use {@link #verifyAction(String, Location)}
*/
@Deprecated
protected boolean verifyAction(String className, String name, Location loc) {
return verifyAction(className, loc);
}
protected boolean verifyAction(String className, Location loc) {
if (className.contains("{")) {
LOG.debug("Action class [{}] contains a wildcard replacement value, so it can't be verified", className);
return true;
@@ -810,15 +822,21 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider
return sb.toString();
}
/**
* @deprecated since 6.2.0, use {@link #buildExceptionMappings(Element)}
*/
@Deprecated
protected List<ExceptionMappingConfig> buildExceptionMappings(Element element, PackageConfig.Builder packageContext) {
return buildExceptionMappings(element);
}
/**
* Build a list of exception mapping objects from below a given XML element.
*
* @param element the given XML element
* @param packageContext the package context
*
* @return list of exception mapping config objects
*/
protected List<ExceptionMappingConfig> buildExceptionMappings(Element element, PackageConfig.Builder packageContext) {
protected List<ExceptionMappingConfig> buildExceptionMappings(Element element) {
List<ExceptionMappingConfig> exceptionMappings = new ArrayList<>();
iterateChildrenByTagName(element, "exception-mapping", ehElement -> {
@@ -50,6 +50,13 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
private final String reloadKey;
private final ServletContext servletContext;
/**
* Constructs the Struts configuration provider using the default struts.xml and no ServletContext
*/
public StrutsXmlConfigurationProvider() {
this("struts.xml", null);
}
/**
* Constructs the configuration provider
*
@@ -57,7 +64,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
*/
@Deprecated
public StrutsXmlConfigurationProvider(boolean errorIfMissing) {
this("struts.xml", errorIfMissing, null);
this("struts.xml", null);
}
/**
@@ -66,22 +73,21 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
* @param filename file with Struts configuration
*/
public StrutsXmlConfigurationProvider(String filename) {
this(filename, false, null);
this(filename, null);
}
/**
* Constructs the configuration provider
* Constructs the Struts configuration provider
*
* @param filename The filename to look for
* @param errorIfMissing If we should throw an exception if the file can't be found, @deprecated and should be dropped
* @param ctx Our ServletContext
*/
public StrutsXmlConfigurationProvider(String filename, @Deprecated boolean errorIfMissing, ServletContext ctx) {
super(filename, errorIfMissing);
public StrutsXmlConfigurationProvider(String filename, ServletContext ctx) {
super(filename);
this.servletContext = ctx;
this.filename = filename;
reloadKey = "configurationReload-" + filename;
Map<String,String> dtdMappings = new HashMap<>(getDtdMappings());
Map<String, String> dtdMappings = new HashMap<>(getDtdMappings());
dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.0//EN", "struts-2.0.dtd");
dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.1//EN", "struts-2.1.dtd");
dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN", "struts-2.1.7.dtd");
@@ -95,6 +101,14 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
}
}
/**
* @deprecated since 6.2.0, use {@link #StrutsXmlConfigurationProvider(String, ServletContext)}
*/
@Deprecated
public StrutsXmlConfigurationProvider(String filename, @Deprecated boolean errorIfMissing, ServletContext ctx) {
this(filename, ctx);
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.config.providers.XmlConfigurationProvider#register(com.opensymphony.xwork2.inject.ContainerBuilder, java.util.Properties)
*/
@@ -112,12 +112,12 @@ public class Dispatcher {
/**
* Provide a thread local instance.
*/
private static ThreadLocal<Dispatcher> instance = new ThreadLocal<>();
private static final ThreadLocal<Dispatcher> instance = new ThreadLocal<>();
/**
* Store list of DispatcherListeners.
*/
private static List<DispatcherListener> dispatcherListeners = new CopyOnWriteArrayList<>();
private static final List<DispatcherListener> dispatcherListeners = new CopyOnWriteArrayList<>();
/**
* Store state of StrutsConstants.STRUTS_DEVMODE setting.
@@ -353,7 +353,7 @@ public class Dispatcher {
try {
((ObjectFactoryDestroyable) objectFactory).destroy();
} catch (Exception e) {
// catch any exception that may occurred during destroy() and log it
// catch any exception that may occur during destroy() and log it
LOG.error("Exception occurred while destroying ObjectFactory [{}]", objectFactory.toString(), e);
}
}
@@ -437,8 +437,16 @@ public class Dispatcher {
}
}
protected XmlConfigurationProvider createStrutsXmlConfigurationProvider(String filename, ServletContext ctx) {
return new StrutsXmlConfigurationProvider(filename, ctx);
}
/**
* @deprecated since 6.2.0, use {@link #createStrutsXmlConfigurationProvider(String, ServletContext)}
*/
@Deprecated
protected XmlConfigurationProvider createStrutsXmlConfigurationProvider(String filename, boolean errorIfMissing, ServletContext ctx) {
return new StrutsXmlConfigurationProvider(filename, errorIfMissing, ctx);
return createStrutsXmlConfigurationProvider(filename, ctx);
}
private void init_JavaConfigurations() {