mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Merge pull request #657 from atlassian/WW-5279-xml-config-provider
WW-5279 Improve readability of XmlConfigurationProvider class
This commit is contained in:
+484
-541
File diff suppressed because it is too large
Load Diff
@@ -201,11 +201,25 @@ public enum Scope {
|
||||
|
||||
<T> Callable<? extends T> toCallable(final InternalContext context,
|
||||
final InternalFactory<? extends T> factory) {
|
||||
return new Callable<T>() {
|
||||
public T call() throws Exception {
|
||||
return InitializableFactory.wrapIfNeeded(factory).create(context);
|
||||
}
|
||||
};
|
||||
return (Callable<T>) () -> InitializableFactory.wrapIfNeeded(factory).create(context);
|
||||
}
|
||||
|
||||
public static Scope fromString(String scopeStr) {
|
||||
switch (scopeStr) {
|
||||
case "prototype":
|
||||
return Scope.PROTOTYPE;
|
||||
case "request":
|
||||
return Scope.REQUEST;
|
||||
case "session":
|
||||
return Scope.SESSION;
|
||||
case "thread":
|
||||
return Scope.THREAD;
|
||||
case "wizard":
|
||||
return Scope.WIZARD;
|
||||
case "singleton":
|
||||
default:
|
||||
return Scope.SINGLETON;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,11 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Override Xwork class so we can use an arbitrary config file
|
||||
@@ -42,9 +46,9 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(StrutsXmlConfigurationProvider.class);
|
||||
private File baseDir = null;
|
||||
private String filename;
|
||||
private String reloadKey;
|
||||
private ServletContext servletContext;
|
||||
private final String filename;
|
||||
private final String reloadKey;
|
||||
private final ServletContext servletContext;
|
||||
|
||||
/**
|
||||
* Constructs the configuration provider
|
||||
@@ -77,7 +81,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
|
||||
this.servletContext = ctx;
|
||||
this.filename = filename;
|
||||
reloadKey = "configurationReload-" + filename;
|
||||
Map<String,String> dtdMappings = new HashMap<String,String>(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");
|
||||
|
||||
Reference in New Issue
Block a user