From caa767f83b9d6107d0bd0c3e8af1dc6304f64daf Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 16 Oct 2018 13:13:01 +1300 Subject: Add injector to the project --- src/org/traccar/Main.java | 9 +++++++++ src/org/traccar/MainModule.java | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/org/traccar/MainModule.java (limited to 'src') diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 48f2323ba..c85d93431 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -15,6 +15,8 @@ */ package org.traccar; +import com.google.inject.Guice; +import com.google.inject.Injector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +36,12 @@ public final class Main { private static final long CLEAN_PERIOD = 24 * 60 * 60 * 1000; + private static Injector injector; + + public static Injector getInjector() { + return injector; + } + private Main() { } @@ -100,6 +108,7 @@ public final class Main { public static void run(String configFile) { try { Context.init(configFile); + injector = Guice.createInjector(new MainModule()); logSystemInfo(); LOGGER.info("Version: " + Context.getAppVersion()); LOGGER.info("Starting server..."); diff --git a/src/org/traccar/MainModule.java b/src/org/traccar/MainModule.java new file mode 100644 index 000000000..99f665134 --- /dev/null +++ b/src/org/traccar/MainModule.java @@ -0,0 +1,26 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar; + +import com.google.inject.AbstractModule; + +public class MainModule extends AbstractModule { + + @Override + protected void configure() { + } + +} -- cgit v1.2.3