All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mp.guides.se-services.adoc Maven / Gradle / Ivy

There is a newer version: 4.1.1
Show newest version
///////////////////////////////////////////////////////////////////////////////

    Copyright (c) 2020, 2024 Oracle and/or its affiliates.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= Reusing Helidon SE services
:description: Helidon WebServer Routing
:keywords: helidon, guide, routing
:rootdir: {docdir}/../..

include::{rootdir}/includes/mp.adoc[]

This guide shows how reuse Helidon SE Service in your Helidon MP application.

== What You Need

For this 10 minute tutorial, you will need the following:

include::{rootdir}/includes/prerequisites.adoc[tag=prerequisites]

Helidon MP supports xref:../server.adoc[WebServer routing] which brings possibility for reusing
`io.helidon.webserver.HttpService` implementations in Helidon MP. Such feature can be quite useful for common
solutions for filtering, auditing, logging or augmenting REST endpoints in hybrid Helidon SE/MP environment.

Let's define simple Helidon SE Service for adding special header to every REST response:

[source,java]
----
include::{sourcedir}/mp/guides/SeServicesSnippets.java[tag=snippet_1, indent=0]
----

It's easy to use it with Helidon SE:

[source,java]
----
include::{sourcedir}/mp/guides/SeServicesSnippets.java[tag=snippet_2, indent=0]
----
<1> register service with routing path

And not much harder to use it with Helidon MP:

[source,java]
----
include::{sourcedir}/mp/guides/SeServicesSnippets.java[tag=snippet_3, indent=0]
----

You can leverage annotations:

* @RoutingPath - path of the WebServer service
* @RoutingName - select routing when xref:../server.adoc[serving requests on multiple ports]




© 2015 - 2024 Weber Informatics LLC | Privacy Policy