Skip to content

Instantly share code, notes, and snippets.

@jeevan-patil
Created July 29, 2017 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeevan-patil/4e72cc0ee9377d82177de512c3ffac9f to your computer and use it in GitHub Desktop.
Save jeevan-patil/4e72cc0ee9377d82177de512c3ffac9f to your computer and use it in GitHub Desktop.
Event Listener class.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@Component
public class EntityCreatedEventListener implements ApplicationListener<EntityCreatedEvent> {
@Autowired
private EmailService emailService;
@Override
public void onApplicationEvent(EntityCreatedEvent event) {
if (event.getEntity() != null) {
if (event.getEntity() instanceof Project) {
emailService.sendProjectCreatedMail(project.getOwnerEmail());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment