diff options
Diffstat (limited to 'src/com/p4square/grow/GrowProcessComponent.java')
-rw-r--r-- | src/com/p4square/grow/GrowProcessComponent.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/com/p4square/grow/GrowProcessComponent.java b/src/com/p4square/grow/GrowProcessComponent.java new file mode 100644 index 0000000..4196a5e --- /dev/null +++ b/src/com/p4square/grow/GrowProcessComponent.java @@ -0,0 +1,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(); + } +} |