Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOCU-2817

...

magnolia
Include Page
_Maven is the easiest way to install
_Maven is the easiest way to install
Artifact maven dependencies snippet
rangeHigherVersion1.7
groupIdinfo.magnolia.restclient
artifactId

Code Block
<dependency>
  <groupId>info.magnolia.restclient</groupId>
  <artifactId>magnolia-rest-client-app</artifactId>
</dependency>

 app
Due to Maven transient dependencies, adding magnolia-rest-client-app to your bundle automatically adds the magnolia-rest-client and magnolia-resteasy-client modules. Include Page_Pre-built jars are also available_Pre-built jars are also available

...

Artifact resource link
rangeHigherVersion1.7
groupIdinfo.magnolia.restclient
artifactIdmagnolia-rest-client
label$artifactId.jar
renderTypedownload_link
resourceTypeJAR

...

Artifact resource link
rangeHigherVersion1.7
groupIdinfo.magnolia.restclient
artifactIdmagnolia-rest-client-app
label$artifactId.jar
renderTypedownload_link
resourceTypeJAR

...

.

...

...

Add all the submodules to your bundle.

...

  • magnolia-resteasy-client:  The easy-to-use Magnolia REST client implementation. It enables interface based service declaration. The module has a dependency to RESTEasy from JBoss.
  • magnolia-rest-client-app: Installs an app to test REST clients in the browser. You can test your clients in the app before using them in template scripts, models or other Java classes. See Testing clients in the REST client app
  • magnolia-rest-client:  Defines Defines the API for API for a Magnolia REST client definition class (to configure), for a REST client factory (to create instances) and for a registry (to obtain configured clients). It is an abstract layer which, besides the registry, you will hardly ever use directly.  If If you have existing Java clients based on jersey or raw javax.ws.rs, you can implement a custom 
    Javadoc resource link
    0info.magnolia.rest.client.factory.ClientFactory
    rangeHigherVersion1.7
    classNameinfo.magnolia.rest.client.factory.ClientFactory
    renderTypeasynchronous
    custom ClientFactory to instantiate your existing custom clients the Magnolia way. 

...

info.magnolia.rest.client.RestClientDefinition, for instance use info.magnolia.resteasy.client.RestEasyClientDefinition or
<rest client name>

required

Add a node for each REST client. The name is arbitrary, but it is good practice to use a descriptive name. The node name is used when obtaining instances of clients.

baseUrl

required

The base URL of the REST endpoint to connect with the client.

class

required

The definition class, it must implement

Javadoc resource link
0info.magnolia.rest.client.RestClientDefinition
rangeHigherVersion1.7
className
renderTypeasynchronous
Javadoc resource link
0info.magnolia.resteasy.client.RestEasyClientDefinition
rangeHigherVersion1.7
className
renderTypeasynchronous
Javadoc resource link
0info.magnolia.resteasy.client.SSLRestEasyClientDefinition
rangeHigherVersion1.7
classNameinfo.magnolia.resteasy.client.SSLRestEasyClientDefinition
renderTypeasynchronous
for SSLRestEasyClientDefinition for secure connections or subclasses.

If you rely on components or clientFilters, the definition class must extend Javadoc resource link0info.magnolia.resteasy.client.RestEasyClientDefinitionrangeHigherVersion1.7classNameinfo.magnolia.resteasy.client.RestEasyClientDefinitionrenderTypeasynchronous.

clientFactoryClass

required

The client factory class. Must implement Javadoc resource link0info.magnolia.rest.client.factory.ClientFactoryrangeHigherVersion1.7classNameinfo.magnolia.rest.client.factory.ClientFactoryrenderTypeasynchronous. Use Javadoc resource link0info.magnolia.resteasy.client.factory.RestEasyClientFactoryrangeHigherVersion1.7classNameinfo.magnolia.resteasy.client.factory.RestEasyClientFactoryrenderTypeasynchronous or

Javadoc resource link
0info.magnolia.resteasy.client.factory.SSLRestEasyClientFactory
rangeHigherVersion1.7
classNameinfo.magnolia.resteasy.client.factory.SSLRestEasyClientFactory
renderTypeasynchronous
for SSLRestEasyClientFactory for secure connections or subclasses.

cachable

optionaldefault is true

Enables the underlying caching mechanism provided by RESTEasy.

components

optional

1.0.8+

A list of components (e.g. ClientRequestFilter, ClientResponseFilter ). Registered components will be executed on every request.

clientFilters

optional

(warning) deprecated since 1.0.8, use components instead

 A list of components (e.g. ClientRequestFilter, ClientResponseFilter).

proxyDefinitions

optional

A map of

Javadoc resource link
0info.magnolia.resteasy.client.proxy.ClientServiceDefinition
rangeHigherVersion1.7
classNameinfo.magnolia.resteasy.client.proxy.ClientServiceDefinition
renderTypeasynchronous
objects. ClientServiceDefinition objects.

Note that ClientErrorInterceptor is not supported.

...

info.magnolia.resteasy.client.setup.RestEasyClientModuleVersionHandler adds restfn to renderer configurations. Make sure that the renderType of your template definition points to a renderer that is configured to use restfn. See Configure the functions in a renderer on how to add templating functions to a renderer.

Tip

During installation of the magnolia-resteasy-client module,  

Javadoc resource link
0info.magnolia.resteasy.client.setup.RestEasyClientModuleVersionHandler
rangeHigherVersion1.7
className
renderTypeasynchronous

...

Code Pro
languagejava
firstline1
linenumberstrue
sections%%(public class)%% -
urlhttps://git.magnolia-cms.com/projects/DOCUMENTATION/repos/rest-client-examples/browse/src/main/java/info/magnolia/documentation/modules/restclientexamples/model/JokesModel.java?at=master&raw
  • Add 
    Javadoc resource link
    0info.magnolia.rest.client.registry.RestClientRegistry
    rangeHigherVersion1.7
    classNameinfo.magnolia.rest.client.registry.RestClientRegistry
    renderTypeasynchronous
    Add RestClientRegistry as parameter into the constructor and assign it as final instance variable (See lines 5, 7, 9.)
  • Obtain 
    Javadoc resource link
    0RestEasyClient
    rangeHigherVersion1.7
    classNameRestEasyClient
    renderTypeasynchronous
    Obtain RestEasyClient object from the RestClientRegistry. Note that #getRestClient requires the configured name of the rest client definition. (See line 17.)
  • Create an instance of the declared interface IcndbService. (See line 18.)
  • Now call the declared method(s) on the service (line 23).

...