Skip to content

Commit 8663d98

Browse files
committed
added features for rest interface and error handler.
1 parent 5051ea7 commit 8663d98

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed To in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.androidannotations.api.rest;
17+
18+
import org.springframework.web.client.RestTemplate;
19+
20+
/**
21+
* A @Rest interface implementing this interface will automatically have the
22+
* implementations of these methods generated.
23+
*/
24+
public interface EnhancedRestClient {
25+
26+
/**
27+
* Gets the root URL for the rest service.
28+
*
29+
* @return String
30+
*/
31+
String getRootUrl();
32+
33+
/**
34+
* Sets the root URL for the rest service.
35+
*
36+
* @param rootUrl
37+
*/
38+
void setRootUrl(String rootUrl);
39+
40+
/**
41+
* Gets the rest template used by the rest service implementation.
42+
*
43+
* @return RestTemplate
44+
*/
45+
RestTemplate getRestTemplate();
46+
47+
/**
48+
* Sets the rest template used by the rest service implementation.
49+
*
50+
* @param rt
51+
*/
52+
void setRestTemplate(RestTemplate rt);
53+
54+
/**
55+
* Sets the error handler called when a rest error occurs.
56+
*
57+
* @param handler
58+
*/
59+
void setRestErrorHandler(RestErrorHandler handler);
60+
61+
String getCookie(String c);
62+
63+
void setHeader(String h, String v);
64+
65+
String getHeader(String h);
66+
67+
void setCookie(String c, String v);
68+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed To in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package org.androidannotations.api.rest;
17+
18+
import org.springframework.web.client.RestClientException;
19+
20+
/**
21+
* This interface is used for handling rest client exceptions.
22+
*/
23+
public interface RestErrorHandler {
24+
/**
25+
* Called when an exception occurs within the rest client.
26+
*
27+
* @param e
28+
*/
29+
void onRestClientExceptionThrown(RestClientException e);
30+
}

0 commit comments

Comments
 (0)