java/sql-dk/src/info/globalcode/sql/dk/configuration/CommandArgument.java
author František Kučera <franta-hg@frantovo.cz>
Tue, 26 Feb 2019 18:19:49 +0100
branchv_0
changeset 236 a3ec71fa8e17
parent 203 504c4ba56d1c
permissions -rw-r--r--
Avoid reusing/rewriting the DB connection properties.
There was weird random errors while testing connection to multiple DB in parallel when one of them was meta connection to same DB connection.
Two kinds of exception: 1) missing password 2) „Passing DB password as CLI parameter is insecure!“
franta-hg@203
     1
/**
franta-hg@203
     2
 * SQL-DK
franta-hg@203
     3
 * Copyright © 2015 František Kučera (frantovo.cz)
franta-hg@203
     4
 *
franta-hg@203
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@203
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@203
     7
 * the Free Software Foundation, either version 3 of the License, or
franta-hg@203
     8
 * (at your option) any later version.
franta-hg@203
     9
 *
franta-hg@203
    10
 * This program is distributed in the hope that it will be useful,
franta-hg@203
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@203
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@203
    13
 * GNU General Public License for more details.
franta-hg@203
    14
 *
franta-hg@203
    15
 * You should have received a copy of the GNU General Public License
franta-hg@203
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@203
    17
 */
franta-hg@203
    18
package info.globalcode.sql.dk.configuration;
franta-hg@203
    19
franta-hg@203
    20
import javax.xml.bind.annotation.XmlAttribute;
franta-hg@203
    21
import javax.xml.bind.annotation.XmlEnum;
franta-hg@203
    22
import javax.xml.bind.annotation.XmlEnumValue;
franta-hg@203
    23
import javax.xml.bind.annotation.XmlValue;
franta-hg@203
    24
franta-hg@203
    25
/**
franta-hg@203
    26
 *
franta-hg@203
    27
 * @author Ing. František Kučera (frantovo.cz)
franta-hg@203
    28
 */
franta-hg@203
    29
public class CommandArgument {
franta-hg@203
    30
franta-hg@203
    31
	private String value;
franta-hg@203
    32
	private TYPE type;
franta-hg@203
    33
franta-hg@203
    34
	@XmlEnum
franta-hg@203
    35
	public static enum TYPE {
franta-hg@203
    36
franta-hg@203
    37
		/**
franta-hg@203
    38
		 * value = literal (text) argument
franta-hg@203
    39
		 */
franta-hg@203
    40
		@XmlEnumValue("literal")
franta-hg@203
    41
		LITERAL,
franta-hg@203
    42
		/**
franta-hg@203
    43
		 * value will be substituted by hostname or IP address of the DB server
franta-hg@203
    44
		 */
franta-hg@203
    45
		@XmlEnumValue("host")
franta-hg@203
    46
		HOST,
franta-hg@203
    47
		/**
franta-hg@203
    48
		 * value will be substituted by the port of the DB server
franta-hg@203
    49
		 */
franta-hg@203
    50
		@XmlEnumValue("port")
franta-hg@203
    51
		PORT,
franta-hg@203
    52
		/**
franta-hg@203
    53
		 * value will be substituted by environmental variable of given name
franta-hg@203
    54
		 */
franta-hg@203
    55
		@XmlEnumValue("env")
franta-hg@203
    56
		ENVIRONMENT_VARIABLE,
franta-hg@203
    57
		/**
franta-hg@203
    58
		 * value will be substituted by database property of given name
franta-hg@203
    59
		 */
franta-hg@203
    60
		@XmlEnumValue("dbProperty")
franta-hg@203
    61
		DB_PROPERTY;
franta-hg@203
    62
	}
franta-hg@203
    63
franta-hg@203
    64
	@XmlValue
franta-hg@203
    65
	public String getValue() {
franta-hg@203
    66
		return value;
franta-hg@203
    67
	}
franta-hg@203
    68
franta-hg@203
    69
	public void setValue(String value) {
franta-hg@203
    70
		this.value = value;
franta-hg@203
    71
	}
franta-hg@203
    72
franta-hg@203
    73
	@XmlAttribute(name = "type")
franta-hg@203
    74
	public TYPE getType() {
franta-hg@203
    75
		return type;
franta-hg@203
    76
	}
franta-hg@203
    77
franta-hg@203
    78
	public void setType(TYPE type) {
franta-hg@203
    79
		this.type = type;
franta-hg@203
    80
	}
franta-hg@203
    81
franta-hg@203
    82
}