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

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

Simple (Native Java) Service Container for Furnace
https://github.com/forge/furnace-simple

Last synced: 9 months ago
JSON representation

Simple (Native Java) Service Container for Furnace

Awesome Lists containing this project

README

          

== Furnace Container: Simple
:idprefix: id_

image:https://forge.ci.cloudbees.com/job/furnace-simple/badge/icon["Build Status", link="https://forge.ci.cloudbees.com/job/furnace-simple/"]
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.
Addons may depend on this to provide service instances to dependencies.

=== 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
simple
forge-addon
${version}


=== Add classes to the simple service registry.
In order for dependencies to use your services, you must add service types to the service registry.

== Features

Provides simple service registration mechanism::
Service types should never extend the `org.jboss.forge.furnace.container.simple.Service` interface.
+
[source,java]
----
public class ExampleService
{
// ...
}
----
+
Service types may also receive the `Furnace` container instance as a constructor parameter:
+
[source,java]
----
public class ExampleService
{
public ExampleService(Furnace furnace) {
// do something constructor-like
}
}
----
+
To register a type as a service, a file must be created with the name
`META-INF/services/org.jboss.forge.furnace.container.simple.Service`, and each service type name must be
added to this file on a separate line:
+
Example registration file:
+
[source,text]
----
META-INF/services/org.jboss.forge.furnace.container.simple.Service
......
org.example.ExampleService
org.example.ExampleService2
org.my.custom.MyService
......
----
TIP: Services registered in this way must exist in the same JAR file as the registry file.

Provides simple event listening mechanism::
To register an `EventListener`, a file must be created with the name `META-INF/services/org.jboss.forge.furnace.container.simple.EventListener`, and each `EventListener` implementation type name must be added on a separate line:
+
[source,java]
----
public class ExampleEventListener implements EventListener
{
public void handleEvent(Object event, Annotation... qualifiers)
{
System.out.println("Handled event: " + event)
}
}
----
+
Example registration file:
[source,text]
----
META-INF/services/org.jboss.forge.furnace.container.simple.EventListener
......
org.example.ExampleEventListener
org.example.ExampleEventListener2
org.my.custom.MyEventListener
......
----
TIP: Listeners registered in this way must exist in the same JAR file as the registry file.