Skip to content

Commit 199dd76

Browse files
committed
initial setup
0 parents  commit 199dd76

File tree

84 files changed

+9359
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+9359
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
*.iml

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2013 Brian Dilley
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a
4+
copy of this software and associated documentation files (the "Software"),
5+
to deal in the Software without restriction, including without limitation the
6+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
sell copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is a fork of jsonrpc4j originally developed by Brian C. Dilley under the MIT License.
2+
3+
jsonrpc4j project homepage: http://jsonrpc4j.googlecode.com/

pom.xml

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.github.esz</groupId>
5+
<artifactId>jsonrpc</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
8+
<properties>
9+
<!-- project properties -->
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
12+
<jdk.version>1.6</jdk.version>
13+
<!-- deps versions -->
14+
<spring.version>3.1.2.RELEASE</spring.version>
15+
<jackson.version>2.0.2</jackson.version>
16+
<servlet.version>3.1-b06</servlet.version>
17+
<portlet.version>2.0</portlet.version>
18+
<commons.codec.version>1.4</commons.codec.version>
19+
<httpcomponents.version>4.2.1</httpcomponents.version>
20+
<junit.version>4.10</junit.version>
21+
<jmock.version>2.5.1</jmock.version>
22+
<jetty.version>9.0.0.RC0</jetty.version>
23+
<!-- plugin versions -->
24+
<mvn.buildnumberplugin.version>1.1</mvn.buildnumberplugin.version>
25+
<mvn.compilerplugin.version>3.1</mvn.compilerplugin.version>
26+
<mvn.sourceplugin.version>2.2.1</mvn.sourceplugin.version>
27+
<mvn.jarplugin.version>2.4</mvn.jarplugin.version>
28+
</properties>
29+
30+
<developers>
31+
<developer>
32+
<email>[email protected]</email>
33+
<id>brian.dilley</id>
34+
<name>Brian Dilley</name>
35+
</developer>
36+
<developer>
37+
<email>[email protected]</email>
38+
<id>eduard.szente</id>
39+
<name>Eduard Szente</name>
40+
</developer>
41+
</developers>
42+
43+
<build>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-compiler-plugin</artifactId>
48+
<version>${mvn.compilerplugin.version}</version>
49+
<configuration>
50+
<source>${jdk.version}</source>
51+
<target>${jdk.version}</target>
52+
</configuration>
53+
</plugin>
54+
<plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-source-plugin</artifactId>
57+
<version>${mvn.sourceplugin.version}</version>
58+
<executions>
59+
<execution>
60+
<goals>
61+
<goal>jar</goal>
62+
</goals>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
<plugin>
67+
<groupId>org.codehaus.mojo</groupId>
68+
<artifactId>buildnumber-maven-plugin</artifactId>
69+
<version>${mvn.buildnumberplugin.version}</version>
70+
<executions>
71+
<execution>
72+
<phase>validate</phase>
73+
<goals>
74+
<goal>create</goal>
75+
</goals>
76+
</execution>
77+
</executions>
78+
</plugin>
79+
<plugin>
80+
<groupId>org.apache.maven.plugins</groupId>
81+
<artifactId>maven-jar-plugin</artifactId>
82+
<version>${mvn.jarplugin.version}</version>
83+
<configuration>
84+
<archive>
85+
<index>true</index>
86+
<manifestEntries>
87+
<git-revision>${buildNumber}</git-revision>
88+
</manifestEntries>
89+
</archive>
90+
</configuration>
91+
</plugin>
92+
</plugins>
93+
</build>
94+
95+
<dependencies>
96+
<!-- json -->
97+
<dependency>
98+
<groupId>com.fasterxml.jackson.core</groupId>
99+
<artifactId>jackson-core</artifactId>
100+
<version>${jackson.version}</version>
101+
</dependency>
102+
<dependency>
103+
<groupId>com.fasterxml.jackson.core</groupId>
104+
<artifactId>jackson-databind</artifactId>
105+
<version>${jackson.version}</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>com.fasterxml.jackson.core</groupId>
109+
<artifactId>jackson-annotations</artifactId>
110+
<version>${jackson.version}</version>
111+
<optional>true</optional>
112+
</dependency>
113+
114+
<!-- servlet -->
115+
<dependency>
116+
<groupId>javax.servlet</groupId>
117+
<artifactId>javax.servlet-api</artifactId>
118+
<version>${servlet.version}</version>
119+
<scope>provided</scope>
120+
</dependency>
121+
<dependency>
122+
<groupId>javax.portlet</groupId>
123+
<artifactId>portlet-api</artifactId>
124+
<version>${portlet.version}</version>
125+
<optional>true</optional>
126+
<scope>provided</scope>
127+
</dependency>
128+
129+
<!-- spring -->
130+
<dependency>
131+
<groupId>org.springframework</groupId>
132+
<artifactId>spring-core</artifactId>
133+
<version>${spring.version}</version>
134+
<optional>true</optional>
135+
</dependency>
136+
<dependency>
137+
<groupId>org.springframework</groupId>
138+
<artifactId>spring-context</artifactId>
139+
<version>${spring.version}</version>
140+
<optional>true</optional>
141+
</dependency>
142+
<dependency>
143+
<groupId>org.springframework</groupId>
144+
<artifactId>spring-web</artifactId>
145+
<version>${spring.version}</version>
146+
<optional>true</optional>
147+
</dependency>
148+
<dependency>
149+
<groupId>org.springframework</groupId>
150+
<artifactId>spring-test</artifactId>
151+
<version>${spring.version}</version>
152+
<scope>test</scope>
153+
</dependency>
154+
155+
<!-- apache commons-->
156+
<dependency>
157+
<groupId>commons-codec</groupId>
158+
<artifactId>commons-codec</artifactId>
159+
<version>${commons.codec.version}</version>
160+
<optional>true</optional>
161+
</dependency>
162+
<dependency>
163+
<groupId>org.apache.httpcomponents</groupId>
164+
<artifactId>httpcore-nio</artifactId>
165+
<version>${httpcomponents.version}</version>
166+
<optional>true</optional>
167+
</dependency>
168+
169+
<!-- test -->
170+
<dependency>
171+
<groupId>junit</groupId>
172+
<artifactId>junit</artifactId>
173+
<version>${junit.version}</version>
174+
<scope>test</scope>
175+
</dependency>
176+
<dependency>
177+
<groupId>org.jmock</groupId>
178+
<artifactId>jmock-junit4</artifactId>
179+
<version>${jmock.version}</version>
180+
<scope>test</scope>
181+
</dependency>
182+
<dependency>
183+
<groupId>org.jmock</groupId>
184+
<artifactId>jmock</artifactId>
185+
<version>${jmock.version}</version>
186+
<scope>test</scope>
187+
</dependency>
188+
<dependency>
189+
<groupId>org.eclipse.jetty</groupId>
190+
<artifactId>jetty-server</artifactId>
191+
<version>${jetty.version}</version>
192+
<scope>test</scope>
193+
<exclusions>
194+
<exclusion>
195+
<artifactId>javax.servlet</artifactId>
196+
<groupId>org.eclipse.jetty.orbit</groupId>
197+
</exclusion>
198+
</exclusions>
199+
</dependency>
200+
<dependency>
201+
<groupId>org.eclipse.jetty</groupId>
202+
<artifactId>jetty-servlet</artifactId>
203+
<version>${jetty.version}</version>
204+
<scope>test</scope>
205+
<exclusions>
206+
<exclusion>
207+
<artifactId>javax.servlet</artifactId>
208+
<groupId>org.eclipse.jetty.orbit</groupId>
209+
</exclusion>
210+
</exclusions>
211+
</dependency>
212+
</dependencies>
213+
214+
</project>
215+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.googlecode.jsonrpc4j;
2+
3+
import java.lang.reflect.Method;
4+
import java.util.List;
5+
6+
import com.fasterxml.jackson.databind.JsonNode;
7+
import com.googlecode.jsonrpc4j.DefaultErrorResolver.ErrorData;
8+
9+
/**
10+
* {@link ErrorResolver} that uses annotations.
11+
*/
12+
public class AnnotationsErrorResolver
13+
implements ErrorResolver {
14+
15+
public static final AnnotationsErrorResolver INSTANCE = new AnnotationsErrorResolver();
16+
17+
/**
18+
* {@inheritDoc}
19+
*/
20+
public JsonError resolveError(Throwable t, Method method, List<JsonNode> arguments) {
21+
22+
// use annotations to map errors
23+
JsonRpcErrors errors = ReflectionUtil.getAnnotation(method, JsonRpcErrors.class);
24+
if (errors!=null) {
25+
for (JsonRpcError em : errors.value()) {
26+
if (em.exception().isInstance(t)) {
27+
String message = em.message()!=null && em.message().trim().length() > 0
28+
? em.message()
29+
: t.getMessage();
30+
return new JsonError(em.code(), message,
31+
new ErrorData(em.exception().getName(), message));
32+
}
33+
}
34+
}
35+
36+
// none found
37+
return null;
38+
}
39+
40+
}

0 commit comments

Comments
 (0)