# CDI Sample

This sample application presents some of the CDI and EJB features supported by Tyrus.

## Contents

The sample comprises of six endpoints, four beans that are injected into the endpoints and one interceptor. The logic behind all endpoints is very similar. Once the endpoint receives a message, it calls a method on the injected bean which returns either text data "(sent from your server)", or value of the inner counter (which gets incremented by 1) for each method call. The endpoint then sends back a message which is a concatenation of the original message and gathered data.

Endpoint | Injected Bean | URI path
--- | --- | ---
org.glassfish.tyrus.sample.cdi.ApplicationScopedEndpoint | org.glassfish.tyrus.sample.cdi.InjectedApplicationScoped | "/injectingappscoped"
org.glassfish.tyrus.sample.cdi.SimpleEndpoint | org.glassfish.tyrus.sample.cdi.InjectedSimpleBean | "/simple"
org.glassfish.tyrus.sample.cdi.InjectToSingletonEndpoint | org.glassfish.tyrus.sample.cdi.InjectedSingletonBean | "/injectingsingleton"
org.glassfish.tyrus.sample.cdi.InjectToStatefulEndpoint | org.glassfish.tyrus.sample.cdi.InjectedStatefulBean | "/injectingstateful"
org.glassfish.tyrus.sample.cdi.SingletonEndpoint | --- | "/singleton"
org.glassfish.tyrus.sample.cdi.StatefulEndpoint | --- | "/stateful"

## Running the Example

Run the example as follows: deploy:

> `$AS_MAIN/bin/asadmin start-domain`

> `$AS_MAIN/bin/asadmin deploy --force ./target/*war`

From a web browser, visit:

> `http://localhost:8080/sample-cdi`

When running the application, the user is expected to press a button, which sends a message to the respective endpoint. The endpoint replies with a message which allows the user to verify that the bean was injected properly. This message is displayed on the screen.