View Javadoc
1   package org.kuali.common.deploy;
2   
3   import java.util.List;
4   
5   import org.kuali.common.deploy.env.model.DeployEnvironment;
6   import org.kuali.common.util.Assert;
7   import org.kuali.common.util.maven.model.Artifact;
8   import org.kuali.common.util.secure.channel.SecureChannel;
9   
10  import com.google.common.base.Optional;
11  import com.google.common.collect.ImmutableList;
12  
13  public final class DeployContext {
14  
15  	private final SecureChannel channel;
16  	private final DeployEnvironment environment;
17  	private final Artifact application;
18  	private final Optional<Artifact> jdbcDriver;
19  	private final List<Deployable> configFiles;
20  
21  	public DeployEnvironment getEnvironment() {
22  		return environment;
23  	}
24  
25  	public Artifact getApplication() {
26  		return application;
27  	}
28  
29  	public Optional<Artifact> getJdbcDriver() {
30  		return jdbcDriver;
31  	}
32  
33  	public List<Deployable> getConfigFiles() {
34  		return configFiles;
35  	}
36  
37  	public SecureChannel getChannel() {
38  		return channel;
39  	}
40  
41  	public static class Builder {
42  
43  		// Required
44  		private final SecureChannel channel;
45  		private final DeployEnvironment environment;
46  		private final Artifact application;
47  
48  		// Optional
49  		private Optional<Artifact> jdbcDriver = Optional.absent();
50  		private List<Deployable> configFiles = ImmutableList.of();
51  
52  		public Builder(DeployEnvironment environment, SecureChannel channel, Artifact application) {
53  			this.channel = channel;
54  			this.environment = environment;
55  			this.application = application;
56  		}
57  
58  		public Builder jdbcDriver(Optional<Artifact> jdbcDriver) {
59  			this.jdbcDriver = jdbcDriver;
60  			return this;
61  		}
62  
63  		public Builder jdbcDriver(Artifact jdbcDriver) {
64  			return jdbcDriver(Optional.fromNullable(jdbcDriver));
65  		}
66  
67  		public Builder configFiles(List<Deployable> configFiles) {
68  			this.configFiles = configFiles;
69  			return this;
70  		}
71  
72  		public DeployContext build() {
73  			Assert.noNulls(environment, channel, application, jdbcDriver, configFiles);
74  			this.configFiles = ImmutableList.copyOf(configFiles);
75  			return new DeployContext(this);
76  		}
77  
78  	}
79  
80  	private DeployContext(Builder builder) {
81  		this.environment = builder.environment;
82  		this.channel = builder.channel;
83  		this.application = builder.application;
84  		this.jdbcDriver = builder.jdbcDriver;
85  		this.configFiles = builder.configFiles;
86  	}
87  
88  }