This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class ProjectServiceImpl implements ProjectService { | |
@Autowired | |
private ApplicationEventPublisher applicationEventPublisher; | |
@Override | |
public void createProject(Project project) { | |
// save project entity in the database and publish an event to send mail to project owner | |
publishProjectCreatedEvent(project); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.context.ApplicationEvent; | |
public class EntityCreatedEvent<T> extends ApplicationEvent { | |
private T entity; | |
public EntityCreatedEvent(Object source, T entity) { | |
super(source); | |
this.entity = entity; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.jeevan.api.domain; | |
import org.springframework.data.annotation.Id; | |
import org.springframework.data.mongodb.core.mapping.Document; | |
/** | |
* Projects mongo document. | |
*/ | |
@Document(collection = "projects") | |
public class Project { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig"> | |
<property name="poolName" value="mercatus_connection_pool" /> | |
<property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"/> | |
<property name="maximumPoolSize" value="50" /> | |
<property name="maxLifetime" value="60000" /> | |
<property name="idleTimeout" value="30000" /> | |
<property name="dataSourceProperties"> | |
<props> | |
<prop key="url">${jdbc.url}</prop> | |
<prop key="user">${jdbc.username}</prop> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.zaxxer</groupId> | |
<artifactId>HikariCP-java7</artifactId> | |
<version>2.4.12</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.mchange</groupId> | |
<artifactId>c3p0</artifactId> | |
<version>0.9.5.2</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> | |
<property name="driverClass" value="${jdbc.driverClassName}"/> | |
<property name="jdbcUrl" value="${jdbc.url}"/> | |
<property name="user" value="${jdbc.username}"/> | |
<property name="password" value="${jdbc.password}"/> | |
<property name="minPoolSize" value="10"/> | |
<property name="maxPoolSize" value="50"/> | |
<property name="acquireIncrement" value="1"/> | |
<property name="idleConnectionTestPeriod" value="1000"/> | |
<property name="maxStatements" value="250"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"> | |
<property name="driverClassName" value="${jdbc.driverClassName}"/> | |
<property name="url" value="${jdbc.url}"/> | |
<property name="username" value="${jdbc.username}"/> | |
<property name="password" value="${jdbc.password}"/> | |
<property name="initialSize" value="10" /> | |
<property name="maxTotal" value="50" /> | |
</bean> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.apache.commons</groupId> | |
<artifactId>commons-dbcp2</artifactId> | |
<version>2.1.1</version> | |
</dependency> |
NewerOlder