1 5 package com.tc.config.schema; 6 7 import com.tc.config.schema.context.ConfigContext; 8 import com.tc.config.schema.dynamic.FileConfigItem; 9 import com.tc.config.schema.dynamic.IntConfigItem; 10 import com.tc.config.schema.dynamic.ParameterSubstituter; 11 import com.tc.config.schema.dynamic.StringConfigItem; 12 import com.terracottatech.config.Authentication; 13 import com.terracottatech.config.Server; 14 15 import java.io.File ; 16 17 import javax.xml.namespace.QName ; 18 19 22 public class NewCommonL2ConfigObject extends BaseNewConfigObject implements NewCommonL2Config { 23 24 private final FileConfigItem dataPath; 25 private final FileConfigItem logsPath; 26 private final IntConfigItem jmxPort; 27 private final StringConfigItem host; 28 private final boolean authentication; 29 private final String passwordFile; 30 private final String accessFile; 31 32 public NewCommonL2ConfigObject(ConfigContext context) { 33 super(context); 34 35 this.context.ensureRepositoryProvides(Server.class); 36 37 this.dataPath = context.configRelativeSubstitutedFileItem("data"); 38 this.logsPath = context.configRelativeSubstitutedFileItem("logs"); 39 this.jmxPort = context.intItem("jmx-port"); 40 this.host = context.stringItem("@host"); 41 42 String pwd = null; 43 String access = null; 44 Server server = (Server) context.bean(); 45 if (server != null) { 46 this.authentication = server.isSetAuthentication(); 47 } else { 48 this.authentication = false; 49 } 50 51 if (authentication) { 52 pwd = server.getAuthentication().getPasswordFile(); 53 if (pwd == null) pwd = Authentication.type.getElementProperty(QName.valueOf("password-file")).getDefaultText(); 54 pwd = new File (ParameterSubstituter.substitute(pwd)).getAbsolutePath(); 55 56 access = server.getAuthentication().getAccessFile(); 57 if (access == null) access = Authentication.type.getElementProperty(QName.valueOf("access-file")) 58 .getDefaultText(); 59 access = new File (ParameterSubstituter.substitute(access)).getAbsolutePath(); 60 } 61 this.passwordFile = pwd; 62 this.accessFile = access; 63 } 64 65 public FileConfigItem dataPath() { 66 return this.dataPath; 67 } 68 69 public FileConfigItem logsPath() { 70 return this.logsPath; 71 } 72 73 public IntConfigItem jmxPort() { 74 return this.jmxPort; 75 } 76 77 public StringConfigItem host() { 78 return this.host; 79 } 80 81 public boolean authentication() { 82 return authentication; 83 } 84 85 public String authenticationAccessFile() { 86 return accessFile; 87 } 88 89 public String authenticationPasswordFile() { 90 return passwordFile; 91 } 92 } 93 | Popular Tags |