Server : Add a basic trait.
This commit is contained in:
parent
9086242ef6
commit
f79582b86e
6
src/main/scala/model/server/Server.scala
Normal file
6
src/main/scala/model/server/Server.scala
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package com.voronind.doublegis.test
|
||||||
|
package model.server
|
||||||
|
|
||||||
|
trait Server {
|
||||||
|
def listen(port: Int): Unit
|
||||||
|
}
|
|
@ -5,8 +5,8 @@ import model.handler.TitleCrawlerHandler
|
||||||
import com.sun.net.httpserver.HttpServer
|
import com.sun.net.httpserver.HttpServer
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
|
|
||||||
class TitleCrawlerServer {
|
class TitleCrawlerServer extends Server {
|
||||||
def listen(port: Int): Unit = {
|
override def listen(port: Int): Unit = {
|
||||||
val server = HttpServer.create(new InetSocketAddress(port), 0)
|
val server = HttpServer.create(new InetSocketAddress(port), 0)
|
||||||
server.createContext(TitleCrawlerHandler.context, new TitleCrawlerHandler())
|
server.createContext(TitleCrawlerHandler.context, new TitleCrawlerHandler())
|
||||||
server.setExecutor(null)
|
server.setExecutor(null)
|
||||||
|
|
Reference in a new issue