Permalink
Browse files

SPR-8543

  • Loading branch information...
1 parent d9c0c30 commit 52af52b67b6a2c38d76cecdb9b72b73e6cfb1f41 @rstoyanchev rstoyanchev committed Jul 25, 2011
View
@@ -0,0 +1,48 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.springframework.issues</groupId>
+ <artifactId>SPR-8543</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArguments>
+ <encoding>UTF-8</encoding>
+ </compilerArguments>
+ <debug>true</debug>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>3.0.5.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+</project>
@@ -0,0 +1,37 @@
+package net.decalog.eppk.web;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+@RequestMapping("/rule_sets")
+public class Spr8543Controller {
+
+ @RequestMapping(value="/{type}", method=RequestMethod.GET)
+ public Map<String, String> hello(@PathVariable("type") String type) {
+ if (type.endsWith(".json")) {
+ throw new RuntimeException("WEBMVC strange behavior");
+ }
+ return success("Hello " + type);
+ }
+
+ @RequestMapping(value="/{id}", method=RequestMethod.DELETE)
+ public Map<String, String> bye(@PathVariable("id") String id) {
+ if (id.endsWith(".json")) {
+ throw new RuntimeException("WEBMVC strange behavior");
+ }
+ return success("Bye " + id);
+ }
+
+ private Map<String, String> success(Object res) {
+ HashMap<String, String> res_ = new HashMap<String, String>();
+ res_.put("res", res.toString());
+ return res_;
+ }
+
+}
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+
+</beans>
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:security="http://www.springframework.org/schema/security"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/security
+ http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+
+<!--
+ <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
+ -->
+ <!-- registers all beans with @Component annotation, especially @Controller -->
+ <context:component-scan base-package="net.decalog.eppk" />
+
+ <!-- share the same mapper between multiple views / message converters -->
+ <bean id="jsonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper">
+ </bean>
+
+ <!-- message converter to use when the input is JSON -->
+ <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
+ <property name="objectMapper" ref="jsonObjectMapper"/>
+ </bean>
+
+ <bean id="mappingJacksonJsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
+ <property name="objectMapper" ref="jsonObjectMapper"/>
+ </bean>
+
+ <!-- bean that is called to parse the body of an incoming POST or PUT request
+ the body must be "json-encoded" -->
+ <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
+ <property name="messageConverters">
+ <list>
+ <ref bean="mappingJacksonHttpMessageConverter"/>
+ </list>
+ </property>
+ </bean>
+
+ <!-- bean that is called to choose the view to render the result of the request : JSON -->
+ <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
+ <property name="mediaTypes">
+ <map>
+ <entry key="json" value="application/json" />
+ </map>
+ </property>
+ <property name="defaultViews">
+ <list>
+ <ref bean="mappingJacksonJsonView" />
+ </list>
+ </property>
+ <property name="defaultContentType" value="application/json" />
+ <property name="ignoreAcceptHeader" value="true" />
+ </bean>
+</beans>
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <import resource="classpath:/eppk-controllers.xml" />
+</beans>
@@ -0,0 +1,32 @@
+<!DOCTYPE web-app PUBLIC
+"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+"http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+ <display-name>e-Paprika</display-name>
+
+ <!-- where to find the spring config for business logic -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>classpath:/appContext-eppk.xml</param-value>
+ </context-param>
+
+ <!-- the "global to all servlets" (even if we have only one servlet) application configuration
+ see the context-param above for the XML file used -->
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <!-- the only servlet of the application is a DispatcherServlet configured in eppk-servlet.xml
+ and called for /rest/* -->
+ <servlet>
+ <servlet-name>eppk</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>eppk</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+</web-app>

0 comments on commit 52af52b

Please sign in to comment.