blob: 4196a5e959feee24feb89c5774e7e22fea9220d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* Copyright 2013 Jesse Morgan
*/
package com.p4square.grow;
import org.restlet.Component;
import org.restlet.data.Protocol;
import com.p4square.grow.backend.GrowBackend;
import com.p4square.grow.config.Config;
import com.p4square.grow.frontend.GrowFrontend;
/**
*
* @author Jesse Morgan <jesse@jesterpm.net>
*/
public class GrowProcessComponent extends Component {
private final Config mConfig;
/**
* Create a new Grow Process website component combining a frontend and backend.
*/
public GrowProcessComponent() throws Exception {
// Clients
getClients().add(Protocol.FILE);
getClients().add(Protocol.HTTP);
getClients().add(Protocol.HTTPS);
// Prepare mConfig
mConfig = new Config();
// Frontend
GrowFrontend frontend = new GrowFrontend(mConfig);
getDefaultHost().attach(frontend);
// Backend
GrowBackend backend = new GrowBackend(mConfig);
getInternalRouter().attach("/backend", backend);
}
@Override
public void start() throws Exception {
// Load mConfigs
mConfig.updateConfig(this.getClass().getResourceAsStream("/grow.properties"));
String configDomain = getContext().getParameters().getFirstValue("com.p4square.grow.configDomain");
if (configDomain != null) {
mConfig.setDomain(configDomain);
}
String configFilename = getContext().getParameters().getFirstValue("com.p4square.grow.configFile");
if (configFilename != null) {
mConfig.updateConfig(configFilename);
}
super.start();
}
}
|