From aa1361d04cfe09f90e7d8bece90c00dd6e4185bb Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 03 Jul 2014 16:57:47 -0400
Subject: [PATCH] Replace Dagger with Guice 4.0 beta and update Guava to 16.0.1

---
 src/main/java/com/gitblit/manager/RuntimeManager.java |   61 +++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/gitblit/manager/RuntimeManager.java b/src/main/java/com/gitblit/manager/RuntimeManager.java
index 9805701..00fe1c9 100644
--- a/src/main/java/com/gitblit/manager/RuntimeManager.java
+++ b/src/main/java/com/gitblit/manager/RuntimeManager.java
@@ -18,8 +18,11 @@
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
+
+import javax.inject.Inject;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,6 +49,7 @@
 
 	private TimeZone timezone;
 
+	@Inject
 	public RuntimeManager(IStoredSettings settings) {
 		this(settings, null);
 	}
@@ -63,6 +67,8 @@
 		logger.info("Settings    : " + settings.toString());
 		logTimezone("JVM timezone: ", TimeZone.getDefault());
 		logTimezone("App timezone: ", getTimezone());
+		logger.info("JVM locale  : " + Locale.getDefault());
+		logger.info("App locale  : " +  (getLocale() == null ? "<client>" : getLocale()));
 		return this;
 	}
 
@@ -116,9 +122,42 @@
 	 */
 	@Override
 	public boolean isServingRepositories() {
-		return settings.getBoolean(Keys.git.enableGitServlet, true)
-				|| (settings.getInteger(Keys.git.daemonPort, 0) > 0)
-				|| (settings.getInteger(Keys.git.sshPort, 0) > 0);
+		return isServingHTTP()
+				|| isServingGIT()
+				|| isServingSSH();
+	}
+
+	/**
+	 * Determine if this Gitblit instance is actively serving git repositories
+	 * over the HTTP protocol.
+	 *
+	 * @return true if Gitblit is serving repositories over the HTTP protocol
+	 */
+	@Override
+	public boolean isServingHTTP() {
+		return settings.getBoolean(Keys.git.enableGitServlet, true);
+	}
+
+	/**
+	 * Determine if this Gitblit instance is actively serving git repositories
+	 * over the Git Daemon protocol.
+	 *
+	 * @return true if Gitblit is serving repositories over the Git Daemon protocol
+	 */
+	@Override
+	public boolean isServingGIT() {
+		return settings.getInteger(Keys.git.daemonPort, 0) > 0;
+	}
+
+	/**
+	 * Determine if this Gitblit instance is actively serving git repositories
+	 * over the SSH protocol.
+	 *
+	 * @return true if Gitblit is serving repositories over the SSH protocol
+	 */
+	@Override
+	public boolean isServingSSH() {
+		return settings.getInteger(Keys.git.sshPort, 0) > 0;
 	}
 
 	/**
@@ -146,6 +185,22 @@
 		logger.info("{}{} ({})", new Object [] { type, zone.getID(), offset });
 	}
 
+	@Override
+	public Locale getLocale() {
+		String lc = settings.getString(Keys.web.forceDefaultLocale, null);
+		if (!StringUtils.isEmpty(lc)) {
+			int underscore = lc.indexOf('_');
+			if (underscore > 0) {
+				String lang = lc.substring(0, underscore);
+				String cc = lc.substring(underscore + 1);
+				return new Locale(lang, cc);
+			} else {
+				return new Locale(lc);
+			}
+		}
+		return null;
+	}
+
 	/**
 	 * Is Gitblit running in debug mode?
 	 *

--
Gitblit v1.9.1