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

    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.

    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.

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

= Microprofile Introduction
:description: Helidon Microprofile introduction
:keywords: helidon, microprofile, micro-profile

MicroProfile is a platform definition that is familiar to Java EE developers. If you have experience with JAX-RS, JSON-P, and CDI, you 
may prefer to use this model.

To extend the functionality of your MicroProfile application, you might also decide to use the Helidon core APIs, especially for 
configuration and security.

== Getting Started with Helidon MicroProfile

Complete these tasks to get started with your MicroProfile application.

=== Maven Coordinates

Declare the following dependency in your project:

[source,xml]
.Maven Dependency
----
<dependency>
  <groupId>io.helidon.microprofile.bundles</groupId>
  <artifactId>helidon-microprofile-1.1</artifactId>
</dependency>
----

=== Project files

Create a JAX-RS Resource class with at least one resource method.

[source,java]
.Sample JAX-RS Resource Class
----
@Path("/")
@RequestScoped
public class HelloWorldResource {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String message() {
        return "Hello World";
    }
}
----

And create a JAX-RS application.
[source,java]
.Sample JAX-RS Application
----
@ApplicationScoped
@ApplicationPath("/")
public class HelloWorldApplication extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        return Set.of(
                HelloWorldResource.class
        );
    }
}
----

Add `beans.xml` in `src/main/resources/META-INF` so
the CDI implementation can pick up your classes.
[source,xml]
.beans.xml
----
<?xml version="1.0" encoding="UTF-8"?>
<beans/>
----

As a last step, add a main method to your application (or a dedicated Main class)
 to start everything up.

[source,java]
.Sample JAX-RS Application
----
public static void main(String[] args) {
    io.helidon.microprofile.server.Main.main(args);
}
----

Run the main class. The server will start on port 7001 and serve your
 resources.

=== Adding Jandex

Jandex is an indexing tool for Weld (CDI implementation) that helps speed up
the boot time of an application.

To use Jandex, configure a Maven plugin that adds the index to your
 JAR file and a dependency on Jandex.

[source,xml]
.jandex dependency
----
<dependency>
    <groupId>org.jboss</groupId>
    <artifactId>jandex</artifactId>
    <version>2.0.4.Final</version>
</dependency>
----

[source,xml]
.jandex plugin configuration
----
<build>
    <plugins>
        <plugin>
            <groupId>org.jboss.jandex</groupId>
            <artifactId>jandex-maven-plugin</artifactId>
            <version>1.0.5</version>
            <executions>
                <execution>
                    <id>make-index</id>
                    <goals>
                        <goal>jandex</goal>
                    </goals>
                    <phase>process-classes</phase>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
----
