Dolda2000 GitWeb
/
jsvc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9f01683
)
Improved the configuration structure.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Fri, 16 Oct 2009 15:29:37 +0000
(17:29 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Fri, 16 Oct 2009 15:29:37 +0000
(17:29 +0200)
src/dolda/jsvc/ServerContext.java
patch
|
blob
|
blame
|
history
src/dolda/jsvc/j2ee/J2eeContext.java
patch
|
blob
|
blame
|
history
src/dolda/jsvc/j2ee/Servlet.java
patch
|
blob
|
blame
|
history
src/dolda/jsvc/j2ee/TomcatContext.java
patch
|
blob
|
blame
|
history
src/dolda/jsvc/store/Store.java
patch
|
blob
|
blame
|
history
diff --git
a/src/dolda/jsvc/ServerContext.java
b/src/dolda/jsvc/ServerContext.java
index
acb27d6
..
423deba
100644
(file)
--- a/
src/dolda/jsvc/ServerContext.java
+++ b/
src/dolda/jsvc/ServerContext.java
@@
-2,6
+2,7
@@
package dolda.jsvc;
public interface ServerContext {
public long starttime();
public interface ServerContext {
public long starttime();
- public String config(String key);
+ public String sysconfig(String key, String def);
+ public String libconfig(String key, String def);
public String name();
}
public String name();
}
diff --git
a/src/dolda/jsvc/j2ee/J2eeContext.java
b/src/dolda/jsvc/j2ee/J2eeContext.java
index
bf1917c
..
84ce918
100644
(file)
--- a/
src/dolda/jsvc/j2ee/J2eeContext.java
+++ b/
src/dolda/jsvc/j2ee/J2eeContext.java
@@
-9,12
+9,13
@@
import java.io.*;
public abstract class J2eeContext implements ServerContext {
private final ServletConfig sc;
private final long ctime;
public abstract class J2eeContext implements ServerContext {
private final ServletConfig sc;
private final long ctime;
- protected final Properties config;
+ protected final Properties
sysconfig, lib
config;
protected J2eeContext(ServletConfig sc) {
this.sc = sc;
this.ctime = System.currentTimeMillis();
protected J2eeContext(ServletConfig sc) {
this.sc = sc;
this.ctime = System.currentTimeMillis();
- config = new Properties();
+ sysconfig = new Properties();
+ libconfig = new Properties();
}
static J2eeContext create(ServletConfig sc) {
}
static J2eeContext create(ServletConfig sc) {
@@
-27,8
+28,16
@@
public abstract class J2eeContext implements ServerContext {
return(ctime);
}
return(ctime);
}
- public String config(String key) {
- return((String)config.get(key));
+ public String sysconfig(String key, String def) {
+ return(sysconfig.getProperty(key, def));
+ }
+
+ public String libconfig(String key, String def) {
+ return(libconfig.getProperty(key, def));
+ }
+
+ void loadconfig(InputStream in) throws IOException {
+ libconfig.load(in);
}
public ServletConfig j2eeconfig() {
}
public ServletConfig j2eeconfig() {
diff --git
a/src/dolda/jsvc/j2ee/Servlet.java
b/src/dolda/jsvc/j2ee/Servlet.java
index
d726474
..
082113c
100644
(file)
--- a/
src/dolda/jsvc/j2ee/Servlet.java
+++ b/
src/dolda/jsvc/j2ee/Servlet.java
@@
-11,18
+11,18
@@
public class Servlet extends HttpServlet {
private ThreadContext tg;
public void init(ServletConfig cfg) throws ServletException {
private ThreadContext tg;
public void init(ServletConfig cfg) throws ServletException {
-
Properties sprop = new Properties(
);
+
J2eeContext ctx = J2eeContext.create(cfg
);
try {
InputStream pi = Servlet.class.getClassLoader().getResourceAsStream("jsvc.properties");
try {
try {
InputStream pi = Servlet.class.getClassLoader().getResourceAsStream("jsvc.properties");
try {
-
sprop.load
(pi);
+
ctx.loadconfig
(pi);
} finally {
pi.close();
}
} catch(IOException e) {
throw(new Error(e));
}
} finally {
pi.close();
}
} catch(IOException e) {
throw(new Error(e));
}
- String clnm =
(String)sprop.get("jsvc.bootstrap"
);
+ String clnm =
ctx.libconfig("jsvc.bootstrap", null
);
if(clnm == null)
throw(new ServletException("No JSvc bootstrapper specified"));
Class<?> bc;
if(clnm == null)
throw(new ServletException("No JSvc bootstrapper specified"));
Class<?> bc;
@@
-31,7
+31,6
@@
public class Servlet extends HttpServlet {
} catch(ClassNotFoundException e) {
throw(new ServletException("Invalid JSvc bootstrapper specified", e));
}
} catch(ClassNotFoundException e) {
throw(new ServletException("Invalid JSvc bootstrapper specified", e));
}
- ServerContext ctx = J2eeContext.create(cfg);
String tgn;
if(ctx.name() != null)
tgn = "JSvc service for " + ctx.name();
String tgn;
if(ctx.name() != null)
tgn = "JSvc service for " + ctx.name();
diff --git
a/src/dolda/jsvc/j2ee/TomcatContext.java
b/src/dolda/jsvc/j2ee/TomcatContext.java
index
bf6312b
..
8672d39
100644
(file)
--- a/
src/dolda/jsvc/j2ee/TomcatContext.java
+++ b/
src/dolda/jsvc/j2ee/TomcatContext.java
@@
-58,10
+58,10
@@
public class TomcatContext extends J2eeContext {
logger.log(Level.WARNING, "no permissions to fetch Tomcat base directory while reading configuration", e);
return;
}
logger.log(Level.WARNING, "no permissions to fetch Tomcat base directory while reading configuration", e);
return;
}
- config.put("jsvc.storage", "file:" + new File(new File(base, "work"), "jsvc").getPath());
+
sys
config.put("jsvc.storage", "file:" + new File(new File(base, "work"), "jsvc").getPath());
File cdir = new File(base, "conf");
try {
File cdir = new File(base, "conf");
try {
- loadprops(config, new File(cdir, "jsvc.properties"));
+ loadprops(
sys
config, new File(cdir, "jsvc.properties"));
} catch(SecurityException e) {
logger.log(Level.WARNING, "no permssions to read from Tomcat conf directory while reading configuration", e);
}
} catch(SecurityException e) {
logger.log(Level.WARNING, "no permssions to read from Tomcat conf directory while reading configuration", e);
}
diff --git
a/src/dolda/jsvc/store/Store.java
b/src/dolda/jsvc/store/Store.java
index
0664156
..
d32b3a2
100644
(file)
--- a/
src/dolda/jsvc/store/Store.java
+++ b/
src/dolda/jsvc/store/Store.java
@@
-24,7
+24,7
@@
public abstract class Store implements Iterable<File> {
ThreadContext ctx = ThreadContext.current();
if(ctx == null)
throw(new RuntimeException("Not running in jsvc context"));
ThreadContext ctx = ThreadContext.current();
if(ctx == null)
throw(new RuntimeException("Not running in jsvc context"));
- String bn = ctx.server().
config("jsvc.storage"
);
+ String bn = ctx.server().
sysconfig("jsvc.storage", null
);
if(bn == null)
throw(new RuntimeException("No storage root has been configured"));
return(bn);
if(bn == null)
throw(new RuntimeException("No storage root has been configured"));
return(bn);