Polishing
This commit is contained in:
parent
777085bbfc
commit
3c726aa6c1
|
@ -36,7 +36,6 @@ import org.springframework.util.concurrent.SettableListenableFuture;
|
|||
*/
|
||||
public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements AsyncClientHttpRequest {
|
||||
|
||||
|
||||
public MockAsyncClientHttpRequest() {
|
||||
}
|
||||
|
||||
|
@ -44,6 +43,7 @@ public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements
|
|||
super(httpMethod, uri);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ListenableFuture<ClientHttpResponse> executeAsync() throws IOException {
|
||||
SettableListenableFuture<ClientHttpResponse> future = new SettableListenableFuture<ClientHttpResponse>();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.view.groovy;
|
||||
|
||||
import groovy.text.markup.MarkupTemplateEngine;
|
||||
|
@ -23,15 +24,16 @@ import groovy.text.markup.MarkupTemplateEngine;
|
|||
* Detected and used by GroovyMarkupView.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @see GroovyMarkupConfigurer
|
||||
* @since 4.1
|
||||
* @see GroovyMarkupConfigurer
|
||||
*/
|
||||
public interface GroovyMarkupConfig {
|
||||
|
||||
/**
|
||||
* Return the Groovy MarkupTemplateEngine for the current web application context.
|
||||
* May be unique to one servlet, or shared in the root context.
|
||||
* @return the Groovy Template engine
|
||||
* Return the Groovy {@link MarkupTemplateEngine} for the current
|
||||
* web application context. May be unique to one servlet, or shared
|
||||
* in the root context.
|
||||
* @return the Groovy MarkupTemplateEngine engine
|
||||
*/
|
||||
MarkupTemplateEngine getTemplateEngine();
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.view.groovy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -26,7 +27,6 @@ import groovy.text.markup.MarkupTemplateEngine;
|
|||
import groovy.text.markup.TemplateConfiguration;
|
||||
import groovy.text.markup.TemplateResolver;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
@ -55,9 +55,9 @@ import org.springframework.util.StringUtils;
|
|||
*
|
||||
* By default this bean will create a {@link MarkupTemplateEngine} with:
|
||||
* <ul>
|
||||
* <li>a parent ClassLoader for loading Groovy templates with their references
|
||||
* <li>the default configuration in the base class {@link TemplateConfiguration}
|
||||
* <li>a {@link groovy.text.markup.TemplateResolver} for resolving template files
|
||||
* <li>a parent ClassLoader for loading Groovy templates with their references
|
||||
* <li>the default configuration in the base class {@link TemplateConfiguration}
|
||||
* <li>a {@link groovy.text.markup.TemplateResolver} for resolving template files
|
||||
* </ul>
|
||||
*
|
||||
* You can provide the {@link MarkupTemplateEngine} instance directly to this bean
|
||||
|
@ -78,7 +78,6 @@ import org.springframework.util.StringUtils;
|
|||
* @author Brian Clozel
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*
|
||||
* @see GroovyMarkupView
|
||||
* @see <a href="http://beta.groovy-lang.org/docs/groovy-2.3.2/html/documentation/markup-template-engine.html">
|
||||
* Groovy Markup Template engine documentation</a>
|
||||
|
@ -119,15 +118,12 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
|||
this.templateEngine = templateEngine;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public MarkupTemplateEngine getTemplateEngine() {
|
||||
return templateEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
@ -161,8 +157,8 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a parent classloader for Groovy to use as parent classloader when
|
||||
* loading and compiling templates.
|
||||
* Create a parent ClassLoader for Groovy to use as parent ClassLoader
|
||||
* when loading and compiling templates.
|
||||
*/
|
||||
protected ClassLoader createTemplateClassLoader() throws IOException {
|
||||
String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath());
|
||||
|
@ -183,20 +179,11 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
|||
|
||||
/**
|
||||
* Resolve a template from the given template path.
|
||||
*
|
||||
* <p>The default implementation uses the Locale associated with the current
|
||||
* request, as obtained through
|
||||
* {@link org.springframework.context.i18n.LocaleContextHolder LocaleContextHolder},
|
||||
* to find the template file. Effectively the locale configured at the engine
|
||||
* level is ignored.
|
||||
*
|
||||
* <p>The default implementation uses the Locale associated with the current request,
|
||||
* as obtained through {@link org.springframework.context.i18n.LocaleContextHolder LocaleContextHolder},
|
||||
* to find the template file. Effectively the locale configured at the engine level is ignored.
|
||||
* @see LocaleContextHolder
|
||||
* @see #setLocale(java.util.Locale)
|
||||
*
|
||||
* @param classLoader
|
||||
* @param templatePath
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @see #setLocale
|
||||
*/
|
||||
protected URL resolveTemplate(ClassLoader classLoader, String templatePath) throws IOException {
|
||||
MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(templatePath);
|
||||
|
@ -233,4 +220,5 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
|||
return GroovyMarkupConfigurer.this.resolveTemplate(this.classLoader, templatePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.view.groovy;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -43,7 +43,6 @@ import org.springframework.web.util.NestedServletException;
|
|||
* @author Brian Clozel
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*
|
||||
* @see GroovyMarkupViewResolver
|
||||
* @see GroovyMarkupConfigurer
|
||||
* @see <a href="http://beta.groovy-lang.org/docs/groovy-2.3.2/html/documentation/markup-template-engine.html">
|
||||
|
@ -56,20 +55,15 @@ public class GroovyMarkupView extends AbstractTemplateView {
|
|||
|
||||
/**
|
||||
* Set the MarkupTemplateEngine to use in this view.
|
||||
*
|
||||
* <p>If not set, the engine is auto-detected by looking up up a single
|
||||
* {@link GroovyMarkupConfig} bean in the web application context and using
|
||||
* it to obtain the configured {@code MarkupTemplateEngine} instance.
|
||||
*
|
||||
* @see GroovyMarkupConfig
|
||||
*/
|
||||
public void setTemplateEngine(MarkupTemplateEngine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean checkResource(Locale locale) throws Exception {
|
||||
try {
|
||||
|
@ -86,7 +80,6 @@ public class GroovyMarkupView extends AbstractTemplateView {
|
|||
* If no {@link #setTemplateEngine(MarkupTemplateEngine) templateEngine} has
|
||||
* been manually set, this method looks up a {@link GroovyMarkupConfig} bean
|
||||
* by type and uses it to obtain the Groovy Markup template engine.
|
||||
*
|
||||
* @see GroovyMarkupConfig
|
||||
* @see #setTemplateEngine(groovy.text.markup.MarkupTemplateEngine)
|
||||
*/
|
||||
|
@ -99,7 +92,7 @@ public class GroovyMarkupView extends AbstractTemplateView {
|
|||
}
|
||||
|
||||
/**
|
||||
* Auto-detect a MarkupTemplateEngine via the ApplicationContext.
|
||||
* Autodetect a MarkupTemplateEngine via the ApplicationContext.
|
||||
* Called if a MarkupTemplateEngine has not been manually configured.
|
||||
*/
|
||||
protected MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansException {
|
||||
|
@ -108,13 +101,13 @@ public class GroovyMarkupView extends AbstractTemplateView {
|
|||
GroovyMarkupConfig.class, true, false).getTemplateEngine();
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
throw new ApplicationContextException(
|
||||
"Expected a single GroovyMarkupConfig bean in the current Servlet web application context " +
|
||||
"or the parent root context: GroovyMarkupConfigurer is the usual implementation. " +
|
||||
"This bean may have any name.", ex);
|
||||
throw new ApplicationContextException("Expected a single GroovyMarkupConfig bean in the current " +
|
||||
"Servlet web application context or the parent root context: GroovyMarkupConfigurer is " +
|
||||
"the usual implementation. This bean may have any name.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderMergedTemplateModel(Map<String, Object> model,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
@ -132,10 +125,9 @@ public class GroovyMarkupView extends AbstractTemplateView {
|
|||
return this.engine.createTemplateByPath(viewUrl);
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
Throwable cause = ex.getCause() != null ? ex.getCause() : ex;
|
||||
throw new NestedServletException(
|
||||
"Could not find class while rendering Groovy Markup view with name '" +
|
||||
getUrl() + "': " + ex.getMessage() + "'", cause);
|
||||
Throwable cause = (ex.getCause() != null ? ex.getCause() : ex);
|
||||
throw new NestedServletException("Could not find class while rendering Groovy Markup view with name '" +
|
||||
getUrl() + "': " + ex.getMessage() + "'", cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,17 +34,15 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
|||
* View object if a template is actually found.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @see GroovyMarkupConfigurer
|
||||
* @since 4.1
|
||||
* @see GroovyMarkupConfigurer
|
||||
*/
|
||||
public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver {
|
||||
|
||||
|
||||
public GroovyMarkupViewResolver() {
|
||||
this.setViewClass(requiredViewClass());
|
||||
setViewClass(requiredViewClass());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<?> requiredViewClass() {
|
||||
return GroovyMarkupView.class;
|
||||
|
@ -58,4 +56,4 @@ public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver {
|
|||
return viewName + "_" + locale;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
|
||||
package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.beans.factory.config.CustomScopeConfigurer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.messaging.simp.SimpSessionScope;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Bean configuration for a "websocket" scope, bound to {@link SimpSessionScope}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
|
|
Loading…
Reference in New Issue