Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
Update README.md #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Orlova committed Jul 28, 2021
1 parent e36cb11 commit 7d5f288
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [Add-on Configuration](#add-on-configuration)
- [Usage](#usage)
- [Predefined Roles](#predefined-roles)
- [Component Functionalities](#component-functionalities)
- [Add-on Functionalities](#add-on-functionalities)
- [IMAP Configuration](#imap-configuration)
- [IMAP Message Browser](#imap-message-browser)
- [Registering EventListeners to Interact with IMAP Events](#registering-eventlisteners-to-interact-with-imap-events)
Expand Down Expand Up @@ -40,20 +40,33 @@ implementation 'io.jmix.imap:jmix-imap-ui-starter'

# Add-on Configuration

### Password Encryption
There is an ability to override default values of properties required to encrypt a password for a mailbox:

Open `application.properties` file of your application and configure the following application properties:

1. ```jmix.imap.encryption.key```
2. ```jmix.imap.encryption.iv```

### IMAP Messages Synchronization
There is a default scheduled task for the IMAP message synchronization. The implementation of the scheduled task is based on [Quartz Job Scheduler](https://www.quartz-scheduler.org/).
To use this task, add the dependency in the ```build.gradle```:
```groovy
implementation 'org.springframework.boot:spring-boot-starter-quartz'
```

There are the following properties to configure default scheduled task:
1. ```jmix.imap.useDefaultQuartzConfiguration``` - allows enable/disable task. Default value: ```true```.
2. ```jmix.imap.imapSyncCron``` - contains [CRON expression](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html) for the task.
Default value: ```0 * * * * ?``` which means "every minute".

# Usage

## Predefined Roles

**IMAP Admin role** - allows user to configure IMAP events.

## Component Functionalities
## Add-on Functionalities

### IMAP Configuration

Expand Down Expand Up @@ -139,7 +152,8 @@ The *Attachments* tab comprises the table of attachments and the button to downl

## Registering EventListeners to Interact with IMAP Events

In order to make your application react to IMAP events, you can register the `@Component` methods as Event listeners by using
There are two ways to register an event listener for the IMAP event.
1. You can register the `@Component` methods as Event listeners by using
the `@EventListener` annotation. The example of how to set up an event listener is provided below.

```java
Expand All @@ -155,10 +169,13 @@ public class EmailReceiveServiceBean implements EmailReceiveService {
}
}
```
In this case it is not required to add a handler for a particular folder and event in the IMAP Configuration Editor.
The ```receiveEmail``` method will be automatically invoked after ```NewEmailImapEvent``` occurs.

Another option is to create `@Component` with a method having the required event type as the only parameter.
2. Another option is to create `@Component` with a method having the required event type as the only parameter.

```java
@Component(EmailReceiver.NAME)
public class EmailReceiver {
String NAME = "ceuia_EmailReceiver";

Expand All @@ -168,7 +185,7 @@ public class EmailReceiver {
}
```

Once it is done, the selected method (in the example, it is `receiveEmail`) should be registered on a particular folder
Once it is done, the selected method (in the example, it is `receiveEmail`) should be registered on a particular folder and event type
for a given IMAP connection. This should be done at runtime using the IMAP configuration UI (see [Creating Handlers for
IMAP Events](#creating-handlers-for-imap-events)).
After that, the method will be invoked every time, when the configured event occurs.
Expand Down

0 comments on commit 7d5f288

Please sign in to comment.