remove remaining kotlin code
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package com.baeldung
|
||||
|
||||
import org.springframework.boot.SpringApplication
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration
|
||||
|
||||
@SpringBootApplication(exclude = arrayOf(MongoReactiveDataAutoConfiguration::class))
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
SpringApplication.run(Application::class.java, *args)
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.baeldung
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
|
||||
@Document
|
||||
data class Event(val id: String, val name: String)
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.baeldung
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository
|
||||
|
||||
interface EventRepository : ReactiveMongoRepository<Event, String>
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.baeldung
|
||||
|
||||
import com.mongodb.reactivestreams.client.MongoClient
|
||||
import com.mongodb.reactivestreams.client.MongoClients
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate
|
||||
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableReactiveMongoRepositories(basePackageClasses = arrayOf(EventRepository::class))
|
||||
class MongoConfig : AbstractReactiveMongoConfiguration() {
|
||||
|
||||
override fun reactiveMongoClient(): MongoClient = mongoClient()
|
||||
|
||||
@Bean
|
||||
fun mongoClient(): MongoClient = MongoClients.create()
|
||||
|
||||
override fun getDatabaseName(): String = "mongoDatabase"
|
||||
|
||||
@Bean
|
||||
override fun reactiveMongoTemplate(): ReactiveMongoTemplate = ReactiveMongoTemplate(mongoClient(), databaseName)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.baeldung
|
||||
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.util.*
|
||||
|
||||
|
||||
@RestController
|
||||
class SendEmitter(val eventRepository: EventRepository) {
|
||||
|
||||
@GetMapping(value = "/save", produces = arrayOf(MediaType.TEXT_EVENT_STREAM_VALUE))
|
||||
fun executeExample(@RequestParam("eventName") eventName: String) =
|
||||
eventRepository.save(Event(UUID.randomUUID().toString(), eventName)).flux()
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<!-- Save new event -->
|
||||
<form method="get" action="/save">
|
||||
<input type="text" name="eventName">
|
||||
<button type="submit">Save new event</button>
|
||||
</form>
|
||||
|
||||
|
||||
<!-- Receive saved event -->
|
||||
<div id="content"></div>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
let source = new EventSource("save");
|
||||
|
||||
source.addEventListener('message', function (e) {
|
||||
console.log('New message is received');
|
||||
const index = JSON.parse(e.data);
|
||||
const content = `New event added: ${index.name}<br>`;
|
||||
document.getElementById("content").innerHTML += content;
|
||||
}, false);
|
||||
|
||||
source.addEventListener('open', function(e) {
|
||||
console.log('The connection has been opened');
|
||||
}, false);
|
||||
|
||||
source.addEventListener('error', function(e) {
|
||||
if (e.readyState == EventSource.CLOSED){
|
||||
console.log('The connection has been closed');
|
||||
}
|
||||
}, false);
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
<html>
|
||||
Reference in New Issue
Block a user