From 5a2019f8ebc1a66aa751da8edf7561b3eb519138 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 23 Jul 2018 16:09:59 +0100 Subject: [PATCH] first pass at main point --- .../main/groovy/com/muwire/core/Core.groovy | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/Core.groovy b/core/src/main/groovy/com/muwire/core/Core.groovy index 6043ba37..f6a17bc2 100644 --- a/core/src/main/groovy/com/muwire/core/Core.groovy +++ b/core/src/main/groovy/com/muwire/core/Core.groovy @@ -1,9 +1,44 @@ package com.muwire.core +import com.muwire.core.trust.TrustEvent +import com.muwire.core.trust.TrustService + +import groovy.util.logging.Log + +@Log class Core { static main(args) { - println "This doesn't do anything yet" + def home = System.getProperty("user.home") + File.separator + ".MuWire" + home = new File(home) + if (!home.exists()) { + log.info("creating home dir") + home.mkdir() + } + + def props = new Properties() + def propsFile = new File(home, "MuWire.properties") + if (propsFile.exists()) { + log.info("loading existing props file") + propsFile.withInputStream { + props.load(it) + } + } else + log.info("creating default properties") + + props = new MuWireSettings(props) + + + EventBus eventBus = new EventBus() + + log.info("initializing trust service") + File goodTrust = new File(home, "trust.good") + File badTrust = new File(home, "trust.bad") + TrustService trustService = new TrustService(goodTrust, badTrust, 5000) + eventBus.register(TrustEvent.class, trustService) + trustService.start() + trustService.waitForLoad() + } }