public abstract class AbstractRestPublishService
extends java.lang.Object
implements jadex.bridge.service.types.publish.IWebPublishService
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractRestPublishService.MappingInfo |
static class |
AbstractRestPublishService.RequestInfo |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ASYNC_CONTEXT_INFO
Async context info.
|
protected jadex.bridge.IInternalAccess |
component
The component.
|
protected jadex.commons.collection.MultiCollection<java.lang.String,jadex.commons.transformation.IObjectStringConverter> |
converters
The media type converters.
|
static java.lang.String |
FINISHED
Finished result marker.
|
static java.lang.String |
HEADER_JADEX_CALLFINISHED
Http header for the call id siganlling that this is the last response.
|
static java.lang.String |
HEADER_JADEX_CALLID
Http header for the call id.
|
static java.lang.String |
HEADER_JADEX_CLIENTTIMEOUT
Http header for the call id.
|
static java.util.List<java.lang.String> |
PARAMETER_MEDIATYPES
Some basic media types for service invocations.
|
protected java.util.Map<java.lang.String,AbstractRestPublishService.RequestInfo> |
requestinfos
The internal request info containing also results per call (coming from the called Jadex service).
|
protected jadex.commons.collection.MultiCollection<java.lang.String,javax.servlet.AsyncContext> |
requestspercall
The requests per call (coming from the rest client).
|
| Constructor and Description |
|---|
AbstractRestPublishService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addConverter(java.lang.String[] mediatypes,
jadex.commons.transformation.IObjectStringConverter converter)
Add a converter for one or multiple types.
|
protected void |
complete(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected java.lang.Object |
convertParameter(java.util.List<java.lang.String> sr,
java.lang.String val,
java.lang.Class<?> targetclazz)
Convert a parameter string to an object if is json or xml.
|
jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.MappingInfo> |
evaluateMapping(jadex.bridge.service.IServiceIdentifier sid,
jadex.bridge.service.PublishInfo pi)
Evaluate the service interface and generate mappings.
|
java.util.Map<java.lang.String,java.lang.String> |
extractCallerValues(java.lang.Object request)
Extract caller values like ip and browser.
|
protected javax.servlet.AsyncContext |
getAsyncContext(javax.servlet.http.HttpServletRequest request)
Get the async
|
java.lang.String |
getCleanPublishId(java.lang.String id)
Get the cleaned publish id.
|
abstract java.lang.Object |
getHttpServer(java.net.URI uri,
jadex.bridge.service.PublishInfo info)
Get or start an api to the http server.
|
static java.util.List<java.lang.String> |
getParameterNames(java.lang.reflect.Method m)
Get parameter names via asm reader.
|
static long |
getRequestTimeout(javax.servlet.http.HttpServletRequest request)
Get the request timeout.
|
java.lang.String |
getServiceInfo(java.lang.Object service,
java.lang.String baseuri,
jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.MappingInfo> mappings)
Functionality blueprint for get service info web method.
|
static java.lang.String |
getServletHost(javax.servlet.http.HttpServletRequest req)
Get the servlet base url.
|
static java.lang.String |
getServletUrl(javax.servlet.http.HttpServletRequest req)
Get the servlet base url.
|
AbstractRestPublishService.MappingInfo.HttpMethod |
guessRestType(java.lang.reflect.Method method)
Guess the http type (GET, POST, PUT, DELETE, ...) of a method.
|
void |
handleRequest(jadex.bridge.service.IService service,
jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.MappingInfo> mappings,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object[] others)
Handle a web request.
|
boolean |
hasStringConvertableParameters(java.lang.reflect.Method method,
java.lang.Class<?> rettype,
java.lang.Class<?>[] paramtypes)
Test if a method has parameters that are all convertible from string.
|
jadex.commons.future.IFuture<java.lang.Void> |
init()
The service init.
|
protected boolean |
isComplete(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
jadex.commons.future.IFuture<java.lang.Boolean> |
isSupported(java.lang.String publishtype)
Test if publishing a specific type is supported (e.g.
|
java.lang.String |
loadFunctionJS() |
java.lang.String |
loadStyleCSS() |
protected jadex.commons.Tuple2<AbstractRestPublishService.MappingInfo,java.lang.Object[]> |
mapParameters(javax.servlet.http.HttpServletRequest request,
java.util.Collection<AbstractRestPublishService.MappingInfo> mis)
Map the incoming uri/post/multipart parameters to the service target parameter types.
|
protected java.lang.Object |
mapResult(java.lang.reflect.Method method,
java.lang.Object ret)
Map a result using the result mapper.
|
static java.util.List<java.lang.String> |
parseMimetypes(java.lang.String mts)
todo: make statically accessible
Copied from Jadex ForwardFilter
|
abstract jadex.commons.future.IFuture<java.lang.Void> |
publishService(jadex.bridge.service.IServiceIdentifier serviceid,
jadex.bridge.service.PublishInfo info)
Publish a service.
|
void |
removeConverter(java.lang.String[] mediatypes,
jadex.commons.transformation.IObjectStringConverter converter)
Remove a converter.
|
protected void |
saveRequestContext(java.lang.String callid,
javax.servlet.AsyncContext ctx) |
static jadex.commons.collection.MultiCollection<java.lang.String,java.lang.String> |
splitQueryString(java.lang.String query)
Split the query and save the order.
|
protected void |
writeResponse(java.lang.Object result,
int status,
java.lang.String callid,
AbstractRestPublishService.MappingInfo mi,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean fin) |
protected void |
writeResponse(java.lang.Object result,
java.lang.String callid,
AbstractRestPublishService.MappingInfo mi,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean fin) |
protected void |
writeResponseContent(java.lang.Object result,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.util.List<java.lang.String> sr)
Write the response content.
|
protected java.util.List<java.lang.String> |
writeResponseHeader(java.lang.Object ret,
int status,
java.lang.String callid,
AbstractRestPublishService.MappingInfo mi,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean fin) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic static final java.lang.String ASYNC_CONTEXT_INFO
public static final java.lang.String HEADER_JADEX_CALLID
public static final java.lang.String HEADER_JADEX_CALLFINISHED
public static final java.lang.String HEADER_JADEX_CLIENTTIMEOUT
public static final java.lang.String FINISHED
public static java.util.List<java.lang.String> PARAMETER_MEDIATYPES
protected jadex.bridge.IInternalAccess component
protected java.util.Map<java.lang.String,AbstractRestPublishService.RequestInfo> requestinfos
protected jadex.commons.collection.MultiCollection<java.lang.String,javax.servlet.AsyncContext> requestspercall
protected jadex.commons.collection.MultiCollection<java.lang.String,jadex.commons.transformation.IObjectStringConverter> converters
public jadex.commons.future.IFuture<java.lang.Void> init()
public void addConverter(java.lang.String[] mediatypes,
jadex.commons.transformation.IObjectStringConverter converter)
public void removeConverter(java.lang.String[] mediatypes,
jadex.commons.transformation.IObjectStringConverter converter)
converter - The converter.public jadex.commons.future.IFuture<java.lang.Boolean> isSupported(java.lang.String publishtype)
isSupported in interface jadex.bridge.service.types.publish.IPublishServicepublishtype - The type to test.public void handleRequest(jadex.bridge.service.IService service,
jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.MappingInfo> mappings,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object[] others)
throws java.io.IOException,
javax.servlet.ServletException
java.io.IOExceptionjavax.servlet.ServletExceptionpublic abstract jadex.commons.future.IFuture<java.lang.Void> publishService(jadex.bridge.service.IServiceIdentifier serviceid,
jadex.bridge.service.PublishInfo info)
publishService in interface jadex.bridge.service.types.publish.IPublishServicecl - The classloader.service - The original service.pid - The publish id (e.g. url or name).public abstract java.lang.Object getHttpServer(java.net.URI uri,
jadex.bridge.service.PublishInfo info)
protected javax.servlet.AsyncContext getAsyncContext(javax.servlet.http.HttpServletRequest request)
protected jadex.commons.Tuple2<AbstractRestPublishService.MappingInfo,java.lang.Object[]> mapParameters(javax.servlet.http.HttpServletRequest request, java.util.Collection<AbstractRestPublishService.MappingInfo> mis)
protected java.lang.Object convertParameter(java.util.List<java.lang.String> sr,
java.lang.String val,
java.lang.Class<?> targetclazz)
sr - The media types.val - The string value.protected java.lang.Object mapResult(java.lang.reflect.Method method,
java.lang.Object ret)
protected void writeResponse(java.lang.Object result,
java.lang.String callid,
AbstractRestPublishService.MappingInfo mi,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean fin)
protected void writeResponse(java.lang.Object result,
int status,
java.lang.String callid,
AbstractRestPublishService.MappingInfo mi,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean fin)
protected java.util.List<java.lang.String> writeResponseHeader(java.lang.Object ret,
int status,
java.lang.String callid,
AbstractRestPublishService.MappingInfo mi,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean fin)
protected void writeResponseContent(java.lang.Object result,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.util.List<java.lang.String> sr)
protected void saveRequestContext(java.lang.String callid,
javax.servlet.AsyncContext ctx)
callid - ctx - public static long getRequestTimeout(javax.servlet.http.HttpServletRequest request)
public static java.util.List<java.lang.String> parseMimetypes(java.lang.String mts)
public static jadex.commons.collection.MultiCollection<java.lang.String,java.lang.String> splitQueryString(java.lang.String query)
throws java.lang.Exception
java.lang.Exceptionpublic jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.MappingInfo> evaluateMapping(jadex.bridge.service.IServiceIdentifier sid, jadex.bridge.service.PublishInfo pi)
public static java.lang.String getServletUrl(javax.servlet.http.HttpServletRequest req)
req - The request.public static java.lang.String getServletHost(javax.servlet.http.HttpServletRequest req)
req - The request.public java.lang.String getServiceInfo(java.lang.Object service,
java.lang.String baseuri,
jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.MappingInfo> mappings)
params - The parameters.public java.lang.String loadFunctionJS()
public java.lang.String loadStyleCSS()
public AbstractRestPublishService.MappingInfo.HttpMethod guessRestType(java.lang.reflect.Method method)
method - The method.public boolean hasStringConvertableParameters(java.lang.reflect.Method method,
java.lang.Class<?> rettype,
java.lang.Class<?>[] paramtypes)
method - The method.rettype - The return types (possibly unwrapped from future type).paramtypes - The parameter types.protected void complete(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - cinfo - protected boolean isComplete(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - cinfo - public static java.util.List<java.lang.String> getParameterNames(java.lang.reflect.Method m)
m - The method.public java.util.Map<java.lang.String,java.lang.String> extractCallerValues(java.lang.Object request)
request - The requrest.vals - The values.public java.lang.String getCleanPublishId(java.lang.String id)