public class RESTWorkItemHandler extends AbstractLogOrThrowWorkItemHandler implements org.kie.internal.runtime.Cacheable
Modifier and Type | Class and Description |
---|---|
static class |
RESTWorkItemHandler.AuthenticationType |
Modifier and Type | Field and Description |
---|---|
protected static org.apache.http.impl.client.CloseableHttpClient |
cachedClient |
protected static org.apache.http.impl.conn.PoolingHttpClientConnectionManager |
connectionManager |
protected static boolean |
HTTP_CLIENT_API_43 |
static String |
PARAM_AUTH_TYPE |
static String |
PARAM_AUTHURL |
static String |
PARAM_CONNECT_TIMEOUT |
static String |
PARAM_CONTENT |
static String |
PARAM_CONTENT_DATA |
static String |
PARAM_CONTENT_TYPE |
static String |
PARAM_HEADERS |
static String |
PARAM_PASSWORD |
static String |
PARAM_READ_TIMEOUT |
static String |
PARAM_RESULT |
static String |
PARAM_STATUS |
static String |
PARAM_STATUS_MSG |
static String |
PARAM_USERNAME |
logThrownException
Constructor and Description |
---|
RESTWorkItemHandler()
Used when no authentication is required
|
RESTWorkItemHandler(boolean doCacheClient)
Used when no authentication is required
|
RESTWorkItemHandler(boolean doCacheClient,
int totalPoolConnections,
int maxPoolConnectionsPerRoute)
Used when no authentication is required
|
RESTWorkItemHandler(ClassLoader classLoader)
Used when no authentication is required
|
RESTWorkItemHandler(ClassLoader classLoader,
boolean doCacheClient)
Used when no authentication is required
|
RESTWorkItemHandler(ClassLoader classLoader,
boolean doCacheClient,
int totalPoolConnections,
int maxPoolConnectionsPerRoute)
Used when no authentication is required
|
RESTWorkItemHandler(String username,
String password)
Dedicated constructor when BASIC authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
boolean doCacheClient)
Dedicated constructor when BASIC authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
boolean doCacheClient,
int totalPoolConnections,
int maxPoolConnectionsPerRoute)
Dedicated constructor when BASIC authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
ClassLoader classLoader)
Dedicated constructor when BASIC authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
ClassLoader classLoader,
boolean doCacheClient)
Dedicated constructor when BASIC authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
ClassLoader classLoader,
boolean doCacheClient,
int totalPoolConnections,
int maxPoolConnectionsPerRoute)
Dedicated constructor when BASIC authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
String authUrl)
Dedicated constructor when FORM BASED authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
String authUrl,
boolean doCacheClient)
Dedicated constructor when FORM BASED authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
String authUrl,
boolean doCacheClient,
int totalPoolConnections,
int maxPoolConnectionsPerRoute)
Dedicated constructor when FORM BASED authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
String authUrl,
ClassLoader classLoader)
Dedicated constructor when FORM BASED authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
String authUrl,
ClassLoader classLoader,
boolean doCacheClient)
Dedicated constructor when FORM BASED authentication method shall be used
|
RESTWorkItemHandler(String username,
String password,
String authUrl,
ClassLoader classLoader,
boolean doCacheClient,
int totalPoolConnections,
int maxPoolConnectionsPerRoute)
Dedicated constructor when FORM BASED authentication method shall be used
|
Modifier and Type | Method and Description |
---|---|
void |
abortWorkItem(org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
protected void |
addAcceptHeader(org.apache.http.client.methods.HttpRequestBase theMethod,
String value) |
protected void |
addAcceptHeader(org.apache.http.client.methods.RequestBuilder builder,
String value) |
protected void |
addCustomHeaders(String headers,
BiConsumer<String,String> consumer) |
void |
close() |
protected void |
close(org.apache.http.client.HttpClient httpClient,
Object httpMethod) |
protected Object |
configureRequest(String method,
String urlStr,
Map<String,Object> params,
String acceptHeaderValue,
String acceptCharset,
String httpHeaders) |
protected org.apache.http.HttpResponse |
doRequestWithAuthorization(org.apache.http.client.HttpClient httpclient,
org.apache.http.client.methods.HttpRequestBase httpMethod,
Map<String,Object> params,
RESTWorkItemHandler.AuthenticationType type) |
protected org.apache.http.HttpResponse |
doRequestWithAuthorization(org.apache.http.client.HttpClient httpclient,
Object method,
Map<String,Object> params,
RESTWorkItemHandler.AuthenticationType authType) |
protected org.apache.http.HttpResponse |
doRequestWithAuthorization(org.apache.http.client.HttpClient httpclient,
org.apache.http.client.methods.RequestBuilder requestBuilder,
Map<String,Object> params,
RESTWorkItemHandler.AuthenticationType type)
This method does the actual request, including the setup for authorization.
|
void |
executeWorkItem(org.kie.api.runtime.process.WorkItem workItem,
org.kie.api.runtime.process.WorkItemManager manager) |
String |
getAuthUrl() |
boolean |
getDoCacheClient() |
protected org.apache.http.client.HttpClient |
getHttpClient(Integer readTimeout,
Integer connectTimeout) |
protected org.apache.http.impl.client.CloseableHttpClient |
getNewPooledHttpClient(Integer readTimeout,
Integer connectTimeout) |
protected Integer |
getParamAsInt(Object param) |
protected void |
postProcessResult(String result,
String resultClass,
String contentType,
Map<String,Object> results) |
protected void |
setBody(org.apache.http.client.methods.HttpRequestBase theMethod,
Map<String,Object> params) |
protected void |
setBody(org.apache.http.client.methods.RequestBuilder builder,
Map<String,Object> params) |
protected void |
setCharset(org.apache.http.client.methods.HttpRequestBase theMethod,
String charset) |
protected void |
setCharset(org.apache.http.client.methods.RequestBuilder builder,
String charset) |
protected String |
transformRequest(Object data,
String contentType) |
protected Object |
transformResult(Class<?> clazz,
String contentType,
String content) |
findNodeInstance, handleException, handleException, setLogThrownException
public static final String PARAM_AUTH_TYPE
public static final String PARAM_CONNECT_TIMEOUT
public static final String PARAM_READ_TIMEOUT
public static final String PARAM_CONTENT_TYPE
public static final String PARAM_HEADERS
public static final String PARAM_CONTENT
public static final String PARAM_CONTENT_DATA
public static final String PARAM_USERNAME
public static final String PARAM_PASSWORD
public static final String PARAM_AUTHURL
public static final String PARAM_RESULT
public static final String PARAM_STATUS
public static final String PARAM_STATUS_MSG
protected static org.apache.http.impl.conn.PoolingHttpClientConnectionManager connectionManager
protected static org.apache.http.impl.client.CloseableHttpClient cachedClient
protected static boolean HTTP_CLIENT_API_43
public RESTWorkItemHandler()
public RESTWorkItemHandler(boolean doCacheClient)
doCacheClient
- - - true/false setting for client cachepublic RESTWorkItemHandler(boolean doCacheClient, int totalPoolConnections, int maxPoolConnectionsPerRoute)
doCacheClient
- - - true/false setting for client cachetotalPoolConnections
- - max pool connections if caching client is usedmaxPoolConnectionsPerRoute
- - max pool connections per route if caching client is usedpublic RESTWorkItemHandler(String username, String password)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationpublic RESTWorkItemHandler(String username, String password, boolean doCacheClient)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationdoCacheClient
- - true/false setting for client cachepublic RESTWorkItemHandler(String username, String password, boolean doCacheClient, int totalPoolConnections, int maxPoolConnectionsPerRoute)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationdoCacheClient
- - true/false setting for client cachetotalPoolConnections
- - max pool connections if caching client is usedmaxPoolConnectionsPerRoute
- - max pool connections per route if caching client is usedpublic RESTWorkItemHandler(String username, String password, String authUrl)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationauthUrl
- - authentication url to be usedpublic RESTWorkItemHandler(String username, String password, String authUrl, boolean doCacheClient)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationauthUrl
- - authentication url to be useddoCacheClient
- - true/false setting for client cachepublic RESTWorkItemHandler(String username, String password, String authUrl, boolean doCacheClient, int totalPoolConnections, int maxPoolConnectionsPerRoute)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationauthUrl
- - authentication url to be useddoCacheClient
- - true/false setting for client cachetotalPoolConnections
- - max pool connections if caching client is usedmaxPoolConnectionsPerRoute
- - max pool connections per route if caching client is usedpublic RESTWorkItemHandler(ClassLoader classLoader)
classLoader
- - given classloaderpublic RESTWorkItemHandler(ClassLoader classLoader, boolean doCacheClient)
classLoader
- - given classloaderdoCacheClient
- - true/false setting for client cachepublic RESTWorkItemHandler(ClassLoader classLoader, boolean doCacheClient, int totalPoolConnections, int maxPoolConnectionsPerRoute)
classLoader
- - given classloaderdoCacheClient
- - true/false setting for client cachetotalPoolConnections
- - max pool connections if caching client is usedmaxPoolConnectionsPerRoute
- - max pool connections per route if caching client is usedpublic RESTWorkItemHandler(String username, String password, ClassLoader classLoader)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationclassLoader
- - given classloaderpublic RESTWorkItemHandler(String username, String password, ClassLoader classLoader, boolean doCacheClient)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationclassLoader
- - given classloaderdoCacheClient
- - true/false setting for client cachepublic RESTWorkItemHandler(String username, String password, ClassLoader classLoader, boolean doCacheClient, int totalPoolConnections, int maxPoolConnectionsPerRoute)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationclassLoader
- - given classloaderdoCacheClient
- - true/false setting for client cachetotalPoolConnections
- - max pool connections if caching client is usedmaxPoolConnectionsPerRoute
- - max pool connections per route if caching client is usedpublic RESTWorkItemHandler(String username, String password, String authUrl, ClassLoader classLoader)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationauthUrl
- - authentication url to be usedclassLoader
- - given classloaderpublic RESTWorkItemHandler(String username, String password, String authUrl, ClassLoader classLoader, boolean doCacheClient)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationauthUrl
- - authentication url to be usedclassLoader
- - given classloaderdoCacheClient
- - true/false setting for client cachepublic RESTWorkItemHandler(String username, String password, String authUrl, ClassLoader classLoader, boolean doCacheClient, int totalPoolConnections, int maxPoolConnectionsPerRoute)
username
- - user name to be used for authenticationpassword
- - password to be used for authenticationauthUrl
- - authentication url to be usedclassLoader
- - given classloaderdoCacheClient
- - true/false setting for client cachetotalPoolConnections
- - max pool connections if caching client is usedmaxPoolConnectionsPerRoute
- - max pool connections per route if caching client is usedpublic String getAuthUrl()
public boolean getDoCacheClient()
public void executeWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
executeWorkItem
in interface org.kie.api.runtime.process.WorkItemHandler
protected void setCharset(org.apache.http.client.methods.RequestBuilder builder, String charset)
protected void addAcceptHeader(org.apache.http.client.methods.RequestBuilder builder, String value)
protected void setCharset(org.apache.http.client.methods.HttpRequestBase theMethod, String charset)
protected void addAcceptHeader(org.apache.http.client.methods.HttpRequestBase theMethod, String value)
protected void addCustomHeaders(String headers, BiConsumer<String,String> consumer)
protected void setBody(org.apache.http.client.methods.RequestBuilder builder, Map<String,Object> params)
protected void setBody(org.apache.http.client.methods.HttpRequestBase theMethod, Map<String,Object> params)
protected void postProcessResult(String result, String resultClass, String contentType, Map<String,Object> results)
protected Object transformResult(Class<?> clazz, String contentType, String content) throws Exception
Exception
protected org.apache.http.HttpResponse doRequestWithAuthorization(org.apache.http.client.HttpClient httpclient, Object method, Map<String,Object> params, RESTWorkItemHandler.AuthenticationType authType)
protected org.apache.http.HttpResponse doRequestWithAuthorization(org.apache.http.client.HttpClient httpclient, org.apache.http.client.methods.RequestBuilder requestBuilder, Map<String,Object> params, RESTWorkItemHandler.AuthenticationType type)
httpclient
- The HttpClient
instancerequestBuilder
- The RequestBuilder
instanceparams
- The parameters that may be needed for authenticationHttpResponse
instance from which we can extract the contentprotected org.apache.http.HttpResponse doRequestWithAuthorization(org.apache.http.client.HttpClient httpclient, org.apache.http.client.methods.HttpRequestBase httpMethod, Map<String,Object> params, RESTWorkItemHandler.AuthenticationType type)
public void abortWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager manager)
abortWorkItem
in interface org.kie.api.runtime.process.WorkItemHandler
protected org.apache.http.client.HttpClient getHttpClient(Integer readTimeout, Integer connectTimeout)
protected org.apache.http.impl.client.CloseableHttpClient getNewPooledHttpClient(Integer readTimeout, Integer connectTimeout)
protected void close(org.apache.http.client.HttpClient httpClient, Object httpMethod) throws IOException
IOException
protected Object configureRequest(String method, String urlStr, Map<String,Object> params, String acceptHeaderValue, String acceptCharset, String httpHeaders)
public void close()
close
in interface org.kie.internal.runtime.Cacheable
Copyright © 2001–2018 JBoss by Red Hat. All rights reserved.