in chatterbox-imap/chatterbox-imap-impl/src/main/java/org/apache/tomee/chatterbox/imap/adapter/ImapResourceAdapter.java [370:421]
public void invoke(Message message) {
// Wrapper for convenient logging
final Email email;
try {
email = new Email(message);
} catch (MessagingException e) {
throw new IllegalStateException(e);
}
// find matching method(s)
final List<Method> matchingMethods =
Arrays.asList(clazz.getDeclaredMethods())
.stream()
.sorted((m1, m2) -> m1.toString().compareTo(m2.toString()))
.filter(this::isPublic)
.filter(this::isNotFinal)
.filter(this::isNotAbstract)
.filter(m -> filterSender(message, m))
.filter(m -> filterSubject(message, m))
.filter(m -> filterMessage(message, m))
.collect(Collectors.toList());
if (matchingMethods == null || matchingMethods.size() == 0) {
LOGGER.log(Level.INFO, "No method to match " + email);
return;
}
if (this.clazz.isAnnotationPresent(InvokeAllMatches.class)) {
for (final Method method : matchingMethods) {
LOGGER.log(level, "Invoking method " + method.toString() + " for " + email);
try {
invoke(method, InternetAddress.toString(message.getFrom()),
message.getSubject(),
getMessageText(message));
} catch (MessagingException e) {
LOGGER.log(Level.SEVERE, "Unable to invoke method " + method.toString() + " for " + email);
}
}
} else {
final Method method = matchingMethods.get(0);
LOGGER.log(level, "Invoking method " + method.toString() + " for " + email);
try {
invoke(method, InternetAddress.toString(message.getFrom()),
message.getSubject(),
getMessageText(message));
} catch (MessagingException e) {
LOGGER.log(Level.SEVERE, "Unable to invoke method " + method.toString() + " for " + email);
}
}
}