/sql-processor-spring/src/main/java/org/sqlproc/engine/spring/jmx/SpringEngineFactoryJmx.java

http://github.com/hudec/sql-processor · Java · 582 lines · 349 code · 60 blank · 173 comment · 0 complexity · ba01983047efdfdbe03f648983223a80 MD5 · raw file

  1. package org.sqlproc.engine.spring.jmx;
  2. import java.util.List;
  3. import org.springframework.jmx.export.annotation.ManagedOperation;
  4. import org.springframework.jmx.export.annotation.ManagedOperationParameter;
  5. import org.springframework.jmx.export.annotation.ManagedOperationParameters;
  6. import org.springframework.jmx.export.annotation.ManagedResource;
  7. import org.sqlproc.engine.SqlEngineException;
  8. import org.sqlproc.engine.jmx.SqlDefaultFactoryMXBean;
  9. /**
  10. * The implementation of the simplified JMX interface for the SQL Engine factory.
  11. *
  12. * <p>
  13. * The factory can be based on Spring DI framework for example.
  14. *
  15. * <p>
  16. * For more info please see the <a href="https://github.com/hudec/sql-processor/wiki">Tutorials</a>.
  17. *
  18. * @author <a href="mailto:Vladimir.Hudec@gmail.com">Vladimir Hudec</a>
  19. */
  20. @ManagedResource(objectName = "sql-processor:type=Engine", description = "The simplified JMX interface for the SQL Engine factory.")
  21. public class SpringEngineFactoryJmx extends SqlDefaultFactoryMXBean {
  22. /**
  23. * {@inheritDoc}
  24. */
  25. @Override
  26. @ManagedOperation(description = "In the case the SQL Query Engines are not initialized, a new static instances are established in the cache.")
  27. @ManagedOperationParameters({
  28. @ManagedOperationParameter(name = "names", description = "The names of the required SQL Query Engines instances") })
  29. public int initQueryEngines(String names) {
  30. return super.initQueryEngines(names);
  31. }
  32. /**
  33. * {@inheritDoc}
  34. */
  35. @Override
  36. @ManagedOperation(description = "In the case the SQL CRUD Engines are not initialized, a new static instances are established in the cache.")
  37. @ManagedOperationParameters({
  38. @ManagedOperationParameter(name = "names", description = "The names of the required SQL CRUD Engines instances") })
  39. public int initCrudEngines(String names) {
  40. return super.initCrudEngines(names);
  41. }
  42. /**
  43. * {@inheritDoc}
  44. */
  45. @Override
  46. @ManagedOperation(description = "In the case the SQL Procedure Engines are not initialized, a new static instances are established in the cache.")
  47. @ManagedOperationParameters({
  48. @ManagedOperationParameter(name = "names", description = "The names of the required SQL Procedure Engines instances") })
  49. public int initProcedureEngines(String names) {
  50. return super.initProcedureEngines(names);
  51. }
  52. /**
  53. * {@inheritDoc}
  54. */
  55. @Override
  56. @ManagedOperation(description = "In the case any dynamic SQL Query Engine is in the cache, the static one is re-established.")
  57. @ManagedOperationParameters({
  58. @ManagedOperationParameter(name = "names", description = "The names of the required SQL Query Engines instances") })
  59. public int resetQueryEngines(String names) {
  60. return super.resetQueryEngines(names);
  61. }
  62. /**
  63. * {@inheritDoc}
  64. */
  65. @Override
  66. @ManagedOperation(description = "In the case any dynamic SQL CRUD Engine is in the cache, the static one is re-established.")
  67. @ManagedOperationParameters({
  68. @ManagedOperationParameter(name = "names", description = "The names of the required SQL CRUD Engines instances") })
  69. public int resetCrudEngines(String names) {
  70. return super.resetCrudEngines(names);
  71. }
  72. /**
  73. * {@inheritDoc}
  74. */
  75. @Override
  76. @ManagedOperation(description = "In the case any dynamic SQL Procedure Engine is in the cache, the static one is re-established.")
  77. @ManagedOperationParameters({
  78. @ManagedOperationParameter(name = "names", description = "The names of the required SQL Procedure Engines instances") })
  79. public int resetProcedureEngines(String names) {
  80. return super.resetProcedureEngines(names);
  81. }
  82. /**
  83. * {@inheritDoc}
  84. */
  85. @Override
  86. @ManagedOperation(description = "A new dynamic SQL Query Engine instance is established in the cache. The static one is suppressed.")
  87. @ManagedOperationParameters({
  88. @ManagedOperationParameter(name = "name", description = "The name of the required SQL Query Engine instances"),
  89. @ManagedOperationParameter(name = "sqlStatement", description = "The new SQL statement, which is going to replace the original one") })
  90. public void newQueryEngine(String name, String sqlStatement) throws SqlEngineException {
  91. super.newQueryEngine(name, sqlStatement);
  92. }
  93. /**
  94. * {@inheritDoc}
  95. */
  96. @Override
  97. @ManagedOperation(description = "A new dynamic SQL CRUD Engine instance is established in the cache. The static one is suppressed.")
  98. @ManagedOperationParameters({
  99. @ManagedOperationParameter(name = "name", description = "The name of the required SQL CRUD Engine instances"),
  100. @ManagedOperationParameter(name = "sqlStatement", description = "The new SQL statement, which is going to replace the original one") })
  101. public void newCrudEngine(String name, String sqlStatement) {
  102. super.newCrudEngine(name, sqlStatement);
  103. }
  104. /**
  105. * {@inheritDoc}
  106. */
  107. @Override
  108. @ManagedOperation(description = "A new dynamic SQL Procedure Engine instance is established in the cache. The static one is suppressed.")
  109. @ManagedOperationParameters({
  110. @ManagedOperationParameter(name = "name", description = "The name of the required Procedure Query Engine instances"),
  111. @ManagedOperationParameter(name = "sqlStatement", description = "The new SQL statement, which is going to replace the original one") })
  112. public void newProcedureEngine(String name, String sqlStatement) {
  113. super.newProcedureEngine(name, sqlStatement);
  114. }
  115. /**
  116. * {@inheritDoc}
  117. */
  118. @Override
  119. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed static SQL Query Engine instances.")
  120. public List<String> getQueryNames() {
  121. return super.getQueryNames();
  122. }
  123. /**
  124. * {@inheritDoc}
  125. */
  126. @Override
  127. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed dynamic SQL Query Engine instances.")
  128. public List<String> getQueryDynamicNames() {
  129. return super.getQueryDynamicNames();
  130. }
  131. /**
  132. * {@inheritDoc}
  133. */
  134. @Override
  135. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed static SQL Crud Engine instances.")
  136. public List<String> getCrudNames() {
  137. return super.getCrudNames();
  138. }
  139. /**
  140. * {@inheritDoc}
  141. */
  142. @Override
  143. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed dynamic SQL Crud Engine instances.")
  144. public List<String> getCrudDynamicNames() {
  145. return super.getCrudDynamicNames();
  146. }
  147. /**
  148. * {@inheritDoc}
  149. */
  150. @Override
  151. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed static SQL Procedure Engine instances.")
  152. public List<String> getProcedureNames() {
  153. return super.getProcedureNames();
  154. }
  155. /**
  156. * {@inheritDoc}
  157. */
  158. @Override
  159. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed dynamic SQL Procedure Engine instances.")
  160. public List<String> getProcedureDynamicNames() {
  161. return super.getProcedureDynamicNames();
  162. }
  163. /**
  164. * {@inheritDoc}
  165. */
  166. @Override
  167. @ManagedOperation(description = "Returns the processing cache used for the selected SQL Query Engine.")
  168. public List<String> getQueryEngineProcessingCache(String name) {
  169. return super.getQueryEngineProcessingCache(name);
  170. }
  171. /**
  172. * {@inheritDoc}
  173. */
  174. @Override
  175. @ManagedOperation(description = "Returns the processing cache used for the selected SQL CRUD Engine.")
  176. public List<String> getCrudEngineProcessingCache(String name) {
  177. return super.getCrudEngineProcessingCache(name);
  178. }
  179. /**
  180. * {@inheritDoc}
  181. */
  182. @Override
  183. @ManagedOperation(description = "Returns the processing cache used for the selected SQL Procedure Engine.")
  184. public List<String> getProcedureEngineProcessingCache(String name) {
  185. return super.getProcedureEngineProcessingCache(name);
  186. }
  187. /**
  188. * {@inheritDoc}
  189. */
  190. @Override
  191. @ManagedOperation(description = "Returns the processing cache statistics used for the selected SQL Query Engine.")
  192. public List<String> getQueryEngineProcessingCacheStatistics(String name) {
  193. return super.getQueryEngineProcessingCacheStatistics(name);
  194. }
  195. /**
  196. * {@inheritDoc}
  197. */
  198. @Override
  199. @ManagedOperation(description = "Returns the processing cache statistics used for the selected SQL CRUD Engine.")
  200. public List<String> getCrudEngineProcessingCacheStatistics(String name) {
  201. return super.getCrudEngineProcessingCacheStatistics(name);
  202. }
  203. /**
  204. * {@inheritDoc}
  205. */
  206. @Override
  207. @ManagedOperation(description = "Returns the processing cache statistics used for the selected SQL Procedure Engine.")
  208. public List<String> getProcedureEngineProcessingCacheStatistics(String name) {
  209. return super.getProcedureEngineProcessingCacheStatistics(name);
  210. }
  211. /**
  212. * {@inheritDoc}
  213. */
  214. @Override
  215. @ManagedOperation(description = "Clears the processing cache used for the selected SQL Query Engine.")
  216. public int resetQueryEngineProcessingCache(String name, String names) {
  217. return super.resetQueryEngineProcessingCache(name, names);
  218. }
  219. /**
  220. * {@inheritDoc}
  221. */
  222. @Override
  223. @ManagedOperation(description = "Clears the processing cache used for the selected SQL CRUD Engine.")
  224. public int resetCrudEngineProcessingCache(String name, String names) {
  225. return super.resetCrudEngineProcessingCache(name, names);
  226. }
  227. /**
  228. * {@inheritDoc}
  229. */
  230. @Override
  231. @ManagedOperation(description = "Clears the processing cache used for the selected SQL Procedure Engine.")
  232. public int resetProcedureEngineProcessingCache(String name, String names) {
  233. return super.resetProcedureEngineProcessingCache(name, names);
  234. }
  235. /**
  236. * {@inheritDoc}
  237. */
  238. @Override
  239. @ManagedOperation(description = "Returns the collection of names of all initialized/constructed static SQL Engine instances.")
  240. public boolean isLazyInit() {
  241. return super.isLazyInit();
  242. }
  243. /**
  244. * {@inheritDoc}
  245. */
  246. @Override
  247. @ManagedOperation(description = "Sets the indicator to speed up the initialization process.")
  248. @ManagedOperationParameters({
  249. @ManagedOperationParameter(name = "lazyInit", description = "The indicator to speed up the initialization process.") })
  250. public void setLazyInit(boolean lazyInit) {
  251. super.setLazyInit(lazyInit);
  252. }
  253. /**
  254. * {@inheritDoc}
  255. */
  256. @Override
  257. @ManagedOperation(description = "Returns the indicator the initialization process should be done asynchronously.")
  258. public Integer getAsyncInitThreads() {
  259. return super.getAsyncInitThreads();
  260. }
  261. /**
  262. * {@inheritDoc}
  263. */
  264. @Override
  265. @ManagedOperation(description = "Sets the number of threads used for asynchronous initialization")
  266. @ManagedOperationParameters({
  267. @ManagedOperationParameter(name = "asyncInitThreads", description = "The number of threads used for asynchronous initialization.") })
  268. public void setAsyncInitThreads(Integer asyncInitThreads) {
  269. super.setAsyncInitThreads(asyncInitThreads);
  270. }
  271. /**
  272. * {@inheritDoc}
  273. */
  274. @Override
  275. @ManagedOperation(description = "Returns the initialization threshold. The engines, which usage is at least this number should be initialized directly.")
  276. public Integer getInitTreshold() {
  277. return super.getInitTreshold();
  278. }
  279. /**
  280. * {@inheritDoc}
  281. */
  282. @Override
  283. @ManagedOperation(description = "Sets the initialization threshold. The engines, which usage is at least this number should be initialized directly.")
  284. @ManagedOperationParameters({
  285. @ManagedOperationParameter(name = "initTreshold", description = "The initialization threshold.") })
  286. public void setInitTreshold(Integer initTreshold) {
  287. super.setInitTreshold(initTreshold);
  288. }
  289. /**
  290. * {@inheritDoc}
  291. */
  292. @Override
  293. @ManagedOperation(description = "Returns the indicator that the most frequently used engines should be initialized preferentially.")
  294. public Boolean getInitInUsageOrder() {
  295. return super.getInitInUsageOrder();
  296. }
  297. @Override
  298. @ManagedOperation(description = "Sets the indicator that the most frequently used engines should be initialized preferentially.")
  299. @ManagedOperationParameters({
  300. @ManagedOperationParameter(name = "initTreshold", description = "The indicator value.") })
  301. public void setInitInUsageOrder(Boolean initInUsageOrder) {
  302. super.setInitInUsageOrder(initInUsageOrder);
  303. }
  304. /**
  305. * {@inheritDoc}
  306. */
  307. @Override
  308. @ManagedOperation(description = "Returns the flag indicating the asynchronous SQL Processor engines initialization has been finished.")
  309. public Boolean isAsyncInitFinished() {
  310. return super.isAsyncInitFinished();
  311. }
  312. /**
  313. * {@inheritDoc}
  314. */
  315. @Override
  316. @ManagedOperation(description = "Returns the result of engines initialization process.")
  317. public String getEnginesInitErrors() {
  318. return super.getEnginesInitErrors();
  319. }
  320. /**
  321. * {@inheritDoc}
  322. */
  323. @Override
  324. @ManagedOperation(description = "Returns the container of the Query Engines' names, which has to be initialized.")
  325. public List<String> getQueryEnginesToInit() {
  326. return super.getQueryEnginesToInit();
  327. }
  328. /**
  329. * {@inheritDoc}
  330. */
  331. @Override
  332. @ManagedOperation(description = "Returns the container of the CRUD Engines' names, which has to be initialized.")
  333. public List<String> getCrudEnginesToInit() {
  334. return super.getCrudEnginesToInit();
  335. }
  336. /**
  337. * {@inheritDoc}
  338. */
  339. @Override
  340. @ManagedOperation(description = "Returns the container of the Procedure Engines' names, which has to be initialized.")
  341. public List<String> getProcedureEnginesToInit() {
  342. return super.getProcedureEnginesToInit();
  343. }
  344. /**
  345. * {@inheritDoc}
  346. */
  347. @Override
  348. @ManagedOperation(description = "Returns the Query Engine usage number.")
  349. @ManagedOperationParameters({
  350. @ManagedOperationParameter(name = "name", description = "The name of the SQL Query Engine") })
  351. public int getQueryEngineUsage(String name) {
  352. return super.getQueryEngineUsage(name);
  353. }
  354. /**
  355. * {@inheritDoc}
  356. */
  357. @Override
  358. @ManagedOperation(description = "Returns the CRUD Engine usage number.")
  359. @ManagedOperationParameters({
  360. @ManagedOperationParameter(name = "name", description = "The name of the SQL CRUD Engine") })
  361. public int getCrudEngineUsage(String name) {
  362. return super.getCrudEngineUsage(name);
  363. }
  364. /**
  365. * {@inheritDoc}
  366. */
  367. @Override
  368. @ManagedOperation(description = "Returns the Procedure Engine usage number.")
  369. @ManagedOperationParameters({
  370. @ManagedOperationParameter(name = "name", description = "The name of the SQL Procedure Engine") })
  371. public int getProcedureEngineUsage(String name) {
  372. return super.getProcedureEngineUsage(name);
  373. }
  374. /**
  375. * {@inheritDoc}
  376. */
  377. @Override
  378. @ManagedOperation(description = "Resets the Query Engine usage number.")
  379. @ManagedOperationParameters({
  380. @ManagedOperationParameter(name = "name", description = "The name of the SQL Query Engine") })
  381. public int resetQueryEngineUsage(String name) {
  382. return super.resetQueryEngineUsage(name);
  383. }
  384. /**
  385. * {@inheritDoc}
  386. */
  387. @Override
  388. @ManagedOperation(description = "Resets the CRUD Engine usage number.")
  389. @ManagedOperationParameters({
  390. @ManagedOperationParameter(name = "name", description = "The name of the SQL CRUD Engine") })
  391. public int resetCrudEngineUsage(String name) {
  392. return super.resetCrudEngineUsage(name);
  393. }
  394. /**
  395. * {@inheritDoc}
  396. */
  397. @Override
  398. @ManagedOperation(description = "Resets the Procedure Engine usage number.")
  399. @ManagedOperationParameters({
  400. @ManagedOperationParameter(name = "name", description = "The name of the SQL Procedure Engine") })
  401. public int resetProcedureEngineUsage(String name) {
  402. return super.resetProcedureEngineUsage(name);
  403. }
  404. /**
  405. * {@inheritDoc}
  406. */
  407. @Override
  408. @ManagedOperation(description = "Loads the persisted configuration.")
  409. public void loadConfiguration() {
  410. super.loadConfiguration();
  411. }
  412. /**
  413. * {@inheritDoc}
  414. */
  415. @Override
  416. @ManagedOperation(description = "Persists the configuration into the external file.")
  417. public void storeConfiguration() {
  418. super.storeConfiguration();
  419. }
  420. /**
  421. * {@inheritDoc}
  422. */
  423. @Override
  424. @ManagedOperation(description = "Resets the state of the dynamic configuration instance.")
  425. public void clearConfiguration() {
  426. super.clearConfiguration();
  427. }
  428. /**
  429. * {@inheritDoc}
  430. */
  431. @Override
  432. @ManagedOperation(description = "Reset the engines' usage counters.")
  433. public void clearConfigurationUsage() {
  434. super.clearConfigurationUsage();
  435. }
  436. @Override
  437. @ManagedOperation(description = "Returns the indicator that the processing cache can be used.")
  438. public Boolean getUseProcessingCache() {
  439. return super.getUseProcessingCache();
  440. }
  441. /**
  442. * {@inheritDoc}
  443. */
  444. @Override
  445. @ManagedOperation(description = "Sets the indicator that the processing cache can be used.")
  446. @ManagedOperationParameters({
  447. @ManagedOperationParameter(name = "useProcessingCache", description = "The indicator that the processing cache can be used") })
  448. public void setUseProcessingCache(Boolean useProcessingCache) {
  449. super.setUseProcessingCache(useProcessingCache);
  450. }
  451. @Override
  452. @ManagedOperation(description = "Returns the indicator that the processing cache can be used dynamically.")
  453. public Boolean getUseDynamicProcessingCache() {
  454. return super.getUseDynamicProcessingCache();
  455. }
  456. /**
  457. * {@inheritDoc}
  458. */
  459. @Override
  460. @ManagedOperation(description = "Sets the indicator that the processing cache can be used dynamically.")
  461. @ManagedOperationParameters({
  462. @ManagedOperationParameter(name = "useDynamicProcessingCache", description = "The indicator that the processing cache can be used dynamically") })
  463. public void setUseDynamicProcessingCache(Boolean useDynamicProcessingCache) {
  464. super.setUseDynamicProcessingCache(useDynamicProcessingCache);
  465. }
  466. /**
  467. * {@inheritDoc}
  468. */
  469. @Override
  470. @ManagedOperation(description = "Returns the negative processing cache.")
  471. public List<String> getDoProcessingCacheEngines() {
  472. return super.getDoProcessingCacheEngines();
  473. }
  474. /**
  475. * {@inheritDoc}
  476. */
  477. @Override
  478. @ManagedOperation(description = "Updates the positive processing cache.")
  479. @ManagedOperationParameters({
  480. @ManagedOperationParameter(name = "names", description = "The names of the SQL Query Engines instances") })
  481. public int initDoProcessingCache(String names) {
  482. return super.initDoProcessingCache(names);
  483. }
  484. /**
  485. * {@inheritDoc}
  486. */
  487. @Override
  488. @ManagedOperation(description = "Updates the positive processing cache.")
  489. @ManagedOperationParameters({
  490. @ManagedOperationParameter(name = "names", description = "The names of the SQL Query Engines instances") })
  491. public int resetDoProcessingCache(String names) {
  492. return super.resetDoProcessingCache(names);
  493. }
  494. /**
  495. * {@inheritDoc}
  496. */
  497. @Override
  498. @ManagedOperation(description = "Returns the negative processing cache.")
  499. public List<String> getDontProcessingCacheEngines() {
  500. return super.getDontProcessingCacheEngines();
  501. }
  502. /**
  503. * {@inheritDoc}
  504. */
  505. @Override
  506. @ManagedOperation(description = "Updates the negative processing cache.")
  507. @ManagedOperationParameters({
  508. @ManagedOperationParameter(name = "names", description = "The names of the SQL Query Engines instances") })
  509. public int initDontProcessingCache(String names) {
  510. return super.initDontProcessingCache(names);
  511. }
  512. /**
  513. * {@inheritDoc}
  514. */
  515. @Override
  516. @ManagedOperation(description = "Updates the negative processing cache.")
  517. @ManagedOperationParameters({
  518. @ManagedOperationParameter(name = "names", description = "The names of the SQL Query Engines instances") })
  519. public int resetDontProcessingCache(String names) {
  520. return super.resetDontProcessingCache(names);
  521. }
  522. }