An open API service indexing awesome lists of open source software.

https://github.com/forge/furnace-cdi

Furnace CDI Service Container
https://github.com/forge/furnace-cdi

Last synced: 6 months ago
JSON representation

Furnace CDI Service Container

Awesome Lists containing this project

README

          

== Furnace Container: CDI
:idprefix: id_

image:https://travis-ci.org/forge/furnace-cdi.svg?branch=master["Build Status", link="https://travis-ci.org/forge/furnace-cdi"]
image:http://img.shields.io/:license-EPL-blue.svg["License", link="https://www.eclipse.org/legal/epl-v10.html"]

This addon is a 'Furnace container' that provides *lifecycle* and *service registry* support for dependent addons.
Other addons may depend on this to use the http://www.cdi-spec.org/[CDI 2.0] programming model and dependency injection
framework.

=== Dependencies: None

== Setup

This Addon requires the following installation steps.

=== Add configuration to pom.xml

To use this Furnace container, you must add it as a dependency in the *pom.xml* of your `forge-addon` classified artifact:


org.jboss.forge.furnace.container
cdi
forge-addon
${version}


=== Add META-INF/beans.xml file
In order for CDI to detect your classes, you must add the `src/main/resources/META-INF/beans.xml` file to your project.

== Features

Full CDI support::
Your addon may use the full CDI specification, provide CDI extensions, and do anything that would otherwise be possible
in a Java SE or Java EE CDI environment.

Automatic service registration::
CDI Beans will automatically be added to the local `ServiceRegistry` for use in other addons.

public class ServiceX {
// Will be available for use in dependent addons
}

Injection of services:: Any types declared as dependencies of your addon will be made
available via the dependency injection model. Service wiring occurs automatically.

public class ConsumerY {
@Inject private ServiceX service; // From some other Addon
}

Observable container events::
The Furnace container publishes several observable events to all addons throughout their lifecycle.

[options="header"]
|===
|Event Type |Description

|@PostStartup
|Fired when this addon is has been fully started by the Furnace container, and may begin its work.

|@PreShutdown
|Fired when this addon is about to be shut down by the Furnace container.

|===

Automatic event propagation::
This container will automatically re-fire any CDI events for all other addons to observe. It also
automatically listens for remote events and re-fires them for your local beans to observe.

Injection of Furnace APIs:: This container also allows for injection of some of the core Furnace APIs into your
objects. Below is a list of all injectable API types.

[options="header"]
|===
|Injectable Type |Description

|@Inject private Furnace service;
|A handle to the Furnace container in which this addon is being run.


|@Inject private Addon self;
|A reference to this addon itself. Allows access to the addon version, `ClassLoader`, service registry, current
lifecycle status, and addon dependencies.

|@Inject private AddonRegistry addonRegistry;
|A reference to the global Furnace addon registry - can be used to retrieve addon and exported service instances.

|@Inject private AddonRepository repository;
|A reference to the repository in which this addon is deployed. Can be used to

|@Inject private ServiceRegistry serviceRegistry;
|A reference to the service registry of this addon. Can be used to retrieve service instances from this addon at
runtime.

|===