forked from LogBlock/LogBlock
Changed accessibility of some classes and methods.
This commit is contained in:
@@ -316,7 +316,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
|
|
||||||
public class CommandLookup extends LBCommand
|
public class CommandLookup extends LBCommand
|
||||||
{
|
{
|
||||||
CommandLookup(CommandSender sender, QueryParams params) throws Exception {
|
public CommandLookup(CommandSender sender, QueryParams params) throws Exception {
|
||||||
super(sender, params);
|
super(sender, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
|
|
||||||
public class CommandSaveQueue extends LBCommand
|
public class CommandSaveQueue extends LBCommand
|
||||||
{
|
{
|
||||||
CommandSaveQueue(CommandSender sender, QueryParams params) throws Exception {
|
public CommandSaveQueue(CommandSender sender, QueryParams params) throws Exception {
|
||||||
super(sender, params);
|
super(sender, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
|
|
||||||
public class CommandTeleport extends LBCommand
|
public class CommandTeleport extends LBCommand
|
||||||
{
|
{
|
||||||
CommandTeleport(CommandSender sender, QueryParams params) throws Exception {
|
public CommandTeleport(CommandSender sender, QueryParams params) throws Exception {
|
||||||
super(sender, params);
|
super(sender, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
|
|
||||||
public class CommandRollback extends LBCommand
|
public class CommandRollback extends LBCommand
|
||||||
{
|
{
|
||||||
CommandRollback(CommandSender sender, QueryParams params) throws Exception {
|
public CommandRollback(CommandSender sender, QueryParams params) throws Exception {
|
||||||
super(sender, params);
|
super(sender, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,11 +441,10 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.RED + "Rollback aborted");
|
sender.sendMessage(ChatColor.RED + "Rollback aborted");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long start = System.currentTimeMillis();
|
|
||||||
editor.start();
|
editor.start();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Rollback finished successfully");
|
sender.sendMessage(ChatColor.GREEN + "Rollback finished successfully");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Undid " + editor.getSuccesses() + " of " + changes + " changes (" + editor.getErrors() + " errors, " + editor.getBlacklistCollisions() + " blacklist collisions)");
|
sender.sendMessage(ChatColor.GREEN + "Undid " + editor.getSuccesses() + " of " + changes + " changes (" + editor.getErrors() + " errors, " + editor.getBlacklistCollisions() + " blacklist collisions)");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Took: " + (System.currentTimeMillis() - start) + "ms");
|
sender.sendMessage(ChatColor.GREEN + "Took: " + editor.getElapsedTime() + "ms");
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
sender.sendMessage(ChatColor.RED + "SQL exception");
|
sender.sendMessage(ChatColor.RED + "SQL exception");
|
||||||
log.log(Level.SEVERE, "[LogBlock Rollback] SQL exception", ex);
|
log.log(Level.SEVERE, "[LogBlock Rollback] SQL exception", ex);
|
||||||
@@ -463,7 +462,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
|
|
||||||
public class CommandRedo extends LBCommand
|
public class CommandRedo extends LBCommand
|
||||||
{
|
{
|
||||||
CommandRedo(CommandSender sender, QueryParams params) throws Exception {
|
public CommandRedo(CommandSender sender, QueryParams params) throws Exception {
|
||||||
super(sender, params);
|
super(sender, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,11 +480,10 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.RED + "Redo aborted");
|
sender.sendMessage(ChatColor.RED + "Redo aborted");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final long start = System.currentTimeMillis();
|
|
||||||
editor.start();
|
editor.start();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Redo finished successfully");
|
sender.sendMessage(ChatColor.GREEN + "Redo finished successfully");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Redid " + editor.getSuccesses() + " of " + changes + " changes (" + editor.getErrors() + " errors, " + editor.getBlacklistCollisions() + " blacklist collisions)");
|
sender.sendMessage(ChatColor.GREEN + "Redid " + editor.getSuccesses() + " of " + changes + " changes (" + editor.getErrors() + " errors, " + editor.getBlacklistCollisions() + " blacklist collisions)");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Took: " + (System.currentTimeMillis() - start) + "ms");
|
sender.sendMessage(ChatColor.GREEN + "Took: " + editor.getElapsedTime() + "ms");
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
sender.sendMessage(ChatColor.RED + "SQL exception");
|
sender.sendMessage(ChatColor.RED + "SQL exception");
|
||||||
log.log(Level.SEVERE, "[LogBlock Redo] SQL exception", ex);
|
log.log(Level.SEVERE, "[LogBlock Redo] SQL exception", ex);
|
||||||
@@ -503,7 +501,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
|
|
||||||
public class CommandClearLog extends LBCommand
|
public class CommandClearLog extends LBCommand
|
||||||
{
|
{
|
||||||
CommandClearLog(CommandSender sender, QueryParams params) throws Exception {
|
public CommandClearLog(CommandSender sender, QueryParams params) throws Exception {
|
||||||
super(sender, params);
|
super(sender, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,12 +144,21 @@ public class Consumer extends TimerTask
|
|||||||
queueBlock(playerName, loc, type, type, (byte)0, null, new ChestAccess(itemType, itemAmount, itemData));
|
queueBlock(playerName, loc, type, type, (byte)0, null, new ChestAccess(itemType, itemAmount, itemData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a container block break. The block type before is assumed to be o (air). All content is assumed to be taken.
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* Must be instanceof ContainerBlock
|
||||||
|
*/
|
||||||
public void queueContainerBreak(String playerName, BlockState container) {
|
public void queueContainerBreak(String playerName, BlockState container) {
|
||||||
if (!(container instanceof ContainerBlock))
|
if (!(container instanceof ContainerBlock))
|
||||||
return;
|
return;
|
||||||
queueContainerBreak(playerName, new Location(container.getWorld(), container.getX(), container.getY(), container.getZ()), container.getTypeId(), container.getRawData(), ((ContainerBlock)container).getInventory());
|
queueContainerBreak(playerName, new Location(container.getWorld(), container.getX(), container.getY(), container.getZ()), container.getTypeId(), container.getRawData(), ((ContainerBlock)container).getInventory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a container block break. The block type before is assumed to be o (air). All content is assumed to be taken.
|
||||||
|
*/
|
||||||
public void queueContainerBreak(String playerName, Location loc, int type, byte data, Inventory inv) {
|
public void queueContainerBreak(String playerName, Location loc, int type, byte data, Inventory inv) {
|
||||||
final ItemStack[] items = BukkitUtils.compressInventory(inv.getContents());
|
final ItemStack[] items = BukkitUtils.compressInventory(inv.getContents());
|
||||||
for (final ItemStack item : items)
|
for (final ItemStack item : items)
|
||||||
@@ -382,13 +391,13 @@ public class Consumer extends TimerTask
|
|||||||
|
|
||||||
private static class BlockRow
|
private static class BlockRow
|
||||||
{
|
{
|
||||||
public final ChestAccess ca;
|
final ChestAccess ca;
|
||||||
public final byte data;
|
final byte data;
|
||||||
public final String name;
|
final String name;
|
||||||
public final int replaced, type;
|
final int replaced, type;
|
||||||
public final String signtext;
|
final String signtext;
|
||||||
public final int worldHash;
|
final int worldHash;
|
||||||
public final int x, y, z;
|
final int x, y, z;
|
||||||
|
|
||||||
BlockRow(int worldHash, String name, int replaced, int type, byte data, int x, int y, int z, String signtext, ChestAccess ca) {
|
BlockRow(int worldHash, String name, int replaced, int type, byte data, int x, int y, int z, String signtext, ChestAccess ca) {
|
||||||
this.worldHash = worldHash;
|
this.worldHash = worldHash;
|
||||||
@@ -406,8 +415,8 @@ public class Consumer extends TimerTask
|
|||||||
|
|
||||||
private static class ChestAccess
|
private static class ChestAccess
|
||||||
{
|
{
|
||||||
public final byte itemData;
|
final byte itemData;
|
||||||
public final short itemType, itemAmount;
|
final short itemType, itemAmount;
|
||||||
|
|
||||||
ChestAccess(short itemType, short itemAmount, byte itemData) {
|
ChestAccess(short itemType, short itemAmount, byte itemData) {
|
||||||
this.itemType = itemType;
|
this.itemType = itemType;
|
||||||
@@ -418,10 +427,10 @@ public class Consumer extends TimerTask
|
|||||||
|
|
||||||
private static class KillRow
|
private static class KillRow
|
||||||
{
|
{
|
||||||
public final String killer;
|
final String killer;
|
||||||
public final String victim;
|
final String victim;
|
||||||
public final int weapon;
|
final int weapon;
|
||||||
public final int worldHash;
|
final int worldHash;
|
||||||
|
|
||||||
KillRow(int worldHash, String attacker, String defender, int weapon) {
|
KillRow(int worldHash, String attacker, String defender, int weapon) {
|
||||||
this.worldHash = worldHash;
|
this.worldHash = worldHash;
|
||||||
|
@@ -20,19 +20,16 @@ import de.diddiz.util.Utils;
|
|||||||
public class QueryParams implements Cloneable
|
public class QueryParams implements Cloneable
|
||||||
{
|
{
|
||||||
private static final HashSet<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode()));
|
private static final HashSet<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode()));
|
||||||
BlockChangeType bct = BlockChangeType.BOTH;
|
public BlockChangeType bct = BlockChangeType.BOTH;
|
||||||
int limit = 15;
|
public int limit = 15, minutes = 0, radius = -1;
|
||||||
Location loc = null;
|
public Location loc = null;
|
||||||
int minutes = 0;
|
public Order order = Order.DESC;
|
||||||
Order order = Order.DESC;
|
public List<String> players = new ArrayList<String>();
|
||||||
List<String> players = new ArrayList<String>();
|
public boolean prepareToolQuery = false, selectFullBlockData = false;
|
||||||
boolean prepareToolQuery = false;
|
public Selection sel = null;
|
||||||
int radius = -1;
|
public SummarizationMode sum = SummarizationMode.NONE;
|
||||||
Selection sel = null;
|
public List<Integer> types = new ArrayList<Integer>();
|
||||||
boolean selectFullBlockData = false;
|
public World world = null;
|
||||||
SummarizationMode sum = SummarizationMode.NONE;
|
|
||||||
List<Integer> types = new ArrayList<Integer>();
|
|
||||||
World world = null;
|
|
||||||
private final LogBlock logblock;
|
private final LogBlock logblock;
|
||||||
|
|
||||||
public QueryParams(LogBlock logblock) {
|
public QueryParams(LogBlock logblock) {
|
||||||
@@ -44,7 +41,7 @@ public class QueryParams implements Cloneable
|
|||||||
parseArgs(sender, args);
|
parseArgs(sender, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isKeyWord(String param) {
|
public static boolean isKeyWord(String param) {
|
||||||
if (keywords.contains(param.toLowerCase().hashCode()))
|
if (keywords.contains(param.toLowerCase().hashCode()))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -119,7 +116,7 @@ public class QueryParams implements Cloneable
|
|||||||
title.append("at " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ() + " ");
|
title.append("at " + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ() + " ");
|
||||||
else if (sel != null)
|
else if (sel != null)
|
||||||
title.append("inside selection ");
|
title.append("inside selection ");
|
||||||
title.append("in " + getfriendlyWorldname());
|
title.append("in " + BukkitUtils.friendlyWorldname(world.getName()));
|
||||||
title.setCharAt(0, String.valueOf(title.charAt(0)).toUpperCase().toCharArray()[0]);
|
title.setCharAt(0, String.valueOf(title.charAt(0)).toUpperCase().toCharArray()[0]);
|
||||||
return title.toString();
|
return title.toString();
|
||||||
}
|
}
|
||||||
@@ -358,13 +355,7 @@ public class QueryParams implements Cloneable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getfriendlyWorldname() {
|
private static String[] getValues(List<String> args, int offset) {
|
||||||
String worldName = world.getName();
|
|
||||||
worldName = worldName.substring(worldName.lastIndexOf('/') + 1);
|
|
||||||
return worldName.substring(worldName.lastIndexOf('\\') + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getValues(List<String> args, int offset) {
|
|
||||||
int i;
|
int i;
|
||||||
for (i = offset; i < args.size(); i++)
|
for (i = offset; i < args.size(); i++)
|
||||||
if (isKeyWord(args.get(i)))
|
if (isKeyWord(args.get(i)))
|
||||||
@@ -377,7 +368,7 @@ public class QueryParams implements Cloneable
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void merge(QueryParams params) {
|
public void merge(QueryParams params) {
|
||||||
players = params.players;
|
players = params.players;
|
||||||
types = params.types;
|
types = params.types;
|
||||||
loc = params.loc;
|
loc = params.loc;
|
||||||
|
@@ -15,53 +15,48 @@ import de.diddiz.util.BukkitUtils;
|
|||||||
|
|
||||||
public class WorldEditor implements Runnable
|
public class WorldEditor implements Runnable
|
||||||
{
|
{
|
||||||
public static class WorldEditorException extends Exception
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 7509084196124728986L;
|
|
||||||
|
|
||||||
public WorldEditorException(String msg) {
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Logger log;
|
private final Logger log;
|
||||||
private final LogBlock logblock;
|
private final LogBlock logblock;
|
||||||
private final Config config;
|
private final Config config;
|
||||||
private final LinkedBlockingQueue<Edit> edits = new LinkedBlockingQueue<Edit>();
|
private final LinkedBlockingQueue<Edit> edits = new LinkedBlockingQueue<Edit>();
|
||||||
private final World world;
|
private final World world;
|
||||||
private int taskID;
|
private int taskID;
|
||||||
private int successes = 0;
|
private int successes = 0, errors = 0, blacklistCollisions = 0;
|
||||||
private int errors = 0;
|
private long elapsedTime = 0;
|
||||||
private int blacklistCollisions = 0;
|
|
||||||
|
|
||||||
WorldEditor(LogBlock logblock, World world) {
|
public WorldEditor(LogBlock logblock, World world) {
|
||||||
log = logblock.getServer().getLogger();
|
log = logblock.getServer().getLogger();
|
||||||
this.logblock = logblock;
|
this.logblock = logblock;
|
||||||
config = logblock.getConfig();
|
config = logblock.getConfig();
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSize() {
|
public int getSize() {
|
||||||
return edits.size();
|
return edits.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSuccesses() {
|
public int getSuccesses() {
|
||||||
return successes;
|
return successes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getErrors() {
|
public int getErrors() {
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getBlacklistCollisions() {
|
public int getBlacklistCollisions() {
|
||||||
return blacklistCollisions;
|
return blacklistCollisions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void queueBlockChange(int type, int replaced, byte data, int x, int y, int z, String signtext, short itemType, short itemAmount, byte itemData) {
|
public void queueBlockChange(int type, int replaced, byte data, int x, int y, int z, String signtext, short itemType, short itemAmount, byte itemData) {
|
||||||
edits.add(new Edit(type, replaced, data, x, y, z, signtext, itemType, itemAmount, itemData));
|
edits.add(new Edit(type, replaced, data, x, y, z, signtext, itemType, itemAmount, itemData));
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void start() throws WorldEditorException {
|
public long getElapsedTime() {
|
||||||
|
return elapsedTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized public void start() throws WorldEditorException {
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
taskID = logblock.getServer().getScheduler().scheduleSyncRepeatingTask(logblock, this, 0, 1);
|
taskID = logblock.getServer().getScheduler().scheduleSyncRepeatingTask(logblock, this, 0, 1);
|
||||||
if (taskID == -1)
|
if (taskID == -1)
|
||||||
throw new WorldEditorException("Failed to schedule task");
|
throw new WorldEditorException("Failed to schedule task");
|
||||||
@@ -70,6 +65,7 @@ public class WorldEditor implements Runnable
|
|||||||
} catch (final InterruptedException ex) {
|
} catch (final InterruptedException ex) {
|
||||||
throw new WorldEditorException("Interrupted");
|
throw new WorldEditorException("Interrupted");
|
||||||
}
|
}
|
||||||
|
elapsedTime = System.currentTimeMillis() - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,8 +117,7 @@ public class WorldEditor implements Runnable
|
|||||||
this.itemData = itemData;
|
this.itemData = itemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Fix doors and beds
|
PerformResult perform() {
|
||||||
private PerformResult perform() {
|
|
||||||
if (config.dontRollback.contains(replaced))
|
if (config.dontRollback.contains(replaced))
|
||||||
return PerformResult.BLACKLISTED;
|
return PerformResult.BLACKLISTED;
|
||||||
try {
|
try {
|
||||||
@@ -195,4 +190,13 @@ public class WorldEditor implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class WorldEditorException extends Exception
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 7509084196124728986L;
|
||||||
|
|
||||||
|
public WorldEditorException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,6 +97,11 @@ public class BukkitUtils
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String friendlyWorldname(String worldName) {
|
||||||
|
worldName = worldName.substring(worldName.lastIndexOf('/') + 1);
|
||||||
|
return worldName.substring(worldName.lastIndexOf('\\') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
public static Set<Set<Integer>> getBlockEquivalents() {
|
public static Set<Set<Integer>> getBlockEquivalents() {
|
||||||
return blockEquivalents;
|
return blockEquivalents;
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ public class ConnectionPool implements Closeable
|
|||||||
private boolean inuse;
|
private boolean inuse;
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
||||||
public JDCConnection(Connection conn) {
|
JDCConnection(Connection conn) {
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
inuse = false;
|
inuse = false;
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
@@ -195,10 +195,6 @@ public class ConnectionPool implements Closeable
|
|||||||
return conn.getHoldability();
|
return conn.getHoldability();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastUse() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseMetaData getMetaData() throws SQLException {
|
public DatabaseMetaData getMetaData() throws SQLException {
|
||||||
return conn.getMetaData();
|
return conn.getMetaData();
|
||||||
@@ -219,10 +215,6 @@ public class ConnectionPool implements Closeable
|
|||||||
return conn.getWarnings();
|
return conn.getWarnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inUse() {
|
|
||||||
return inuse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosed() throws SQLException {
|
public boolean isClosed() throws SQLException {
|
||||||
return conn.isClosed();
|
return conn.isClosed();
|
||||||
@@ -233,14 +225,6 @@ public class ConnectionPool implements Closeable
|
|||||||
return conn.isReadOnly();
|
return conn.isReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
try {
|
|
||||||
return conn.isValid(1);
|
|
||||||
} catch (final SQLException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(int timeout) throws SQLException {
|
public boolean isValid(int timeout) throws SQLException {
|
||||||
return conn.isValid(timeout);
|
return conn.isValid(timeout);
|
||||||
@@ -251,14 +235,6 @@ public class ConnectionPool implements Closeable
|
|||||||
return conn.isWrapperFor(iface);
|
return conn.isWrapperFor(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean lease() {
|
|
||||||
if (inuse)
|
|
||||||
return false;
|
|
||||||
inuse = true;
|
|
||||||
timestamp = System.currentTimeMillis();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String nativeSQL(String sql) throws SQLException {
|
public String nativeSQL(String sql) throws SQLException {
|
||||||
return conn.nativeSQL(sql);
|
return conn.nativeSQL(sql);
|
||||||
@@ -374,15 +350,39 @@ public class ConnectionPool implements Closeable
|
|||||||
conn.setTypeMap(map);
|
conn.setTypeMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terminate() {
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (final SQLException ex) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||||
return conn.unwrap(iface);
|
return conn.unwrap(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long getLastUse() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean inUse() {
|
||||||
|
return inuse;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isValid() {
|
||||||
|
try {
|
||||||
|
return conn.isValid(1);
|
||||||
|
} catch (final SQLException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized boolean lease() {
|
||||||
|
if (inuse)
|
||||||
|
return false;
|
||||||
|
inuse = true;
|
||||||
|
timestamp = System.currentTimeMillis();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void terminate() {
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (final SQLException ex) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user