Java tutorial
package com.electronicpanopticon.wb.shell.commands; import java.io.IOException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.shell.core.CommandMarker; import org.springframework.shell.core.annotation.CliCommand; import org.springframework.stereotype.Component; import com.electronicpanopticon.wb.shell.plugins.CorePlugin; @Component public class CoreCommands implements CommandMarker { private static final String LICENSE_FILENAME = "LICENSE"; @Autowired CorePlugin coreplugin; @Autowired DriverManagerDataSource dataSource; @CliCommand(value = "license", help = "Prints the license for this application.") public String licenseCommand() throws IOException { return this.coreplugin.getClasspathResourceAsString(LICENSE_FILENAME); } /** * * @return * @throws IOException */ @CliCommand(value = "ping", help = "Tests the database connection.") public String pingCommand() throws IOException { JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource); jdbcTemplate.execute("SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);"); return "ping"; } }