PageRenderTime 129ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/UniwareCore/src/main/java/com/uniware/core/vo/DataSourceConfigurationVO.java

https://bitbucket.org/piyushgd10/bhumi
Java | 446 lines | 338 code | 89 blank | 19 comment | 0 complexity | 62b3aa777b9495ece80b1389d9d2bc14 MD5 | raw file
  1. /*
  2. * Copyright 2013 Unicommerce Technologies (P) Limited . All Rights Reserved.
  3. * UNICOMMERCE TECHONOLOGIES PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. *
  5. * @version 1.0, 22-Aug-2013
  6. * @author sunny
  7. */
  8. package com.uniware.core.vo;
  9. import com.google.gson.Gson;
  10. import org.springframework.data.annotation.Id;
  11. import org.springframework.data.mongodb.core.index.CompoundIndex;
  12. import org.springframework.data.mongodb.core.index.CompoundIndexes;
  13. import org.springframework.data.mongodb.core.index.Indexed;
  14. import org.springframework.data.mongodb.core.mapping.Document;
  15. @Document(collection = "dataSourceConfiguration")
  16. @CompoundIndexes({ @CompoundIndex(name = "serverNameAndType", def = "{'serverName' : 1, 'type' : 1}", unique = true) })
  17. public class DataSourceConfigurationVO {
  18. // <Resource name="jdbc/UniwareDS"
  19. // auth="Container"
  20. // type="javax.sql.DataSource"
  21. // maxActive="100"
  22. // maxIdle="20"
  23. // maxWaitMillis="15000"
  24. // username="root"
  25. // password="uniware"
  26. // driverClassName="com.mysql.jdbc.Driver"
  27. // removeAbandoned="true"
  28. // removeAbandonedTimeout="30"
  29. // url="jdbc:mysql://localhost:3306/uniware?autoReconnect=true&amp;characterEncoding=UTF-8"/>
  30. public enum Type {
  31. MAIN,
  32. REPLICATION
  33. }
  34. @Id
  35. private String id;
  36. private String serverName;
  37. private Type type;
  38. private String driverClassName;
  39. private String url;
  40. private String username;
  41. private String password;
  42. private String defaultCatalog;
  43. private String evictionPolicyClassName;
  44. private boolean abandonedUsageTracking;
  45. private boolean cacheState;
  46. private boolean enableAutoCommitOnReturn;
  47. private int initialSize;
  48. private boolean lifo;
  49. private boolean logAbandoned;
  50. private int maxConnLifetimeMillis;
  51. private int maxIdle;
  52. private int maxOpenPreparedStatements;
  53. private int maxTotal;
  54. private int maxWaitMillis;
  55. private int minIdle;
  56. private int numTestsPerEvictionRun;
  57. private boolean poolPreparedStatements;
  58. private boolean removeAbandonedOnBorrow;
  59. private boolean removeAbandonedOnMaintenance;
  60. private int removeAbandonedTimeout;
  61. private boolean rollbackOnReturn;
  62. private int softMinEvictableIdleTimeMillis;
  63. private boolean testOnBorrow;
  64. private boolean testOnCreate;
  65. private boolean testOnReturn;
  66. private boolean testWhileIdle;
  67. private int timeBetweenEvictionRunsMillis;
  68. private String validationQuery;
  69. private int validationQueryTimeout;
  70. private boolean accessToUnderlyingConnectionAllowed;
  71. private boolean defaultReadOnly;
  72. private String connectionProperties;
  73. public String getId() {
  74. return id;
  75. }
  76. public void setId(String id) {
  77. this.id = id;
  78. }
  79. public String getServerName() {
  80. return serverName;
  81. }
  82. public void setServerName(String serverName) {
  83. this.serverName = serverName;
  84. }
  85. public Type getType() {
  86. return type;
  87. }
  88. public void setType(Type type) {
  89. this.type = type;
  90. }
  91. public String getDriverClassName() {
  92. return driverClassName;
  93. }
  94. public void setDriverClassName(String driverClassName) {
  95. this.driverClassName = driverClassName;
  96. }
  97. public String getUrl() {
  98. return url;
  99. }
  100. public void setUrl(String url) {
  101. this.url = url;
  102. }
  103. public String getUsername() {
  104. return username;
  105. }
  106. public void setUsername(String username) {
  107. this.username = username;
  108. }
  109. public String getPassword() {
  110. return password;
  111. }
  112. public void setPassword(String password) {
  113. this.password = password;
  114. }
  115. public String getDefaultCatalog() {
  116. return defaultCatalog;
  117. }
  118. public void setDefaultCatalog(String defaultCatalog) {
  119. this.defaultCatalog = defaultCatalog;
  120. }
  121. public String getEvictionPolicyClassName() {
  122. return evictionPolicyClassName;
  123. }
  124. public void setEvictionPolicyClassName(String evictionPolicyClassName) {
  125. this.evictionPolicyClassName = evictionPolicyClassName;
  126. }
  127. public boolean isAbandonedUsageTracking() {
  128. return abandonedUsageTracking;
  129. }
  130. public void setAbandonedUsageTracking(boolean abandonedUsageTracking) {
  131. this.abandonedUsageTracking = abandonedUsageTracking;
  132. }
  133. public boolean isCacheState() {
  134. return cacheState;
  135. }
  136. public void setCacheState(boolean cacheState) {
  137. this.cacheState = cacheState;
  138. }
  139. public boolean isEnableAutoCommitOnReturn() {
  140. return enableAutoCommitOnReturn;
  141. }
  142. public void setEnableAutoCommitOnReturn(boolean enableAutoCommitOnReturn) {
  143. this.enableAutoCommitOnReturn = enableAutoCommitOnReturn;
  144. }
  145. public int getInitialSize() {
  146. return initialSize;
  147. }
  148. public void setInitialSize(int initialSize) {
  149. this.initialSize = initialSize;
  150. }
  151. public boolean isLifo() {
  152. return lifo;
  153. }
  154. public void setLifo(boolean lifo) {
  155. this.lifo = lifo;
  156. }
  157. public boolean isLogAbandoned() {
  158. return logAbandoned;
  159. }
  160. public void setLogAbandoned(boolean logAbandoned) {
  161. this.logAbandoned = logAbandoned;
  162. }
  163. public int getMaxConnLifetimeMillis() {
  164. return maxConnLifetimeMillis;
  165. }
  166. public void setMaxConnLifetimeMillis(int maxConnLifetimeMillis) {
  167. this.maxConnLifetimeMillis = maxConnLifetimeMillis;
  168. }
  169. public int getMaxIdle() {
  170. return maxIdle;
  171. }
  172. public void setMaxIdle(int maxIdle) {
  173. this.maxIdle = maxIdle;
  174. }
  175. public int getMaxOpenPreparedStatements() {
  176. return maxOpenPreparedStatements;
  177. }
  178. public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) {
  179. this.maxOpenPreparedStatements = maxOpenPreparedStatements;
  180. }
  181. public int getMaxTotal() {
  182. return maxTotal;
  183. }
  184. public void setMaxTotal(int maxTotal) {
  185. this.maxTotal = maxTotal;
  186. }
  187. public int getMaxWaitMillis() {
  188. return maxWaitMillis;
  189. }
  190. public void setMaxWaitMillis(int maxWaitMillis) {
  191. this.maxWaitMillis = maxWaitMillis;
  192. }
  193. public int getMinIdle() {
  194. return minIdle;
  195. }
  196. public void setMinIdle(int minIdle) {
  197. this.minIdle = minIdle;
  198. }
  199. public int getNumTestsPerEvictionRun() {
  200. return numTestsPerEvictionRun;
  201. }
  202. public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
  203. this.numTestsPerEvictionRun = numTestsPerEvictionRun;
  204. }
  205. public boolean isPoolPreparedStatements() {
  206. return poolPreparedStatements;
  207. }
  208. public void setPoolPreparedStatements(boolean poolPreparedStatements) {
  209. this.poolPreparedStatements = poolPreparedStatements;
  210. }
  211. public boolean isRemoveAbandonedOnBorrow() {
  212. return removeAbandonedOnBorrow;
  213. }
  214. public void setRemoveAbandonedOnBorrow(boolean removeAbandonedOnBorrow) {
  215. this.removeAbandonedOnBorrow = removeAbandonedOnBorrow;
  216. }
  217. public boolean isRemoveAbandonedOnMaintenance() {
  218. return removeAbandonedOnMaintenance;
  219. }
  220. public void setRemoveAbandonedOnMaintenance(boolean removeAbandonedOnMaintenance) {
  221. this.removeAbandonedOnMaintenance = removeAbandonedOnMaintenance;
  222. }
  223. public int getRemoveAbandonedTimeout() {
  224. return removeAbandonedTimeout;
  225. }
  226. public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
  227. this.removeAbandonedTimeout = removeAbandonedTimeout;
  228. }
  229. public boolean isRollbackOnReturn() {
  230. return rollbackOnReturn;
  231. }
  232. public void setRollbackOnReturn(boolean rollbackOnReturn) {
  233. this.rollbackOnReturn = rollbackOnReturn;
  234. }
  235. public int getSoftMinEvictableIdleTimeMillis() {
  236. return softMinEvictableIdleTimeMillis;
  237. }
  238. public void setSoftMinEvictableIdleTimeMillis(int softMinEvictableIdleTimeMillis) {
  239. this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
  240. }
  241. public boolean isTestOnBorrow() {
  242. return testOnBorrow;
  243. }
  244. public void setTestOnBorrow(boolean testOnBorrow) {
  245. this.testOnBorrow = testOnBorrow;
  246. }
  247. public boolean isTestOnCreate() {
  248. return testOnCreate;
  249. }
  250. public void setTestOnCreate(boolean testOnCreate) {
  251. this.testOnCreate = testOnCreate;
  252. }
  253. public boolean isTestOnReturn() {
  254. return testOnReturn;
  255. }
  256. public void setTestOnReturn(boolean testOnReturn) {
  257. this.testOnReturn = testOnReturn;
  258. }
  259. public boolean isTestWhileIdle() {
  260. return testWhileIdle;
  261. }
  262. public void setTestWhileIdle(boolean testWhileIdle) {
  263. this.testWhileIdle = testWhileIdle;
  264. }
  265. public int getTimeBetweenEvictionRunsMillis() {
  266. return timeBetweenEvictionRunsMillis;
  267. }
  268. public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
  269. this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
  270. }
  271. public String getValidationQuery() {
  272. return validationQuery;
  273. }
  274. public void setValidationQuery(String validationQuery) {
  275. this.validationQuery = validationQuery;
  276. }
  277. public int getValidationQueryTimeout() {
  278. return validationQueryTimeout;
  279. }
  280. public void setValidationQueryTimeout(int validationQueryTimeout) {
  281. this.validationQueryTimeout = validationQueryTimeout;
  282. }
  283. public boolean isAccessToUnderlyingConnectionAllowed() {
  284. return accessToUnderlyingConnectionAllowed;
  285. }
  286. public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
  287. this.accessToUnderlyingConnectionAllowed = accessToUnderlyingConnectionAllowed;
  288. }
  289. public boolean isDefaultReadOnly() {
  290. return defaultReadOnly;
  291. }
  292. public void setDefaultReadOnly(boolean defaultReadOnly) {
  293. this.defaultReadOnly = defaultReadOnly;
  294. }
  295. public String getConnectionProperties() {
  296. return connectionProperties;
  297. }
  298. public void setConnectionProperties(String connectionProperties) {
  299. this.connectionProperties = connectionProperties;
  300. }
  301. @Override
  302. public String toString() {
  303. return "DataSourceConfigurationVO{" + "id='" + id + '\'' + ", serverName='" + serverName + '\'' + ", type=" + type + ", driverClassName='" + driverClassName + '\''
  304. + ", url='" + url + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + ", defaultCatalog='" + defaultCatalog + '\''
  305. + ", evictionPolicyClassName='" + evictionPolicyClassName + '\'' + ", abandonedUsageTracking=" + abandonedUsageTracking + ", cacheState=" + cacheState
  306. + ", enableAutoCommitOnReturn=" + enableAutoCommitOnReturn + ", initialSize=" + initialSize + ", lifo=" + lifo + ", logAbandoned=" + logAbandoned
  307. + ", maxConnLifetimeMillis=" + maxConnLifetimeMillis + ", maxIdle=" + maxIdle + ", maxOpenPreparedStatements=" + maxOpenPreparedStatements + ", maxTotal="
  308. + maxTotal + ", maxWaitMillis=" + maxWaitMillis + ", minIdle=" + minIdle + ", numTestsPerEvictionRun=" + numTestsPerEvictionRun + ", poolPreparedStatements="
  309. + poolPreparedStatements + ", removeAbandonedOnBorrow=" + removeAbandonedOnBorrow + ", removeAbandonedOnMaintenance=" + removeAbandonedOnMaintenance
  310. + ", removeAbandonedTimeout=" + removeAbandonedTimeout + ", rollbackOnReturn=" + rollbackOnReturn + ", softMinEvictableIdleTimeMillis='"
  311. + softMinEvictableIdleTimeMillis + '\'' + ", testOnBorrow=" + testOnBorrow + ", testOnCreate=" + testOnCreate + ", testOnReturn=" + testOnReturn
  312. + ", testWhileIdle=" + testWhileIdle + ", timeBetweenEvictionRunsMillis=" + timeBetweenEvictionRunsMillis + ", validationQuery='" + validationQuery + '\''
  313. + ", validationQueryTimeout=" + validationQueryTimeout + ", accessToUnderlyingConnectionAllowed=" + accessToUnderlyingConnectionAllowed + ", defaultReadOnly="
  314. + defaultReadOnly + ", connectionProperties='" + connectionProperties + '\'' + '}';
  315. }
  316. public static void main(String[] args) {
  317. DataSourceConfigurationVO d = new DataSourceConfigurationVO();
  318. d.setType(Type.MAIN);
  319. d.setServerName("StgEnterprise1");
  320. d.setDriverClassName("com.mysql.jdbc.Driver");
  321. d.setUrl("jdbc:mysql://localhost:3306/uniware?autoReconnect=true");
  322. d.setUsername("root");
  323. d.setPassword("uniware");
  324. d.setDefaultCatalog("uniware");
  325. d.setEvictionPolicyClassName("org.apache.tomcat.dbcp.pool2.impl.DefaultEvictionPolicy");
  326. d.setAbandonedUsageTracking(false);
  327. d.setCacheState(true);
  328. d.setEnableAutoCommitOnReturn(true);
  329. d.setInitialSize(1);
  330. d.setLifo(true);
  331. d.setLogAbandoned(false);
  332. d.setMaxConnLifetimeMillis(-1);
  333. d.setMaxIdle(20);
  334. d.setMaxOpenPreparedStatements(-1);
  335. d.setMaxTotal(-1);
  336. d.setMaxWaitMillis(15000);
  337. d.setMinIdle(0);
  338. d.setNumTestsPerEvictionRun(3);
  339. d.setPoolPreparedStatements(false);
  340. d.setRemoveAbandonedOnBorrow(false);
  341. d.setRemoveAbandonedOnMaintenance(false);
  342. d.setRemoveAbandonedTimeout(300);
  343. d.setRollbackOnReturn(true);
  344. d.setSoftMinEvictableIdleTimeMillis(-1);
  345. d.setTestOnBorrow(true);
  346. d.setTestOnCreate(false);
  347. d.setTestOnReturn(false);
  348. d.setTestWhileIdle(false);
  349. d.setTimeBetweenEvictionRunsMillis(-1);
  350. d.setValidationQuery("select 1");
  351. d.setValidationQueryTimeout(100);
  352. d.setAccessToUnderlyingConnectionAllowed(false);
  353. d.setDefaultReadOnly(false);
  354. d.setConnectionProperties("");
  355. System.out.println(new Gson().toJson(d));
  356. }
  357. }