public class StartAndStopSQL extends Object implements org.springframework.context.Lifecycle, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware
Modifier and Type | Field and Description |
---|---|
protected org.springframework.context.ApplicationContext |
context |
protected DataSource |
dataSource |
protected String |
delimiter |
protected String |
delimiterType |
protected static int |
RUNNING |
protected static int |
STARTING |
protected String |
startSQL |
protected String |
startSqlCondition |
protected String |
startSqlConditionResource |
protected String |
startSqlResource |
protected AtomicInteger |
state |
protected static String[] |
stateNames |
protected static int |
STOPPING |
protected String |
stopSQL |
protected String |
stopSqlCondition |
protected String |
stopSqlConditionResource |
protected String |
stopSqlResource |
protected static int |
UNKNOWN |
protected boolean |
useAnt |
Constructor and Description |
---|
StartAndStopSQL() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
destroy() |
protected void |
executeSQL(String sql)
Execute one SQL statement.
|
protected void |
executeSqlResource(String resource)
Execute SQL statements stored in a resource.
|
DataSource |
getDataSource() |
String |
getDelimiter() |
String |
getDelimiterType() |
String |
getStartSQL() |
String |
getStartSqlCondition() |
String |
getStartSqlConditionResource() |
String |
getStartSqlResource() |
String |
getStopSQL() |
String |
getStopSqlCondition() |
String |
getStopSqlConditionResource() |
String |
getStopSqlResource() |
protected boolean |
isInCondition(String sql)
Check if the database is in a specific condition by checking the result of a SQL statement
|
protected boolean |
isInConditionResource(String resource)
Check if the database is in a specific condition by checking the result of a SQL statement loaded as a resource.
|
boolean |
isRunning() |
boolean |
isUseAnt() |
void |
setApplicationContext(org.springframework.context.ApplicationContext appContext) |
void |
setDataSource(DataSource dataSource) |
void |
setDelimiter(String delimiter) |
void |
setDelimiterType(String delimiterType) |
void |
setStartSQL(String startSQL)
Multiple SQL statements is allowed if useAnt is true.
|
void |
setStartSqlCondition(String startSqlCondition)
This must be a single SQL statement returning a number
|
void |
setStartSqlConditionResource(String startSqlConditionResource)
The resource must contain only a single SQL statement returning a number.
|
void |
setStartSqlResource(String startSqlResource)
Multiple SQL statements can be contained in the resource if useAnt is true.
|
void |
setStopSQL(String shutdownSQL)
Multiple SQL statements is allowed if useAnt is true.
|
void |
setStopSqlCondition(String stopSqlCondition)
This must be a single SQL statement returning a number
|
void |
setStopSqlConditionResource(String stopSqlConditionResource)
The resource must contain only a single SQL statement returning a number.
|
void |
setStopSqlResource(String stopSqlResource)
Multiple SQL statements can be contained in the resource if useAnt is true.
|
void |
setUseAnt(boolean useAnt) |
void |
start() |
void |
stop() |
protected static final int UNKNOWN
protected static final int STARTING
protected static final int RUNNING
protected static final int STOPPING
protected static final String[] stateNames
protected AtomicInteger state
protected DataSource dataSource
protected String startSQL
protected String stopSQL
protected String startSqlResource
protected String stopSqlResource
protected boolean useAnt
protected String delimiter
protected String delimiterType
protected String startSqlCondition
protected String stopSqlCondition
protected String startSqlConditionResource
protected String stopSqlConditionResource
protected org.springframework.context.ApplicationContext context
protected void executeSQL(String sql)
sql
- the statement to be executedprotected void executeSqlResource(String resource)
resource
- the resource where SQL statements are storedpublic boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
protected boolean isInCondition(String sql)
sql
- the SQL statement that would return a numberprotected boolean isInConditionResource(String resource)
resource
- the resource containing the SQL statement that would return a numberpublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
Exception
public void setApplicationContext(org.springframework.context.ApplicationContext appContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public DataSource getDataSource()
public void setDataSource(DataSource dataSource)
public String getStartSQL()
public void setStartSQL(String startSQL)
startSQL
- public String getStopSQL()
public void setStopSQL(String shutdownSQL)
shutdownSQL
- public String getStartSqlResource()
public String getStopSqlResource()
public void setStartSqlResource(String startSqlResource)
startSqlResource
- public void setStopSqlResource(String stopSqlResource)
stopSqlResource
- public boolean isUseAnt()
public void setUseAnt(boolean useAnt)
public String getDelimiter()
public void setDelimiter(String delimiter)
public String getDelimiterType()
public void setDelimiterType(String delimiterType)
public String getStartSqlCondition()
public void setStartSqlCondition(String startSqlCondition)
startSqlCondition
- public String getStopSqlCondition()
public void setStopSqlCondition(String stopSqlCondition)
stopSqlCondition
- public String getStopSqlConditionResource()
public void setStopSqlConditionResource(String stopSqlConditionResource)
stopSqlConditionResource
- public String getStartSqlConditionResource()
public void setStartSqlConditionResource(String startSqlConditionResource)
startSqlConditionResource
- Copyright © 2014. All Rights Reserved.