Commit 67bf379d authored by seykron's avatar seykron

Updates dependencies and configuration

parent 8e1ac844
......@@ -24,7 +24,7 @@
<junit-jupiter.version>5.3.1</junit-jupiter.version>
<reactor-test.version>3.2.5.RELEASE</reactor-test.version>
<assertj.version>3.11.1</assertj.version>
<mockito.version>2.23.0</mockito.version>
<mockito.version>2.28.2</mockito.version>
<mockito-kotlin.version>1.6.0</mockito-kotlin.version>
<bytebuddy.version>[1.9,)</bytebuddy.version>
......@@ -34,11 +34,12 @@
<joda.version>2.10</joda.version>
<dockerfile-maven-version>1.4.10</dockerfile-maven-version>
<typesafe.version>1.3.3</typesafe.version>
<springframework.all.version>5.0.6.RELEASE</springframework.all.version>
<netty.version>0.7.14.RELEASE</netty.version>
<antifaz.version>1.5.0</antifaz.version>
<springframework.all.version>5.1.5.RELEASE</springframework.all.version>
<netty.version>0.8.9.RELEASE</netty.version>
<tehanu.version>2.0.2</tehanu.version>
<h2.version>1.4.197</h2.version>
<kotlin.version>1.3.21</kotlin.version>
<kotlin.version>1.3.40</kotlin.version>
<kotlin-coroutines.version>1.1.1</kotlin-coroutines.version>
<kotlin.code.style>official</kotlin.code.style>
</properties>
......@@ -101,6 +102,12 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
......@@ -194,28 +201,23 @@
<version>${springframework.all.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.ipc</groupId>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>${netty.version}</version>
</dependency>
<!-- Dependency injection -->
<!-- Tehanu -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springframework.all.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<groupId>be.rlab</groupId>
<artifactId>tehanu</artifactId>
<version>${tehanu.version}</version>
</dependency>
<!-- Antifaz -->
<!-- Data Access -->
<dependency>
<groupId>be.rlab</groupId>
<artifactId>antifaz</artifactId>
<version>${antifaz.version}</version>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
......
......@@ -2,35 +2,48 @@ package be.rlab.eoc
import be.rlab.eoc.config.DomainBeans
import be.rlab.eoc.config.WebConfig
import be.rlab.tehanu.config.DataSourceBeans
import be.rlab.tehanu.config.MemoryBeans
import be.rlab.tehanu.util.persistence.DataSourceInitializer
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.getBean
import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.http.server.reactive.HttpHandler
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter
import org.springframework.web.reactive.DispatcherHandler
import org.springframework.web.server.WebHandler
import org.springframework.web.server.adapter.WebHttpHandlerBuilder
import reactor.ipc.netty.http.server.HttpServer
import reactor.netty.http.server.HttpServer
import java.time.Duration
class Application(port: Int = 8080) {
class Application(port: Int = 8090) {
private val httpHandler: HttpHandler
private val logger: Logger = LoggerFactory.getLogger(Application::class.java)
private val server: HttpServer
private val httpHandler: HttpHandler
init {
val context = AnnotationConfigApplicationContext {
DataSourceBeans.beans().initialize(this)
MemoryBeans.beans().initialize(this)
DomainBeans.beans().initialize(this)
register(WebConfig::class.java)
refresh()
}
val handler: WebHandler = DispatcherHandler(context)
logger.info("Initializing data source")
val dataSourceInitializer: DataSourceInitializer = context.getBean()
dataSourceInitializer.init()
server = HttpServer.create(port)
httpHandler = WebHttpHandlerBuilder
.webHandler(handler)
.applicationContext(context)
.build()
server.startAndAwait(ReactorHttpHandlerAdapter(httpHandler))
HttpServer.create()
.port(port)
.handle(ReactorHttpHandlerAdapter(httpHandler))
.bindUntilJavaShutdown(Duration.ZERO) {
logger.info("Application started")
}
}
}
......
......@@ -5,6 +5,7 @@ import be.rlab.eoc.domain.model.Notification
data class NotificationDTO(
val userName: String,
val subject: String,
val summary: String,
val eventType: String,
val additionalData: Map<String, String>
) {
......@@ -13,6 +14,7 @@ data class NotificationDTO(
return Notification.new(
userName = userName,
subject = subject,
summary = summary,
eventType = eventType,
additionalData = additionalData
)
......
package be.rlab.eoc.config
import be.rlab.antifaz.bot.memory.DatabaseMemory
import be.rlab.antifaz.domain.persistence.MemorySlots
import be.rlab.antifaz.domain.persistence.MemorySlotsDAO
import be.rlab.eoc.domain.NotificationService
import be.rlab.eoc.util.ObjectMapperFactory
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.deleteAll
import org.jetbrains.exposed.sql.transactions.transaction
import org.springframework.context.support.beans
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
object DomainBeans {
fun beans() = beans {
bean<DatabaseMemory>()
bean {
val db: Database = Database.connect(
url = System.getenv("db.connection_string"),
driver = System.getenv("db.driver")
)
transaction(db) {
SchemaUtils.create(MemorySlots)
}
MemorySlotsDAO(
db = db
)
}
bean<NotificationService>()
bean {
MappingJackson2HttpMessageConverter(ObjectMapperFactory.snakeCaseMapper)
}
bean<NotificationService>()
}
}
\ No newline at end of file
package be.rlab.eoc.domain
import be.rlab.antifaz.bot.Memory
import be.rlab.eoc.domain.model.Notification
import be.rlab.tehanu.domain.Memory
class NotificationService(
memory: Memory
......
package be.rlab.eoc.domain.model
enum class Flag {
SEEN,
UNSEEN,
ANSWERED,
DRAFT,
DELETED,
FLAGGED
}
package be.rlab.eoc.domain.model
import be.rlab.antifaz.domain.command.inbox.model.Flag
import org.joda.time.DateTime
data class Notification(
val userName: String,
val subject: String,
val summary: String,
val timestamp: DateTime,
val eventType: String,
val additionalData: Map<String, String>,
......@@ -15,11 +15,13 @@ data class Notification(
fun new(
userName: String,
subject: String,
summary: String,
eventType: String,
additionalData: Map<String, String>
): Notification = Notification(
userName = userName,
subject = subject,
summary = summary,
timestamp = DateTime.now(),
eventType = eventType,
additionalData = additionalData,
......
db {
url: "jdbc:h2:file:./db/default"
url: "jdbc:h2:tcp://localhost:7777/tmp/h2-data-antifaz"
url: ${?db_url}
user: "sa"
user: ${?db_user}
password: ""
password: ${?db_password}
driver: "org.h2.Driver"
driver: ${?db_driver}
log-statements: false
}
q
classifiers: [{
category: "jobs",
resource-location: "/classifiers/jobs.txt"
}, {
category: "first_names",
resource-location: "/classifiers/first_names.txt"
}]
......@@ -13,9 +13,11 @@
<logger name="reactor" level="ERROR" />
<logger name="io.netty" level="INFO" />
<logger name="org.springframework" level="INFO" />
<logger name="org.springframework" level="DEBUG" />
<logger name="com.zaxxer" level="INFO" />
<logger name="Exposed" level="INFO" />
<root level="debug">
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment