Skip to content

Commit 2a70056

Browse files
committed
Document Lifecycle support
This closes #73
1 parent 3a8b268 commit 2a70056

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Lifecycle Support
2+
3+
Each Sisu managed bean/component may optionally use annotations on methods to be called whenever the bean is started or stopped.
4+
5+
Those are
6+
7+
Annotation | Method called... | Leveraged Guice Hook
8+
--- | ---
9+
`org.eclipse.sisu.PostConstruct` (or `javax.annotation.PostConstruct`) | Before bean is started | [`com.google.inject.spi.InjectionListener.afterInjection(...)`](https://google.github.io/guice/api-docs/6.0.0/javadoc/com/google/inject/spi/InjectionListener.html#afterInjection(I))
10+
`org.eclipse.sisu.PreDestroy` (or `javax.annotation.PreDestroy.`) | Before bean is stopped | Is not called by default, only via [Plexus API](../org.eclipse.sisu.plexus).
11+
12+
The annotations defined in [JSR 250](https://jcp.org/en/jsr/detail?id=250) are recognized in addition to the native Sisu ones when their classes are detected in the class path.
13+
14+
The support needs to be explicitly enabled by passing an instance of [`org.eclipse.sisu.bean.LifecycleModule`](apidocs/org/eclipse/sisu/bean/LifecycleModule.html) when creating the `Injector`.

org.eclipse.sisu.inject/src/site/site.xml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<menu name="Overview">
1515
<item name="Introduction" href="index.html"/>
1616
<item name="Named Index" href="named-index.html"/>
17+
<item name="Lifecycle Support" href="lifecycle.html"/>
1718
</menu>
1819
</body>
1920
</site>

org.eclipse.sisu.plexus/src/site/markdown/conversion-to-jsr330.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ public class MyComponent
458458

459459
### Startable
460460

461-
Support for JSR250 lifecycle annotations is available when enabled for the Plexus wrapper (\[Maven 3.5+\](https://issues.apache.org/jira/browse/MNG-6084) enables JSR250 support). If JSR250 support is not enabled then applications can use other techniques to handle start/stop behavior. The examples below show the solution used in Sonatype Nexus, which relies on a modified implementation of the Google-Guava EventBus to manage lifecycle events.
461+
Support for [Sisu/JSR250 lifecycle annotations](../org.eclipse.sisu.inject/lifecycle.html) is available when enabled for the Plexus wrapper (\[Maven 3.5+\](https://issues.apache.org/jira/browse/MNG-6084) enables JSR250 support).
462+
463+
If JSR250 support is not enabled then applications can use other techniques to handle start/stop behavior. The examples below show the solution used in Sonatype Nexus, which relies on a modified implementation of the Google-Guava EventBus to manage lifecycle events.
462464

463465
```
464466
@Component(role=Component.class, hint="my")

0 commit comments

Comments
 (0)