| 1 | |
package com.aurea.maven.plugins.sonic.topology.utils; |
| 2 | |
|
| 3 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
| 4 | |
|
| 5 | |
public class Environment implements java.io.Serializable{ |
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
private static final long serialVersionUID = 1L; |
| 10 | |
String containerDir; |
| 11 | |
String registerAsService; |
| 12 | |
String encryptPWD; |
| 13 | |
String serviceStartupTime; |
| 14 | |
|
| 15 | 0 | public Environment(){ |
| 16 | |
|
| 17 | 0 | } |
| 18 | |
|
| 19 | |
public String getContainerDir() { |
| 20 | 0 | return containerDir; |
| 21 | |
} |
| 22 | |
|
| 23 | |
public void setContainerDir(String containerDir) { |
| 24 | 0 | this.containerDir = containerDir; |
| 25 | 0 | } |
| 26 | |
|
| 27 | |
public String getRegisterAsService() { |
| 28 | 0 | return registerAsService; |
| 29 | |
} |
| 30 | |
|
| 31 | |
public void setRegisterAsService(String registerAsService) { |
| 32 | 0 | this.registerAsService = registerAsService; |
| 33 | 0 | } |
| 34 | |
|
| 35 | |
public String getEncryptPWD() { |
| 36 | 0 | return encryptPWD; |
| 37 | |
} |
| 38 | |
|
| 39 | |
public void setEncryptPWD(String encryptPWD) { |
| 40 | 0 | this.encryptPWD = encryptPWD; |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
public String getServiceStartupTime() { |
| 44 | 0 | return serviceStartupTime; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public void setServiceStartupTime(String serviceStartupTime) { |
| 48 | 0 | this.serviceStartupTime = serviceStartupTime; |
| 49 | 0 | } |
| 50 | |
|
| 51 | |
public String toString(){ |
| 52 | 0 | StringBuffer sb = new StringBuffer(); |
| 53 | 0 | sb.append("Container Dir: " + getContainerDir() + "\n"); |
| 54 | 0 | sb.append("Register as Service: " + getRegisterAsService() + "\n"); |
| 55 | 0 | sb.append("Encrypt PWD: " + getEncryptPWD() + "\n"); |
| 56 | 0 | sb.append("Startup time: " + getServiceStartupTime() + "\n"); |
| 57 | 0 | return sb.toString(); |
| 58 | |
} |
| 59 | |
|
| 60 | |
public void createEnvironmentXmlContent(Xpp3Dom topology) { |
| 61 | 0 | Xpp3Dom settings = null; |
| 62 | |
|
| 63 | 0 | if(getContainerDir() != null && !getContainerDir().equals("")){ |
| 64 | 0 | if(settings == null){ |
| 65 | 0 | settings = new Xpp3Dom("Settings"); |
| 66 | |
} |
| 67 | 0 | Xpp3Dom location = new Xpp3Dom("Locations"); |
| 68 | 0 | Xpp3Dom containerDir = new Xpp3Dom("ContainersDir"); |
| 69 | 0 | containerDir.setValue(getContainerDir()); |
| 70 | 0 | location.addChild(containerDir); |
| 71 | 0 | settings.addChild(location); |
| 72 | |
} |
| 73 | |
|
| 74 | 0 | if(getEncryptPWD() != null && !getEncryptPWD().equals("")){ |
| 75 | 0 | if(settings == null){ |
| 76 | 0 | settings = new Xpp3Dom("Settings"); |
| 77 | |
} |
| 78 | 0 | Xpp3Dom encryption = new Xpp3Dom("BootfilesEncryptionPassword"); |
| 79 | 0 | encryption.setValue(getEncryptPWD()); |
| 80 | 0 | settings.addChild(encryption); |
| 81 | |
} |
| 82 | |
|
| 83 | 0 | if(getRegisterAsService() != null && !getRegisterAsService().equals("")){ |
| 84 | 0 | if(settings == null){ |
| 85 | 0 | settings = new Xpp3Dom("Settings"); |
| 86 | |
} |
| 87 | 0 | Xpp3Dom winService = new Xpp3Dom("RegisterBootContainersAsServices"); |
| 88 | 0 | winService.setValue(getRegisterAsService()); |
| 89 | 0 | settings.addChild(winService); |
| 90 | |
} |
| 91 | |
|
| 92 | 0 | if(getServiceStartupTime() != null && !getServiceStartupTime().equals("")){ |
| 93 | 0 | if(settings == null){ |
| 94 | 0 | settings = new Xpp3Dom("Settings"); |
| 95 | |
} |
| 96 | 0 | Xpp3Dom timeout = new Xpp3Dom("WindowsServicesStartupTimeout"); |
| 97 | 0 | timeout.setValue(getServiceStartupTime()); |
| 98 | 0 | settings.addChild(timeout); |
| 99 | |
} |
| 100 | |
|
| 101 | 0 | if(settings != null){ |
| 102 | 0 | topology.addChild(settings); |
| 103 | |
} |
| 104 | |
|
| 105 | |
|
| 106 | 0 | } |
| 107 | |
|
| 108 | |
} |