Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions oap-application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Services are plain Java classes — no framework annotations required. Everythin
- [Application Configuration (application.conf)](#application-configuration-applicationconf)
- [Reference Syntax](#reference-syntax)
- [Supervision and Service Lifecycle](#supervision-and-service-lifecycle)
- [Lifecycle Annotations](#lifecycle-annotations)
- [Dependency Injection Mechanics](#dependency-injection-mechanics)
- [Abstract Services](#abstract-services)
- [Module Discovery](#module-discovery)
Expand Down Expand Up @@ -322,6 +323,42 @@ On `kernel.stop()`, the `Supervisor` stops services in reverse registration orde

`shutdown.serviceTimeout` (default `5s`) is the warn threshold per service. Set `shutdown.serviceAsyncShutdownAfterTimeout = true` to continue shutdown after a timeout rather than waiting.

### Lifecycle Annotations

As an alternative to relying on method names (`preStart`, `start`, etc.), lifecycle hooks can be declared with annotations from the `oap.application.annotation` package. The kernel discovers annotated methods at startup regardless of their name.

| Annotation | Phase | Equivalent supervision field |
|---|---|---|
| `@PreStart` | Before service start | `preStartWith` |
| `@Start` | Service start | `startWith` |
| `@PreStop` | Before service stop | `preStopWith` |
| `@Stop` | Service stop | `stopWith` |

Annotations and name-based discovery are independent — both are applied. An annotated method named `start` is invoked by both paths; an annotated method with any other name is invoked only via the annotation.

```java
import oap.application.annotation.PreStart;
import oap.application.annotation.Start;
import oap.application.annotation.PreStop;
import oap.application.annotation.Stop;

public class MyService {
@PreStart
public void onBeforeStart() { /* runs before start */ }

@Start
public void onStart() { /* runs on start */ }

@PreStop
public void onBeforeStop() { /* runs before stop */ }

@Stop
public void onStop() { /* runs on stop */ }
}
```

The service still needs `supervision.supervise = true` in its `oap-module.oap` declaration.

---

## Dependency Injection Mechanics
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</dependencies>

<properties>
<oap.project.version>25.7.5</oap.project.version>
<oap.project.version>25.7.6</oap.project.version>

<oap.deps.config.version>25.0.1</oap.deps.config.version>
<oap.deps.oap-teamcity.version>25.0.0</oap.deps.oap-teamcity.version>
Expand Down
Loading