https://github.com/forge/furnace-guice
Furnace Guice Service Container
https://github.com/forge/furnace-guice
Last synced: 7 months ago
JSON representation
Furnace Guice Service Container
- Host: GitHub
- URL: https://github.com/forge/furnace-guice
- Owner: forge
- Created: 2015-08-05T21:00:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-12-07T00:17:41.000Z (over 9 years ago)
- Last Synced: 2025-07-22T06:35:46.117Z (8 months ago)
- Language: Java
- Size: 57.6 KB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.asciidoc
Awesome Lists containing this project
README
== Furnace Container: Guice
:idprefix: id_
image:https://forge.ci.cloudbees.com/job/furnace-guice/badge/icon["Build Status", link="https://forge.ci.cloudbees.com/job/furnace-guice/"]
image:http://img.shields.io/:license-EPL-blue.svg["License", link="https://www.eclipse.org/legal/epl-v10.html"]
image:https://maven-badges.herokuapp.com/maven-central/org.jboss.forge.furnace.container/guice/badge.svg["Maven Central", link="https://maven-badges.herokuapp.com/maven-central/org.jboss.forge.furnace.container/guice"]
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 Guice programming model and dependency injection framework.
=== Dependencies: None
== Setup
This Addon requires the following installation steps.
=== Add configuration to pom.xml
To use this addon, you must add it as a dependency in the *pom.xml* of your `forge-addon` classified artifact:
[source,xml]
----
org.jboss.forge.furnace.container
guice
forge-addon
${version}
----
== Create a `com.google.inject.Module` implementation as a Service provider in your addon
In order for Guice to detect your services, you must add a `src/main/resources/META-INF/services/com.google.inject.Module` file in your project containing the `com.google.inject.Module` implementation.
== Features
Observable events::
The Furnace container publishes several observable events to all addons throughout their lifecycle. In order to listen for events, implement the `org.jboss.forge.furnace.container.guice.EventListener` interface.
[source,java]
----
public class MyEmitter {
@Inject
EventManager eventManager;
public void fire() {
eventManager.fireEvent("FOO");
}
}
public class MyObserver implements EventListener {
public void handleEvent(Object event, Annotation ... qualifiers) {
// "FOO".equals(event) == true
}
}
----
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.
|===