-
Notifications
You must be signed in to change notification settings - Fork 7
/
INSTALL
63 lines (51 loc) · 1.82 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Build Project
=============
mvn clean install
mvn test
mvn source:jar javadoc:javadoc javadoc:jar
How to Use
==========
Install JAR file
----------------
mvn install:install-file "-Dfile=json-service-1.2.3.jar" "-DgroupId=org.stefaniuk.json.service" "-DartifactId=json-service" "-Dversion=1.2.3" "-Dpackaging=jar"
Edit pom.xml
------------
<dependency>
<groupId>org.stefaniuk.json.service</groupId>
<artifactId>json-service</artifactId>
<version>1.2.3</version>
</dependency>
Create ExampleService bean
--------------------------
package org.example.service;
import org.stefaniuk.json.service.JsonService;
public class ExampleService {
@JsonService
public String echo(String text) {
return text;
}
}
Edit Spring configuration file
------------------------------
<bean id="jsonService" class="org.stefaniuk.json.service.JsonServiceRegistry">
<property name="registry">
<list>
<value>org.example.service.ExampleService</value> <!-- This is not necessary as per change made in 2013/01/17. -->
</list>
</property>
</bean>
Edit Spring controller
----------------------
@RequestMapping("service/{service}")
public ResponseEntity<String> service(HttpServletRequest request, HttpServletResponse response,
@PathVariable String service) throws Exception {
ResponseEntity<String> re = null;
if(service.equals("example")) {
re = handleJsonRpc(request, response, ExampleService.class);
}
return re;
}
private ResponseEntity<String> handleJsonRpc(HttpServletRequest request, HttpServletResponse response,
Class<?> clazz) throws IOException {
return JsonServiceUtil.handle(jsonService, request, response, clazz);
}