Skip to content

io microsphere event EventListener

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

EventListener

Type: Interface | Module: microsphere-java-core | Package: io.microsphere.event | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/event/EventListener.java

Overview

The Event Event Listener that is based on Java standard java.util.EventListener interface supports the generic Event.

The #onEvent(Event) handle method will be notified when the matched-type Event Event is published, whose priority could be changed by #getPriority() method.

Example Usage

Here is a simple example of how to implement this interface:

`public class MyEventListener implements EventListener {

    private final int priority;

    public MyEventListener(int priority) {
        this.priority = priority;
    `

### Declaration

```java
public interface EventListener extends java.util.EventListener, Prioritized
```

**Author:** Mercy

## Version Information

- **Introduced in:** `1.0.0`
- **Current Project Version:** `0.1.10-SNAPSHOT`

## Version Compatibility

This component is tested and compatible with the following Java versions:

| Java Version | Status |
|:---:|:---:|
| Java 8 | ✅ Compatible |
| Java 11 | ✅ Compatible |
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |

## Examples

```java
public class MyEventListener implements EventListener {

    private final int priority;

    public MyEventListener(int priority) {
        this.priority = priority;
    }

    @Override
    public void onEvent(MyEvent event) {
        // Handle the event
    }

    @Override
    public int getPriority() {
        return priority;
    }
}
```

## Usage

### Maven Dependency

Add the following dependency to your `pom.xml`:

```xml

    io.github.microsphere-projects
    microsphere-java-core
    ${microsphere-java.version}

```

> **Tip:** Use the BOM (`microsphere-java-dependencies`) for consistent version management. See the [Getting Started](https://github.com/microsphere-projects/microsphere-java#getting-started) guide.

### Import

```java
import io.microsphere.event.EventListener;
```

## API Reference

### Public Methods

| Method | Description |
|--------|-------------|
| `onEvent` |  |
| `onEvent` |  |
| `onEvent` |  |

## See Also

- `Event`
- `java.util.EventListener`

---

*This documentation was auto-generated from the source code of [microsphere-java](https://github.com/microsphere-projects/microsphere-java).*

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally