Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Add controller interface with annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoyanchev committed Feb 11, 2014
1 parent 6c9b02b commit 4070f06
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Expand Up @@ -4,16 +4,17 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
*
* @author Alessandro Polverini
*/
@RestController
@Transactional
public class Controller1 implements ApplicationListener<MyEvent> {
@Controller
public class Controller1 implements Controller1Operations, ApplicationListener<MyEvent> {

private static final Logger logger = LoggerFactory.getLogger(Controller1.class);

Expand All @@ -26,7 +27,6 @@ public void onApplicationEvent(MyEvent e) {
logger.info("Received MyEvent");
}

@RequestMapping("/test")
public Object test(String msg) {
logger.info("Test method called");
return "test: " + msg;
Expand Down
@@ -0,0 +1,18 @@
package org.springframework.issues;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.transaction.Transactional;

@RestController
@Transactional
public interface Controller1Operations {

@RequestMapping("/test")
Object test(@RequestParam("msg") String msg);

}
12 changes: 6 additions & 6 deletions SPR-11281/src/main/webapp/WEB-INF/applicationContext.xml
Expand Up @@ -17,7 +17,12 @@
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
">


<context:annotation-config />
<context:component-scan base-package="org.springframework.issues"/>

<tx:annotation-driven proxy-target-class="false" />

<mvc:annotation-driven />

<mvc:view-controller path="/" view-name="home" />
Expand All @@ -27,9 +32,4 @@
<property name="suffix" value=".jsp" />
</bean>

<context:annotation-config />
<context:component-scan base-package="org.springframework.issues"/>

<tx:annotation-driven proxy-target-class="false" />

</beans>

0 comments on commit 4070f06

Please sign in to comment.