java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
author František Kučera <franta-hg@frantovo.cz>
Sat, 15 Aug 2015 10:47:56 +0200
branchv_0
changeset 209 8dfe037b3274
parent 203 504c4ba56d1c
child 210 f8aa3686d512
permissions -rw-r--r--
property annotations: grounds for --list-formatter-properties
     1 /**
     2  * SQL-DK
     3  * Copyright © 2013 František Kučera (frantovo.cz)
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, either version 3 of the License, or
     8  * (at your option) any later version.
     9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 package info.globalcode.sql.dk;
    19 
    20 import info.globalcode.sql.dk.configuration.CommandArgument;
    21 import info.globalcode.sql.dk.configuration.Configuration;
    22 import info.globalcode.sql.dk.configuration.ConfigurationException;
    23 import info.globalcode.sql.dk.configuration.ConfigurationProvider;
    24 import info.globalcode.sql.dk.configuration.DatabaseDefinition;
    25 import info.globalcode.sql.dk.configuration.FormatterDefinition;
    26 import info.globalcode.sql.dk.configuration.Properties;
    27 import info.globalcode.sql.dk.configuration.Property;
    28 import info.globalcode.sql.dk.configuration.TunnelDefinition;
    29 import info.globalcode.sql.dk.formatting.ColumnsHeader;
    30 import info.globalcode.sql.dk.formatting.FakeSqlArray;
    31 import info.globalcode.sql.dk.formatting.Formatter;
    32 import info.globalcode.sql.dk.formatting.FormatterContext;
    33 import info.globalcode.sql.dk.formatting.FormatterException;
    34 import java.io.BufferedReader;
    35 import java.io.ByteArrayOutputStream;
    36 import java.io.InputStreamReader;
    37 import java.io.PrintStream;
    38 import java.sql.Array;
    39 import java.sql.Driver;
    40 import java.sql.DriverManager;
    41 import java.sql.DriverPropertyInfo;
    42 import java.sql.SQLException;
    43 import java.util.ArrayList;
    44 import java.util.Collections;
    45 import java.util.Comparator;
    46 import java.util.EnumSet;
    47 import java.util.HashSet;
    48 import java.util.List;
    49 import java.util.Map.Entry;
    50 import java.util.ServiceLoader;
    51 import java.util.Set;
    52 import java.util.concurrent.ExecutorService;
    53 import java.util.concurrent.Executors;
    54 import java.util.concurrent.TimeUnit;
    55 import java.util.logging.Level;
    56 import java.util.logging.LogRecord;
    57 import java.util.logging.Logger;
    58 import javax.sql.rowset.RowSetMetaDataImpl;
    59 
    60 /**
    61  * Displays info like help, version etc.
    62  *
    63  * @author Ing. František Kučera (frantovo.cz)
    64  */
    65 public class InfoLister {
    66 
    67 	private static final Logger log = Logger.getLogger(InfoLister.class.getName());
    68 	/**
    69 	 * Fake database name for output formatting
    70 	 */
    71 	public static final String CONFIG_DB_NAME = "sqldk_configuration";
    72 	private final PrintStream out;
    73 	private final ConfigurationProvider configurationProvider;
    74 	private final CLIOptions options;
    75 	private Formatter formatter;
    76 
    77 	public InfoLister(PrintStream out, ConfigurationProvider configurationProvider, CLIOptions options) {
    78 		this.out = out;
    79 		this.configurationProvider = configurationProvider;
    80 		this.options = options;
    81 	}
    82 
    83 	public void showInfo() throws ConfigurationException, FormatterException {
    84 		EnumSet<InfoType> commands = options.getShowInfo();
    85 
    86 		boolean formattinNeeded = false;
    87 
    88 		for (InfoType infoType : commands) {
    89 			switch (infoType) {
    90 				case CONNECTION:
    91 				case JDBC_DRIVERS:
    92 				case JDBC_PROPERTIES:
    93 				case DATABASES:
    94 				case FORMATTERS:
    95 				case TYPES:
    96 				case JAVA_PROPERTIES:
    97 				case ENVIRONMENT_VARIABLES:
    98 					formattinNeeded = true;
    99 					break;
   100 			}
   101 		}
   102 
   103 		if (formattinNeeded) {
   104 			try (Formatter f = getFormatter()) {
   105 				formatter = f;
   106 				formatter.writeStartBatch();
   107 				DatabaseDefinition dd = new DatabaseDefinition();
   108 				dd.setName(CONFIG_DB_NAME);
   109 				formatter.writeStartDatabase(dd);
   110 				showInfos(commands);
   111 				formatter.writeEndDatabase();
   112 				formatter.writeEndBatch();
   113 				formatter.close();
   114 			}
   115 		} else {
   116 			showInfos(commands);
   117 		}
   118 	}
   119 
   120 	private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {
   121 		for (InfoType infoType : commands) {
   122 			infoType.showInfo(this);
   123 		}
   124 	}
   125 
   126 	private void listJavaProperties() throws FormatterException, ConfigurationException {
   127 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("value", SQLType.VARCHAR));
   128 		List<Object[]> data = new ArrayList<>();
   129 		for (Entry<Object, Object> e : System.getProperties().entrySet()) {
   130 			data.add(new Object[]{e.getKey(), e.getValue()});
   131 		}
   132 		printTable(formatter, header, "-- Java system properties", null, data, 0);
   133 	}
   134 
   135 	private void listEnvironmentVariables() throws FormatterException, ConfigurationException {
   136 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("value", SQLType.VARCHAR));
   137 		List<Object[]> data = new ArrayList<>();
   138 		for (Entry<String, String> e : System.getenv().entrySet()) {
   139 			data.add(new Object[]{e.getKey(), e.getValue()});
   140 		}
   141 		printTable(formatter, header, "-- environment variables", null, data, 0);
   142 	}
   143 
   144 	private void listFormatters() throws ConfigurationException, FormatterException {
   145 		ColumnsHeader header = constructHeader(
   146 				new HeaderField("name", SQLType.VARCHAR),
   147 				new HeaderField("built_in", SQLType.BOOLEAN),
   148 				new HeaderField("default", SQLType.BOOLEAN),
   149 				new HeaderField("class_name", SQLType.VARCHAR),
   150 				new HeaderField("valid", SQLType.BOOLEAN));
   151 		List<Object[]> data = new ArrayList<>();
   152 
   153 		String defaultFormatter = configurationProvider.getConfiguration().getDefaultFormatter();
   154 		defaultFormatter = defaultFormatter == null ? Configuration.DEFAULT_FORMATTER : defaultFormatter;
   155 
   156 		for (FormatterDefinition fd : configurationProvider.getConfiguration().getBuildInFormatters()) {
   157 			data.add(new Object[]{fd.getName(), true, defaultFormatter.equals(fd.getName()), fd.getClassName(), isInstantiable(fd)});
   158 		}
   159 
   160 		for (FormatterDefinition fd : configurationProvider.getConfiguration().getFormatters()) {
   161 			data.add(new Object[]{fd.getName(), false, defaultFormatter.equals(fd.getName()), fd.getClassName(), isInstantiable(fd)});
   162 		}
   163 
   164 		printTable(formatter, header, "-- configured and built-in output formatters", null, data);
   165 	}
   166 
   167 	private boolean isInstantiable(FormatterDefinition fd) {
   168 		try {
   169 			try (ByteArrayOutputStream testStream = new ByteArrayOutputStream()) {
   170 				fd.getInstance(new FormatterContext(testStream, new Properties(0)));
   171 				return true;
   172 			}
   173 		} catch (Exception e) {
   174 			log.log(Level.SEVERE, "Unable to create an instance of formatter: " + fd.getName(), e);
   175 			return false;
   176 		}
   177 	}
   178 
   179 	private void listFormatterProperties() {
   180 		for (String name : options.getFormatterNamesToListProperties()) {
   181 			log.log(Level.SEVERE, "TODO: list formatter properties for {0}", name);
   182 		}
   183 	}
   184 
   185 	public void listTypes() throws FormatterException, ConfigurationException {
   186 		ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER));
   187 		List<Object[]> data = new ArrayList<>();
   188 		for (SQLType sqlType : SQLType.values()) {
   189 			data.add(new Object[]{sqlType.name(), sqlType.getCode()});
   190 		}
   191 		printTable(formatter, header, "-- data types", null, data);
   192 		log.log(Level.INFO, "Type names in --types option are case insensitive");
   193 	}
   194 
   195 	public void listDatabases() throws ConfigurationException, FormatterException {
   196 		ColumnsHeader header = constructHeader(
   197 				new HeaderField("database_name", SQLType.VARCHAR),
   198 				new HeaderField("user_name", SQLType.VARCHAR),
   199 				new HeaderField("database_url", SQLType.VARCHAR));
   200 		List<Object[]> data = new ArrayList<>();
   201 
   202 		final List<DatabaseDefinition> configuredDatabases = configurationProvider.getConfiguration().getDatabases();
   203 		if (configuredDatabases.isEmpty()) {
   204 			log.log(Level.WARNING, "No databases are configured.");
   205 		} else {
   206 			for (DatabaseDefinition dd : configuredDatabases) {
   207 				data.add(new Object[]{dd.getName(), dd.getUserName(), dd.getUrl()});
   208 
   209 				final TunnelDefinition tunnel = dd.getTunnel();
   210 				if (tunnel != null) {
   211 					log.log(Level.INFO, "Tunnel command: {0}", tunnel.getCommand());
   212 					for (CommandArgument ca : Functions.notNull(tunnel.getArguments())) {
   213 						log.log(Level.INFO, "\targument: {0}/{1}", new Object[]{ca.getType(), ca.getValue()});
   214 					}
   215 				}
   216 
   217 			}
   218 		}
   219 
   220 		printTable(formatter, header, "-- configured databases", null, data);
   221 	}
   222 
   223 	public void listJdbcDrivers() throws FormatterException, ConfigurationException {
   224 		ColumnsHeader header = constructHeader(
   225 				new HeaderField("class", SQLType.VARCHAR),
   226 				new HeaderField("version", SQLType.VARCHAR),
   227 				new HeaderField("major", SQLType.INTEGER),
   228 				new HeaderField("minor", SQLType.INTEGER),
   229 				new HeaderField("jdbc_compliant", SQLType.BOOLEAN));
   230 		List<Object[]> data = new ArrayList<>();
   231 
   232 		final ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
   233 		for (Driver d : drivers) {
   234 			data.add(new Object[]{
   235 				d.getClass().getName(),
   236 				d.getMajorVersion() + "." + d.getMinorVersion(),
   237 				d.getMajorVersion(),
   238 				d.getMinorVersion(),
   239 				d.jdbcCompliant()
   240 			});
   241 		}
   242 
   243 		printTable(formatter, header, "-- discovered JDBC drivers (available on the CLASSPATH)", null, data);
   244 	}
   245 
   246 	public void listJdbcProperties() throws FormatterException, ConfigurationException {
   247 		for (String dbName : options.getDatabaseNamesToListProperties()) {
   248 			ColumnsHeader header = constructHeader(
   249 					new HeaderField("property_name", SQLType.VARCHAR),
   250 					new HeaderField("required", SQLType.BOOLEAN),
   251 					new HeaderField("choices", SQLType.ARRAY),
   252 					new HeaderField("configured_value", SQLType.VARCHAR),
   253 					new HeaderField("description", SQLType.VARCHAR));
   254 			List<Object[]> data = new ArrayList<>();
   255 
   256 			DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName);
   257 
   258 			Driver driver = findDriver(dd);
   259 
   260 			if (driver == null) {
   261 				log.log(Level.WARNING, "No JDBC driver was found for DB: {0} with URL: {1}", new Object[]{dd.getName(), dd.getUrl()});
   262 			} else {
   263 				log.log(Level.INFO, "For DB: {0} was found JDBC driver: {1}", new Object[]{dd.getName(), driver.getClass().getName()});
   264 
   265 				try {
   266 					DriverPropertyInfo[] propertyInfos = driver.getPropertyInfo(dd.getUrl(), dd.getProperties().getJavaProperties());
   267 
   268 					Set<String> standardProperties = new HashSet<>();
   269 
   270 					for (DriverPropertyInfo pi : propertyInfos) {
   271 						Array choices = new FakeSqlArray(pi.choices, SQLType.VARCHAR);
   272 						data.add(new Object[]{
   273 							pi.name,
   274 							pi.required,
   275 							choices.getArray() == null ? "" : choices,
   276 							pi.value == null ? "" : pi.value,
   277 							pi.description
   278 						});
   279 						standardProperties.add(pi.name);
   280 					}
   281 
   282 					for (Property p : dd.getProperties()) {
   283 						if (!standardProperties.contains(p.getName())) {
   284 							data.add(new Object[]{
   285 								p.getName(),
   286 								"",
   287 								"",
   288 								p.getValue(),
   289 								""
   290 							});
   291 							log.log(Level.WARNING, "Your configuration contains property „{0}“ not declared by the JDBC driver.", p.getName());
   292 						}
   293 					}
   294 
   295 				} catch (SQLException e) {
   296 					log.log(Level.WARNING, "Error during getting property infos.", e);
   297 				}
   298 
   299 				List<Parameter> parameters = new ArrayList<>();
   300 				parameters.add(new NamedParameter("database", dbName, SQLType.VARCHAR));
   301 				parameters.add(new NamedParameter("driver_class", driver.getClass().getName(), SQLType.VARCHAR));
   302 				parameters.add(new NamedParameter("driver_major_version", driver.getMajorVersion(), SQLType.INTEGER));
   303 				parameters.add(new NamedParameter("driver_minor_version", driver.getMinorVersion(), SQLType.INTEGER));
   304 
   305 				printTable(formatter, header, "-- configured and configurable JDBC driver properties", parameters, data);
   306 			}
   307 		}
   308 
   309 	}
   310 
   311 	private Driver findDriver(DatabaseDefinition dd) {
   312 		final ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
   313 		for (Driver d : drivers) {
   314 			try {
   315 				if (d.acceptsURL(dd.getUrl())) {
   316 					return d;
   317 				}
   318 			} catch (SQLException e) {
   319 				log.log(Level.WARNING, "Error during finding JDBC driver for: " + dd.getName(), e);
   320 			}
   321 		}
   322 		return null;
   323 	}
   324 
   325 	/**
   326 	 * Parallelism for connection testing – maximum concurrent database connections.
   327 	 */
   328 	private static final int TESTING_THREAD_COUNT = 64;
   329 	/**
   330 	 * Time limit for all connection testing threads – particular timeouts per connection will be
   331 	 * much smaller.
   332 	 */
   333 	private static final long TESTING_AWAIT_LIMIT = 1;
   334 	private static final TimeUnit TESTING_AWAIT_UNIT = TimeUnit.DAYS;
   335 
   336 	public void testConnections() throws FormatterException, ConfigurationException {
   337 		ColumnsHeader header = constructHeader(
   338 				new HeaderField("database_name", SQLType.VARCHAR),
   339 				new HeaderField("configured", SQLType.BOOLEAN),
   340 				new HeaderField("connected", SQLType.BOOLEAN));
   341 
   342 		log.log(Level.FINE, "Testing DB connections in {0} threads", TESTING_THREAD_COUNT);
   343 
   344 		ExecutorService es = Executors.newFixedThreadPool(TESTING_THREAD_COUNT);
   345 
   346 		final Formatter currentFormatter = formatter;
   347 
   348 		printHeader(currentFormatter, header, "-- database configuration and connectivity test", null);
   349 
   350 		for (final String dbName : options.getDatabaseNamesToTest()) {
   351 			preloadDriver(dbName);
   352 		}
   353 
   354 		for (final String dbName : options.getDatabaseNamesToTest()) {
   355 			es.submit(() -> {
   356 				final Object[] row = testConnection(dbName);
   357 				synchronized (currentFormatter) {
   358 					printRow(currentFormatter, row);
   359 				}
   360 			}
   361 			);
   362 		}
   363 
   364 		es.shutdown();
   365 
   366 		try {
   367 			log.log(Level.FINEST, "Waiting for test results: {0} {1}", new Object[]{TESTING_AWAIT_LIMIT, TESTING_AWAIT_UNIT.name()});
   368 			boolean finished = es.awaitTermination(TESTING_AWAIT_LIMIT, TESTING_AWAIT_UNIT);
   369 			if (finished) {
   370 				log.log(Level.FINEST, "All testing threads finished in time limit.");
   371 			} else {
   372 				throw new FormatterException("Exceeded total time limit for test threads – this should never happen");
   373 			}
   374 		} catch (InterruptedException e) {
   375 			throw new FormatterException("Interrupted while waiting for test results", e);
   376 		}
   377 
   378 		printFooter(currentFormatter);
   379 	}
   380 
   381 	/**
   382 	 * JDBC driver classes should be preloaded in single thread to avoid deadlocks while doing
   383 	 * {@linkplain DriverManager#registerDriver(java.sql.Driver)} during parallel connections.
   384 	 *
   385 	 * @param dbName
   386 	 */
   387 	private void preloadDriver(String dbName) {
   388 		try {
   389 			DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName);
   390 			Driver driver = findDriver(dd);
   391 			if (driver == null) {
   392 				log.log(Level.WARNING, "No Driver found for DB: {0}", dbName);
   393 			} else {
   394 				log.log(Level.FINEST, "Driver preloading for DB: {0} was successfull", dbName);
   395 			}
   396 		} catch (Exception e) {
   397 			LogRecord r = new LogRecord(Level.WARNING, "Failed to preload the Driver for DB: {0}");
   398 			r.setParameters(new Object[]{dbName});
   399 			r.setThrown(e);
   400 			log.log(r);
   401 		}
   402 	}
   403 
   404 	public Object[] testConnection(String dbName) {
   405 		log.log(Level.FINE, "Testing connection to database: {0}", dbName);
   406 
   407 		boolean succesfullyConnected = false;
   408 		boolean succesfullyConfigured = false;
   409 
   410 		try {
   411 			DatabaseDefinition dd = configurationProvider.getConfiguration().getDatabase(dbName);
   412 			log.log(Level.FINE, "Database definition was loaded from configuration");
   413 			succesfullyConfigured = true;
   414 			try (DatabaseConnection dc = dd.connect(options.getDatabaseProperties())) {
   415 				succesfullyConnected = dc.test();
   416 			}
   417 			log.log(Level.FINE, "Database connection test was successful");
   418 		} catch (ConfigurationException | SQLException | RuntimeException e) {
   419 			log.log(Level.SEVERE, "Error during testing connection " + dbName, e);
   420 		}
   421 
   422 		return new Object[]{dbName, succesfullyConfigured, succesfullyConnected};
   423 	}
   424 
   425 	public void printResource(String fileName) {
   426 		try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(fileName)))) {
   427 			while (true) {
   428 				String line = reader.readLine();
   429 				if (line == null) {
   430 					break;
   431 				} else {
   432 					println(line);
   433 				}
   434 			}
   435 		} catch (Exception e) {
   436 			log.log(Level.SEVERE, "Unable to print this info. Please see our website for it: " + Constants.WEBSITE, e);
   437 		}
   438 	}
   439 
   440 	private void println(String line) {
   441 		out.println(line);
   442 	}
   443 
   444 	private void printTable(Formatter formatter, ColumnsHeader header, String sql, List<Parameter> parameters, List<Object[]> data) throws ConfigurationException, FormatterException {
   445 		printTable(formatter, header, sql, parameters, data, null);
   446 	}
   447 
   448 	private void printTable(Formatter formatter, ColumnsHeader header, String sql, List<Parameter> parameters, List<Object[]> data, final Integer sortByColumn) throws ConfigurationException, FormatterException {
   449 		printHeader(formatter, header, sql, parameters);
   450 
   451 		if (sortByColumn != null) {
   452 			Collections.sort(data, new Comparator<Object[]>() {
   453 
   454 				@Override
   455 				public int compare(Object[] o1, Object[] o2) {
   456 					String s1 = String.valueOf(o1[sortByColumn]);
   457 					String s2 = String.valueOf(o2[sortByColumn]);
   458 					return s1.compareTo(s2);
   459 				}
   460 			});
   461 		}
   462 
   463 		for (Object[] row : data) {
   464 			printRow(formatter, row);
   465 		}
   466 
   467 		printFooter(formatter);
   468 	}
   469 
   470 	private void printHeader(Formatter formatter, ColumnsHeader header, String sql, List<Parameter> parameters) {
   471 		formatter.writeStartStatement();
   472 		if (sql != null) {
   473 			formatter.writeQuery(sql);
   474 			if (parameters != null) {
   475 				formatter.writeParameters(parameters);
   476 			}
   477 		}
   478 		formatter.writeStartResultSet(header);
   479 	}
   480 
   481 	private void printRow(Formatter formatter, Object[] row) {
   482 		formatter.writeStartRow();
   483 		for (Object cell : row) {
   484 			formatter.writeColumnValue(cell);
   485 		}
   486 		formatter.writeEndRow();
   487 	}
   488 
   489 	private void printFooter(Formatter formatter) {
   490 		formatter.writeEndResultSet();
   491 		formatter.writeEndStatement();
   492 	}
   493 
   494 	private Formatter getFormatter() throws ConfigurationException, FormatterException {
   495 		String formatterName = options.getFormatterName();
   496 		formatterName = formatterName == null ? Configuration.DEFAULT_FORMATTER_PREFETCHING : formatterName;
   497 		FormatterDefinition fd = configurationProvider.getConfiguration().getFormatter(formatterName);
   498 		FormatterContext context = new FormatterContext(out, options.getFormatterProperties());
   499 		return fd.getInstance(context);
   500 	}
   501 
   502 	private ColumnsHeader constructHeader(HeaderField... fields) throws FormatterException {
   503 		try {
   504 			RowSetMetaDataImpl metaData = new RowSetMetaDataImpl();
   505 			metaData.setColumnCount(fields.length);
   506 
   507 			for (int i = 0; i < fields.length; i++) {
   508 				HeaderField hf = fields[i];
   509 				int sqlIndex = i + 1;
   510 				metaData.setColumnName(sqlIndex, hf.name);
   511 				metaData.setColumnLabel(sqlIndex, hf.name);
   512 				metaData.setColumnType(sqlIndex, hf.type.getCode());
   513 				metaData.setColumnTypeName(sqlIndex, hf.type.name());
   514 			}
   515 
   516 			return new ColumnsHeader(metaData);
   517 		} catch (SQLException e) {
   518 			throw new FormatterException("Error while constructing table headers", e);
   519 		}
   520 	}
   521 
   522 	private static class HeaderField {
   523 
   524 		String name;
   525 		SQLType type;
   526 
   527 		public HeaderField(String name, SQLType type) {
   528 			this.name = name;
   529 			this.type = type;
   530 		}
   531 	}
   532 
   533 	public enum InfoType {
   534 
   535 		HELP {
   536 					@Override
   537 					public void showInfo(InfoLister infoLister) {
   538 						infoLister.printResource(Constants.HELP_FILE);
   539 					}
   540 				},
   541 		VERSION {
   542 					@Override
   543 					public void showInfo(InfoLister infoLister) {
   544 						infoLister.printResource(Constants.VERSION_FILE);
   545 					}
   546 				},
   547 		LICENSE {
   548 					@Override
   549 					public void showInfo(InfoLister infoLister) {
   550 						infoLister.printResource(Constants.LICENSE_FILE);
   551 					}
   552 				},
   553 		JAVA_PROPERTIES {
   554 					@Override
   555 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   556 						infoLister.listJavaProperties();
   557 					}
   558 				},
   559 		ENVIRONMENT_VARIABLES {
   560 					@Override
   561 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   562 						infoLister.listEnvironmentVariables();
   563 					}
   564 				},
   565 		FORMATTERS {
   566 					@Override
   567 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   568 						infoLister.listFormatters();
   569 					}
   570 				},
   571 		FORMATTER_PROPERTIES {
   572 					@Override
   573 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   574 						infoLister.listFormatterProperties();
   575 					}
   576 				},
   577 		TYPES {
   578 					@Override
   579 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   580 						infoLister.listTypes();
   581 					}
   582 				},
   583 		JDBC_DRIVERS {
   584 					@Override
   585 					public void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException {
   586 						infoLister.listJdbcDrivers();
   587 					}
   588 				},
   589 		JDBC_PROPERTIES {
   590 					@Override
   591 					public void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException {
   592 						infoLister.listJdbcProperties();
   593 					}
   594 				},
   595 		DATABASES {
   596 					@Override
   597 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   598 						infoLister.listDatabases();
   599 					}
   600 				},
   601 		CONNECTION {
   602 					@Override
   603 					public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
   604 						infoLister.testConnections();
   605 					}
   606 				};
   607 
   608 		public abstract void showInfo(InfoLister infoLister) throws ConfigurationException, FormatterException;
   609 	}
   610 }