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.ResultInfo |
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 jadex.commons.collection.MultiCollection<java.lang.String,javax.servlet.AsyncContext> |
requestspercall
The requests per call (coming from the rest client).
|
protected jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.ResultInfo> |
resultspercall
The results per call (coming from the called Jadex service).
|
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)
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
|
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) |
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> |
publishExternal(java.net.URI uri,
java.lang.String rootpath)
Publish file resources from the file system.
|
abstract jadex.commons.future.IFuture<java.lang.Void> |
publishHMTLPage(java.net.URI uri,
java.lang.String vhost,
java.lang.String html)
Publish a static page (without ressources).
|
abstract jadex.commons.future.IFuture<java.lang.Void> |
publishResources(java.net.URI uri,
java.lang.String rootpath)
Publish file resources from the classpath.
|
abstract jadex.commons.future.IFuture<java.lang.Void> |
publishService(java.lang.ClassLoader cl,
jadex.bridge.service.IService service,
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.
|
abstract jadex.commons.future.IFuture<java.lang.Void> |
unpublishService(jadex.bridge.service.IServiceIdentifier sid)
Unpublish a service.
|
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) |
public 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 jadex.commons.collection.MultiCollection<java.lang.String,AbstractRestPublishService.ResultInfo> resultspercall
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.IPublishService
publishtype
- 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.IOException
javax.servlet.ServletException
public abstract jadex.commons.future.IFuture<java.lang.Void> publishService(java.lang.ClassLoader cl, jadex.bridge.service.IService service, jadex.bridge.service.PublishInfo info)
publishService
in interface jadex.bridge.service.types.publish.IPublishService
cl
- 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)
public abstract jadex.commons.future.IFuture<java.lang.Void> unpublishService(jadex.bridge.service.IServiceIdentifier sid)
unpublishService
in interface jadex.bridge.service.types.publish.IPublishService
unpublishService
in interface jadex.bridge.service.types.publish.IWebPublishService
sid
- The service identifier.public abstract jadex.commons.future.IFuture<java.lang.Void> publishHMTLPage(java.net.URI uri, java.lang.String vhost, java.lang.String html)
publishHMTLPage
in interface jadex.bridge.service.types.publish.IWebPublishService
public abstract jadex.commons.future.IFuture<java.lang.Void> publishResources(java.net.URI uri, java.lang.String rootpath)
publishResources
in interface jadex.bridge.service.types.publish.IWebPublishService
public abstract jadex.commons.future.IFuture<java.lang.Void> publishExternal(java.net.URI uri, java.lang.String rootpath)
publishExternal
in interface jadex.bridge.service.types.publish.IWebPublishService
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)
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.Exception
public 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.