summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoraholland <aholland@a1dutch.co.uk>2014-02-24 22:44:39 +0000
committeraholland <aholland@a1dutch.co.uk>2014-02-24 22:44:39 +0000
commit2f3c342b5751f0ea41b0711b6d8757471572a79c (patch)
tree0643b0889f9b90d2e0fe61b2858d29b66d4987cf /src/main
parent5559638f52c00e2bec780e7f1c7a1710300817d4 (diff)
downloadgitblit-2f3c342b5751f0ea41b0711b6d8757471572a79c.tar.gz
gitblit-2f3c342b5751f0ea41b0711b6d8757471572a79c.zip
openshift war support (non express)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/gitblit/servlet/GitblitContext.java31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/main/java/com/gitblit/servlet/GitblitContext.java b/src/main/java/com/gitblit/servlet/GitblitContext.java
index 682b590c..d4ec9671 100644
--- a/src/main/java/com/gitblit/servlet/GitblitContext.java
+++ b/src/main/java/com/gitblit/servlet/GitblitContext.java
@@ -149,7 +149,11 @@ public class GitblitContext extends DaggerContext {
String contextRealPath = context.getRealPath("/");
File contextFolder = (contextRealPath != null) ? new File(contextRealPath) : null;
- if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR"))) {
+ // if the base folder dosen't match the default assume they don't want to use express,
+ // this allows for other containers to customise the basefolder per context.
+ String defaultBase = Constants.contextFolder$ + "/WEB-INF/data";
+ String base = lookupBaseFolderFromJndi();
+ if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR")) && defaultBase.equals(base)) {
// RedHat OpenShift
baseFolder = configureExpress(context, webxmlSettings, contextFolder, runtimeSettings);
} else {
@@ -184,6 +188,18 @@ public class GitblitContext extends DaggerContext {
logger.info("");
}
+ private String lookupBaseFolderFromJndi() {
+ try {
+ // try to lookup JNDI env-entry for the baseFolder
+ InitialContext ic = new InitialContext();
+ Context env = (Context) ic.lookup("java:comp/env");
+ return (String) env.lookup("baseFolder");
+ } catch (NamingException n) {
+ logger.error("Failed to get JNDI env-entry: " + n.getExplanation());
+ }
+ return null;
+ }
+
protected <X extends IManager> X startManager(ObjectGraph injector, Class<X> clazz) {
logManager(clazz);
X x = injector.get(clazz);
@@ -268,16 +284,9 @@ public class GitblitContext extends DaggerContext {
logger.error("");
}
- try {
- // try to lookup JNDI env-entry for the baseFolder
- InitialContext ic = new InitialContext();
- Context env = (Context) ic.lookup("java:comp/env");
- String val = (String) env.lookup("baseFolder");
- if (!StringUtils.isEmpty(val)) {
- path = val;
- }
- } catch (NamingException n) {
- logger.error("Failed to get JNDI env-entry: " + n.getExplanation());
+ String baseFromJndi = lookupBaseFolderFromJndi();
+ if (!StringUtils.isEmpty(baseFromJndi)) {
+ path = baseFromJndi;
}
File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path);