TransactionManager.smali
.class public Lcom/j256/ormlite/misc/TransactionManager;
.super Ljava/lang/Object;
.source "SourceFile"
# static fields
.field private static final SAVE_POINT_PREFIX:Ljava/lang/String; = "ORMLITE"
.field private static final logger:Lcom/j256/ormlite/logger/Logger;
.field private static savePointCounter:Ljava/util/concurrent/atomic/AtomicInteger;
# instance fields
.field private connectionSource:Lcom/j256/ormlite/support/ConnectionSource;
# direct methods
.method public static constructor <clinit>()V
.registers 1
.line 1
const-class v0, Lcom/j256/ormlite/misc/TransactionManager;
invoke-static {v0}, Lcom/j256/ormlite/logger/LoggerFactory;->getLogger(Ljava/lang/Class;)Lcom/j256/ormlite/logger/Logger;
move-result-object v0
sput-object v0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
.line 2
new-instance v0, Ljava/util/concurrent/atomic/AtomicInteger;
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V
sput-object v0, Lcom/j256/ormlite/misc/TransactionManager;->savePointCounter:Ljava/util/concurrent/atomic/AtomicInteger;
return-void
.end method
.method public constructor <init>()V
.registers 1
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public constructor <init>(Lcom/j256/ormlite/support/ConnectionSource;)V
.registers 2
.line 2
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 3
iput-object p1, p0, Lcom/j256/ormlite/misc/TransactionManager;->connectionSource:Lcom/j256/ormlite/support/ConnectionSource;
.line 4
invoke-virtual {p0}, Lcom/j256/ormlite/misc/TransactionManager;->initialize()V
return-void
.end method
.method public static callInTransaction(Lcom/j256/ormlite/support/ConnectionSource;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
.registers 3
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/j256/ormlite/support/ConnectionSource;",
"Ljava/util/concurrent/Callable<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
const/4 v0, 0x0
.line 3
invoke-static {v0, p0, p1}, Lcom/j256/ormlite/misc/TransactionManager;->callInTransaction(Ljava/lang/String;Lcom/j256/ormlite/support/ConnectionSource;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
move-result-object p0
return-object p0
.end method
.method public static callInTransaction(Lcom/j256/ormlite/support/DatabaseConnection;Lcom/j256/ormlite/db/DatabaseType;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/j256/ormlite/support/DatabaseConnection;",
"Lcom/j256/ormlite/db/DatabaseType;",
"Ljava/util/concurrent/Callable<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
const/4 v0, 0x0
.line 11
invoke-static {p0, v0, p1, p2}, Lcom/j256/ormlite/misc/TransactionManager;->callInTransaction(Lcom/j256/ormlite/support/DatabaseConnection;ZLcom/j256/ormlite/db/DatabaseType;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
move-result-object p0
return-object p0
.end method
.method public static callInTransaction(Lcom/j256/ormlite/support/DatabaseConnection;ZLcom/j256/ormlite/db/DatabaseType;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
.registers 10
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/j256/ormlite/support/DatabaseConnection;",
"Z",
"Lcom/j256/ormlite/db/DatabaseType;",
"Ljava/util/concurrent/Callable<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
const-string v0, "after commit exception, rolling back to save-point also threw exception"
const/4 v1, 0x0
const-string v2, "restored auto-commit to true"
const/4 v3, 0x0
const/4 v4, 0x1
if-nez p1, :cond_12
.line 12
:try_start_9
invoke-interface {p2}, Lcom/j256/ormlite/db/DatabaseType;->isNestedSavePointsSupported()Z
move-result p1
if-eqz p1, :cond_10
goto :goto_12
:cond_10
const/4 p1, 0x0
goto :goto_60
.line 13
:cond_12
:goto_12
invoke-interface {p0}, Lcom/j256/ormlite/support/DatabaseConnection;->isAutoCommitSupported()Z
move-result p1
if-eqz p1, :cond_2e
.line 14
invoke-interface {p0}, Lcom/j256/ormlite/support/DatabaseConnection;->isAutoCommit()Z
move-result p1
if-eqz p1, :cond_2e
.line 15
invoke-interface {p0, v3}, Lcom/j256/ormlite/support/DatabaseConnection;->setAutoCommit(Z)V
:try_end_21
.catchall {:try_start_9 .. :try_end_21} :catchall_98
.line 16
:try_start_21
sget-object p1, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p2, "had to set auto-commit to false"
invoke-virtual {p1, p2}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;)V
:try_end_28
.catchall {:try_start_21 .. :try_end_28} :catchall_2a
const/4 v3, 0x1
goto :goto_2e
:catchall_2a
move-exception p1
const/4 v3, 0x1
goto/16 :goto_99
.line 17
:cond_2e
:goto_2e
:try_start_2e
new-instance p1, Ljava/lang/StringBuilder;
invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V
const-string p2, "ORMLITE"
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
sget-object p2, Lcom/j256/ormlite/misc/TransactionManager;->savePointCounter:Ljava/util/concurrent/atomic/AtomicInteger;
invoke-virtual {p2}, Ljava/util/concurrent/atomic/AtomicInteger;->incrementAndGet()I
move-result p2
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-interface {p0, p1}, Lcom/j256/ormlite/support/DatabaseConnection;->setSavePoint(Ljava/lang/String;)Ljava/sql/Savepoint;
move-result-object v1
if-nez v1, :cond_53
.line 18
sget-object p1, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p2, "started savePoint transaction"
invoke-virtual {p1, p2}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;)V
goto :goto_5e
.line 19
:cond_53
sget-object p1, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p2, "started savePoint transaction {}"
invoke-interface {v1}, Ljava/sql/Savepoint;->getSavepointName()Ljava/lang/String;
move-result-object v5
invoke-virtual {p1, p2, v5}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;Ljava/lang/Object;)V
:try_end_5e
.catchall {:try_start_2e .. :try_end_5e} :catchall_98
:goto_5e
move p1, v3
const/4 v3, 0x1
.line 20
:goto_60
:try_start_60
invoke-interface {p3}, Ljava/util/concurrent/Callable;->call()Ljava/lang/Object;
move-result-object p2
if-eqz v3, :cond_69
.line 21
invoke-static {p0, v1}, Lcom/j256/ormlite/misc/TransactionManager;->commit(Lcom/j256/ormlite/support/DatabaseConnection;Ljava/sql/Savepoint;)V
:try_end_69
.catch Ljava/sql/SQLException; {:try_start_60 .. :try_end_69} :catch_8b
.catch Ljava/lang/Exception; {:try_start_60 .. :try_end_69} :catch_78
.catchall {:try_start_60 .. :try_end_69} :catchall_74
:cond_69
if-eqz p1, :cond_73
.line 22
invoke-interface {p0, v4}, Lcom/j256/ormlite/support/DatabaseConnection;->setAutoCommit(Z)V
.line 23
sget-object p0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
invoke-virtual {p0, v2}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;)V
:cond_73
return-object p2
:catchall_74
move-exception p2
move v3, p1
move-object p1, p2
goto :goto_99
:catch_78
move-exception p2
if-eqz v3, :cond_84
.line 24
:try_start_7b
invoke-static {p0, v1}, Lcom/j256/ormlite/misc/TransactionManager;->rollBack(Lcom/j256/ormlite/support/DatabaseConnection;Ljava/sql/Savepoint;)V
:try_end_7e
.catch Ljava/sql/SQLException; {:try_start_7b .. :try_end_7e} :catch_7f
.catchall {:try_start_7b .. :try_end_7e} :catchall_74
goto :goto_84
.line 25
:catch_7f
:try_start_7f
sget-object p3, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
invoke-virtual {p3, p2, v0}, Lcom/j256/ormlite/logger/Logger;->error(Ljava/lang/Throwable;Ljava/lang/String;)V
:cond_84
:goto_84
const-string p3, "Transaction callable threw non-SQL exception"
.line 26
invoke-static {p3, p2}, Lcom/j256/ormlite/misc/SqlExceptionUtil;->create(Ljava/lang/String;Ljava/lang/Throwable;)Ljava/sql/SQLException;
move-result-object p2
throw p2
:try_end_8b
.catchall {:try_start_7f .. :try_end_8b} :catchall_74
:catch_8b
move-exception p2
if-eqz v3, :cond_97
.line 27
:try_start_8e
invoke-static {p0, v1}, Lcom/j256/ormlite/misc/TransactionManager;->rollBack(Lcom/j256/ormlite/support/DatabaseConnection;Ljava/sql/Savepoint;)V
:try_end_91
.catch Ljava/sql/SQLException; {:try_start_8e .. :try_end_91} :catch_92
.catchall {:try_start_8e .. :try_end_91} :catchall_74
goto :goto_97
.line 28
:catch_92
:try_start_92
sget-object p3, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
invoke-virtual {p3, p2, v0}, Lcom/j256/ormlite/logger/Logger;->error(Ljava/lang/Throwable;Ljava/lang/String;)V
.line 29
:cond_97
:goto_97
throw p2
:try_end_98
.catchall {:try_start_92 .. :try_end_98} :catchall_74
:catchall_98
move-exception p1
:goto_99
if-eqz v3, :cond_a3
.line 30
invoke-interface {p0, v4}, Lcom/j256/ormlite/support/DatabaseConnection;->setAutoCommit(Z)V
.line 31
sget-object p0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
invoke-virtual {p0, v2}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;)V
:cond_a3
throw p1
.end method
.method public static callInTransaction(Ljava/lang/String;Lcom/j256/ormlite/support/ConnectionSource;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
.registers 5
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Ljava/lang/String;",
"Lcom/j256/ormlite/support/ConnectionSource;",
"Ljava/util/concurrent/Callable<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
.line 4
invoke-interface {p1, p0}, Lcom/j256/ormlite/support/ConnectionSource;->getReadWriteConnection(Ljava/lang/String;)Lcom/j256/ormlite/support/DatabaseConnection;
move-result-object p0
.line 5
:try_start_4
invoke-interface {p1, p0}, Lcom/j256/ormlite/support/ConnectionSource;->saveSpecialConnection(Lcom/j256/ormlite/support/DatabaseConnection;)Z
move-result v0
.line 6
invoke-interface {p1}, Lcom/j256/ormlite/support/ConnectionSource;->getDatabaseType()Lcom/j256/ormlite/db/DatabaseType;
move-result-object v1
invoke-static {p0, v0, v1, p2}, Lcom/j256/ormlite/misc/TransactionManager;->callInTransaction(Lcom/j256/ormlite/support/DatabaseConnection;ZLcom/j256/ormlite/db/DatabaseType;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
move-result-object p2
:try_end_10
.catchall {:try_start_4 .. :try_end_10} :catchall_17
.line 7
invoke-interface {p1, p0}, Lcom/j256/ormlite/support/ConnectionSource;->clearSpecialConnection(Lcom/j256/ormlite/support/DatabaseConnection;)V
.line 8
invoke-interface {p1, p0}, Lcom/j256/ormlite/support/ConnectionSource;->releaseConnection(Lcom/j256/ormlite/support/DatabaseConnection;)V
return-object p2
:catchall_17
move-exception p2
.line 9
invoke-interface {p1, p0}, Lcom/j256/ormlite/support/ConnectionSource;->clearSpecialConnection(Lcom/j256/ormlite/support/DatabaseConnection;)V
.line 10
invoke-interface {p1, p0}, Lcom/j256/ormlite/support/ConnectionSource;->releaseConnection(Lcom/j256/ormlite/support/DatabaseConnection;)V
throw p2
.end method
.method private static commit(Lcom/j256/ormlite/support/DatabaseConnection;Ljava/sql/Savepoint;)V
.registers 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
if-nez p1, :cond_4
const/4 v0, 0x0
goto :goto_8
.line 1
:cond_4
invoke-interface {p1}, Ljava/sql/Savepoint;->getSavepointName()Ljava/lang/String;
move-result-object v0
.line 2
:goto_8
invoke-interface {p0, p1}, Lcom/j256/ormlite/support/DatabaseConnection;->commit(Ljava/sql/Savepoint;)V
if-nez v0, :cond_15
.line 3
sget-object p0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p1, "committed savePoint transaction"
invoke-virtual {p0, p1}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;)V
goto :goto_1c
.line 4
:cond_15
sget-object p0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p1, "committed savePoint transaction {}"
invoke-virtual {p0, p1, v0}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;Ljava/lang/Object;)V
:goto_1c
return-void
.end method
.method private static rollBack(Lcom/j256/ormlite/support/DatabaseConnection;Ljava/sql/Savepoint;)V
.registers 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
if-nez p1, :cond_4
const/4 v0, 0x0
goto :goto_8
.line 1
:cond_4
invoke-interface {p1}, Ljava/sql/Savepoint;->getSavepointName()Ljava/lang/String;
move-result-object v0
.line 2
:goto_8
invoke-interface {p0, p1}, Lcom/j256/ormlite/support/DatabaseConnection;->rollback(Ljava/sql/Savepoint;)V
if-nez v0, :cond_15
.line 3
sget-object p0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p1, "rolled back savePoint transaction"
invoke-virtual {p0, p1}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;)V
goto :goto_1c
.line 4
:cond_15
sget-object p0, Lcom/j256/ormlite/misc/TransactionManager;->logger:Lcom/j256/ormlite/logger/Logger;
const-string p1, "rolled back savePoint transaction {}"
invoke-virtual {p0, p1, v0}, Lcom/j256/ormlite/logger/Logger;->debug(Ljava/lang/String;Ljava/lang/Object;)V
:goto_1c
return-void
.end method
# virtual methods
.method public callInTransaction(Ljava/lang/String;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Ljava/lang/String;",
"Ljava/util/concurrent/Callable<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
.line 2
iget-object v0, p0, Lcom/j256/ormlite/misc/TransactionManager;->connectionSource:Lcom/j256/ormlite/support/ConnectionSource;
invoke-static {p1, v0, p2}, Lcom/j256/ormlite/misc/TransactionManager;->callInTransaction(Ljava/lang/String;Lcom/j256/ormlite/support/ConnectionSource;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
move-result-object p1
return-object p1
.end method
.method public callInTransaction(Ljava/util/concurrent/Callable;)Ljava/lang/Object;
.registers 3
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Ljava/util/concurrent/Callable<",
"TT;>;)TT;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/sql/SQLException;
}
.end annotation
.line 1
iget-object v0, p0, Lcom/j256/ormlite/misc/TransactionManager;->connectionSource:Lcom/j256/ormlite/support/ConnectionSource;
invoke-static {v0, p1}, Lcom/j256/ormlite/misc/TransactionManager;->callInTransaction(Lcom/j256/ormlite/support/ConnectionSource;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
move-result-object p1
return-object p1
.end method
.method public initialize()V
.registers 4
.line 1
iget-object v0, p0, Lcom/j256/ormlite/misc/TransactionManager;->connectionSource:Lcom/j256/ormlite/support/ConnectionSource;
if-eqz v0, :cond_5
return-void
.line 2
:cond_5
new-instance v0, Ljava/lang/IllegalStateException;
const-string v1, "dataSource was not set on "
.line 3
invoke-static {v1}, Landroid/support/v4/media/c;->c(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
.line 4
invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public setConnectionSource(Lcom/j256/ormlite/support/ConnectionSource;)V
.registers 2
iput-object p1, p0, Lcom/j256/ormlite/misc/TransactionManager;->connectionSource:Lcom/j256/ormlite/support/ConnectionSource;
return-void
.end method