Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test_block_process
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
test_block_process
Commits
686ace2b
Commit
686ace2b
authored
Dec 10, 2019
by
Aigul Baimussayeva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
application with db
parent
13bb6ac0
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1857 additions
and
0 deletions
+1857
-0
build.gradle
build.gradle
+2
-0
src/main/java/kz/arta/test/blocking/BlockProcessListener.java
...main/java/kz/arta/test/blocking/BlockProcessListener.java
+15
-0
src/main/java/kz/arta/test/blocking/ITSMRestService.java
src/main/java/kz/arta/test/blocking/ITSMRestService.java
+35
-0
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlCheckConnThread.java
...kz/arta/test/blocking/mysql/ArtaMysqlCheckConnThread.java
+85
-0
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlConfigDefaultFields.java
...rta/test/blocking/mysql/ArtaMysqlConfigDefaultFields.java
+11
-0
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlConfigManager.java
...a/kz/arta/test/blocking/mysql/ArtaMysqlConfigManager.java
+52
-0
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlConnectionPool.java
.../kz/arta/test/blocking/mysql/ArtaMysqlConnectionPool.java
+58
-0
src/main/java/kz/arta/test/blocking/mysql/CallableStatementImpl.java
...va/kz/arta/test/blocking/mysql/CallableStatementImpl.java
+594
-0
src/main/java/kz/arta/test/blocking/mysql/ConnectionImpl.java
...main/java/kz/arta/test/blocking/mysql/ConnectionImpl.java
+292
-0
src/main/java/kz/arta/test/blocking/mysql/DataExtractorCommon.java
...java/kz/arta/test/blocking/mysql/DataExtractorCommon.java
+34
-0
src/main/java/kz/arta/test/blocking/mysql/DbConfig.java
src/main/java/kz/arta/test/blocking/mysql/DbConfig.java
+135
-0
src/main/java/kz/arta/test/blocking/mysql/PreparedStatementImpl.java
...va/kz/arta/test/blocking/mysql/PreparedStatementImpl.java
+302
-0
src/main/java/kz/arta/test/blocking/mysql/StatementImpl.java
src/main/java/kz/arta/test/blocking/mysql/StatementImpl.java
+242
-0
No files found.
build.gradle
View file @
686ace2b
...
@@ -32,6 +32,8 @@ dependencies {
...
@@ -32,6 +32,8 @@ dependencies {
providedCompile
'org.apache.httpcomponents:httpclient:4.5'
providedCompile
'org.apache.httpcomponents:httpclient:4.5'
compile
"commons-io:commons-io:2.1"
compile
"commons-io:commons-io:2.1"
compile
group:
'com.google.guava'
,
name:
'guava-gwt'
,
version:
'18.0'
compile
group:
'com.google.guava'
,
name:
'guava-gwt'
,
version:
'18.0'
compile
(
'org.jboss.spec:jboss-javaee-6.0:3.0.3.Final'
)
providedCompile
group:
'org.jboss.resteasy'
,
name:
'resteasy-jaxrs'
,
version:
'2.3.3.Final'
}
}
...
...
src/main/java/kz/arta/test/blocking/BlockProcessListener.java
View file @
686ace2b
...
@@ -2,6 +2,7 @@ package kz.arta.test.blocking;
...
@@ -2,6 +2,7 @@ package kz.arta.test.blocking;
import
kz.arta.test.blocking.data.ASFData
;
import
kz.arta.test.blocking.data.ASFData
;
import
kz.arta.test.blocking.data.ASFDataWrapperExt
;
import
kz.arta.test.blocking.data.ASFDataWrapperExt
;
import
kz.arta.test.blocking.mysql.ArtaMysqlConnectionPool
;
import
kz.arta.test.blocking.utils.AsfDataApi
;
import
kz.arta.test.blocking.utils.AsfDataApi
;
import
kz.arta.test.blocking.utils.DictApi
;
import
kz.arta.test.blocking.utils.DictApi
;
import
kz.arta.test.blocking.utils.PropsUtil
;
import
kz.arta.test.blocking.utils.PropsUtil
;
...
@@ -16,6 +17,9 @@ import javax.ejb.MessageDriven;
...
@@ -16,6 +17,9 @@ import javax.ejb.MessageDriven;
import
javax.jms.Message
;
import
javax.jms.Message
;
import
javax.jms.MessageListener
;
import
javax.jms.MessageListener
;
import
javax.jms.TextMessage
;
import
javax.jms.TextMessage
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
/**
/**
* User: Aigul
* User: Aigul
...
@@ -76,6 +80,17 @@ public class BlockProcessListener implements MessageListener {
...
@@ -76,6 +80,17 @@ public class BlockProcessListener implements MessageListener {
asfDataApi
.
saveData
(
REGULAR_MAPPER
.
writeValueAsString
(
data
.
getData
()),
data
.
getForm
(),
data
.
getUuid
(),
null
);
asfDataApi
.
saveData
(
REGULAR_MAPPER
.
writeValueAsString
(
data
.
getData
()),
data
.
getForm
(),
data
.
getUuid
(),
null
);
}
}
/*тут пример с БД*/
try
(
Connection
con
=
ArtaMysqlConnectionPool
.
getXAConnection
()){
PreparedStatement
ps
=
con
.
prepareStatement
(
"INSERT INTO docs_opened(documentID, userID, date) VALUES(?,?,CURRENT_TIMESTAMP )"
);
ps
.
setString
(
1
,
"docID"
);
ps
.
setString
(
2
,
"userID"
);
ps
.
execute
();
}
catch
(
SQLException
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
}
catch
(
Exception
exc
)
{
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
"Error processing text message"
,
exc
);
LOGGER
.
error
(
"Error processing text message"
,
exc
);
}
finally
{
}
finally
{
...
...
src/main/java/kz/arta/test/blocking/ITSMRestService.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking
;
import
kz.arta.test.blocking.mysql.ArtaMysqlConnectionPool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
@Path
(
"/"
)
public
class
ITSMRestService
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ITSMRestService
.
class
);
@GET
@Path
(
"/close"
)
@Produces
(
MediaType
.
TEXT_PLAIN
+
"; charset=utf-8"
)
public
Response
rate
(
@QueryParam
(
"documentID"
)
String
documentID
,
@QueryParam
(
"userID"
)
String
userID
)
{
try
(
Connection
con
=
ArtaMysqlConnectionPool
.
getXAConnection
())
{
PreparedStatement
ps
=
con
.
prepareStatement
(
"DELETE FROM docs_opened WHERE documentID = ? and userID = ?"
);
ps
.
setString
(
1
,
documentID
);
ps
.
setString
(
2
,
userID
);
ps
.
execute
();
return
Response
.
ok
(
"Doc deleted"
).
build
();
}
catch
(
Exception
e
)
{
return
Response
.
status
(
Response
.
Status
.
INTERNAL_SERVER_ERROR
).
entity
(
"Error while doc deleting"
).
build
();
}
}
}
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlCheckConnThread.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.sql.Connection
;
/**
* Поток проверки соединений mysql arta-synergy
*
* @author MGetmanov
* @since 28.05.15 8:43
*/
public
class
ArtaMysqlCheckConnThread
extends
Thread
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ArtaMysqlCheckConnThread
.
class
);
private
StackTraceElement
[]
elements
;
private
Connection
con
=
null
;
private
static
boolean
isEnabled
=
false
;
private
static
long
timeout
=
0
;
private
static
boolean
closeConnections
=
false
;
static
{
if
(
ArtaMysqlConfigManager
.
getProps
().
containsKey
(
ArtaMysqlConfigManager
.
ConfigKeyProperties
.
observe_connections
.
name
())
&&
DataExtractorCommon
.
getBoolean
(
ArtaMysqlConfigManager
.
getProps
().
get
(
ArtaMysqlConfigManager
.
ConfigKeyProperties
.
observe_connections
.
name
())))
{
isEnabled
=
true
;
timeout
=
DataExtractorCommon
.
getLongStat
(
ArtaMysqlConfigManager
.
getProps
().
get
(
ArtaMysqlConfigManager
.
ConfigKeyProperties
.
observe_connection_timeout
.
name
()));
closeConnections
=
DataExtractorCommon
.
getBoolean
(
ArtaMysqlConfigManager
.
getProps
().
get
(
ArtaMysqlConfigManager
.
ConfigKeyProperties
.
close_observing_connection
.
name
()));
if
(
timeout
<
180000
)
{
timeout
=
180000
;
}
}
LOGGER
.
info
(
"Observing opened connections is "
+
(
isEnabled
?
"enabled"
:
"disabled"
));
if
(
isEnabled
)
{
LOGGER
.
info
(
"Started observing connections with parameters: timeout="
+
timeout
+
"ms; close_connections="
+
closeConnections
);
if
(
closeConnections
)
{
LOGGER
.
error
(
"WARNING! Closing connections in production mode is a VERY BAD IDEA. If you really need to do this "
+
"contact developers."
);
}
}
}
private
ArtaMysqlCheckConnThread
(
StackTraceElement
[]
elements
,
Connection
con
)
{
this
.
elements
=
elements
;
this
.
con
=
con
;
}
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
timeout
);
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
try
{
if
(
con
!=
null
&&
!
con
.
isClosed
())
{
StringBuilder
str
=
new
StringBuilder
();
for
(
StackTraceElement
element
:
elements
)
{
str
.
append
(
"\n\t"
);
str
.
append
(
element
.
toString
());
}
LOGGER
.
error
(
"Connection was not closed within allowed timeout ["
+
timeout
+
"] !"
+
str
.
toString
());
if
(
closeConnections
)
{
LOGGER
.
error
(
"Closing connection for you"
);
try
{
con
.
close
();
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
public
static
void
startObserveConnection
(
Connection
con
)
{
if
(!
isEnabled
)
{
return
;
}
new
ArtaMysqlCheckConnThread
(
Thread
.
currentThread
().
getStackTrace
(),
con
).
start
();
}
}
\ No newline at end of file
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlConfigDefaultFields.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
/**
* Поля по умолчанию для менеджера конфигурации mysql соединений arta-synergy
*
* @author MGetmanov
* @since 28.05.15 8:40
*/
interface
ArtaMysqlConfigDefaultFields
{
}
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlConfigManager.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
java.util.Properties
;
/**
* Менеджер конфигурации работы с MYSQL для arta-synergy
*
* @author MGetmanov
* @since 28.05.15 8:39
*/
public
class
ArtaMysqlConfigManager
{
public
static
DbConfig
config
;
public
enum
ConfigKeyProperties
{
observe_connections
,
observe_connection_timeout
,
close_observing_connection
}
public
synchronized
static
Properties
getProps
()
{
return
getConfig
().
getProps
();
}
private
synchronized
static
DbConfig
getConfig
()
{
if
(
config
==
null
)
{
config
=
new
DbConfig
();
config
.
initialize
();
}
return
config
;
}
public
static
String
getEarName
()
{
return
getConfig
().
getEarName
();
}
public
static
String
getCfgURL
()
{
return
getConfig
().
getCfgURL
();
}
public
static
String
getCfgDirectory
()
{
return
getConfig
().
getCfgDirectory
();
}
public
static
String
getSynergyDS
()
{
return
getConfig
().
getSynergyDS
();
}
public
static
String
getConfFilePath
(
String
relativePath
)
{
return
getConfig
().
getConfFilePath
(
relativePath
);
}
}
src/main/java/kz/arta/test/blocking/mysql/ArtaMysqlConnectionPool.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.naming.InitialContext
;
import
javax.sql.DataSource
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
/**
* Класс предназначен для управления соединениями с базой данных
* Для получения соединения необходимо использовать метод getXAConnection
* Для закрытия соединения необходимо использовать метод closeConnection
* User: topa
* Date: 15.07.2008
* Time: 12:34:40
*/
public
class
ArtaMysqlConnectionPool
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ArtaMysqlConnectionPool
.
class
);
private
static
final
String
POOL_NAME
=
"java:/SynergyItsm"
;
/**
* Метод для получения соединения из пула
*
* @return - открытое соединение
*/
public
static
Connection
getXAConnection
()
{
Connection
con
=
null
;
try
{
InitialContext
ctx
=
new
InitialContext
();
DataSource
ds
=
(
DataSource
)
ctx
.
lookup
(
POOL_NAME
);
con
=
ds
.
getConnection
();
ArtaMysqlCheckConnThread
.
startObserveConnection
(
con
);
return
new
ConnectionImpl
(
con
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
closeConnection
(
con
);
throw
new
IllegalStateException
(
e
);
}
}
/**
* Метод для закрытия соединения
*
* @param con - соединение которое необходимо закрыть
*/
public
static
void
closeConnection
(
Connection
con
)
{
if
(
con
!=
null
)
{
try
{
con
.
close
();
}
catch
(
SQLException
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
}
}
}
src/main/java/kz/arta/test/blocking/mysql/CallableStatementImpl.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
java.io.InputStream
;
import
java.io.Reader
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.sql.*
;
import
java.util.Calendar
;
import
java.util.Map
;
/**
* User: vsl
* Date: 8/25/16
* Time: 1:03 PM
*/
public
class
CallableStatementImpl
extends
PreparedStatementImpl
implements
CallableStatement
{
private
CallableStatement
jdbcStatement
;
public
CallableStatementImpl
(
CallableStatement
jdbcStatement
,
ConnectionImpl
connectionWrapper
)
{
super
(
jdbcStatement
,
connectionWrapper
);
this
.
jdbcStatement
=
jdbcStatement
;
}
@Override
protected
CallableStatement
getJdbcStatement
()
{
return
jdbcStatement
;
}
@Override
public
void
registerOutParameter
(
int
parameterIndex
,
int
sqlType
)
throws
SQLException
{
getJdbcStatement
().
registerOutParameter
(
parameterIndex
,
sqlType
);
}
@Override
public
void
registerOutParameter
(
int
parameterIndex
,
int
sqlType
,
int
scale
)
throws
SQLException
{
getJdbcStatement
().
registerOutParameter
(
parameterIndex
,
sqlType
,
scale
);
}
@Override
public
boolean
wasNull
()
throws
SQLException
{
return
getJdbcStatement
().
wasNull
();
}
@Override
public
String
getString
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getString
(
parameterIndex
);
}
@Override
public
boolean
getBoolean
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getBoolean
(
parameterIndex
);
}
@Override
public
byte
getByte
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getByte
(
parameterIndex
);
}
@Override
public
short
getShort
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getShort
(
parameterIndex
);
}
@Override
public
int
getInt
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getInt
(
parameterIndex
);
}
@Override
public
long
getLong
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getLong
(
parameterIndex
);
}
@Override
public
float
getFloat
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getFloat
(
parameterIndex
);
}
@Override
public
double
getDouble
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getDouble
(
parameterIndex
);
}
@Override
public
BigDecimal
getBigDecimal
(
int
parameterIndex
,
int
scale
)
throws
SQLException
{
return
getJdbcStatement
().
getBigDecimal
(
parameterIndex
,
scale
);
}
@Override
public
byte
[]
getBytes
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getBytes
(
parameterIndex
);
}
@Override
public
Date
getDate
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getDate
(
parameterIndex
);
}
@Override
public
Time
getTime
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getTime
(
parameterIndex
);
}
@Override
public
Timestamp
getTimestamp
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getTimestamp
(
parameterIndex
);
}
@Override
public
Object
getObject
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getObject
(
parameterIndex
);
}
@Override
public
BigDecimal
getBigDecimal
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getBigDecimal
(
parameterIndex
);
}
@Override
public
Object
getObject
(
int
parameterIndex
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
return
getJdbcStatement
().
getObject
(
parameterIndex
,
map
);
}
@Override
public
Ref
getRef
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getRef
(
parameterIndex
);
}
@Override
public
Blob
getBlob
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getBlob
(
parameterIndex
);
}
@Override
public
Clob
getClob
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getClob
(
parameterIndex
);
}
@Override
public
Array
getArray
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getArray
(
parameterIndex
);
}
@Override
public
Date
getDate
(
int
parameterIndex
,
Calendar
cal
)
throws
SQLException
{
return
getJdbcStatement
().
getDate
(
parameterIndex
,
cal
);
}
@Override
public
Time
getTime
(
int
parameterIndex
,
Calendar
cal
)
throws
SQLException
{
return
getJdbcStatement
().
getTime
(
parameterIndex
,
cal
);
}
@Override
public
Timestamp
getTimestamp
(
int
parameterIndex
,
Calendar
cal
)
throws
SQLException
{
return
getJdbcStatement
().
getTimestamp
(
parameterIndex
,
cal
);
}
@Override
public
void
registerOutParameter
(
int
parameterIndex
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
getJdbcStatement
().
registerOutParameter
(
parameterIndex
,
sqlType
,
typeName
);
}
@Override
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
getJdbcStatement
().
registerOutParameter
(
parameterName
,
sqlType
);
}
@Override
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
,
int
scale
)
throws
SQLException
{
getJdbcStatement
().
registerOutParameter
(
parameterName
,
sqlType
,
scale
);
}
@Override
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
getJdbcStatement
().
registerOutParameter
(
parameterName
,
sqlType
,
typeName
);
}
@Override
public
URL
getURL
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getURL
(
parameterIndex
);
}
@Override
public
void
setURL
(
String
parameterName
,
URL
val
)
throws
SQLException
{
getJdbcStatement
().
setURL
(
parameterName
,
val
);
}
@Override
public
void
setNull
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
getJdbcStatement
().
setNull
(
parameterName
,
sqlType
);
}
@Override
public
void
setBoolean
(
String
parameterName
,
boolean
x
)
throws
SQLException
{
getJdbcStatement
().
setBoolean
(
parameterName
,
x
);
}
@Override
public
void
setByte
(
String
parameterName
,
byte
x
)
throws
SQLException
{
getJdbcStatement
().
setByte
(
parameterName
,
x
);
}
@Override
public
void
setShort
(
String
parameterName
,
short
x
)
throws
SQLException
{
getJdbcStatement
().
setShort
(
parameterName
,
x
);
}
@Override
public
void
setInt
(
String
parameterName
,
int
x
)
throws
SQLException
{
getJdbcStatement
().
setInt
(
parameterName
,
x
);
}
@Override
public
void
setLong
(
String
parameterName
,
long
x
)
throws
SQLException
{
getJdbcStatement
().
setLong
(
parameterName
,
x
);
}
@Override
public
void
setFloat
(
String
parameterName
,
float
x
)
throws
SQLException
{
getJdbcStatement
().
setFloat
(
parameterName
,
x
);
}
@Override
public
void
setDouble
(
String
parameterName
,
double
x
)
throws
SQLException
{
getJdbcStatement
().
setDouble
(
parameterName
,
x
);
}
@Override
public
void
setBigDecimal
(
String
parameterName
,
BigDecimal
x
)
throws
SQLException
{
getJdbcStatement
().
setBigDecimal
(
parameterName
,
x
);
}
@Override
public
void
setString
(
String
parameterName
,
String
x
)
throws
SQLException
{
getJdbcStatement
().
setString
(
parameterName
,
x
);
}
@Override
public
void
setBytes
(
String
parameterName
,
byte
[]
x
)
throws
SQLException
{
getJdbcStatement
().
setBytes
(
parameterName
,
x
);
}
@Override
public
void
setDate
(
String
parameterName
,
Date
x
)
throws
SQLException
{
getJdbcStatement
().
setDate
(
parameterName
,
x
);
}
@Override
public
void
setTime
(
String
parameterName
,
Time
x
)
throws
SQLException
{
getJdbcStatement
().
setTime
(
parameterName
,
x
);
}
@Override
public
void
setTimestamp
(
String
parameterName
,
Timestamp
x
)
throws
SQLException
{
getJdbcStatement
().
setTimestamp
(
parameterName
,
x
);
}
@Override
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setAsciiStream
(
parameterName
,
x
,
length
);
}
@Override
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setBinaryStream
(
parameterName
,
x
,
length
);
}
@Override
public
void
setObject
(
String
parameterName
,
Object
x
,
int
targetSqlType
,
int
scale
)
throws
SQLException
{
getJdbcStatement
().
setObject
(
parameterName
,
x
,
targetSqlType
,
scale
);
}
@Override
public
void
setObject
(
String
parameterName
,
Object
x
,
int
targetSqlType
)
throws
SQLException
{
getJdbcStatement
().
setObject
(
parameterName
,
x
,
targetSqlType
);
}
@Override
public
void
setObject
(
String
parameterName
,
Object
x
)
throws
SQLException
{
getJdbcStatement
().
setObject
(
parameterName
,
x
);
}
@Override
public
void
setCharacterStream
(
String
parameterName
,
Reader
reader
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setCharacterStream
(
parameterName
,
reader
,
length
);
}
@Override
public
void
setDate
(
String
parameterName
,
Date
x
,
Calendar
cal
)
throws
SQLException
{
getJdbcStatement
().
setDate
(
parameterName
,
x
,
cal
);
}
@Override
public
void
setTime
(
String
parameterName
,
Time
x
,
Calendar
cal
)
throws
SQLException
{
getJdbcStatement
().
setTime
(
parameterName
,
x
,
cal
);
}
@Override
public
void
setTimestamp
(
String
parameterName
,
Timestamp
x
,
Calendar
cal
)
throws
SQLException
{
getJdbcStatement
().
setTimestamp
(
parameterName
,
x
,
cal
);
}
@Override
public
void
setNull
(
String
parameterName
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
getJdbcStatement
().
setNull
(
parameterName
,
sqlType
,
typeName
);
}
@Override
public
String
getString
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getString
(
parameterName
);
}
@Override
public
boolean
getBoolean
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getBoolean
(
parameterName
);
}
@Override
public
byte
getByte
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getByte
(
parameterName
);
}
@Override
public
short
getShort
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getShort
(
parameterName
);
}
@Override
public
int
getInt
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getInt
(
parameterName
);
}
@Override
public
long
getLong
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getLong
(
parameterName
);
}
@Override
public
float
getFloat
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getFloat
(
parameterName
);
}
@Override
public
double
getDouble
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getDouble
(
parameterName
);
}
@Override
public
byte
[]
getBytes
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getBytes
(
parameterName
);
}
@Override
public
Date
getDate
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getDate
(
parameterName
);
}
@Override
public
Time
getTime
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getTime
(
parameterName
);
}
@Override
public
Timestamp
getTimestamp
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getTimestamp
(
parameterName
);
}
@Override
public
Object
getObject
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getObject
(
parameterName
);
}
@Override
public
BigDecimal
getBigDecimal
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getBigDecimal
(
parameterName
);
}
@Override
public
Object
getObject
(
String
parameterName
,
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
return
getJdbcStatement
().
getObject
(
parameterName
,
map
);
}
@Override
public
Ref
getRef
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getRef
(
parameterName
);
}
@Override
public
Blob
getBlob
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getBlob
(
parameterName
);
}
@Override
public
Clob
getClob
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getClob
(
parameterName
);
}
@Override
public
Array
getArray
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getArray
(
parameterName
);
}
@Override
public
Date
getDate
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
return
getJdbcStatement
().
getDate
(
parameterName
,
cal
);
}
@Override
public
Time
getTime
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
return
getJdbcStatement
().
getTime
(
parameterName
,
cal
);
}
@Override
public
Timestamp
getTimestamp
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
return
getJdbcStatement
().
getTimestamp
(
parameterName
,
cal
);
}
@Override
public
URL
getURL
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getURL
(
parameterName
);
}
@Override
public
RowId
getRowId
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getRowId
(
parameterIndex
);
}
@Override
public
RowId
getRowId
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getRowId
(
parameterName
);
}
@Override
public
void
setRowId
(
String
parameterName
,
RowId
x
)
throws
SQLException
{
getJdbcStatement
().
setRowId
(
parameterName
,
x
);
}
@Override
public
void
setNString
(
String
parameterName
,
String
value
)
throws
SQLException
{
getJdbcStatement
().
setNString
(
parameterName
,
value
);
}
@Override
public
void
setNCharacterStream
(
String
parameterName
,
Reader
value
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setNCharacterStream
(
parameterName
,
value
,
length
);
}
@Override
public
void
setNClob
(
String
parameterName
,
NClob
value
)
throws
SQLException
{
getJdbcStatement
().
setNClob
(
parameterName
,
value
);
}
@Override
public
void
setClob
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setClob
(
parameterName
,
reader
,
length
);
}
@Override
public
void
setBlob
(
String
parameterName
,
InputStream
inputStream
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setBlob
(
parameterName
,
inputStream
,
length
);
}
@Override
public
void
setNClob
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setNClob
(
parameterName
,
reader
,
length
);
}
@Override
public
NClob
getNClob
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getNClob
(
parameterIndex
);
}
@Override
public
NClob
getNClob
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getNClob
(
parameterName
);
}
@Override
public
void
setSQLXML
(
String
parameterName
,
SQLXML
xmlObject
)
throws
SQLException
{
getJdbcStatement
().
setSQLXML
(
parameterName
,
xmlObject
);
}
@Override
public
SQLXML
getSQLXML
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getSQLXML
(
parameterIndex
);
}
@Override
public
SQLXML
getSQLXML
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getSQLXML
(
parameterName
);
}
@Override
public
String
getNString
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getNString
(
parameterIndex
);
}
@Override
public
String
getNString
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getNString
(
parameterName
);
}
@Override
public
Reader
getNCharacterStream
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getNCharacterStream
(
parameterIndex
);
}
@Override
public
Reader
getNCharacterStream
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getNCharacterStream
(
parameterName
);
}
@Override
public
Reader
getCharacterStream
(
int
parameterIndex
)
throws
SQLException
{
return
getJdbcStatement
().
getCharacterStream
(
parameterIndex
);
}
@Override
public
Reader
getCharacterStream
(
String
parameterName
)
throws
SQLException
{
return
getJdbcStatement
().
getCharacterStream
(
parameterName
);
}
@Override
public
void
setBlob
(
String
parameterName
,
Blob
x
)
throws
SQLException
{
getJdbcStatement
().
setBlob
(
parameterName
,
x
);
}
@Override
public
void
setClob
(
String
parameterName
,
Clob
x
)
throws
SQLException
{
getJdbcStatement
().
setClob
(
parameterName
,
x
);
}
@Override
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setAsciiStream
(
parameterName
,
x
,
length
);
}
@Override
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setBinaryStream
(
parameterName
,
x
,
length
);
}
@Override
public
void
setCharacterStream
(
String
parameterName
,
Reader
reader
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setCharacterStream
(
parameterName
,
reader
,
length
);
}
@Override
public
void
setAsciiStream
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
getJdbcStatement
().
setAsciiStream
(
parameterName
,
x
);
}
@Override
public
void
setBinaryStream
(
String
parameterName
,
InputStream
x
)
throws
SQLException
{
getJdbcStatement
().
setBinaryStream
(
parameterName
,
x
);
}
@Override
public
void
setCharacterStream
(
String
parameterName
,
Reader
reader
)
throws
SQLException
{
getJdbcStatement
().
setCharacterStream
(
parameterName
,
reader
);
}
@Override
public
void
setNCharacterStream
(
String
parameterName
,
Reader
value
)
throws
SQLException
{
getJdbcStatement
().
setNCharacterStream
(
parameterName
,
value
);
}
@Override
public
void
setClob
(
String
parameterName
,
Reader
reader
)
throws
SQLException
{
getJdbcStatement
().
setClob
(
parameterName
,
reader
);
}
@Override
public
void
setBlob
(
String
parameterName
,
InputStream
inputStream
)
throws
SQLException
{
getJdbcStatement
().
setBlob
(
parameterName
,
inputStream
);
}
@Override
public
void
setNClob
(
String
parameterName
,
Reader
reader
)
throws
SQLException
{
getJdbcStatement
().
setNClob
(
parameterName
,
reader
);
}
@Override
public
<
T
>
T
getObject
(
int
parameterIndex
,
Class
<
T
>
type
)
throws
SQLException
{
return
getJdbcStatement
().
getObject
(
parameterIndex
,
type
);
}
@Override
public
<
T
>
T
getObject
(
String
parameterName
,
Class
<
T
>
type
)
throws
SQLException
{
return
getJdbcStatement
().
getObject
(
parameterName
,
type
);
}
}
src/main/java/kz/arta/test/blocking/mysql/ConnectionImpl.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.concurrent.Executor
;
/**
* Created by exile
* Date: 18.06.15
* Time: 13:51
* класс обертка для соединения, который собирает все открытые стейтменты и закрывает их
*/
public
class
ConnectionImpl
implements
Connection
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ArtaMysqlConnectionPool
.
class
);
private
Connection
connection
;
private
List
<
Statement
>
statements
=
new
ArrayList
<>();
public
ConnectionImpl
(
Connection
connection
)
{
this
.
connection
=
connection
;
}
@Override
public
void
close
()
throws
SQLException
{
for
(
Statement
st
:
statements
)
{
try
{
st
.
close
();
}
catch
(
SQLException
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
}
connection
.
close
();
statements
=
null
;
connection
=
null
;
}
private
Statement
statementOpened
(
Statement
st
){
statements
.
add
(
st
);
return
new
StatementImpl
(
st
,
this
);
}
private
PreparedStatement
statementOpened
(
PreparedStatement
st
)
{
statements
.
add
(
st
);
return
new
PreparedStatementImpl
(
st
,
this
);
}
private
CallableStatement
statementOpened
(
CallableStatement
st
)
{
statements
.
add
(
st
);
return
new
CallableStatementImpl
(
st
,
this
);
}
public
void
setAutoCommit
(
boolean
autoCommit
)
throws
SQLException
{
connection
.
setAutoCommit
(
autoCommit
);
}
public
boolean
getAutoCommit
()
throws
SQLException
{
return
connection
.
getAutoCommit
();
}
public
PreparedStatement
prepareStatement
(
String
sql
)
throws
SQLException
{
PreparedStatement
st
=
connection
.
prepareStatement
(
sql
);
return
statementOpened
(
st
);
}
public
Statement
createStatement
()
throws
SQLException
{
Statement
st
=
connection
.
createStatement
();
return
statementOpened
(
st
);
}
public
void
commit
()
throws
SQLException
{
if
(!
connection
.
getAutoCommit
())
{
connection
.
commit
();
}
}
public
void
rollback
()
throws
SQLException
{
connection
.
rollback
();
}
public
boolean
isClosed
()
throws
SQLException
{
return
connection
.
isClosed
();
}
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
Statement
st
=
connection
.
createStatement
(
resultSetType
,
resultSetConcurrency
);
return
statementOpened
(
st
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
PreparedStatement
st
=
connection
.
prepareStatement
(
sql
,
resultSetType
,
resultSetConcurrency
);
return
statementOpened
(
st
);
}
public
Savepoint
setSavepoint
(
String
name
)
throws
SQLException
{
return
connection
.
setSavepoint
(
name
);
}
public
Savepoint
setSavepoint
()
throws
SQLException
{
return
connection
.
setSavepoint
();
}
public
void
rollback
(
Savepoint
savepoint
)
throws
SQLException
{
connection
.
rollback
(
savepoint
);
}
public
void
releaseSavepoint
(
Savepoint
savepoint
)
throws
SQLException
{
connection
.
releaseSavepoint
(
savepoint
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
PreparedStatement
st
=
connection
.
prepareStatement
(
sql
,
resultSetType
,
resultSetConcurrency
,
resultSetHoldability
);
return
statementOpened
(
st
);
}
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
Statement
st
=
connection
.
createStatement
(
resultSetType
,
resultSetConcurrency
,
resultSetHoldability
);
return
statementOpened
(
st
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
PreparedStatement
st
=
connection
.
prepareStatement
(
sql
,
autoGeneratedKeys
);
return
statementOpened
(
st
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
String
columnNames
[])
throws
SQLException
{
PreparedStatement
st
=
connection
.
prepareStatement
(
sql
,
columnNames
);
return
statementOpened
(
st
);
}
public
PreparedStatement
prepareStatement
(
String
sql
,
int
columnIndexes
[])
throws
SQLException
{
PreparedStatement
st
=
connection
.
prepareStatement
(
sql
,
columnIndexes
);
return
statementOpened
(
st
);
}
public
CallableStatement
prepareCall
(
String
sql
)
throws
SQLException
{
return
connection
.
prepareCall
(
sql
);
}
public
String
nativeSQL
(
String
sql
)
throws
SQLException
{
return
connection
.
nativeSQL
(
sql
);
}
public
DatabaseMetaData
getMetaData
()
throws
SQLException
{
return
connection
.
getMetaData
();
}
public
void
setReadOnly
(
boolean
readOnly
)
throws
SQLException
{
connection
.
setReadOnly
(
readOnly
);
}
public
boolean
isReadOnly
()
throws
SQLException
{
return
connection
.
isReadOnly
();
}
public
void
setCatalog
(
String
catalog
)
throws
SQLException
{
connection
.
setCatalog
(
catalog
);
}
public
String
getCatalog
()
throws
SQLException
{
return
connection
.
getCatalog
();
}
public
void
setTransactionIsolation
(
int
level
)
throws
SQLException
{
connection
.
setTransactionIsolation
(
level
);
}
public
int
getTransactionIsolation
()
throws
SQLException
{
return
connection
.
getTransactionIsolation
();
}
public
SQLWarning
getWarnings
()
throws
SQLException
{
return
connection
.
getWarnings
();
}
public
void
clearWarnings
()
throws
SQLException
{
connection
.
clearWarnings
();
}
public
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
return
connection
.
prepareCall
(
sql
,
resultSetType
,
resultSetConcurrency
);
}
public
Map
<
String
,
Class
<?>>
getTypeMap
()
throws
SQLException
{
return
connection
.
getTypeMap
();
}
public
void
setTypeMap
(
Map
<
String
,
Class
<?>>
map
)
throws
SQLException
{
connection
.
setTypeMap
(
map
);
}
public
void
setHoldability
(
int
holdability
)
throws
SQLException
{
connection
.
setHoldability
(
holdability
);
}
public
int
getHoldability
()
throws
SQLException
{
return
connection
.
getHoldability
();
}
public
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
CallableStatement
st
=
connection
.
prepareCall
(
sql
,
resultSetType
,
resultSetConcurrency
,
resultSetHoldability
);
return
statementOpened
(
st
);
}
public
Array
createArrayOf
(
String
typeName
,
Object
[]
elements
)
throws
SQLException
{
return
connection
.
createArrayOf
(
typeName
,
elements
);
}
public
Clob
createClob
()
throws
SQLException
{
return
connection
.
createClob
();
}
public
Blob
createBlob
()
throws
SQLException
{
return
connection
.
createBlob
();
}
public
NClob
createNClob
()
throws
SQLException
{
return
connection
.
createNClob
();
}
public
SQLXML
createSQLXML
()
throws
SQLException
{
return
connection
.
createSQLXML
();
}
public
boolean
isValid
(
int
timeout
)
throws
SQLException
{
return
connection
.
isValid
(
timeout
);
}
public
void
setClientInfo
(
String
name
,
String
value
)
throws
SQLClientInfoException
{
connection
.
setClientInfo
(
name
,
value
);
}
public
void
setClientInfo
(
Properties
properties
)
throws
SQLClientInfoException
{
connection
.
setClientInfo
(
properties
);
}
public
String
getClientInfo
(
String
name
)
throws
SQLException
{
return
connection
.
getClientInfo
(
name
);
}
public
Properties
getClientInfo
()
throws
SQLException
{
return
connection
.
getClientInfo
();
}
public
Struct
createStruct
(
String
typeName
,
Object
[]
attributes
)
throws
SQLException
{
return
connection
.
createStruct
(
typeName
,
attributes
);
}
public
<
T
>
T
unwrap
(
Class
<
T
>
iFace
)
throws
SQLException
{
return
connection
.
unwrap
(
iFace
);
}
public
boolean
isWrapperFor
(
Class
<?>
iFace
)
throws
SQLException
{
return
connection
.
isWrapperFor
(
iFace
);
}
public
void
setSchema
(
String
schema
)
throws
SQLException
{
connection
.
setSchema
(
schema
);
}
public
String
getSchema
()
throws
SQLException
{
return
connection
.
getSchema
();
}
public
void
abort
(
Executor
executor
)
throws
SQLException
{
connection
.
abort
(
executor
);
}
public
void
setNetworkTimeout
(
Executor
executor
,
int
milliseconds
)
throws
SQLException
{
connection
.
setNetworkTimeout
(
executor
,
milliseconds
);
}
public
int
getNetworkTimeout
()
throws
SQLException
{
return
connection
.
getNetworkTimeout
();
}
}
src/main/java/kz/arta/test/blocking/mysql/DataExtractorCommon.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
/**
* Извлекатель данных из объектов
*
* @author MGetmanov
* @since 28.05.15 8:44
*/
class
DataExtractorCommon
{
public
static
Long
getLongStat
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
0
l
;
}
try
{
return
new
Long
(
obj
.
toString
());
}
catch
(
Exception
e
)
{
return
0
l
;
}
}
public
static
Boolean
getBoolean
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
false
;
}
try
{
if
(
Boolean
.
parseBoolean
(
obj
.
toString
())
||
(
obj
+
""
).
equalsIgnoreCase
(
"true"
)
||
(
obj
+
""
).
equals
(
"1"
))
{
return
true
;
}
}
catch
(
Exception
ignored
)
{
}
return
false
;
}
}
src/main/java/kz/arta/test/blocking/mysql/DbConfig.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Properties
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
DbConfig
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ArtaMysqlConfigManager
.
class
);
private
static
final
String
DEFAULT_EAR_NAME
=
"Synergy"
;
private
String
ear_name
=
"Synergy"
;
private
Properties
props
=
new
Properties
();
public
DbConfig
()
{
}
public
Properties
getProps
()
{
return
props
;
}
public
void
initialize
()
{
String
cfgFolder
=
getCfgURL
();
LOGGER
.
info
(
"JBoss cfg directory is "
+
cfgFolder
+
". Trying read settings from it"
);
try
{
File
file
=
new
File
(
getConfFilePath
(
"arta/management/db.properties"
));
if
(
file
.
exists
())
{
FileInputStream
fis
=
new
FileInputStream
(
file
);
props
.
load
(
fis
);
fis
.
close
();
}
else
{
throw
new
RuntimeException
(
"File "
+
file
.
getAbsolutePath
()
+
" does not exist!"
);
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
LOGGER
.
error
(
"Failed to read settings from "
+
cfgFolder
);
}
try
{
if
(
ear_name
!=
null
&&
ear_name
.
length
()
>
0
)
{
LOGGER
.
debug
(
"Going to read jcr mapped resource name"
);
}
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
/**
* Инициализация кэша очередей для документов
*/
private
void
initDocExents
()
{
final
String
docQueue
=
"java:jboss/exported/jms/queue/DocIndex"
;
final
Collection
<
String
>
queue
=
new
HashSet
<
String
>();
queue
.
add
(
docQueue
);
}
public
String
getEarName
()
{
String
classLoader
=
Thread
.
currentThread
().
getContextClassLoader
().
toString
();
Pattern
p
=
Pattern
.
compile
(
"(?:deployment.)([A-Za-z0-9_-[.]]+)(.ear)"
);
Matcher
m
=
p
.
matcher
(
classLoader
);
if
(
m
.
find
())
{
return
m
.
group
(
1
);
}
else
{
return
""
;
}
}
public
String
getCfgURL
()
{
//For JBoss AS5
String
cfgDir
=
System
.
getProperty
(
"jboss.server.config.url"
);
//For JBoss AS7
if
(
cfgDir
==
null
)
{
cfgDir
=
System
.
getProperty
(
"jboss.server.config.dir"
);
if
(
cfgDir
!=
null
)
{
cfgDir
=
"file://"
+
cfgDir
;
}
else
{
//If nothing helps
cfgDir
=
"file:///home/topa/services/jboss/server/default/conf"
;
}
}
return
cfgDir
;
}
public
String
getCfgDirectory
()
{
//For JBoss AS5
String
cfgDir
=
System
.
getProperty
(
"jboss.server.config.url"
);
if
(
cfgDir
!=
null
&&
cfgDir
.
startsWith
(
"file://"
))
{
try
{
URL
url
=
new
URL
(
cfgDir
);
return
url
.
getFile
();
}
catch
(
MalformedURLException
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
}
//For JBoss AS7
if
(
cfgDir
==
null
)
{
cfgDir
=
System
.
getProperty
(
"jboss.server.config.dir"
);
if
(
cfgDir
!=
null
)
{
return
cfgDir
;
}
else
{
//If nothing helps
return
"/home/topa/services/jboss/server/default/conf"
;
}
}
return
cfgDir
;
}
public
String
getSynergyDS
()
{
if
(
ear_name
.
equals
(
DEFAULT_EAR_NAME
))
{
return
"java:/SynergyDS"
;
}
return
"java:jboss/datasources/"
+
ear_name
+
"/synergy"
;
}
public
String
getConfFilePath
(
String
relativePath
)
{
if
(
ear_name
==
null
||
ear_name
.
equals
(
DEFAULT_EAR_NAME
))
return
getCfgDirectory
()
+
"/"
+
relativePath
;
return
getCfgDirectory
()
+
"/"
+
ear_name
+
"/"
+
relativePath
;
}
}
src/main/java/kz/arta/test/blocking/mysql/PreparedStatementImpl.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
java.io.InputStream
;
import
java.io.Reader
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.sql.*
;
import
java.util.Calendar
;
/**
* User: vsl
* Date: 8/25/16
* Time: 12:52 PM
*/
public
class
PreparedStatementImpl
extends
StatementImpl
implements
PreparedStatement
{
private
PreparedStatement
jdbcStatement
;
public
PreparedStatementImpl
(
PreparedStatement
jdbcStatement
,
ConnectionImpl
connectionWrapper
)
{
super
(
jdbcStatement
,
connectionWrapper
);
this
.
jdbcStatement
=
jdbcStatement
;
}
@Override
protected
PreparedStatement
getJdbcStatement
()
{
return
jdbcStatement
;
}
@Override
public
ResultSet
executeQuery
()
throws
SQLException
{
return
getJdbcStatement
().
executeQuery
();
}
@Override
public
int
executeUpdate
()
throws
SQLException
{
return
getJdbcStatement
().
executeUpdate
();
}
@Override
public
void
setNull
(
int
parameterIndex
,
int
sqlType
)
throws
SQLException
{
getJdbcStatement
().
setNull
(
parameterIndex
,
sqlType
);
}
@Override
public
void
setBoolean
(
int
parameterIndex
,
boolean
x
)
throws
SQLException
{
getJdbcStatement
().
setBoolean
(
parameterIndex
,
x
);
}
@Override
public
void
setByte
(
int
parameterIndex
,
byte
x
)
throws
SQLException
{
getJdbcStatement
().
setByte
(
parameterIndex
,
x
);
}
@Override
public
void
setShort
(
int
parameterIndex
,
short
x
)
throws
SQLException
{
getJdbcStatement
().
setShort
(
parameterIndex
,
x
);
}
@Override
public
void
setInt
(
int
parameterIndex
,
int
x
)
throws
SQLException
{
getJdbcStatement
().
setInt
(
parameterIndex
,
x
);
}
@Override
public
void
setLong
(
int
parameterIndex
,
long
x
)
throws
SQLException
{
getJdbcStatement
().
setLong
(
parameterIndex
,
x
);
}
@Override
public
void
setFloat
(
int
parameterIndex
,
float
x
)
throws
SQLException
{
getJdbcStatement
().
setFloat
(
parameterIndex
,
x
);
}
@Override
public
void
setDouble
(
int
parameterIndex
,
double
x
)
throws
SQLException
{
getJdbcStatement
().
setDouble
(
parameterIndex
,
x
);
}
@Override
public
void
setBigDecimal
(
int
parameterIndex
,
BigDecimal
x
)
throws
SQLException
{
getJdbcStatement
().
setBigDecimal
(
parameterIndex
,
x
);
}
@Override
public
void
setString
(
int
parameterIndex
,
String
x
)
throws
SQLException
{
getJdbcStatement
().
setString
(
parameterIndex
,
x
);
}
@Override
public
void
setBytes
(
int
parameterIndex
,
byte
[]
x
)
throws
SQLException
{
getJdbcStatement
().
setBytes
(
parameterIndex
,
x
);
}
@Override
public
void
setDate
(
int
parameterIndex
,
Date
x
)
throws
SQLException
{
getJdbcStatement
().
setDate
(
parameterIndex
,
x
);
}
@Override
public
void
setTime
(
int
parameterIndex
,
Time
x
)
throws
SQLException
{
getJdbcStatement
().
setTime
(
parameterIndex
,
x
);
}
@Override
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
)
throws
SQLException
{
getJdbcStatement
().
setTimestamp
(
parameterIndex
,
x
);
}
@Override
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setAsciiStream
(
parameterIndex
,
x
,
length
);
}
@Override
public
void
setUnicodeStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setUnicodeStream
(
parameterIndex
,
x
,
length
);
}
@Override
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setBinaryStream
(
parameterIndex
,
x
,
length
);
}
@Override
public
void
clearParameters
()
throws
SQLException
{
getJdbcStatement
().
clearParameters
();
}
@Override
public
void
setObject
(
int
parameterIndex
,
Object
x
,
int
targetSqlType
)
throws
SQLException
{
getJdbcStatement
().
setObject
(
parameterIndex
,
x
,
targetSqlType
);
}
@Override
public
void
setObject
(
int
parameterIndex
,
Object
x
)
throws
SQLException
{
getJdbcStatement
().
setObject
(
parameterIndex
,
x
);
}
@Override
public
boolean
execute
()
throws
SQLException
{
return
getJdbcStatement
().
execute
();
}
@Override
public
void
addBatch
()
throws
SQLException
{
getJdbcStatement
().
addBatch
();
}
@Override
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
,
int
length
)
throws
SQLException
{
getJdbcStatement
().
setCharacterStream
(
parameterIndex
,
reader
,
length
);
}
@Override
public
void
setRef
(
int
parameterIndex
,
Ref
x
)
throws
SQLException
{
getJdbcStatement
().
setRef
(
parameterIndex
,
x
);
}
@Override
public
void
setBlob
(
int
parameterIndex
,
Blob
x
)
throws
SQLException
{
getJdbcStatement
().
setBlob
(
parameterIndex
,
x
);
}
@Override
public
void
setClob
(
int
parameterIndex
,
Clob
x
)
throws
SQLException
{
getJdbcStatement
().
setClob
(
parameterIndex
,
x
);
}
@Override
public
void
setArray
(
int
parameterIndex
,
Array
x
)
throws
SQLException
{
getJdbcStatement
().
setArray
(
parameterIndex
,
x
);
}
@Override
public
ResultSetMetaData
getMetaData
()
throws
SQLException
{
return
getJdbcStatement
().
getMetaData
();
}
@Override
public
void
setDate
(
int
parameterIndex
,
Date
x
,
Calendar
cal
)
throws
SQLException
{
getJdbcStatement
().
setDate
(
parameterIndex
,
x
,
cal
);
}
@Override
public
void
setTime
(
int
parameterIndex
,
Time
x
,
Calendar
cal
)
throws
SQLException
{
getJdbcStatement
().
setTime
(
parameterIndex
,
x
,
cal
);
}
@Override
public
void
setTimestamp
(
int
parameterIndex
,
Timestamp
x
,
Calendar
cal
)
throws
SQLException
{
getJdbcStatement
().
setTimestamp
(
parameterIndex
,
x
,
cal
);
}
@Override
public
void
setNull
(
int
parameterIndex
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
getJdbcStatement
().
setNull
(
parameterIndex
,
sqlType
,
typeName
);
}
@Override
public
void
setURL
(
int
parameterIndex
,
URL
x
)
throws
SQLException
{
getJdbcStatement
().
setURL
(
parameterIndex
,
x
);
}
@Override
public
ParameterMetaData
getParameterMetaData
()
throws
SQLException
{
return
getJdbcStatement
().
getParameterMetaData
();
}
@Override
public
void
setRowId
(
int
parameterIndex
,
RowId
x
)
throws
SQLException
{
getJdbcStatement
().
setRowId
(
parameterIndex
,
x
);
}
@Override
public
void
setNString
(
int
parameterIndex
,
String
value
)
throws
SQLException
{
getJdbcStatement
().
setNString
(
parameterIndex
,
value
);
}
@Override
public
void
setNCharacterStream
(
int
parameterIndex
,
Reader
value
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setNCharacterStream
(
parameterIndex
,
value
,
length
);
}
@Override
public
void
setNClob
(
int
parameterIndex
,
NClob
value
)
throws
SQLException
{
getJdbcStatement
().
setNClob
(
parameterIndex
,
value
);
}
@Override
public
void
setClob
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setClob
(
parameterIndex
,
reader
,
length
);
}
@Override
public
void
setBlob
(
int
parameterIndex
,
InputStream
inputStream
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setBlob
(
parameterIndex
,
inputStream
,
length
);
}
@Override
public
void
setNClob
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setNClob
(
parameterIndex
,
reader
,
length
);
}
@Override
public
void
setSQLXML
(
int
parameterIndex
,
SQLXML
xmlObject
)
throws
SQLException
{
getJdbcStatement
().
setSQLXML
(
parameterIndex
,
xmlObject
);
}
@Override
public
void
setObject
(
int
parameterIndex
,
Object
x
,
int
targetSqlType
,
int
scaleOrLength
)
throws
SQLException
{
getJdbcStatement
().
setObject
(
parameterIndex
,
x
,
targetSqlType
,
scaleOrLength
);
}
@Override
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setAsciiStream
(
parameterIndex
,
x
,
length
);
}
@Override
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setBinaryStream
(
parameterIndex
,
x
,
length
);
}
@Override
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
,
long
length
)
throws
SQLException
{
getJdbcStatement
().
setCharacterStream
(
parameterIndex
,
reader
,
length
);
}
@Override
public
void
setAsciiStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
getJdbcStatement
().
setAsciiStream
(
parameterIndex
,
x
);
}
@Override
public
void
setBinaryStream
(
int
parameterIndex
,
InputStream
x
)
throws
SQLException
{
getJdbcStatement
().
setBinaryStream
(
parameterIndex
,
x
);
}
@Override
public
void
setCharacterStream
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
getJdbcStatement
().
setCharacterStream
(
parameterIndex
,
reader
);
}
@Override
public
void
setNCharacterStream
(
int
parameterIndex
,
Reader
value
)
throws
SQLException
{
getJdbcStatement
().
setNCharacterStream
(
parameterIndex
,
value
);
}
@Override
public
void
setClob
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
getJdbcStatement
().
setClob
(
parameterIndex
,
reader
);
}
@Override
public
void
setBlob
(
int
parameterIndex
,
InputStream
inputStream
)
throws
SQLException
{
getJdbcStatement
().
setBlob
(
parameterIndex
,
inputStream
);
}
@Override
public
void
setNClob
(
int
parameterIndex
,
Reader
reader
)
throws
SQLException
{
getJdbcStatement
().
setNClob
(
parameterIndex
,
reader
);
}
}
src/main/java/kz/arta/test/blocking/mysql/StatementImpl.java
0 → 100644
View file @
686ace2b
package
kz.arta.test.blocking.mysql
;
import
java.sql.*
;
/**
* User: vsl
* Date: 8/25/16
* Time: 11:51 AM
*/
public
class
StatementImpl
implements
Statement
{
private
Statement
jdbcStatement
;
protected
ConnectionImpl
connectionWrapper
;
public
StatementImpl
(
Statement
jdbcStatement
,
ConnectionImpl
connectionWrapper
)
{
this
.
jdbcStatement
=
jdbcStatement
;
this
.
connectionWrapper
=
connectionWrapper
;
}
protected
Statement
getJdbcStatement
()
{
return
jdbcStatement
;
}
@Override
public
ResultSet
executeQuery
(
String
sql
)
throws
SQLException
{
return
getJdbcStatement
().
executeQuery
(
sql
);
}
@Override
public
int
executeUpdate
(
String
sql
)
throws
SQLException
{
return
getJdbcStatement
().
executeUpdate
(
sql
);
}
@Override
public
void
close
()
throws
SQLException
{
getJdbcStatement
().
close
();
}
@Override
public
int
getMaxFieldSize
()
throws
SQLException
{
return
getJdbcStatement
().
getMaxFieldSize
();
}
@Override
public
void
setMaxFieldSize
(
int
max
)
throws
SQLException
{
getJdbcStatement
().
setMaxFieldSize
(
max
);
}
@Override
public
int
getMaxRows
()
throws
SQLException
{
return
getJdbcStatement
().
getMaxRows
();
}
@Override
public
void
setMaxRows
(
int
max
)
throws
SQLException
{
getJdbcStatement
().
setMaxRows
(
max
);
}
@Override
public
void
setEscapeProcessing
(
boolean
enable
)
throws
SQLException
{
getJdbcStatement
().
setEscapeProcessing
(
enable
);
}
@Override
public
int
getQueryTimeout
()
throws
SQLException
{
return
getJdbcStatement
().
getQueryTimeout
();
}
@Override
public
void
setQueryTimeout
(
int
seconds
)
throws
SQLException
{
getJdbcStatement
().
setQueryTimeout
(
seconds
);
}
@Override
public
void
cancel
()
throws
SQLException
{
getJdbcStatement
().
cancel
();
}
@Override
public
SQLWarning
getWarnings
()
throws
SQLException
{
return
getJdbcStatement
().
getWarnings
();
}
@Override
public
void
clearWarnings
()
throws
SQLException
{
getJdbcStatement
().
clearWarnings
();
}
@Override
public
void
setCursorName
(
String
name
)
throws
SQLException
{
getJdbcStatement
().
setCursorName
(
name
);
}
@Override
public
boolean
execute
(
String
sql
)
throws
SQLException
{
return
getJdbcStatement
().
execute
(
sql
);
}
@Override
public
ResultSet
getResultSet
()
throws
SQLException
{
return
getJdbcStatement
().
getResultSet
();
}
@Override
public
int
getUpdateCount
()
throws
SQLException
{
return
getJdbcStatement
().
getUpdateCount
();
}
@Override
public
boolean
getMoreResults
()
throws
SQLException
{
return
getJdbcStatement
().
getMoreResults
();
}
@Override
public
void
setFetchDirection
(
int
direction
)
throws
SQLException
{
getJdbcStatement
().
setFetchDirection
(
direction
);
}
@Override
public
int
getFetchDirection
()
throws
SQLException
{
return
getJdbcStatement
().
getFetchDirection
();
}
@Override
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
getJdbcStatement
().
setFetchSize
(
rows
);
}
@Override
public
int
getFetchSize
()
throws
SQLException
{
return
getJdbcStatement
().
getFetchSize
();
}
@Override
public
int
getResultSetConcurrency
()
throws
SQLException
{
return
getJdbcStatement
().
getResultSetConcurrency
();
}
@Override
public
int
getResultSetType
()
throws
SQLException
{
return
getJdbcStatement
().
getResultSetType
();
}
@Override
public
void
addBatch
(
String
sql
)
throws
SQLException
{
getJdbcStatement
().
addBatch
(
sql
);
}
@Override
public
void
clearBatch
()
throws
SQLException
{
getJdbcStatement
().
clearBatch
();
}
@Override
public
int
[]
executeBatch
()
throws
SQLException
{
return
getJdbcStatement
().
executeBatch
();
}
@Override
public
Connection
getConnection
()
throws
SQLException
{
return
connectionWrapper
;
}
@Override
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
return
getJdbcStatement
().
getMoreResults
(
current
);
}
@Override
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
return
getJdbcStatement
().
getGeneratedKeys
();
}
@Override
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
return
getJdbcStatement
().
executeUpdate
(
sql
,
autoGeneratedKeys
);
}
@Override
public
int
executeUpdate
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
return
getJdbcStatement
().
executeUpdate
(
sql
,
columnIndexes
);
}
@Override
public
int
executeUpdate
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
return
getJdbcStatement
().
executeUpdate
(
sql
,
columnNames
);
}
@Override
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
return
getJdbcStatement
().
execute
(
sql
,
autoGeneratedKeys
);
}
@Override
public
boolean
execute
(
String
sql
,
int
[]
columnIndexes
)
throws
SQLException
{
return
getJdbcStatement
().
execute
(
sql
,
columnIndexes
);
}
@Override
public
boolean
execute
(
String
sql
,
String
[]
columnNames
)
throws
SQLException
{
return
getJdbcStatement
().
execute
(
sql
,
columnNames
);
}
@Override
public
int
getResultSetHoldability
()
throws
SQLException
{
return
getJdbcStatement
().
getResultSetHoldability
();
}
@Override
public
boolean
isClosed
()
throws
SQLException
{
return
getJdbcStatement
().
isClosed
();
}
@Override
public
void
setPoolable
(
boolean
poolable
)
throws
SQLException
{
getJdbcStatement
().
setPoolable
(
poolable
);
}
@Override
public
boolean
isPoolable
()
throws
SQLException
{
return
getJdbcStatement
().
isPoolable
();
}
@Override
public
void
closeOnCompletion
()
throws
SQLException
{
getJdbcStatement
().
closeOnCompletion
();
}
@Override
public
boolean
isCloseOnCompletion
()
throws
SQLException
{
return
getJdbcStatement
().
isCloseOnCompletion
();
}
@Override
public
<
T
>
T
unwrap
(
Class
<
T
>
iface
)
throws
SQLException
{
return
getJdbcStatement
().
unwrap
(
iface
);
}
@Override
public
boolean
isWrapperFor
(
Class
<?>
iface
)
throws
SQLException
{
return
getJdbcStatement
().
isWrapperFor
(
iface
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment