View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.argeo.slc.support.deploy;
17  
18  import java.io.File;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  import org.argeo.slc.SlcException;
23  import org.argeo.slc.build.Distribution;
24  import org.argeo.slc.deploy.DeployEnvironment;
25  import org.argeo.slc.deploy.DeployedSystem;
26  import org.argeo.slc.deploy.Deployment;
27  import org.argeo.slc.deploy.DeploymentData;
28  import org.argeo.slc.deploy.TargetData;
29  
30  public class HttpdApplicationDeployment implements Deployment {
31  	private static final Log log = LogFactory
32  			.getLog(HttpdApplicationDeployment.class);
33  
34  	private HttpdApplicationTargetData targetData;
35  	private DeploymentData deploymentData;
36  	private SimpleHttpdApplication deployedSystem;
37  	private Distribution distribution;
38  
39  	private DeployEnvironment deployEnvironment;
40  
41  	public void run() {
42  		try {
43  			deployEnvironment.unpackTo(distribution, targetData
44  					.getTargetRootLocation(), null);
45  
46  			// FIXME: make it generic
47  			String deployDataPath = targetData.getTargetRootLocation()
48  					.getCanonicalPath();
49  
50  			deployEnvironment.unpackTo(deploymentData,
51  					new File(deployDataPath), null);
52  			deployedSystem = new SimpleHttpdApplication();
53  			deployedSystem.setTargetData(targetData);
54  
55  			log.info("Deployed " + distribution + " to " + targetData);
56  		} catch (Exception e) {
57  			throw new SlcException("Cannot deploy " + distribution + " to "
58  					+ targetData, e);
59  		}
60  
61  	}
62  
63  	public void setTargetData(TargetData targetData) {
64  		this.targetData = (HttpdApplicationTargetData) targetData;
65  	}
66  
67  	public void setDeploymentData(DeploymentData deploymentData) {
68  		this.deploymentData = deploymentData;
69  	}
70  
71  	public DeployedSystem getDeployedSystem() {
72  		return deployedSystem;
73  	}
74  
75  	public void setDistribution(Distribution distribution) {
76  		this.distribution = distribution;
77  	}
78  
79  	public void setDeployEnvironment(DeployEnvironment deployEnvironment) {
80  		this.deployEnvironment = deployEnvironment;
81  	}
82  
83  }