public class OARestClient extends Object
To create remote method calls, a Java Interface is used with annotations to describe the behavior and interaction with the remote server. OARestClient getInstance(class) can then be used to get an implementation that will automatically have the method invoke use HTTP to get the method's return value.
Methods can be defined to automatically call:
1: web url
2: REST API call
3: OA Graph - query, persistence, method calls by working with OARestServlet that allows secure access to object model data.
4: Java implementation of the Java interface being remoted (java2java remote method call).
Includes an annotation checker that is useful for finding any configuration errors.
OARestClass, OARestMethod, OARestParam annotations
Constructor and Description |
---|
OARestClient()
Create an OARestClient that can be used to call another server using HTTP.
|
Modifier and Type | Method and Description |
---|---|
protected OARestInvokeInfo |
_onInvoke(Method method,
Object[] args)
Creates an OARestInvokeInfo to setup and manage a remote method call over HTTP
|
protected static void |
_setupHttpsAccess() |
OARestInvokeInfo |
callEndPoint(OARestInvokeInfo ii,
String httpMethod,
String urlPath,
String urlQuery,
Map<String,Object> mapUrlQuery,
String jsonBody,
Map<String,Object> mapFormData)
Call an HTTP endPoint.
|
void |
callHttpEndPoint(OARestInvokeInfo invokeInfo) |
String |
callJsonEndpoint(String httpMethod,
String urlPath,
String query,
String jsonBody)
Manually call an HTTP end point using JSON and expecting JSON return value.
|
<T extends OAObject> |
callOADelete(OARestInvokeInfo ii,
T obj)
call an OARestServlet to insert an object.
|
OARestInvokeInfo |
callOAGet(OARestInvokeInfo ii,
Class<? extends OAObject> clazz,
Object id,
Object id2,
String... includePPs)
call an OARestServlet to access an object with 2 part key, from an OAGraph.
|
OARestInvokeInfo |
callOAGet(OARestInvokeInfo ii,
Class<? extends OAObject> clazz,
Object id,
String... includePPs)
call an OARestServlet to access an object from an OAGraph.
|
<T extends OAObject> |
callOAInsert(OARestInvokeInfo ii,
T obj,
String... includePPs)
call an OARestServlet to insert an object.
|
OARestInvokeInfo |
callOASelect(OARestInvokeInfo ii,
Class<? extends OAObject> clazz,
String searchWhere,
String searchOrderBy,
String... includePPs)
call an OARestServlet to access data in an OAGraph.
|
<T extends OAObject> |
callOAUpdate(OARestInvokeInfo ii,
T obj,
String... includePPs)
call an OARestServlet to update an object.
|
String |
getBaseUrl() |
String |
getDefaultIdSeperator() |
String |
getDefaultOARestUrl() |
<API> API |
getInstance(Class<API> clazz)
Used to create and instance of a Java interface that has been annotated using OARest* for the class, methods, and method parameters.
|
String |
getProtocol() |
OARestClassInfo |
getRestClassInfo(Class interfaceClass)
Get OARestClassInfo about an existing Java instance created from calling getInstance(class)
|
protected void |
loadMetaData(Class interfaceClass)
Used by getInstance to gather class/method/parameter metadata to be able to make an HTTP method call for each method in the Java
interface.
|
protected Object |
onInvoke(Method method,
Object[] args)
Manages any method that is called from a remote object.
|
void |
setBaseUrl(String baseUrl) |
void |
setDefaultIdSeperator(String defaultIdSeperator) |
void |
setDefaultOARestUrl(String defaultOARestUrl) |
void |
setProtocol(String p) |
static void |
setupHttpsAccess()
Configure HTTPS support.
|
void |
setUserPw(String userId,
String pw) |
ArrayList<String> |
verify(Class interfaceClass) |
public OARestClient()
public void setBaseUrl(String baseUrl)
public String getBaseUrl()
public void setProtocol(String p)
public String getProtocol()
public void setDefaultOARestUrl(String defaultOARestUrl)
public String getDefaultOARestUrl()
public void setDefaultIdSeperator(String defaultIdSeperator)
public String getDefaultIdSeperator()
public <API> API getInstance(Class<API> clazz) throws Exception
This will use a Java proxy object to manage all of the method calls.
clazz
- Java interface to create an instance of.Exception
protected Object onInvoke(Method method, Object[] args) throws Throwable
Throwable
protected OARestInvokeInfo _onInvoke(Method method, Object[] args) throws Throwable
Throwable
public OARestClassInfo getRestClassInfo(Class interfaceClass)
protected void loadMetaData(Class interfaceClass) throws Exception
Exception
public void callHttpEndPoint(OARestInvokeInfo invokeInfo) throws Exception
Exception
public String callJsonEndpoint(String httpMethod, String urlPath, String query, String jsonBody) throws Exception
Exception
public static void setupHttpsAccess() throws Exception
Exception
public OARestInvokeInfo callEndPoint(OARestInvokeInfo ii, String httpMethod, String urlPath, String urlQuery, Map<String,Object> mapUrlQuery, String jsonBody, Map<String,Object> mapFormData) throws Exception
ii
- (optional) defines details about how to call the server.httpMethod
- ex: GET, POST, DELETE, etcurlPath
- url path to go with base urlurlQuery
- url querymapUrlQuery
- name/value pairs for url queryjsonBody
- JSON object(s) to send as http bodymapFormData
- Exception
public OARestInvokeInfo callOASelect(OARestInvokeInfo ii, Class<? extends OAObject> clazz, String searchWhere, String searchOrderBy, String... includePPs) throws Exception
ii
- (optional) defines details about how to call the server.clazz
- OAObject class that is being called.searchWhere
- object query searchsearchOrderBy
- sort order byincludePPs
- extra property paths to include in the results.Exception
public OARestInvokeInfo callOAGet(OARestInvokeInfo ii, Class<? extends OAObject> clazz, Object id, String... includePPs) throws Exception
ii
- (optional) defines details about how to call the server.clazz
- OAObject class that is being called.id
- the object key value of object.includePPs
- extra property paths to include in the results.Exception
public OARestInvokeInfo callOAGet(OARestInvokeInfo ii, Class<? extends OAObject> clazz, Object id, Object id2, String... includePPs) throws Exception
ii
- (optional) defines details about how to call the server.clazz
- OAObject class that is being called.id
- the object key value of object.includePPs
- extra property paths to include in the results.Exception
public <T extends OAObject> OARestInvokeInfo callOAInsert(OARestInvokeInfo ii, T obj, String... includePPs) throws Exception
ii
- (optional) defines details about how to call the server.obj
- object to insert.includePPs
- extra property paths to include in the results.Exception
public <T extends OAObject> OARestInvokeInfo callOADelete(OARestInvokeInfo ii, T obj) throws Exception
ii
- (optional) defines details about how to call the server.obj
- object to insert.Exception
public <T extends OAObject> OARestInvokeInfo callOAUpdate(OARestInvokeInfo ii, T obj, String... includePPs) throws Exception
ii
- (optional) defines details about how to call the server.obj
- object to update.includePPs
- extra property paths to include in the results.Exception
Copyright © 1999–2025 ViaOA. All rights reserved.