A simple framework to build web application, Just write xml file!
- Simple and fast to build web application
- No need to write Controller, Service, Dao, just write xml file, and then it works
- Base on spring framework, almost every java developer can be used
The following guides illustrate how to use some features concretely:
Want to Integration Nomiky Framework?
Just use springboot @Configuration to define some beans:
@Configuration
public class AutoConfiguration {
@Bean
public static DataSource dataSource(Environment environment){
DataSourceProperties properties = Binder.get(environment).bind("spring.datasource", DataSourceProperties.class).get();
return properties.initializeDataSourceBuilder().build();
}
@Bean
public static JdbcTemplate jdbcTemplate(DataSource dataSource){
return new JdbcTemplate(dataSource);
}
@Bean
public static FrameworkBeanProcessor frameworkBeanProcessor(JdbcTemplate jdbcTemplate) {
return new FrameworkBeanProcessor(jdbcTemplate);
}
}Nomiky Framework will scan classpath dir, find tableDefine.xml and *_controller.xml and load them to build
Controller and DaoExecutor.
In tableDefine.xml, you can define the database tables which your web application want to use.
This tableDefine.xml define a table: statistic, and its primary key will generator by SNOWFLAKE.
The framework will create a DaoExecutor spring bean named by ocr.statistics, and implement some default CURD method:
- insert
- deleteById
- updateById
- select
- selectOne
- exist
- count
- selectPage
The parameter of default method is Map<String, Object>, it will receive parameters from controller request.
<?xml version="1.0" encoding="UTF-8" ?>
<TableExecutors>
<table schema="ocr" name="statistics" keyGenerator="SNOWFLAKE"/>
</TableExecutors>In *_controller.xml, you can define Controller attributes.
The framework will use it to register request mapping, and the mapping handler will call DaoExecutor which
specify by ref attribute.
This statistic_controller.xml define a Controller with path statistics, method GET, and it will reference
DaoExecutor bean which name is ocr.statistics, and then call the method select. The method parameter will
get from request.getParameter("appKey")
<?xml version="1.0" encoding="UTF-8" ?>
<controller path="statistics">
<controller method="GET">
<executor ref="ocr.statistics.select" params="param.appKey"/>
</controller>
</controller>Want to use transaction in Framework? Just add an attribute in <Controller> tag.
This statistic_controller.xml define a controller use transaction to execute 3 executors.
<controller path="statistics">
<controller method="GET" useTransaction="true">
<executor ref="ocr.statistics.select" params="param.appKey"/>
<executor ref="ocr.statistics.insert" params="param.appKey,param.name,param.sex"/>
<executor ref="ocr.statistics.deleteById" params="param.id"/>
</controller>
</controller>Nomiky Framework can define complex sql statement use Groovy or JavaScript engine.
You can write Groovy script or JavaScript code to define a complex sql.
Like this:
<controller method="GET">
<executor type="sql" engine="groovy">
sqlResult += "select * from user"
if (param.id){
sqlResult += " where id = ?"
sqlParams[sqlParams.length] = param.id
}
</executor>
</controller><controller method="GET">
<executor type="sql" engine="JavaScript">
sqlResult += "select * from user"
if (param.id){
sqlResult += " where id = ?"
sqlParams[sqlParams.length] = param.id
}
</executor>
</controller>When you code Groovy or JavaScript to define sql statement, you can get build-in parameters:
- param: all parameters from request
- bodyJson: the json object from requestBody
- bodyString: the string value from requestBody
- parent: the value from parent executor
- header: all parameters from request headers
All these build-in parameters are used in xml tag <executor params="">.
Otherwise, you can assign value to variable sqlResult and sqlParams, framework will get it and
execute by jdbcTemplate.