Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed Nov 4, 2024
1 parent 191a678 commit f2ec819
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,13 @@ private ServletContextRuntime getServletRuntime(String localPath, String context
//set session timeout
deploymentInfo.setSessionTimeout(webAppInfo.getSessionTimeout());
deploymentInfo.setLoginConfig(webAppInfo.getLoginConfig());
if (StringUtils.isNotBlank(webAppInfo.getVersion())) {
String[] array = webAppInfo.getVersion().split("\\.");
if (array.length == 2) {
deploymentInfo.setEffectiveMajorVersion(Integer.parseInt(array[0]));
deploymentInfo.setEffectiveMinorVersion(Integer.parseInt(array[1]));
}
}
// if (webAppInfo.getLoginConfig() != null && webAppInfo.getLoginConfig().getLoginPage().endsWith(".jsp")) {
// servletRuntime.getServletContext().addJspFile("aaaaaa", webAppInfo.getLoginConfig().getLoginPage());
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private Element commonParse(WebAppInfo webAppInfo, InputStream contextFile) thro
Element parentElement = document.getDocumentElement();

webAppInfo.setMetadataComplete("true".equals(parentElement.getAttribute("metadata-complete")));
webAppInfo.setVersion(parentElement.getAttribute("version"));
parseBasicInfo(webAppInfo, parentElement);

parseServlet(webAppInfo, parentElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* @version V1.0 , 2019/12/11
*/
public class DeploymentInfo {
private int effectiveMajorVersion;
private int effectiveMinorVersion;
private final Map<String, ServletInfo> servlets = new HashMap<>();
private final List<ServletMappingInfo> servletMappings = new ArrayList<>();
private final Map<Integer, ErrorPageInfo> errorStatusPages = new HashMap<>();
Expand Down Expand Up @@ -324,5 +326,20 @@ public Set<String> getSecurityRoles() {
public void setDynamicListenerState(boolean dynamicListenerState) {
this.dynamicListenerState = dynamicListenerState;
}


public int getEffectiveMajorVersion() {
return effectiveMajorVersion;
}

public void setEffectiveMajorVersion(int effectiveMajorVersion) {
this.effectiveMajorVersion = effectiveMajorVersion;
}

public int getEffectiveMinorVersion() {
return effectiveMinorVersion;
}

public void setEffectiveMinorVersion(int effectiveMinorVersion) {
this.effectiveMinorVersion = effectiveMinorVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @version V1.0 , 2019/12/12
*/
public class WebAppInfo {
private String version;
private String displayName;
private String description;
private boolean metadataComplete;
Expand Down Expand Up @@ -190,4 +191,12 @@ public LoginConfig getLoginConfig() {
public void setLoginConfig(LoginConfig loginConfig) {
this.loginConfig = loginConfig;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ public int getMinorVersion() {

@Override
public int getEffectiveMajorVersion() {
return 6;
return deploymentInfo.getEffectiveMajorVersion();
}

@Override
public int getEffectiveMinorVersion() {
checkContextInitializeState();
return 0;
return deploymentInfo.getEffectiveMinorVersion();
}

@Override
Expand Down Expand Up @@ -476,6 +476,7 @@ public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends F

@Override
public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException {
checkContextInitializeState();
return newInstance(clazz);
}

Expand Down

0 comments on commit f2ec819

Please sign in to comment.