├── .gitignore ├── README.md ├── pom.xml └── src ├── main ├── java │ └── mariuszs │ │ └── hessian │ │ ├── Application.java │ │ ├── Foo.java │ │ ├── HelloService.java │ │ └── HelloServiceImpl.java └── resources │ └── application.properties └── test └── java └── mariuszs └── hessian ├── ApplicationTest.java └── TestConfig.java /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.iml 3 | .idea 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Spring Boot Sample Application with Hessian Support 3 | 4 | ## Build and run 5 | 6 | mvn clean install spring-boot:run 7 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | mariuszs.hessian 7 | hessian-demo 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | hessian-demo 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 1.1.3.RELEASE 17 | 18 | 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | com.caucho 28 | hessian 29 | 4.0.38 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | org.assertj 39 | assertj-core 40 | 1.6.1 41 | test 42 | 43 | 44 | 45 | 46 | 47 | UTF-8 48 | mariuszs.hessian.Application 49 | 1.8 50 | 51 | 52 | 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-maven-plugin 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/main/java/mariuszs/hessian/Application.java: -------------------------------------------------------------------------------- 1 | package mariuszs.hessian; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.remoting.caucho.HessianServiceExporter; 10 | 11 | @Configuration 12 | @ComponentScan 13 | @EnableAutoConfiguration 14 | public class Application { 15 | 16 | @Autowired 17 | private HelloService helloService; 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(Application.class, args); 21 | } 22 | 23 | @Bean(name = "/HelloService") 24 | public HessianServiceExporter accountService() { 25 | HessianServiceExporter exporter = new HessianServiceExporter(); 26 | exporter.setService(helloService); 27 | exporter.setServiceInterface(HelloService.class); 28 | return exporter; 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/mariuszs/hessian/Foo.java: -------------------------------------------------------------------------------- 1 | package mariuszs.hessian; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Foo implements Serializable{ 6 | 7 | private String name; 8 | 9 | private int x; 10 | 11 | public Foo(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public int getX() { 24 | return x; 25 | } 26 | 27 | public void setX(int x) { 28 | this.x = x; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/mariuszs/hessian/HelloService.java: -------------------------------------------------------------------------------- 1 | package mariuszs.hessian; 2 | 3 | public interface HelloService { 4 | String sayHello(); 5 | 6 | Foo foo(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/mariuszs/hessian/HelloServiceImpl.java: -------------------------------------------------------------------------------- 1 | package mariuszs.hessian; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | @Service("helloService") 6 | public class HelloServiceImpl implements HelloService { 7 | 8 | @Override 9 | public String sayHello(){ 10 | return "Hello World"; 11 | } 12 | 13 | @Override 14 | public Foo foo() { 15 | return new Foo("foo"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariuszs/hessian-boot-example/4d9381517897e592494b82069cb86fef4f8339b8/src/main/resources/application.properties -------------------------------------------------------------------------------- /src/test/java/mariuszs/hessian/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package mariuszs.hessian; 2 | 3 | import static org.assertj.core.api.BDDAssertions.then; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.IntegrationTest; 9 | import org.springframework.boot.test.SpringApplicationConfiguration; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | import org.springframework.test.context.web.WebAppConfiguration; 12 | 13 | @IntegrationTest 14 | @WebAppConfiguration 15 | @RunWith(SpringJUnit4ClassRunner.class) 16 | @SpringApplicationConfiguration(classes = {Application.class, TestConfig.class}) 17 | public class ApplicationTest { 18 | 19 | @Autowired 20 | private HelloService helloClient; 21 | 22 | @Test 23 | public void shouldSayHello() { 24 | 25 | //when 26 | String message = helloClient.sayHello(); 27 | 28 | then(message) 29 | .isNotEmpty() 30 | .isEqualTo("Hello World"); 31 | } 32 | 33 | @Test 34 | public void shouldReceiveFoo() { 35 | 36 | //when 37 | Foo foo = helloClient.foo(); 38 | 39 | then(foo.getName()) 40 | .isEqualTo("foo"); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/mariuszs/hessian/TestConfig.java: -------------------------------------------------------------------------------- 1 | package mariuszs.hessian; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.remoting.caucho.HessianProxyFactoryBean; 6 | 7 | @Configuration 8 | public class TestConfig { 9 | 10 | @Bean 11 | public HessianProxyFactoryBean helloClient() { 12 | HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); 13 | factory.setServiceUrl("http://localhost:8080/HelloService"); 14 | factory.setServiceInterface(HelloService.class); 15 | return factory; 16 | } 17 | } 18 | --------------------------------------------------------------------------------