mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
WW-5289 Fixes creating executor to avoid locking JVM on shutdown
This commit is contained in:
@@ -25,7 +25,10 @@
|
||||
|
||||
<struts>
|
||||
|
||||
<bean type="org.apache.struts2.interceptor.exec.ExecutorProvider" class="org.apache.struts2.showcase.wait.ThreadPoolExecutorProvider"/>
|
||||
<bean type="org.apache.struts2.interceptor.exec.ExecutorProvider" name="threadPool"
|
||||
class="org.apache.struts2.showcase.wait.ThreadPoolExecutorProvider"/>
|
||||
|
||||
<constant name="struts.executor.provider" value="threadPool"/>
|
||||
|
||||
<package name="wait" extends="struts-default" namespace="/wait">
|
||||
<default-action-ref name="index"/>
|
||||
|
||||
+4
@@ -118,6 +118,8 @@ import org.apache.struts2.conversion.StrutsTypeConverterCreator;
|
||||
import org.apache.struts2.conversion.StrutsTypeConverterHolder;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.dispatcher.Parameter;
|
||||
import org.apache.struts2.interceptor.exec.ExecutorProvider;
|
||||
import org.apache.struts2.interceptor.exec.StrutsExecutorProvider;
|
||||
import org.apache.struts2.url.QueryStringBuilder;
|
||||
import org.apache.struts2.url.QueryStringParser;
|
||||
import org.apache.struts2.url.StrutsQueryStringBuilder;
|
||||
@@ -242,6 +244,8 @@ public class StrutsDefaultConfigurationProvider implements ConfigurationProvider
|
||||
.factory(QueryStringParser.class, StrutsQueryStringParser.class, Scope.SINGLETON)
|
||||
.factory(UrlEncoder.class, StrutsUrlEncoder.class, Scope.SINGLETON)
|
||||
.factory(UrlDecoder.class, StrutsUrlDecoder.class, Scope.SINGLETON)
|
||||
|
||||
.factory(ExecutorProvider.class, StrutsExecutorProvider.class, Scope.SINGLETON)
|
||||
;
|
||||
|
||||
props.setProperty(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, Boolean.FALSE.toString());
|
||||
|
||||
@@ -463,4 +463,7 @@ public final class StrutsConstants {
|
||||
|
||||
/** A global flag to set property {@link org.apache.struts2.components.Checkbox#setSubmitUnchecked(String)} */
|
||||
public static final String STRUTS_UI_CHECKBOX_SUBMIT_UNCHECKED = "struts.ui.checkbox.submitUnchecked";
|
||||
|
||||
/** See {@link org.apache.struts2.interceptor.exec.ExecutorProvider} */
|
||||
public static final String STRUTS_EXECUTOR_PROVIDER = "struts.executor.provider";
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.apache.struts2.dispatcher.DispatcherErrorHandler;
|
||||
import org.apache.struts2.dispatcher.StaticContentLoader;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
|
||||
import org.apache.struts2.interceptor.exec.ExecutorProvider;
|
||||
import org.apache.struts2.url.QueryStringBuilder;
|
||||
import org.apache.struts2.url.QueryStringParser;
|
||||
import org.apache.struts2.url.UrlDecoder;
|
||||
@@ -438,6 +439,8 @@ public class StrutsBeanSelectionProvider extends AbstractBeanSelectionProvider {
|
||||
alias(UrlEncoder.class, StrutsConstants.STRUTS_URL_ENCODER, builder, props, Scope.SINGLETON);
|
||||
alias(UrlDecoder.class, StrutsConstants.STRUTS_URL_DECODER, builder, props, Scope.SINGLETON);
|
||||
|
||||
alias(ExecutorProvider.class, StrutsConstants.STRUTS_EXECUTOR_PROVIDER, builder, props, Scope.SINGLETON);
|
||||
|
||||
switchDevMode(props);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Inject(required = false)
|
||||
@Inject
|
||||
public void setExecutorProvider(ExecutorProvider executorProvider) {
|
||||
this.executor = executorProvider;
|
||||
}
|
||||
@@ -387,7 +387,8 @@ public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor {
|
||||
public void init() {
|
||||
super.init();
|
||||
if (executor == null) {
|
||||
executor = new StrutsExecutorProvider();
|
||||
LOG.debug("Using: {} as ExecutorProvider", StrutsExecutorProvider.class.getSimpleName());
|
||||
executor = container.getInstance(StrutsExecutorProvider.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class StrutsExecutorProvider implements ExecutorProvider {
|
||||
private final ExecutorService executor;
|
||||
|
||||
public StrutsExecutorProvider() {
|
||||
this.executor = Executors.newSingleThreadExecutor();
|
||||
this.executor = Executors.newFixedThreadPool(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -245,4 +245,7 @@
|
||||
<bean type="org.apache.struts2.url.UrlDecoder" name="strutsUrlDecoder"
|
||||
class="org.apache.struts2.url.StrutsUrlDecoder" scope="singleton"/>
|
||||
|
||||
<bean type="org.apache.struts2.interceptor.exec.ExecutorProvider" name="struts"
|
||||
class="org.apache.struts2.interceptor.exec.StrutsExecutorProvider"/>
|
||||
|
||||
</struts>
|
||||
|
||||
Reference in New Issue
Block a user