Package rs.jerseyclient
Class JerseyClient
java.lang.Object
rs.jerseyclient.util.AbstractClient
rs.jerseyclient.JerseyClient
The main entrance class.
- Author:
- ralph
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJerseyClient(javax.ws.rs.client.Client config) Constructor.JerseyClient(JerseyClientConfig config) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidBase method for authentication.voidclose()Close the client.protected voidconfigure(javax.ws.rs.client.Client client) Configures the client by setting the default auth filter and - if applicable - the proxy filter.protected voidconfigure(JerseyClientConfig config) Configures JAX-RS client and main web target based on this config.protected javax.ws.rs.client.ClientCreates the actual JAX-WS Jersey client instance.protected org.glassfish.jersey.client.ClientConfigCreates the Jersey client configuration based on the config for this client.protected javax.ws.rs.client.ClientRequestFilterReturns the default filter(s) for authorization.javax.ws.rs.client.ClientReturns the configured Jersey client.Returns the config of this client.protected StringReturns the User-Agent string to be injected in calls.Methods inherited from class rs.jerseyclient.util.AbstractClient
applyPaging, applySort, checkResponse, checkResponse, get, getLog, getRequest, getResults, getTarget, getTarget, getTarget, getTarget, setTarget
-
Field Details
-
NAME
Default name for User-Agent -
VERSION
Default version for User-Agent -
URL
Default URL for User-Agent
-
-
Constructor Details
-
JerseyClient
Constructor.Be aware that the constructor immediately calls
configure(JerseyClientConfig)andauthorize().- Parameters:
config- - the config to be used
-
JerseyClient
public JerseyClient(javax.ws.rs.client.Client config) Constructor.Be aware that the constructor immediately calls
authorize().- Parameters:
config- - the config to be used
-
-
Method Details
-
configure
Configures JAX-RS client and main web target based on this config.Calls
createClient()to actually create the client.- Parameters:
config- - the config to be used- See Also:
-
createClientConfig
protected org.glassfish.jersey.client.ClientConfig createClientConfig()Creates the Jersey client configuration based on the config for this client.Descendants can override this method in order to manipulate the config.
- Returns:
- the config to be used for the JAX-WS Jersey client.
-
createClient
protected javax.ws.rs.client.Client createClient()Creates the actual JAX-WS Jersey client instance.Desecendants can override this method when they want full control over the creation of the client.
Also calls
configure(Client).- Returns:
- the client
- See Also:
-
configure
protected void configure(javax.ws.rs.client.Client client) Configures the client by setting the default auth filter and - if applicable - the proxy filter.- Parameters:
client- the client to configure- See Also:
-
getUserAgent
Returns the User-Agent string to be injected in calls.- Returns:
- the user agent string
- See Also:
-
getAuthorizationFilter
protected javax.ws.rs.client.ClientRequestFilter getAuthorizationFilter()Returns the default filter(s) for authorization.- Returns:
- the authorization filter.
- See Also:
-
getClient
public javax.ws.rs.client.Client getClient()Returns the configured Jersey client.- Returns:
- the client
-
getConfig
Returns the config of this client.- Returns:
- the config
-
authorize
protected void authorize()Base method for authentication.The method is called after configuration from Constructor. You can override it to implement an automatic authentication.
The default implementation does nothing.
-
close
public void close()Close the client.
-