Browse files

Start REST service on container bootup.

  • Loading branch information...
1 parent e1e3ba2 commit d950d9dfb25524dc9c9c3184982c6792ebb3fdc5 @labisso labisso committed Feb 24, 2010
View
2 home/sbin/setup.py
@@ -23,7 +23,7 @@
hostkey: var/hostkey.pem
CA.dir: var/ca
-gridmap: var/gridmap
+gridmap: services/etc/nimbus/nimbus-grid-mapfile
keystore: var/keystore.jks
keystore.pass: changeit
View
6 messaging/gt4.0-elastic/java/msgbridge/etc/elastic/other/main.conflocator.xml
@@ -48,4 +48,10 @@
<property name="placeholderPrefix" value="$QUERY{" />
</bean>
+ <bean id="restSettings"
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="location" value="file://@REST_CONFDIR@/rest.conf" />
+ <property name="placeholderPrefix" value="$REST{" />
+ </bean>
+
</beans>
View
11 messaging/gt4.0-elastic/java/msgbridge/etc/elastic/other/main.xml
@@ -208,6 +208,17 @@
</bean>
+ <!-- TODO this should happen somewhere else... -->
+ <bean id="nimbus-rest.httpserver"
+ class="org.nimbustools.messaging.rest.RestHttp"
+ init-method="startListening">
+ <property name="enabled" value="$REST{rest.enabled}" />
+ <property name="port" value="$REST{rest.port}" />
+ <property name="keystoreLocation" value="$REST{keystore.path}"/>
+ <property name="keystorePassword" value="$REST{keystore.password}"/>
+ <property name="springConfig" value="$REST{rest.spring.path}"/>
+ </bean>
+
<!--
property sources are concentrated in this file
View
5 messaging/rest/java/source/etc/rest/other/main.conflocator.xml
@@ -21,11 +21,8 @@
<bean id="restSettings"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-
- <!-- grab some shared settings from the workspace-service common.conf file,
- will have to adjust for other deployment scenarios -->
<property name="location" value="file://@REST_CONFDIR@/rest.conf" />
- <property name="placeholderPrefix" value="REST{" />
+ <property name="placeholderPrefix" value="$REST{" />
</bean>
</beans>
View
16 messaging/rest/java/source/etc/rest/rest.conf
@@ -1,4 +1,12 @@
-gridmap.path=/path/to/gridmap
-groupauthz.path=/path/to/groupauthz
-query.usermap.path=/path/to/users.txt
-gridmap.localuser=cloudimages
+rest.enabled=false
+rest.port=4443
+
+keystore.path=/path/to/keystore
+keystore.password=secrets
+
+gridmap.path=file:///path/to/grid-mapfile
+groupauthz.path=
+query.usermap.path=file://@QUERY_CONFDIR@/users.txt
+gridmap.localuser=cloudimages
+
+rest.spring.path=file://@REST_CONFDIR@/other/main.xml
View
56 messaging/rest/java/source/src/org/nimbustools/messaging/rest/RestHttp.java
@@ -32,10 +32,15 @@
public class RestHttp {
+ private boolean enabled;
+
private int port;
private String springConfig;
private String keystoreLocation;
private String keystorePassword;
+ private Server server;
+
+ public RestHttp() {}
public RestHttp(String springConfig, int port,
String keystoreLocation, String keystorePassword) {
@@ -47,6 +52,10 @@ public RestHttp(String springConfig, int port,
public synchronized void startListening() throws Exception {
+ if (!enabled) {
+ return;
+ }
+
if (port <= 0) {
throw new IllegalStateException("port is invalid");
}
@@ -63,7 +72,7 @@ public synchronized void startListening() throws Exception {
}
- Server server = new Server();
+ server = new Server();
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setPort(port);
@@ -90,9 +99,51 @@ public synchronized void startListening() throws Exception {
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/");
server.start();
- server.join();
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getSpringConfig() {
+ return springConfig;
+ }
+
+ public void setSpringConfig(String springConfig) {
+ this.springConfig = springConfig;
+ }
+
+ public String getKeystoreLocation() {
+ return keystoreLocation;
+ }
+
+ public void setKeystoreLocation(String keystoreLocation) {
+ this.keystoreLocation = keystoreLocation;
+ }
+
+ public String getKeystorePassword() {
+ return keystorePassword;
+ }
+
+ public void setKeystorePassword(String keystorePassword) {
+ this.keystorePassword = keystorePassword;
+ }
+
+ public Server getServer() {
+ return server;
+ }
public static void main(String[] args) {
@@ -115,6 +166,7 @@ public static void main(String[] args) {
try {
http.startListening();
+ http.server.join();
} catch (Exception e) {
System.err.println("Error running REST http server:");
e.printStackTrace();

0 comments on commit d950d9d

Please sign in to comment.