├── .gitignore
├── GET_START.md
├── LICENSE
├── README.md
├── axe
├── LICENSE
├── favicon.png
├── maven-deployer.txt
├── mysql-keyword.txt
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── axe
│ ├── Axe.java
│ ├── DispatcherServlet.java
│ ├── annotation
│ ├── aop
│ │ └── Aspect.java
│ ├── ioc
│ │ ├── Autowired.java
│ │ ├── Component.java
│ │ ├── Controller.java
│ │ └── Service.java
│ ├── mvc
│ │ ├── Default.java
│ │ ├── FilterFuckOff.java
│ │ ├── Interceptor.java
│ │ ├── Request.java
│ │ ├── RequestEntity.java
│ │ ├── RequestParam.java
│ │ └── UnFuckOff.java
│ └── persistence
│ │ ├── ColumnDefine.java
│ │ ├── Comment.java
│ │ ├── Dao.java
│ │ ├── DataSource.java
│ │ ├── Id.java
│ │ ├── JustInsert.java
│ │ ├── ResultProxy.java
│ │ ├── Sql.java
│ │ ├── Table.java
│ │ ├── Tns.java
│ │ └── Unique.java
│ ├── bean
│ ├── mvc
│ │ ├── Data.java
│ │ ├── ExceptionHolder.java
│ │ ├── FileParam.java
│ │ ├── FormParam.java
│ │ ├── Handler.java
│ │ ├── Header.java
│ │ ├── Param.java
│ │ ├── ResultHolder.java
│ │ └── View.java
│ └── persistence
│ │ ├── EntityFieldMethod.java
│ │ ├── InsertResult.java
│ │ ├── Page.java
│ │ ├── PageConfig.java
│ │ ├── ShardingTableCreateTask.java
│ │ ├── SqlExecutor.java
│ │ ├── SqlPackage.java
│ │ └── TableSchema.java
│ ├── constant
│ ├── CharacterEncoding.java
│ ├── ConfigConstant.java
│ ├── ContentType.java
│ ├── IdGenerateWay.java
│ ├── RequestContent.java
│ └── RequestMethod.java
│ ├── exception
│ ├── RedirectorInterrupt.java
│ └── RestException.java
│ ├── extra
│ ├── abc_thread
│ │ ├── README.txt
│ │ ├── SerialExecutor.java
│ │ ├── SerialExecutorPool.java
│ │ ├── TaskPack.java
│ │ └── TaskPackBusController.java
│ └── timer
│ │ ├── TimerTask.java
│ │ └── TimerTaskHelper.java
│ ├── factory
│ └── persistence
│ │ ├── DbcpDataSourceFactory.java
│ │ └── DefaultDataSourceFactory.java
│ ├── helper
│ ├── HelperLoader.java
│ ├── aop
│ │ └── AopHelper.java
│ ├── base
│ │ ├── ConfigHelper.java
│ │ ├── FrameworkStatusHelper.java
│ │ └── MailHelper.java
│ ├── ioc
│ │ ├── BeanHelper.java
│ │ ├── ClassHelper.java
│ │ └── IocHelper.java
│ ├── mvc
│ │ ├── ControllerHelper.java
│ │ ├── FilterHelper.java
│ │ ├── FormRequestHelper.java
│ │ ├── InterceptorHelper.java
│ │ ├── ListenerHelper.java
│ │ └── TimerHelper.java
│ └── persistence
│ │ ├── DataBaseHelper.java
│ │ ├── DataSourceHelper.java
│ │ ├── SchemaHelper.java
│ │ └── TableHelper.java
│ ├── home
│ ├── interceptor
│ │ └── HomeInterceptor.java
│ └── rest
│ │ ├── AxeRest.java
│ │ └── html
│ │ ├── action.html
│ │ ├── action_list.html
│ │ ├── controller_list.html
│ │ ├── filter_action_list.html
│ │ ├── filter_list.html
│ │ ├── index.html
│ │ ├── interceptor_action_list.html
│ │ ├── interceptor_list.html
│ │ ├── lib
│ │ ├── bootstrap.min.css
│ │ ├── bootstrap.min.js
│ │ ├── doc.min.css
│ │ ├── jquery.form.min.js
│ │ ├── jquery.min.js
│ │ ├── nice-ajax.js
│ │ └── nice-mvvm.js
│ │ └── table_list.html
│ ├── interface_
│ ├── base
│ │ └── Helper.java
│ ├── mvc
│ │ ├── AfterBeanInited.java
│ │ ├── AfterClassLoaded.java
│ │ ├── AfterConfigLoaded.java
│ │ ├── Filter.java
│ │ ├── Interceptor.java
│ │ ├── Listener.java
│ │ └── Timer.java
│ ├── persistence
│ │ ├── BaseDataSource.java
│ │ ├── BaseRepository.java
│ │ ├── Sharding.java
│ │ ├── SqlResultProxy.java
│ │ └── TableNameEditor.java
│ ├── proxy
│ │ └── Proxy.java
│ └── type_convert
│ │ └── BaseTypeConvert.java
│ ├── interface_implement
│ ├── mvc
│ │ ├── AxeRequestParamAnalyzeFilter.java
│ │ ├── HeaderFilter.java
│ │ └── Utf8CharSetFilter.java
│ └── type_convert
│ │ ├── BigDecimal2DoubleConvert.java
│ │ ├── BigDecimal2IntegerConvert.java
│ │ ├── BigInteger2LongConvert.java
│ │ ├── Boolean2IntegerConvert.java
│ │ ├── Double2BigDecimalConvert.java
│ │ ├── Integer2BigDecimalConvert.java
│ │ ├── Integer2LongConvert.java
│ │ ├── Long2BigDecimalConvert.java
│ │ ├── Long2DateConvert.java
│ │ ├── Long2SqlDateConvert.java
│ │ ├── SqlDate2DateConvert.java
│ │ ├── String2BigDecimalConvert.java
│ │ ├── String2DateConvert.java
│ │ ├── String2DoubleConvert.java
│ │ ├── String2IntegerConvert.java
│ │ ├── String2LongConvert.java
│ │ ├── String2SqlDateConvert.java
│ │ ├── String2SqlTimestampConvert.java
│ │ └── Timestamp2DateConvert.java
│ ├── jetty
│ ├── JettyManager.java
│ └── JettyServletFilter.java
│ ├── proxy
│ ├── base
│ │ ├── AspectProxy.java
│ │ ├── ProxyChain.java
│ │ └── ProxyManger.java
│ └── implement
│ │ ├── DaoAspect.java
│ │ └── TransactionAspect.java
│ └── util
│ ├── AjaxRequestUtil.java
│ ├── ApiExportUtil.java
│ ├── ArrayUtil.java
│ ├── CastUtil.java
│ ├── ClassUtil.java
│ ├── CollectionUtil.java
│ ├── FileUtil.java
│ ├── HttpUtil.java
│ ├── IpUtil.java
│ ├── JsonUtil.java
│ ├── LogUtil.java
│ ├── MD5Util.java
│ ├── PropsUtil.java
│ ├── ReflectionUtil.java
│ ├── RequestUtil.java
│ ├── StreamUtil.java
│ ├── StringUtil.java
│ ├── TableExportUtil.java
│ ├── mail
│ ├── MailSenderInfo.java
│ ├── MyAuthenticator.java
│ └── SimpleMailSender.java
│ └── sql
│ ├── CommonSqlUtil.java
│ ├── MySqlUtil.java
│ └── OracleUtil.java
├── first_project
├── README.md
├── pom.xml
└── src
│ └── main
│ ├── java
│ ├── com
│ │ └── axe
│ │ │ └── first_project
│ │ │ ├── JettyStart.java
│ │ │ └── rest
│ │ │ └── TestRest.java
│ └── test
│ │ └── Test.java
│ └── resources
│ ├── axe.properties
│ └── log4j.properties
└── unpublished
└── unpublished.zip
/.gitignore:
--------------------------------------------------------------------------------
1 | ##### ignore auto-generated files by eclipse #####
2 | .classpath
3 | .DS_Store
4 | .settings/
5 | .idea/
6 | ##### ignore all folder except source codes #####
7 | build/
8 | node_modules/
9 | _build/
10 |
11 |
12 | bin/
13 | bower_components/
14 | classes/
15 | test-classes/
16 | .sass-cache/
17 | style.css.map
18 | target/
19 | ##### ignore fixed files #####
20 | *.class
21 | #/lngiot-service/lngiot-api/.classpath
22 | #/lngiot-service/lngiot-api/.project
23 | dist/
24 | *.project
25 | .gitignore
26 | *.iml
27 |
28 | log/
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 CaiDongyu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Axe是一个java框架,提供了使用简单的RESTful、IOC、持久化等功能。
2 |
3 | ##### 需要 jdk 1.7及以上
4 |
5 | ### [快速上手开始](https://github.com/DongyuCai/Axe/blob/19.8.6/GET_START.md)
6 |
7 | ### RESTful 简单展示,更多使用细节请直接上手
8 | ```java
9 | @Controller(basePath="",desc="HelloWord")
10 | public class TestRest {
11 |
12 | @Request(path="/first",method=RequestMethod.GET,desc="第一个接口")
13 | public String first(
14 | @RequestParam(name="name",required=true,desc="姓名")String name,
15 | @RequestParam(name="age",desc="年龄")Integer age
16 | ){
17 | return "姓名:"+name+" 年龄:"+(age == null?"不知道":age);
18 | }
19 |
20 | }
21 | ```
22 |
23 | ### IOC 简单展示,更多使用细节请直接上手
24 | ```java
25 | @Service
26 | public class TestService {
27 |
28 | @Autowired
29 | private TestDao testDao;
30 |
31 | public List list(){
32 | return testDao.list();
33 | }
34 |
35 | }
36 | ```
37 | ```java
38 | public class Test {
39 |
40 | public static void main(String[] args) {
41 | try{
42 | Axe.init();
43 | TestController controller = BeanHelper.getBean(TestController.class);
44 | System.out.println(controller);
45 | TestService service = BeanHelper.getBean(TestService.class);
46 | System.out.println(service);
47 | TestDao dao = BeanHelper.getBean(TestDao.class);
48 | System.out.println(dao);
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 | }
55 | ```
56 |
57 | ### 持久化 简单展示,更多使用细节请直接上手
58 | ```java
59 | @Dao
60 | public interface TestDao extends BaseRepository{//如果不需要saveEntity、deleteEntity等持久化对象操作方法,可以不继承BaseRespository
61 |
62 | @Sql("select * from TestTable order by id")
63 | public List list();
64 | }
65 |
66 | ```
67 |
--------------------------------------------------------------------------------
/axe/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 CaiDongyu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/axe/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DongyuCai/Axe/3b58ecd5384ad6c8ffeb23ae2948cb138944edd9/axe/favicon.png
--------------------------------------------------------------------------------
/axe/maven-deployer.txt:
--------------------------------------------------------------------------------
1 | mvn deploy:deploy-file -DgroupId=org.axe -DartifactId=axe -Dversion=0.1.7 -Dpackaging=jar -Dfile=D:\axe-0.1.7.jar -Durl=http://mvn.lngtop.com/nexus/content/repositories/Lngtop-Releases/ -DrepositoryId=lngtop-releases
--------------------------------------------------------------------------------
/axe/mysql-keyword.txt:
--------------------------------------------------------------------------------
1 | ADD ALL ALTER
2 | ANALYZE AND AS
3 | ASC ASENSITIVE BEFORE
4 | BETWEEN BIGINT BINARY
5 | BLOB BOTH BY
6 | CALL CASCADE CASE
7 | CHANGE CHAR CHARACTER
8 | CHECK COLLATE COLUMN
9 | CONDITION CONNECTION CONSTRAINT
10 | CONTINUE CONVERT CREATE
11 | CROSS CURRENT_DATE CURRENT_TIME
12 | CURRENT_TIMESTAMP CURRENT_USER CURSOR
13 | DATABASE DATABASES DAY_HOUR
14 | DAY_MICROSECOND DAY_MINUTE DAY_SECOND
15 | DEC DECIMAL DECLARE
16 | DEFAULT DELAYED DELETE
17 | DESC DESCRIBE DETERMINISTIC
18 | DISTINCT DISTINCTROW DIV
19 | DOUBLE DROP DUAL
20 | EACH ELSE ELSEIF
21 | ENCLOSED ESCAPED EXISTS
22 | EXIT EXPLAIN FALSE
23 | FETCH FLOAT FLOAT4
24 | FLOAT8 FOR FORCE
25 | FOREIGN FROM FULLTEXT
26 | GOTO GRANT GROUP
27 | HAVING HIGH_PRIORITY HOUR_MICROSECOND
28 | HOUR_MINUTE HOUR_SECOND IF
29 | IGNORE IN INDEX
30 | INFILE INNER INOUT
31 | INSENSITIVE INSERT INT
32 | INT1 INT2 INT3
33 | INT4 INT8 INTEGER
34 | INTERVAL INTO IS
35 | ITERATE JOIN KEY
36 | KEYS KILL LABEL
37 | LEADING LEAVE LEFT
38 | LIKE LIMIT LINEAR
39 | LINES LOAD LOCALTIME
40 | LOCALTIMESTAMP LOCK LONG
41 | LONGBLOB LONGTEXT LOOP
42 | LOW_PRIORITY MATCH MEDIUMBLOB
43 | MEDIUMINT MEDIUMTEXT MIDDLEINT
44 | MINUTE_MICROSECOND MINUTE_SECOND MOD
45 | MODIFIES NATURAL NOT
46 | NO_WRITE_TO_BINLOG NULL NUMERIC
47 | ON OPTIMIZE OPTION
48 | OPTIONALLY OR ORDER
49 | OUT OUTER OUTFILE
50 | PRECISION PRIMARY PROCEDURE
51 | PURGE RAID0 RANGE
52 | READ READS REAL
53 | REFERENCES REGEXP RELEASE
54 | RENAME REPEAT REPLACE
55 | REQUIRE RESTRICT RETURN
56 | REVOKE RIGHT RLIKE
57 | SCHEMA SCHEMAS SECOND_MICROSECOND
58 | SELECT SENSITIVE SEPARATOR
59 | SET SHOW SMALLINT
60 | SPATIAL SPECIFIC SQL
61 | SQLEXCEPTION SQLSTATE SQLWARNING
62 | SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT
63 | SSL STARTING STRAIGHT_JOIN
64 | TABLE TERMINATED THEN
65 | TINYBLOB TINYINT TINYTEXT
66 | TO TRAILING TRIGGER
67 | TRUE UNDO UNION
68 | UNIQUE UNLOCK UNSIGNED
69 | UPDATE USAGE USE
70 | USING UTC_DATE UTC_TIME
71 | UTC_TIMESTAMP VALUES VARBINARY
72 | VARCHAR VARCHARACTER VARYING
73 | WHEN WHERE WHILE
74 | WITH WRITE X509
75 | XOR YEAR_MONTH ZEROFILL
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/Axe.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe;
25 |
26 | import java.util.Properties;
27 |
28 | import org.axe.helper.HelperLoader;
29 | import org.axe.helper.base.ConfigHelper;
30 |
31 | /**
32 | * Axe启动入口类
33 | * @author CaiDongyu
34 | */
35 | public class Axe {
36 |
37 | public static void initWithoutConfigFile(Properties configInitProperties) throws Exception{
38 | ConfigHelper.setConfigProps(configInitProperties);//预设代码配置,这样就不需要axe.properties配置文件了
39 | HelperLoader.init();
40 | }
41 |
42 | public static void init() throws Exception{
43 | HelperLoader.init();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/aop/Aspect.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.aop;
25 |
26 | import java.lang.annotation.*;
27 |
28 | /**
29 | * 切面
30 | * @author CaiDongyu on 2016/4/11.
31 | */
32 | @Target(ElementType.TYPE)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface Aspect {
35 | Class extends Annotation>[] value();
36 | }
37 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/ioc/Autowired.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.ioc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 依赖注入注解
33 | * @author CaiDongyu on 2016/4/8.
34 | */
35 | @Target(ElementType.FIELD)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface Autowired {
38 | }
39 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/ioc/Component.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.ioc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * Ioc 注解
33 | * 其实效果与@Service一样,但是@Service有@Tns切面了,所以分开
34 | * @Component还没有什么切面加强,比较干净,是纯的Bean
35 | * @author CaiDongyu on 2016年5月11日 上午10:20:16.
36 | */
37 | @Target(ElementType.TYPE)
38 | @Retention(RetentionPolicy.RUNTIME)
39 | public @interface Component {
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/ioc/Controller.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.ioc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 控制器注解
33 | * @author CaiDongyu on 2016/4/8.
34 | */
35 | @Target(ElementType.TYPE)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface Controller {
38 | String desc() default "";
39 | /**
40 | * 路径 path
41 | */
42 | String basePath() default "";
43 | }
44 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/ioc/Service.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.ioc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 服务类注解
33 | * @author CaiDongyu on 2016/4/8.
34 | */
35 | @Target(ElementType.TYPE)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface Service {
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/Default.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 用于{@link RequestParam}默认值
33 | * 例子:@Default("paramValue")
34 | *
35 | * 用于{@link RequestEntity}默认值
36 | * 例子:@Default({"name:val_1","age:val_2"})
37 | */
38 | @Target(ElementType.PARAMETER)
39 | @Retention(RetentionPolicy.RUNTIME)
40 | public @interface Default {
41 |
42 | String[] value() default {};
43 | }
44 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/FilterFuckOff.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | import org.axe.interface_.mvc.Filter;
32 | import org.axe.interface_implement.mvc.AxeRequestParamAnalyzeFilter;
33 |
34 | /**
35 | * 排除过滤器注解
36 | * 应用在那些不需要某些过滤器的Controller方法上
37 | * 也可以直接暴力加在Controller上,这样方法上的此注解会失效,
38 | * Controller中所有方法都依照Controller上的此注解配置
39 | * @author CaiDongyu on 2016/4/8.
40 | */
41 | @Target({ElementType.TYPE,ElementType.METHOD})
42 | @Retention(RetentionPolicy.RUNTIME)
43 | public @interface FilterFuckOff {
44 |
45 | /**
46 | * 需要排除的过滤器列表
47 | * 默认为空,注意注意,为空不是说不排除,而是排除所有!
48 | */
49 | Class extends Filter>[] value() default {};
50 |
51 | /**
52 | * 不包括的过滤器列表
53 | * 如果与排除项冲突,从排除项中扣除
54 | * 默认不包括 AxeRequestParamAnalyzeFilter
55 | */
56 | Class extends Filter>[] notFuckOff() default {AxeRequestParamAnalyzeFilter.class};
57 | }
58 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/Interceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 拦截器 注解
33 | * 拦截器没有FuckOff排除
34 | * @author CaiDongyu on 2016年5月30日 下午12:16:43.
35 | */
36 | @Target({ElementType.TYPE,ElementType.METHOD})
37 | @Retention(RetentionPolicy.RUNTIME)
38 | public @interface Interceptor {
39 | /**
40 | * 需要排除的过滤器列表
41 | * 默认为空,注意注意,为空不是说不排除,而是排除所有!
42 | */
43 | Class extends org.axe.interface_.mvc.Interceptor>[] value();
44 | }
45 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/Request.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | import org.axe.constant.CharacterEncoding;
32 | import org.axe.constant.ContentType;
33 | import org.axe.constant.RequestMethod;
34 |
35 | /**
36 | * 控制器方法注解
37 | * @author CaiDongyu on 2016/4/8.
38 | */
39 | @Target(ElementType.METHOD)
40 | @Retention(RetentionPolicy.RUNTIME)
41 | public @interface Request {
42 |
43 | String desc() default "";
44 | /**
45 | * 请求路径
46 | */
47 | String path();
48 |
49 | /**
50 | * 请求类型
51 | */
52 | RequestMethod method();
53 |
54 | /**
55 | * 返回结果 MIME 类型
56 | */
57 | ContentType contentType() default ContentType.APPLICATION_JSON;
58 |
59 | /**
60 | * 编码类型
61 | */
62 | CharacterEncoding characterEncoding() default CharacterEncoding.UTF_8;
63 | }
64 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/RequestEntity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 必填
33 | */
34 | @Target(ElementType.PARAMETER)
35 | @Retention(RetentionPolicy.RUNTIME)
36 | public @interface RequestEntity {
37 |
38 | /**
39 | * 必填的字段
40 | */
41 | String[] requiredFields() default {};
42 |
43 | /**
44 | * 排除的,不接受的字段
45 | */
46 | String[] excludedFields() default {};
47 | }
48 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/RequestParam.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * ActionMethod 获取请求参数的注解
33 | * TODO:增加default值,暂时不增加,前台传参数就是要规范,不规范怎么行
34 | */
35 | @Target(ElementType.PARAMETER)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface RequestParam {
38 | /**
39 | * 参数字段名
40 | */
41 | String name();
42 |
43 | /**
44 | * 描述
45 | */
46 | String desc() default "";
47 |
48 | /**
49 | * 是否必填
50 | */
51 | boolean required() default false;
52 |
53 | /**
54 | * 正则校验
55 | */
56 | String compile() default "";
57 | }
58 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/mvc/UnFuckOff.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.mvc;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 不可排除的过滤器
33 | * 注解用在过滤器上
34 | * 如果FilterFuckOff未指明排除此注解注释的Filter,则正常不排除,如果指明,则启动报错提示不可排除
35 | * @author CaiDongyu on 2018/11/1.
36 | */
37 | @Target({ElementType.TYPE,ElementType.METHOD})
38 | @Retention(RetentionPolicy.RUNTIME)
39 | public @interface UnFuckOff {}
40 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/ColumnDefine.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 | /**
31 | * #Dao entity 类属性注解
32 | * 用来给Entity字段做定义
33 | * 不包含列名定义
34 | * axe中认为,列名就应该根据字段名按规范映射生成,不应该另作他名
35 | * 用法比如:
36 | * 没有使用@ColumnDefine的字段是这样的:
37 | * private String name;
38 | * 对应的数据库列默认定义是这样的:
39 | * name varchar(255) DEFAULT NULL;
40 | * 如果加上@ColumnDefine自定义字段类型:
41 | * @ColumnDefine("varchar(10) NOT NULL");
42 | * private String name;
43 | * 则对于的数据库列定义会是这样:
44 | * name varchar(10) NOT NULL;
45 | * 当然可以写更多的指令,比如long类型可以加上AUTO_INCREMENT,唯一属性可以UNIQUE等等
46 | * 当与@Id同时存在时,@ColumnDefine优先级更高
47 | * @author CaiDongyu on 2016/9/22.
48 | */
49 | @Target(ElementType.FIELD)
50 | @Retention(RetentionPolicy.RUNTIME)
51 | public @interface ColumnDefine {
52 | String value();
53 | }
54 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Comment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 | /**
31 | * #Dao entity 类属性注解
32 | * 用来给Entity字段做描述
33 | * 当与@ColumnDefine同时存在时,@ColumnDefine优先级更高
34 | * @author CaiDongyu on 2016/9/22.
35 | */
36 | @Target(ElementType.FIELD)
37 | @Retention(RetentionPolicy.RUNTIME)
38 | public @interface Comment {
39 | String value();
40 | }
41 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Dao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * Dao 注解
33 | * @author CaiDongyu on 2016/4/8.
34 | */
35 | @Target(ElementType.TYPE)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface Dao {
38 |
39 | String dataSource() default "";
40 | }
41 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/DataSource.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * DataSource实现类 注解
33 | * 用于标注DataSource名称
34 | * @author CaiDongyu on 2016/4/8.
35 | */
36 | @Target({ElementType.TYPE})
37 | @Retention(RetentionPolicy.RUNTIME)
38 | public @interface DataSource {
39 | String value();
40 | }
41 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Id.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | import org.axe.constant.IdGenerateWay;
32 |
33 | /**
34 | * 主键指定 PRIMARY KEY
35 | * 联合主键非常简单,只要在需要联合的字段上,都加注这个注解即可
36 | */
37 | @Target(ElementType.FIELD)
38 | @Retention(RetentionPolicy.RUNTIME)
39 | public @interface Id {
40 | IdGenerateWay idGenerateWay() default IdGenerateWay.NONE;
41 | }
42 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/JustInsert.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 | /**
31 | * #Dao entity 类属性注解
32 | * 用来给Entity字段做定义
33 | * 效果:使用此注解的字段,将无法在updateEntity和saveEntity中被修改到数据库。
34 | * axe中,saveEntity方法是添加或修改,主要看数据唯一键在表里是否有值,当修改时候,是全字段修改
35 | * 但是往往存在使用saveEntity时候,只希望修改部分字段,有一些字段是不希望修改的,希望剩余数据保持一致
36 | * 所以可以使用哪个@JustInsert来注解表明哪些字段,只能通过@Sql语句来修改,用法比如:
37 | * 使用@JustInsert标注的字段如下
38 | * @JustInsert
39 | * @Comment("用户积分")
40 | * private int points;
41 | * 那么points字段当使用saveEntity方法保存Entity时候,points字段不会被update,只有当@Id字段是空时,points字段会被insert。
42 | * @author CaiDongyu on 2019/8/21. *完整的3年*
43 | */
44 | @Target(ElementType.FIELD)
45 | @Retention(RetentionPolicy.RUNTIME)
46 | public @interface JustInsert {
47 | }
48 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/ResultProxy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | import org.axe.interface_.persistence.SqlResultProxy;
32 |
33 | /**
34 | * Dao方法注解
35 | * 对执行结果指定一个代理
36 | * @author CaiDongyu on 2016/4/8.
37 | */
38 | @Target(ElementType.METHOD)
39 | @Retention(RetentionPolicy.RUNTIME)
40 | public @interface ResultProxy {
41 |
42 | Class extends SqlResultProxy> value();
43 |
44 | /**
45 | * void.class实际上就是List> 是一个效果
46 | * rowType是外层类型
47 | * returnType是泛型类型
48 | */
49 | Class> rawType() default void.class;
50 | Class> returnType() default void.class;
51 | }
52 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Sql.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * Dao方法注解
33 | * @author CaiDongyu on 2016/4/8.
34 | */
35 | @Target(ElementType.METHOD)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface Sql {
38 |
39 | String value();
40 |
41 | //CaiDongyu 2019/2/14 这在sql解析自动union之后,会作为整句开始拼接
42 | String headAfterUnion() default "";
43 |
44 | //CaiDongyu 2019/2/14 这在sql解析自动union之后,会作为整句结尾拼接
45 | String tailAfterUnion() default "";
46 | }
47 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Table.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 用来指定表
33 | * #Dao entity 类注解
34 | * 其实就算不指定这个注解,也一样可以用@Sql查询后映射成Bean,
35 | * 这个注解是为了让@Sql支持类似HQL风格的,基于类的Sql语法,
36 | * 如果不使用这个注解,@Sql就只能写传统的本地方言,
37 | * #特殊要求是,加了这个注解的类,全局不能出现相同的两个,即便包路径不同也不行。
38 | * 因为在@Sql解析,当做HQL的时候,sql里只含有类名,所以全局找Bean的时候,同名会出问题
39 | * @author CaiDongyu on 2016/4/8.
40 | */
41 | @Target(ElementType.TYPE)
42 | @Retention(RetentionPolicy.RUNTIME)
43 | public @interface Table {
44 | /**
45 | * 表名
46 | */
47 | String tableName();
48 | /**
49 | * 描述
50 | */
51 | String comment();
52 | /**
53 | * 是否自建
54 | * 默认是自建,但是,需要全局打开jdbc.auto_create_table参数,才会生效
55 | * 如果改成false,那么就算全局打开了jdbc.auto_create_table参数,也不会自建此表
56 | */
57 | boolean autoCreate() default true;
58 |
59 | String dataSource() default "";
60 | }
61 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Tns.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 事务注解
33 | * @author CaiDongyu on 2016/4/18.
34 | */
35 | //TODO:目前只支持 method ,要与service注解配合使用,将来改成支持 类全切的,支持多数据源的
36 | @Target({ElementType.METHOD})
37 | @Retention(RetentionPolicy.RUNTIME)
38 | public @interface Tns {
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/annotation/persistence/Unique.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.annotation.persistence;
25 |
26 | import java.lang.annotation.ElementType;
27 | import java.lang.annotation.Retention;
28 | import java.lang.annotation.RetentionPolicy;
29 | import java.lang.annotation.Target;
30 |
31 | /**
32 | * 唯一键指定 unique key
33 | * 多个唯一键字段,都加注这个注解即可
34 | * 注意!:此注解不会对sql层执行有任何影响,具体唯一约束任然要靠数据库自身判断
35 | * 这个注解目前只是提供给CreateTableUtil生成建表sql时候使用
36 | */
37 | @Target(ElementType.FIELD)
38 | @Retention(RetentionPolicy.RUNTIME)
39 | public @interface Unique {
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/Data.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | /**
27 | * 数据对象
28 | * handler
29 | * @author CaiDongyu on 2016/4/11.
30 | */
31 | public final class Data {
32 | /**
33 | * 模型数据
34 | */
35 | private Object model;
36 |
37 | public Data(Object model){
38 | this.model = model;
39 | }
40 |
41 | public Object getModel() {
42 | return model;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/ExceptionHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | /**
27 | * 异常的包装、持有类,普通对象,只是用来set get异常
28 | */
29 | public final class ExceptionHolder {
30 |
31 | private Exception exception;
32 |
33 | public Exception getException() {
34 | return exception;
35 | }
36 |
37 | public void setException(Exception exception) {
38 | this.exception = exception;
39 | }
40 |
41 | public void clean(){
42 | setException(null);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/FileParam.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | import java.io.InputStream;
27 |
28 | /**
29 | * 文件上传
30 | * @author CaiDongyu on 2016/4/25.
31 | */
32 | public final class FileParam {
33 | private String fieldName;//文件上传表单的字段名
34 | private String fileName;
35 | private long fileSize;
36 | private String contentType;
37 | private InputStream inputStream;
38 |
39 | public FileParam(String fieldName, String fileName, long fileSize, String contentType, InputStream inputStream) {
40 | this.fieldName = fieldName;
41 | this.fileName = fileName;
42 | this.fileSize = fileSize;
43 | this.contentType = contentType;
44 | this.inputStream = inputStream;
45 | }
46 |
47 | public String getFieldName() {
48 | return fieldName;
49 | }
50 |
51 | public String getFileName() {
52 | return fileName;
53 | }
54 |
55 | public long getFileSize() {
56 | return fileSize;
57 | }
58 |
59 | public String getContentType() {
60 | return contentType;
61 | }
62 |
63 | public InputStream getInputStream() {
64 | return inputStream;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/FormParam.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | /**
27 | * 表单参数
28 | * @author CaiDongyu on 2016/4/25.
29 | */
30 | public final class FormParam {
31 | private String fieldName;
32 | private String fieldValue;
33 |
34 | public FormParam(String fieldName, String fieldValue) {
35 | this.fieldName = fieldName;
36 | this.fieldValue = fieldValue;
37 | }
38 |
39 | public String getFieldName() {
40 | return fieldName;
41 | }
42 |
43 | public String getFieldValue() {
44 | return fieldValue;
45 | }
46 |
47 | public void setFieldName(String fieldName) {
48 | this.fieldName = fieldName;
49 | }
50 |
51 | public void setFieldValue(String fieldValue) {
52 | this.fieldValue = fieldValue;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/Header.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | /**
27 | * 描述请求头字段
28 | * @author CaiDongyu on 2018/4/28.
29 | */
30 | public final class Header {
31 |
32 | private String name;
33 |
34 | private String value;
35 |
36 | public Header(String name) {
37 | setName(name);
38 | }
39 |
40 | public Header(String name,String value) {
41 | setName(name);
42 | setValue(value);
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | public String getValue() {
54 | return value;
55 | }
56 |
57 | public void setValue(String value) {
58 | this.value = value;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/ResultHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | /**
27 | * 返回结果的包装、持有类,普通对象,只是用来set get返回结果
28 | */
29 | public final class ResultHolder {
30 |
31 | private Object result;
32 |
33 | public Object getResult() {
34 | return result;
35 | }
36 |
37 | public void setResult(Object result) {
38 | this.result = result;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/mvc/View.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.mvc;
25 |
26 | import java.util.HashMap;
27 | import java.util.Map;
28 |
29 | /**
30 | * Handler处理结果,返回如果是jsp
31 | * @author CaiDongyu on 2016/4/11.
32 | */
33 | public final class View {
34 | /**
35 | * 视图路径
36 | */
37 | private String path;
38 |
39 | //默认redirect
40 | private boolean redirect = true;
41 |
42 | //默认是uri,认为是相对地址
43 | private boolean uri = true;
44 |
45 | /**
46 | * 模型数据
47 | */
48 | private Map model;
49 |
50 | public View(String path){
51 | this.path = path;
52 | model = new HashMap<>();
53 | }
54 |
55 | public View addModel(String key,Object value){
56 | model.put(key,value);
57 | return this;
58 | }
59 |
60 | public String getPath() {
61 | return path;
62 | }
63 |
64 | public Map getModel() {
65 | return model;
66 | }
67 |
68 | public View dispatcher(){
69 | redirect = false;
70 | return this;
71 | }
72 |
73 | public boolean isRedirect() {
74 | return redirect;
75 | }
76 |
77 | public View asUrl(){
78 | uri = false;
79 | return this;
80 | }
81 |
82 | public boolean isUri(){
83 | return uri;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/EntityFieldMethod.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.persistence;
25 |
26 | import java.lang.reflect.Field;
27 | import java.lang.reflect.Method;
28 |
29 | /**
30 | * 封装 Dao Entity类的字段和Get Set方法
31 | * @author CaiDongyu on 2016/5/5.
32 | */
33 | public final class EntityFieldMethod {
34 | private Field field;
35 | private Method method;
36 | public EntityFieldMethod(Field field, Method method) {
37 | this.field = field;
38 | this.method = method;
39 | }
40 | public Field getField() {
41 | return field;
42 | }
43 | public Method getMethod() {
44 | return method;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/InsertResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.persistence;
25 |
26 | /**
27 | * Insert操作结果的包装
28 | * 因为Insert可能需要返回自增主键
29 | * 所以包装一下条目和自增主键
30 | * @author CaiDongyu on 2016年5月16日 上午9:52:22.
31 | */
32 | public final class InsertResult {
33 |
34 | private int effectedRows;
35 | private Object generatedKey;
36 |
37 | public InsertResult(int effectedRows, Object generatedKey) {
38 | super();
39 | this.effectedRows = effectedRows;
40 | this.generatedKey = generatedKey;
41 | }
42 |
43 | public int getEffectedRows() {
44 | return effectedRows;
45 | }
46 |
47 | public Object getGeneratedKey() {
48 | return generatedKey;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/Page.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.persistence;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * Dao BaseRepostory 分页参数包
30 | * @author CaiDongyu on 2016年5月9日 下午1:54:11.
31 | */
32 | public final class Page {
33 | /**
34 | * 记录
35 | */
36 | private List records;
37 |
38 | /**
39 | * 分页配置
40 | */
41 | private PageConfig pageConfig;
42 |
43 | /**
44 | * 全部页加起来的总条数
45 | */
46 | private long count;
47 |
48 | /**
49 | * 页数
50 | */
51 | private long pages;
52 |
53 | public Page(List records, PageConfig pageConfig, long count, long pages) {
54 | this.records = records;
55 | this.pageConfig = pageConfig;
56 | this.count = count;
57 | this.pages = pages;
58 | }
59 |
60 | public List getRecords() {
61 | return records;
62 | }
63 |
64 | public PageConfig getPageConfig() {
65 | return pageConfig;
66 | }
67 |
68 | public long getCount() {
69 | return count;
70 | }
71 |
72 | public long getPages() {
73 | return pages;
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/PageConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.persistence;
25 |
26 | /**
27 | * Dao 分页配置
28 | * pageConfig必须放在@Sql注解的Dao方法的最后一个参数位置
29 | * @author CaiDongyu on 2016年5月9日 下午2:00:00.
30 | */
31 | public final class PageConfig {
32 |
33 | /**
34 | * 当前页码
35 | */
36 | private long pageNum;
37 | /**
38 | * 每页大小
39 | */
40 | private long pageSize;
41 | /**
42 | * 起始行
43 | */
44 | private long limitParam1;
45 | /**
46 | * 查询条数
47 | */
48 | private long limitParam2;
49 |
50 |
51 | public PageConfig(long pageNum, long pageSize) {
52 | this.pageNum = pageNum;
53 | this.pageSize = pageSize;
54 | init();
55 | }
56 |
57 | private void init(){
58 | this.pageNum = this.pageNum < 1 ? 1:this.pageNum;
59 | this.pageSize = this.pageSize < 1 ? 1:this.pageSize;
60 | this.limitParam1 = (this.pageNum-1)*this.pageSize;
61 | this.limitParam2 = this.pageSize;
62 | }
63 |
64 | public long getPageNum() {
65 | return pageNum;
66 | }
67 |
68 | public long getPageSize() {
69 | return pageSize;
70 | }
71 |
72 | public long getLimitParam1() {
73 | return limitParam1;
74 | }
75 |
76 | public long getLimitParam2() {
77 | return limitParam2;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/ShardingTableCreateTask.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.persistence;
25 |
26 | /**
27 | * 分片表的新增分片任务
28 | */
29 | public final class ShardingTableCreateTask {
30 | /*public static void main(String[] args) {
31 | Set set = new HashSet<>();
32 | ShardingTableCreateTask task1 = new ShardingTableCreateTask();
33 | task1.setTableName("abc");
34 | task1.setShardingFlag(1);
35 | ShardingTableCreateTask task2 = new ShardingTableCreateTask();
36 | task2.setTableName("abc");
37 | task2.setShardingFlag(2);
38 | set.add(task1);
39 | set.add(task2);
40 | for(ShardingTableCreateTask t:set){
41 | LogUtil.log(t.getTableName());
42 | LogUtil.log(t.getShardingFlag());
43 | }
44 | }*/
45 |
46 | private String dataSourceName;
47 |
48 | //表名,原始表名,不带分片b标识
49 | private String tableName;
50 |
51 | //分片标识
52 | private int shardingFlag;
53 |
54 | //建表语句
55 | private String[] createDataTableSqlAry;
56 |
57 | //gt表更新语句
58 | private String updateGtTableRecordSql;
59 |
60 | public String getDataSourceName() {
61 | return dataSourceName;
62 | }
63 |
64 | public void setDataSourceName(String dataSourceName) {
65 | this.dataSourceName = dataSourceName;
66 | }
67 |
68 | public String getTableName() {
69 | return tableName;
70 | }
71 |
72 | public void setTableName(String tableName) {
73 | this.tableName = tableName;
74 | }
75 |
76 | public int getShardingFlag() {
77 | return shardingFlag;
78 | }
79 |
80 | public void setShardingFlag(int shardingFlag) {
81 | this.shardingFlag = shardingFlag;
82 | }
83 |
84 | public String[] getCreateDataTableSqlAry() {
85 | return createDataTableSqlAry;
86 | }
87 |
88 | public void setCreateDataTableSqlAry(String[] createDataTableSqlAry) {
89 | this.createDataTableSqlAry = createDataTableSqlAry;
90 | }
91 |
92 | public String getUpdateGtTableRecordSql() {
93 | return updateGtTableRecordSql;
94 | }
95 |
96 | public void setUpdateGtTableRecordSql(String updateGtTableRecordSql) {
97 | this.updateGtTableRecordSql = updateGtTableRecordSql;
98 | }
99 |
100 | @Override
101 | public boolean equals(Object otherObj) {
102 | if(otherObj instanceof ShardingTableCreateTask){
103 | ShardingTableCreateTask other = (ShardingTableCreateTask)otherObj;
104 | return other.getTableName().equals(this.tableName);
105 | }else{
106 | return false;
107 | }
108 | }
109 |
110 | @Override
111 | public int hashCode() {
112 | return this.tableName.hashCode();
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/SqlExecutor.java:
--------------------------------------------------------------------------------
1 | package org.axe.bean.persistence;
2 |
3 | import java.sql.PreparedStatement;
4 | import java.sql.ResultSet;
5 | import java.sql.SQLException;
6 |
7 | import org.axe.util.sql.CommonSqlUtil;
8 |
9 | /**
10 | * Sql 执行类,包装了PrepareStatement
11 | * @author CaiDongyu on 2019/2/13.
12 | */
13 | public final class SqlExecutor {
14 |
15 | private String dataSourceName;
16 | private SqlPackage sp;
17 | private PreparedStatement ps;
18 |
19 | public SqlExecutor(String dataSourceName,SqlPackage sp,PreparedStatement ps) {
20 | this.dataSourceName = dataSourceName;
21 | this.sp = sp;
22 | this.ps = ps;
23 | }
24 |
25 | /**
26 | * 准备执行 PreparedStatement
27 | */
28 | public PreparedStatement readyExecuteStatement() {
29 | //调试打印sql
30 | CommonSqlUtil.debugSql(dataSourceName,sp);
31 | return ps;
32 | }
33 |
34 | public Object getGeneratedKeys() throws SQLException{
35 | Object generatedKey = null;
36 | ResultSet rs = ps.getGeneratedKeys();
37 | if(rs.next()){
38 | generatedKey = rs.getObject(1);
39 | }
40 | rs.close();
41 | return generatedKey;
42 | }
43 |
44 | public void close() throws SQLException{
45 | ps.close();
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/bean/persistence/SqlPackage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.bean.persistence;
25 |
26 | /**
27 | * Sql 执行需要的 元素包
28 | * @author CaiDongyu on 2016/5/6.
29 | */
30 | public final class SqlPackage {
31 | /**
32 | * sql语句
33 | */
34 | private String sql;
35 | /**
36 | * 方法参数
37 | */
38 | private Object[] params;
39 | /**
40 | * 参数类型
41 | */
42 | private Class>[] paramTypes;
43 | /**
44 | * 语句中?占位符的模式
45 | */
46 | private boolean[] getFlagModeAry;
47 |
48 | public SqlPackage(String sql, Object[] params, Class>[] paramTypes) {
49 | super();
50 | this.sql = sql;
51 | this.params = params;
52 | this.paramTypes = paramTypes;
53 | }
54 |
55 | public SqlPackage(String sql, Object[] params, Class>[] paramTypes, boolean[] getFlagModeAry) {
56 | super();
57 | this.sql = sql;
58 | this.params = params;
59 | this.paramTypes = paramTypes;
60 | this.getFlagModeAry = getFlagModeAry;
61 | }
62 |
63 | public String getSql() {
64 | return sql;
65 | }
66 |
67 | public Object[] getParams() {
68 | return params;
69 | }
70 |
71 | public Class>[] getParamTypes() {
72 | return paramTypes;
73 | }
74 |
75 | public boolean[] getGetFlagModeAry() {
76 | return getFlagModeAry;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/constant/CharacterEncoding.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.constant;
25 |
26 | /**
27 | * Http 字符 编码
28 | * @author CaiDongyu on 2016年5月10日 上午8:27:31.
29 | */
30 | public enum CharacterEncoding {
31 |
32 | UTF_8("UTF-8");
33 |
34 | public String CHARACTER_ENCODING;
35 |
36 | private CharacterEncoding(String cHARACTER_ENCODING) {
37 | CHARACTER_ENCODING = cHARACTER_ENCODING;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/constant/ConfigConstant.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.constant;
25 |
26 | /**
27 | * 框架配置的相关常量
28 | * @author CaiDongyu on 2016/4/8.
29 | */
30 | public final class ConfigConstant {
31 | //#axe配置文件名称
32 | public static final String CONFIG_FILE = "axe.properties";
33 |
34 | //#系统参数配置
35 | public static final String AXE_HOME = "axe.home";
36 | public static final String AXE_EMAIL_NOTIFICATION = "axe.email_notification";//是否打开axe邮箱通知,如果打开,下面的配置才生效
37 | public static final String AXE_EMAIL_SERVER_HOST = "axe.email_server_host";//邮箱host地址
38 | public static final String AXE_EMAIL_SERVER_PORT = "axe.email_server_port";//邮箱host端口
39 | public static final String AXE_EMAIL_SERVER_USER_NAME = "axe.email_server_user_name";//邮箱host的用户名,就是邮箱地址
40 | public static final String AXE_EMAIL_SERVER_PASSWORD = "axe.email_server_password";//邮箱host的密码
41 | public static final String AXE_EMAIL_TITLE = "axe.email_title";//邮件的抬头,除了配置文件里以外,也可以在代码里运行时再修改
42 | public static final String AXE_EMAIL_ERROR_ADDRESSEE = "axe.email_error_addressee";//系统异常的默认邮件接受地址,多个地址可以用英文逗号分隔
43 |
44 | //#持久层配置
45 | public static final String JDBC_DRIVER = "jdbc.driver";
46 | public static final String JDBC_URL = "jdbc.url";
47 | public static final String JDBC_USERNAME = "jdbc.username";
48 | public static final String JDBC_PASSWORD = "jdbc.password";
49 | public static final String JDBC_DATASOURCE = "jdbc.datasource";
50 | public static final String JDBC_CONNECTION_POOL_SIZE = "jdbc.connection_pool_size";
51 | //这个部分是jdbc配置的子项,需要JDBC_DATASOURCE+dataSourceName+以下名称配置{
52 | public static final String JDBC_AUTO_CREATE_TABLE = "auto_create_table";
53 | public static final String JDBC_SHOW_SQL = "show_sql";
54 | public static final String JDBC_CHARACTER = "character";
55 | public static final String JDBC_COLLATE = "collate";
56 | //}
57 |
58 | //#项目基本配置
59 | public static final String APP_BASE_PACKAGE = "app.base_package";
60 | public static final String APP_JSP_PATH = "app.jsp_path";
61 | public static final String APP_ASSET_PATH = "app.asset_path";
62 | public static final String APP_UPLOAD_LIMIT = "app.upload_limit";
63 | }
64 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/constant/ContentType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.constant;
25 |
26 | /**
27 | * Http Content Type类型
28 | * @author CaiDongyu on 2016年5月10日 上午8:29:06.
29 | */
30 | public enum ContentType {
31 |
32 | APPLICATION_JSON("application/json"),
33 | APPLICATION_HTML("text/html; charset=utf-8"),
34 | APPLICATION_TXT("text/plain; charset=utf-8"),
35 | APPLICATION_XML("text/xml; charset=utf-8"),
36 | APPLICATION_CSS("text/css"),
37 | APPLICATION_JS("application/x-javascript"),
38 | IMAGE_ICON("image/x-icon"),
39 | IMAGE_JPEG("image/jpeg"),
40 | IMAGE_PNG("image/png"),
41 | IMAGE_GIF("image/gif"),
42 | FONT_WOFF2("font/woff2"),
43 | FONT_WOFF("font/woff"),
44 | FONT_TTF("font/ttf"),
45 | FONT_SVG("text/xml"),
46 | FONT_EOT("font/eot"),
47 | VIDEO_MPEG4("video/mpeg4"),
48 | ZIP_FILE("application/zip");
49 |
50 | public String CONTENT_TYPE;
51 |
52 | private ContentType(String CONTENT_TYPE) {
53 | this.CONTENT_TYPE = CONTENT_TYPE;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/constant/IdGenerateWay.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.constant;
25 |
26 | /**
27 | * 表主键的生成方式
28 | */
29 | public enum IdGenerateWay {
30 | NONE,
31 | AUTO_INCREMENT;
32 | }
33 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/constant/RequestContent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.constant;
25 |
26 | import java.util.HashMap;
27 | import java.util.Map;
28 |
29 | /**
30 | * 请求处理的上下文对象
31 | * 生命周期在一次请求
32 | * 这个上下文,是线程安全的
33 | * 即便多次请求出现线程被复用,也不会有问题
34 | * @author CaiDongyu 2020/3/21
35 | */
36 | public final class RequestContent {
37 | private static ThreadLocal> CONTENT = new ThreadLocal<>();
38 |
39 | public synchronized static void setParam(String name,Object value){
40 | Map map = CONTENT.get();
41 | if(map == null){
42 | map = new HashMap<>();
43 | }
44 | map.put(name, value);
45 | CONTENT.set(map);
46 | }
47 |
48 | @SuppressWarnings("unchecked")
49 | public synchronized static T getParam(String name){
50 | Map map = CONTENT.get();
51 | if(map == null){
52 | return null;
53 | }
54 | return (T)map.get(name);
55 | }
56 |
57 | public synchronized static void clean(){
58 | CONTENT.remove();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/constant/RequestMethod.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.constant;
25 |
26 |
27 | /**
28 | * 请求类型注解
29 | * @author CaiDongyu on 2016/4/8.
30 | */
31 | public enum RequestMethod {
32 | POST("POST"),
33 | DELETE("DELETE"),
34 | PUT("PUT"),
35 | GET("GET");
36 |
37 | public String REQUEST_METHOD;
38 |
39 | private RequestMethod(String method) {
40 | this.REQUEST_METHOD = method;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/exception/RedirectorInterrupt.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.exception;
25 |
26 | import org.axe.bean.mvc.View;
27 |
28 | /**
29 | * 提供异中断转服务
30 | * 特别在Filter和Interceptor中,因为只能返回true或false,所以借助此类,可以请求中断跳转
31 | * @author CaiDongyu on 2016年6月1日 下午1:59:03.
32 | */
33 | public final class RedirectorInterrupt extends RuntimeException {
34 | private static final long serialVersionUID = 1L;
35 |
36 | private View view;
37 |
38 | public RedirectorInterrupt(View view) {
39 | this.view = view;
40 | }
41 |
42 | public View getView() {
43 | return view;
44 | }
45 |
46 | public void setView(View view) {
47 | this.view = view;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/abc_thread/README.txt:
--------------------------------------------------------------------------------
1 | 移植来自smart_thread项目
2 | 这是一个多线程下任务串行执行的包
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/abc_thread/SerialExecutor.java:
--------------------------------------------------------------------------------
1 | package org.axe.extra.abc_thread;
2 |
3 | import java.util.LinkedList;
4 | import java.util.Queue;
5 |
6 | /**
7 | * 串行执行器
8 | * 这是基于线程的,每个串行执行器,拥有自己的的待处理任务包队列
9 | * 队列中的任务包,拥有自己的业务及数据,他们顺序固定,必须串行执行
10 | * 任务包的业务不一定要相同
11 | */
12 | public final class SerialExecutor extends Thread{
13 |
14 | //任务包队列
15 | private Queue taskPackQueue = new LinkedList<>();
16 |
17 | public int getQueueSize(){
18 | synchronized (taskPackQueue) {
19 | return taskPackQueue.size();
20 | }
21 | }
22 |
23 | /**
24 | * 往串行执行器里添加一个任务包,等待执行
25 | */
26 | public void addTaskPack(TaskPack taskPack){
27 | synchronized (taskPackQueue) {
28 | taskPackQueue.add(taskPack);
29 | }
30 | }
31 |
32 | @Override
33 | public void run() {
34 | //执行器核心
35 | //从队列获取并执行任务包
36 | while(true){
37 | TaskPack taskPack = null;
38 | synchronized (taskPackQueue) {
39 | taskPack = taskPackQueue.poll();
40 | }
41 | if(taskPack != null){
42 | try {
43 | boolean needAgain = taskPack.task(this);
44 | if(needAgain){
45 | addTaskPack(taskPack);
46 | }
47 | } catch (Throwable e) {
48 | //任何运行时错误都吃掉
49 | }
50 | }
51 | try {
52 | Thread.sleep(10);//TODO 这个休眠可以去掉
53 | } catch (Exception e) {}
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/abc_thread/SerialExecutorPool.java:
--------------------------------------------------------------------------------
1 | package org.axe.extra.abc_thread;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import org.axe.annotation.ioc.Component;
7 |
8 | /**
9 | * 根据名称匹配的串行执行器池
10 | * 系统启动后,就会初始化一批串行执行器,放入到池子
11 | * 需要串行执行的请求,会从池子里取空闲的执行器
12 | */
13 | @Component
14 | public final class SerialExecutorPool {
15 | //默认的池大小是10个SerialExecutor
16 | //要修改可以在系统启动的时候,通过Listener来设置此值
17 | private int maxSize = 10;
18 |
19 | public int getMaxSize() {
20 | return maxSize;
21 | }
22 |
23 | public void setMaxSize(int maxSize) {
24 | this.maxSize = maxSize;
25 | }
26 |
27 | private Map pool = new HashMap<>();
28 |
29 | //线程安全
30 | public int getPoolSize(){
31 | synchronized (pool) {
32 | return pool.size();
33 | }
34 | }
35 |
36 | //获取一个串行执行器
37 | //此方法非线程安全,必须只能单一线程使用
38 | SerialExecutor getOne(String name){
39 | //线程执行器的名字,是可以改的
40 | SerialExecutor one = pool.get(name);
41 | if(one == null){
42 | //如果池子里没有要的执行器,则查看池子现在是否已满
43 | if(pool.size() < maxSize){
44 | //没有满就可以新弄个执行器
45 | one = new SerialExecutor();
46 | one.setName(name);
47 | pool.put(name, one);
48 | one.start();
49 | }else{
50 | //如果满了,就查看一遍,是否有任务包队列已经是空了的执行器
51 | //如果有,则改名此执行器,用于此任务包的执行
52 | for(SerialExecutor executor:pool.values()){
53 | if(executor.getQueueSize() == 0){
54 | pool.remove(executor.getName());
55 | executor.setName(name);
56 | pool.put(name, executor);
57 | one = executor;
58 | break;
59 | }
60 | }
61 | }
62 | }
63 | return one;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/abc_thread/TaskPack.java:
--------------------------------------------------------------------------------
1 | package org.axe.extra.abc_thread;
2 |
3 | /**
4 | * 任务包
5 | * 把http的一次请求,想象成发起者要服务者做一个事情,给了服务者一个叫做“任务包”的东西
6 | * 任务包有自己的业务以及携带的数据
7 | */
8 | public abstract class TaskPack {
9 | //与executor的name对应
10 | private String name;
11 |
12 | public TaskPack(String name) {
13 | this.name = name;
14 | }
15 |
16 | public String getName() {
17 | return name;
18 | }
19 |
20 | public void setName(String name) {
21 | this.name = name;
22 | }
23 |
24 | public abstract boolean task(SerialExecutor executor);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/abc_thread/TaskPackBusController.java:
--------------------------------------------------------------------------------
1 | package org.axe.extra.abc_thread;
2 |
3 | import java.util.LinkedList;
4 | import java.util.Queue;
5 |
6 | import org.axe.annotation.ioc.Autowired;
7 | import org.axe.annotation.ioc.Component;
8 | import org.axe.util.LogUtil;
9 |
10 | /**
11 | * 任务包总线
12 | * 所有的请求,都会先封装成任务包,进入任务包总线
13 | * 等待总线调度器,自动协商任务包与串行执行器池的协作
14 | * 如果当前池子繁忙(没有可用于此任务包的执行器)
15 | * 则此任务包会被插入到总线末端,等待下次询问
16 | *
17 | */
18 | @Component
19 | public final class TaskPackBusController extends Thread{
20 |
21 | //任务包总线
22 | private Queue taskPackBus = new LinkedList<>();
23 |
24 | public Boolean started = false;
25 |
26 | @Override
27 | public synchronized void start() {
28 | synchronized (started) {
29 | if(!started){
30 | started = true;
31 | //总线调度启动
32 | super.start();
33 | }
34 | }
35 | }
36 |
37 | public TaskPackBusController() {
38 | setName("TaskPackBusController");
39 | }
40 |
41 | @Autowired
42 | private SerialExecutorPool serialExecutorPool;
43 |
44 | public void addTaskPack(TaskPack taskPack) {
45 | synchronized (taskPackBus) {
46 | taskPackBus.add(taskPack);
47 | }
48 | }
49 |
50 | @Override
51 | public void run() {
52 | while(true){
53 | TaskPack pack = null;
54 | synchronized (taskPackBus) {
55 | pack = taskPackBus.poll();
56 | }
57 | if(pack != null){
58 | SerialExecutor one = serialExecutorPool.getOne(pack.getName());
59 | if(one == null){
60 | //如果没取到执行器,说明池子现在繁忙,那就排到队尾等待
61 | try {
62 | //要先更改包状态,否则加不进去
63 | addTaskPack(pack);
64 | } catch (Exception e) {
65 | LogUtil.error(e);
66 | }
67 | }else{
68 | //否则,就交给执行器去等待串行执行了
69 | one.addTaskPack(pack);
70 | }
71 | }
72 | try {
73 | Thread.sleep(10);//TODO 可以去掉休眠
74 | } catch (Exception e) {}
75 | }
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/timer/TimerTask.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.extra.timer;
25 |
26 | import org.axe.extra.abc_thread.SerialExecutor;
27 | import org.axe.extra.abc_thread.TaskPack;
28 |
29 | /**
30 | * 定时器接口
31 | *
32 | * @author CaiDongYu on 2020/12/7.
33 | */
34 | public abstract class TimerTask extends TaskPack {
35 | // 最后一次执行时间
36 | private long lastExecuteTime = 0;
37 |
38 | public TimerTask() {
39 | super(null);
40 | setName(name());
41 | }
42 |
43 | private TimerTask(String name) {
44 | super(name);
45 | }
46 |
47 | @Override
48 | public boolean task(SerialExecutor executor) {
49 | if (!doOnceAfterStartup() && lastExecuteTime == 0) {
50 | lastExecuteTime = System.currentTimeMillis();
51 | }
52 | long currentTime = System.currentTimeMillis();
53 | if (currentTime - lastExecuteTime > timeSec() * 1000) {
54 | lastExecuteTime = currentTime;
55 | try {
56 | doSomething();
57 | } catch (Exception e) {
58 | }
59 | }
60 | return true;// 因为是定时任务,所以会循环执行
61 | }
62 |
63 | /**
64 | * 定时器名称
65 | */
66 | public abstract String name();
67 |
68 | /**
69 | * 定时秒数
70 | */
71 | public abstract int timeSec();
72 |
73 | /**
74 | * 如果可以执行,那就做点什么
75 | */
76 | public abstract void doSomething();
77 |
78 | /**
79 | * 是否需要启动后立即执行1次
80 | */
81 | public boolean doOnceAfterStartup() {
82 | return false;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/extra/timer/TimerTaskHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.extra.timer;
25 |
26 | import java.lang.reflect.Modifier;
27 | import java.util.HashMap;
28 | import java.util.Map;
29 | import java.util.Set;
30 |
31 | import org.axe.extra.abc_thread.TaskPackBusController;
32 | import org.axe.helper.ioc.BeanHelper;
33 | import org.axe.helper.ioc.ClassHelper;
34 | import org.axe.interface_.base.Helper;
35 | import org.axe.util.CollectionUtil;
36 | import org.axe.util.ReflectionUtil;
37 |
38 | /**
39 | * Timer 助手 ,类似BeanHelper管理加载所有bean一样,这里是托管Timer
40 | * 之所以和BeanHelper分开,因为BeanHelper托管了Controller和Service Timer不应该放一起 Created by
41 | * CaiDongYu on 2020/4/7.
42 | */
43 | public final class TimerTaskHelper implements Helper {
44 | private static final Map TIMER_TASK_MAP = new HashMap<>();
45 |
46 | @Override
47 | public void init() throws Exception{
48 | synchronized (this) {
49 | Set> timerClassSet = ClassHelper.getClassSetBySuper(TimerTask.class);
50 | if (CollectionUtil.isNotEmpty(timerClassSet)) {
51 | for (Class> timerClass : timerClassSet) {
52 | boolean isAbstract = Modifier.isAbstract(timerClass.getModifiers());
53 | if(isAbstract) continue;
54 |
55 | TimerTask timer = ReflectionUtil.newInstance(timerClass);
56 |
57 | if(TIMER_TASK_MAP.containsKey(timer.name())){
58 | throw new Exception("find the same timer name:"+timer.name()+" class:"+timer.getClass()+" === "+TIMER_TASK_MAP.get(timer.name()).getClass());
59 | }
60 | TIMER_TASK_MAP.put(timer.name(), timer);
61 | BeanHelper.setBean(timerClass, timer);
62 | }
63 | }
64 | }
65 | }
66 |
67 | public static Map getTimerTaskMap() {
68 | return TIMER_TASK_MAP;
69 | }
70 |
71 | @Override
72 | public void onStartUp() throws Exception {
73 | //系统启动完成后,开始定时任务
74 | if(CollectionUtil.isNotEmpty(TIMER_TASK_MAP)){
75 | TaskPackBusController tpBusController = BeanHelper.getBean(TaskPackBusController.class);
76 | tpBusController.start();
77 |
78 | for(TimerTask tt:TIMER_TASK_MAP.values()){
79 | tpBusController.addTaskPack(tt);
80 | }
81 | }
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/base/FrameworkStatusHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.base;
25 |
26 | import java.util.Date;
27 |
28 | import org.axe.interface_.base.Helper;
29 |
30 | /**
31 | * 框架自身状态 助手类
32 | * @author CaiDongyu on 2016年5月20日 上午8:43:39.
33 | */
34 | public final class FrameworkStatusHelper implements Helper{
35 |
36 | /**
37 | * 框架启动时间
38 | */
39 | private static Date STARTUP_TIME;
40 |
41 | @Override
42 | public void init() throws Exception{
43 | synchronized (this) {
44 | STARTUP_TIME = new Date();
45 | }
46 | }
47 |
48 | public static Date getStartupTime() {
49 | return STARTUP_TIME;
50 | }
51 |
52 | @Override
53 | public void onStartUp() throws Exception {}
54 | }
55 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/base/MailHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.base;
25 |
26 | import java.io.ByteArrayOutputStream;
27 | import java.io.PrintStream;
28 |
29 | import org.axe.interface_.base.Helper;
30 | import org.axe.util.IpUtil;
31 | import org.axe.util.LogUtil;
32 | import org.axe.util.mail.MailSenderInfo;
33 | import org.axe.util.mail.SimpleMailSender;
34 |
35 | /**
36 | * 邮件 助手类
37 | * 目前只发送两种邮件
38 | * 1.异常邮件
39 | * 2.密码找回邮件
40 | * @author CaiDongyu on 2016年6月2日 上午11:11:40.
41 | */
42 | public final class MailHelper implements Helper{
43 |
44 | private static MailSenderInfo MAILINFO;
45 |
46 | public static MailSenderInfo getMAILINFO() {
47 | return MAILINFO;
48 | }
49 |
50 | @Override
51 | public void init() throws Exception{
52 | synchronized (this) {
53 | if(ConfigHelper.getAxeEmailNotification()){
54 | MAILINFO = new MailSenderInfo();
55 | MAILINFO.setMailServerHost(ConfigHelper.getAxeEmailServerHost());
56 | MAILINFO.setMailServerPort(ConfigHelper.getAxeEmailServerPort());
57 | MAILINFO.setValidate(true);
58 | MAILINFO.setUserName(ConfigHelper.getAxeEmailServerUserName());
59 | MAILINFO.setPassword(ConfigHelper.getAxeEmailServerPassword());
60 | MAILINFO.setFromAddress(ConfigHelper.getAxeEmailServerUserName());
61 | }
62 | }
63 | }
64 |
65 | public static void errorMail(Exception e){
66 | if(MAILINFO != null){
67 | ByteArrayOutputStream baos = null;
68 | try {
69 | baos = new ByteArrayOutputStream();
70 | e.printStackTrace(new PrintStream(baos));
71 | String exception = baos.toString();
72 | MAILINFO.setSubject(ConfigHelper.getAxeEmailTitle()+"系统异常提醒,IP:"+IpUtil.getLocalHostIpAddress());
73 | MAILINFO.setContent(exception);
74 | try {
75 | String[] toAddress = ConfigHelper.getAxeEmailErrorAddressee().split(",");
76 | SimpleMailSender.sendHtmlMail(MAILINFO,toAddress);
77 | } catch (Exception e1) {
78 | LogUtil.error(e1);
79 | }
80 | } catch (Exception e2) {} finally {
81 | try {
82 | if(baos != null){
83 | baos.close();
84 | }
85 | } catch (Exception e3) {}
86 | }
87 | }
88 | }
89 |
90 | public static boolean sendMail(String email,String title,String content){
91 | if(MAILINFO != null){
92 | MAILINFO.setSubject(title);
93 | MAILINFO.setContent(content);
94 | try {
95 | SimpleMailSender.sendHtmlMail(MAILINFO,email);
96 | return true;
97 | } catch (Exception e1) {
98 | LogUtil.error(e1);
99 | }
100 | }
101 | return false;
102 | }
103 |
104 | @Override
105 | public void onStartUp() throws Exception {}
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/ioc/BeanHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.ioc;
25 |
26 | import java.util.ArrayList;
27 | import java.util.HashMap;
28 | import java.util.List;
29 | import java.util.Map;
30 | import java.util.Set;
31 |
32 | import org.axe.interface_.base.Helper;
33 | import org.axe.interface_.mvc.AfterBeanInited;
34 | import org.axe.util.ReflectionUtil;
35 |
36 | /**
37 | * Bean 助手
38 | * ClassHelper 负责加载
39 | * ReflectionUtil 负责实例化
40 | * BeanHelper 负责托管所有Bean (Controller、Service)
41 | * BeanHelper 只是实例化,但是没有注入依赖,依赖注入靠IocHelper
42 | * @author CaiDongyu on 2016/4/9.
43 | */
44 | public final class BeanHelper implements Helper{
45 | /**
46 | * 定义 Bean 映射(用于存放 Bean 类与 Bean 实例的映射
47 | */
48 | private static Map,Object> BEAN_MAP;
49 |
50 | private static List AFTER_BEAN_INITED_LIST = new ArrayList<>();
51 |
52 | public static void addAfterBeanInitedCallback(AfterBeanInited callback){
53 | synchronized (AFTER_BEAN_INITED_LIST) {
54 | AFTER_BEAN_INITED_LIST.add(callback);
55 | }
56 | }
57 |
58 | @Override
59 | public void init() throws Exception{
60 | synchronized (this) {
61 | BEAN_MAP = new HashMap<>();
62 | Set> beanClassSet = ClassHelper.getBeanClassSet();
63 | for(Class> beanClass:beanClassSet){
64 | Object obj = ReflectionUtil.newInstance(beanClass);
65 | BEAN_MAP.put(beanClass, obj);
66 | }
67 | }
68 |
69 | //加载完配置后,执行
70 | for(AfterBeanInited acl:AFTER_BEAN_INITED_LIST){
71 | acl.doSomething(BEAN_MAP);
72 | }
73 | }
74 |
75 | /**
76 | * 获取 BEAN_MAP
77 | * 只是实例化,但是没有注入依赖
78 | */
79 | public static Map,Object> getBeanMap(){
80 | return BEAN_MAP;
81 | }
82 |
83 | /**
84 | * 获取 Bean 实例
85 | */
86 | @SuppressWarnings("unchecked")
87 | public static T getBean(Class cls){
88 | if(!BEAN_MAP.containsKey(cls)){
89 | throw new RuntimeException("can not get bean by class:"+cls);
90 | }
91 | return (T) BEAN_MAP.get(cls);
92 | }
93 |
94 | /**
95 | * 设置 Bean 实例
96 | */
97 | public static void setBean(Class> cls,Object obj){
98 | BEAN_MAP.put(cls, obj);
99 | }
100 |
101 | @Override
102 | public void onStartUp() throws Exception {}
103 | }
104 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/ioc/IocHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.ioc;
25 |
26 | import java.lang.reflect.Field;
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 | import org.axe.annotation.ioc.Autowired;
31 | import org.axe.interface_.base.Helper;
32 | import org.axe.util.CollectionUtil;
33 | import org.axe.util.ReflectionUtil;
34 |
35 | /**
36 | * 依赖注入 助手类
37 | * @author CaiDongyu on 2016/4/9.
38 | */
39 | public final class IocHelper implements Helper{
40 |
41 | @Override
42 | public void init() throws Exception{
43 | synchronized (this) {
44 | //获取所有 Bean 与 Bean 实例之间的映射 BEAN_MAP
45 | Map,Object> beanMap = BeanHelper.getBeanMap();
46 | if (CollectionUtil.isNotEmpty(beanMap)){
47 | //遍历 Bean Map
48 | for (Map.Entry,Object> beanEntry:beanMap.entrySet()){
49 | //从 BeanMap 中 获取 Bean 类与 Bean 实例
50 | Class> beanClass = beanEntry.getKey();
51 | Object beanInstance = beanEntry.getValue();
52 | //获取 Bean 类 定义的所有成员变量 ( Bean Field )
53 | List beanFieldList = ReflectionUtil.getDeclaredFieldsAll(beanClass);
54 | if (CollectionUtil.isNotEmpty(beanFieldList)){
55 | //遍历 bBean Field
56 | for (Field beanField:beanFieldList){
57 | if(beanField.isAnnotationPresent(Autowired.class)){
58 | //再 Bean Map 中获取 Bean Field 对应的实例
59 | Class> beanFieldClass = beanField.getType();
60 | Object beanFieldInstance = beanMap.get(beanFieldClass);
61 | //通过反射初始化 Bean Field 值
62 | ReflectionUtil.setField(beanInstance,beanField,beanFieldInstance);
63 | }
64 | }
65 | }
66 | }
67 | }
68 | }
69 | }
70 |
71 | @Override
72 | public void onStartUp() throws Exception {}
73 | }
74 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/mvc/FilterHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.mvc;
25 |
26 | import java.lang.reflect.Modifier;
27 | import java.util.ArrayList;
28 | import java.util.HashMap;
29 | import java.util.LinkedList;
30 | import java.util.List;
31 | import java.util.Map;
32 | import java.util.Set;
33 |
34 | import org.axe.bean.mvc.Handler;
35 | import org.axe.helper.ioc.ClassHelper;
36 | import org.axe.interface_.base.Helper;
37 | import org.axe.interface_.mvc.Filter;
38 | import org.axe.util.CollectionUtil;
39 | import org.axe.util.ReflectionUtil;
40 |
41 | /**
42 | * Filter 助手 ,类似BeanHelper管理加载所有bean一样,这里是托管Filter
43 | * 之所以和BeanHelper分开,因为BeanHelper托管了Controller和Service Filter不应该放一起 Created by
44 | * CaiDongYu on 2016/4/9.
45 | */
46 | public final class FilterHelper implements Helper {
47 | private static final List FILTER_LIST = new ArrayList<>();// 保证顺序
48 |
49 | private static final Map> ACTION_SIZE_MAP = new HashMap<>();
50 | public static Map> getActionSizeMap(){
51 | return ACTION_SIZE_MAP;
52 | }
53 |
54 | @Override
55 | public void init() throws Exception{
56 | synchronized (this) {
57 | Set> filterClassSet = ClassHelper.getClassSetBySuper(Filter.class);
58 | List filterSortedList = new LinkedList<>();
59 | if (CollectionUtil.isNotEmpty(filterClassSet)) {
60 | for (Class> filterClass : filterClassSet) {
61 | boolean isAbstract = Modifier.isAbstract(filterClass.getModifiers());
62 | if(isAbstract) continue;
63 |
64 | Filter filter = ReflectionUtil.newInstance(filterClass);
65 | filter.init();// 初始化Filter
66 |
67 | // 排序比较,按顺序插入到Filter链里
68 | if (CollectionUtil.isEmpty(filterSortedList)) {
69 | filterSortedList.add(filter);
70 | } else {
71 | int index = 0;
72 | for (Filter filter_ : filterSortedList) {
73 | if (filter.setLevel() < filter_.setLevel()) {
74 | filterSortedList.add(index, filter);
75 | break;
76 | }/* else if (filter.setLevel() == filter_.setLevel()){
77 | throw new Exception("find the same level "+filter.setLevel()+" Filter: "+filterClass+" === "+filter_.getClass());
78 | } */else {
79 | index++;
80 | }
81 | }
82 | if (index == filterSortedList.size()) {
83 | filterSortedList.add(filter);
84 | }
85 | }
86 |
87 | }
88 | FILTER_LIST.addAll(filterSortedList);
89 | }
90 | }
91 | }
92 |
93 | public static List getSortedFilterList() {
94 | return FILTER_LIST;
95 | }
96 |
97 | @Override
98 | public void onStartUp() throws Exception {}
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/mvc/InterceptorHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.mvc;
25 |
26 | import java.util.HashMap;
27 | import java.util.List;
28 | import java.util.Map;
29 | import java.util.Set;
30 |
31 | import org.axe.bean.mvc.Handler;
32 | import org.axe.helper.ioc.ClassHelper;
33 | import org.axe.interface_.base.Helper;
34 | import org.axe.interface_.mvc.Interceptor;
35 | import org.axe.util.CollectionUtil;
36 | import org.axe.util.ReflectionUtil;
37 |
38 | /**
39 | * 拦截器 助手类
40 | * @author CaiDongyu on 2016年5月30日 下午12:21:51.
41 | */
42 | public final class InterceptorHelper implements Helper{
43 |
44 | private static Map,Interceptor> INTERCEPTOR_MAP;//不保证顺序
45 |
46 | private static final Map> ACTION_SIZE_MAP = new HashMap<>();
47 | public static Map> getActionSizeMap(){
48 | return ACTION_SIZE_MAP;
49 | }
50 |
51 | @Override
52 | public void init() throws Exception{
53 | synchronized (this) {
54 | INTERCEPTOR_MAP = new HashMap<>();
55 | Set> interceptorClassSet = ClassHelper.getClassSetBySuper(Interceptor.class);
56 | if(CollectionUtil.isNotEmpty(interceptorClassSet)){
57 | for(Class> interceptorClass:interceptorClassSet){
58 | Interceptor interceptor = ReflectionUtil.newInstance(interceptorClass);
59 | interceptor.init();// 初始化Interceptor
60 | INTERCEPTOR_MAP.put(interceptor.getClass(), interceptor);
61 | }
62 | }
63 | }
64 | }
65 |
66 | public static Map, Interceptor> getInterceptorMap() {
67 | return INTERCEPTOR_MAP;
68 | }
69 |
70 | @Override
71 | public void onStartUp() throws Exception {}
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/helper/mvc/ListenerHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.helper.mvc;
25 |
26 | import java.util.LinkedList;
27 | import java.util.List;
28 | import java.util.Set;
29 |
30 | import org.axe.helper.ioc.BeanHelper;
31 | import org.axe.helper.ioc.ClassHelper;
32 | import org.axe.interface_.base.Helper;
33 | import org.axe.interface_.mvc.Listener;
34 | import org.axe.util.CollectionUtil;
35 | import org.axe.util.ReflectionUtil;
36 |
37 | /**
38 | * Listener 启动助手类
39 | * @author CaiDongyu on 2016年6月7日 下午1:35:37.
40 | */
41 | public final class ListenerHelper implements Helper{
42 |
43 | private static List LISTENER_LIST;
44 |
45 | @Override
46 | public void init() throws Exception {
47 | synchronized (this) {
48 | LISTENER_LIST = new LinkedList<>();
49 | Set> classSet = ClassHelper.getClassSetBySuper(Listener.class);
50 | if(CollectionUtil.isNotEmpty(classSet)){
51 | for(Class> listenerClass:classSet){
52 | Listener listener = ReflectionUtil.newInstance(listenerClass);
53 | BeanHelper.setBean(listenerClass, listener);
54 | if(LISTENER_LIST.size() == 0){
55 | LISTENER_LIST.add(listener);
56 | }else{
57 | int i=0;
58 | for(;i getListenerList() {
82 | return LISTENER_LIST;
83 | }
84 |
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/home/interceptor/HomeInterceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.home.interceptor;
25 |
26 | import javax.servlet.http.HttpServletRequest;
27 | import javax.servlet.http.HttpServletResponse;
28 |
29 | import org.axe.bean.mvc.ExceptionHolder;
30 | import org.axe.bean.mvc.Handler;
31 | import org.axe.bean.mvc.Param;
32 | import org.axe.bean.mvc.ResultHolder;
33 | import org.axe.helper.base.ConfigHelper;
34 | import org.axe.interface_.mvc.Interceptor;
35 |
36 | public final class HomeInterceptor implements Interceptor{
37 |
38 | private boolean AXE_HOME = false;
39 | @Override
40 | public void init() {
41 | AXE_HOME = ConfigHelper.getAxeHome();
42 | }
43 |
44 | @Override
45 | public boolean doInterceptor(HttpServletRequest request, HttpServletResponse response, Param param,
46 | Handler handler) {
47 | return AXE_HOME;
48 | }
49 |
50 | @Override
51 | public void doEnd(HttpServletRequest request, HttpServletResponse response, Param param, Handler handler,
52 | ResultHolder resultHolder, ExceptionHolder exceptionHolder) {}
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/base/Helper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.base;
25 |
26 | /**
27 | * Helper 助手类顶层接口,负责初始化
28 | * @author CaiDongyu on 2016年5月31日 下午4:56:19.
29 | */
30 | public interface Helper {
31 |
32 |
33 | public void init() throws Exception;
34 |
35 | public void onStartUp() throws Exception;
36 | }
37 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/AfterBeanInited.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.mvc;
25 |
26 | import java.util.Map;
27 |
28 | public interface AfterBeanInited {
29 |
30 | public void doSomething(Map,Object> BEAN_MAP);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/AfterClassLoaded.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2020 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.mvc;
25 |
26 | import java.util.Set;
27 |
28 | public interface AfterClassLoaded {
29 |
30 | public void doSomething(Set> classSet);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/AfterConfigLoaded.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.mvc;
25 |
26 | import java.util.Properties;
27 |
28 | public interface AfterConfigLoaded {
29 |
30 | public void doSomething(Properties config);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/Filter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.mvc;
25 |
26 | import javax.servlet.http.HttpServletRequest;
27 | import javax.servlet.http.HttpServletResponse;
28 |
29 | import org.axe.bean.mvc.ExceptionHolder;
30 | import org.axe.bean.mvc.Handler;
31 | import org.axe.bean.mvc.Param;
32 | import org.axe.bean.mvc.ResultHolder;
33 | import org.axe.exception.RestException;
34 |
35 |
36 | /**
37 | * 过滤器 接口
38 | * 提供Controller之前的请求过滤操作
39 | * 也可以结合 @FilterFuckOff 注解使用来屏蔽过滤器
40 | * @author CaiDongyu on 2016/4/9.
41 | */
42 | public interface Filter {
43 | /**
44 | * 初始化
45 | */
46 | public void init();
47 |
48 | /**
49 | * 层级 执行顺序从小到大
50 | */
51 | public int setLevel();
52 |
53 | /**
54 | * 匹配mappingPath方法的正则
55 | */
56 | // public Pattern setMapping();
57 |
58 | /**
59 | * 不需要匹配mappingPath方法的正则
60 | */
61 | // public Pattern setNotMapping();
62 |
63 | /**
64 | * 是否匹配此Request
65 | */
66 | /**
67 | * 匹配mappingPath方法的正则
68 | */
69 | public boolean mapping(String requestMethod, String mappingPath);
70 |
71 | /**
72 | * 执行过滤
73 | * @param request
74 | * @param response
75 | * @param param 请求参数
76 | * @param handler 请求action Handler
77 | */
78 | public boolean doFilter(HttpServletRequest request,HttpServletResponse response,Param param,Handler handler) throws RestException;
79 |
80 | /**
81 | * 执行收尾
82 | */
83 | public void doEnd(HttpServletRequest request,HttpServletResponse response,Param param,Handler handler,ResultHolder resultHolder,ExceptionHolder exceptionHolder);
84 | }
85 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/Interceptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.mvc;
25 |
26 | import javax.servlet.http.HttpServletRequest;
27 | import javax.servlet.http.HttpServletResponse;
28 |
29 | import org.axe.bean.mvc.ExceptionHolder;
30 | import org.axe.bean.mvc.Handler;
31 | import org.axe.bean.mvc.Param;
32 | import org.axe.bean.mvc.ResultHolder;
33 |
34 | /**
35 | * 拦截器
36 | * 针对的是方法
37 | * 多个拦截器之间不区分先后
38 | */
39 | public interface Interceptor {
40 |
41 | public void init();
42 |
43 | public boolean doInterceptor(HttpServletRequest request,HttpServletResponse response,Param param,Handler handler);
44 |
45 | /**
46 | * 执行收尾
47 | */
48 | public void doEnd(HttpServletRequest request,HttpServletResponse response,Param param,Handler handler,ResultHolder resultHolder,ExceptionHolder exceptionHolder);
49 | }
50 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/Listener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.mvc;
25 |
26 | /**
27 | * Listener 在框架启动的时候就会跟着初始化
28 | * @author CaiDongyu on 2016年6月7日 下午1:37:03.
29 | */
30 | public interface Listener {
31 |
32 | /**
33 | * 启动顺序
34 | */
35 | public int index();
36 |
37 | public void init() throws Exception;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/mvc/Timer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *//*
24 | package org.axe.interface_.mvc;
25 |
26 | *//**
27 | * 定时器接口
28 | * @author CaiDongYu on 2020/4/7.
29 | *//*
30 | public interface Timer {
31 |
32 | *//**
33 | * 定时器名称
34 | * @return
35 | *//*
36 | public String name();
37 |
38 | *//**
39 | * 现在是否可以执行了
40 | * @return
41 | *//*
42 | public boolean canExecuteNow();
43 |
44 | *//**
45 | * 如果可以执行,那就做点什么
46 | *//*
47 | public void doSomething();
48 |
49 | }
50 | */
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/persistence/BaseDataSource.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.persistence;
25 |
26 | import java.sql.Connection;
27 | import java.sql.SQLException;
28 |
29 | /**
30 | * 数据库数据源
31 | * 扩展持久层数据源,需要实现这个接口
32 | * 然后在axe.properties里配置jdbc.datasource即可
33 | * @author CaiDongyu on 2016年5月16日 上午11:03:51.
34 | */
35 | public interface BaseDataSource {
36 |
37 | public Connection getConnection() throws SQLException ;
38 |
39 | public void closeConnection(Connection con) throws SQLException;
40 |
41 | public String setJdbcDriver();
42 |
43 | public String setJdbcUrl();
44 |
45 | public String setJdbcUserName();
46 |
47 | public String setJdbcPassword();
48 |
49 | public int setJdbcConnectionPoolSize();
50 |
51 | public boolean tns();
52 | }
53 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/persistence/BaseRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.persistence;
25 |
26 | /**
27 | * 基础Dao 接口,使用时候可选
28 | * 使用这个接口内的方法,Entity类必须要有@Id标注的字段
29 | * 可以没有@Table注解,但是类名和表名要一只,有@Table注解则无所谓
30 | * Dao可以不继承 这个接口,只需要有@Dao注解,DaoAspect也会加载
31 | * 继承此接口可以让Dao拥有一些基本的面向对象的Entity操作
32 | * @author CaiDongyu on 2016/5/5.
33 | */
34 | public interface BaseRepository {
35 | public T insertEntity(T entity);
36 |
37 | /**
38 | * 需要entity类有@Id字段
39 | */
40 | public int deleteEntity(Object entity);
41 |
42 | /**
43 | * 需要entity类有@Id字段
44 | */
45 | public int updateEntity(Object entity);
46 |
47 | /**
48 | * 需要entity类有@Id字段
49 | */
50 | public T getEntity(T entity);
51 |
52 | /**
53 | * 保存entity
54 | * 这是个 INSERT ... ON DUPLICATE KEY UPDATE 操作,
55 | * *2019年改为通过@Id主键判断,如果主键都有值,执行update,否则执行insert,报错与否业由务控制和数据库自身校验。
56 | * 如果entity有主键,并且主键已存在,执行update
57 | * TODO(OK):返回Entity,并且是查询出来值塞满的,包括Id
58 | */
59 | public T saveEntity(T entity);
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/persistence/Sharding.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_.persistence;
2 |
3 | import org.axe.annotation.persistence.Comment;
4 | import org.axe.annotation.persistence.Table;
5 |
6 | /**
7 | * 数据库分表超类
8 | * @author CaiDongyu 2018/12/26
9 | */
10 | public abstract class Sharding implements TableNameEditor{
11 |
12 | @Comment("分片标识")
13 | private Integer shardingFlag;
14 |
15 | public final Integer getShardingFlag() {
16 | return shardingFlag;
17 | }
18 |
19 | public final void setShardingFlag(Integer shardingFlag) {
20 | this.shardingFlag = shardingFlag;
21 | }
22 |
23 | //单表达到多少数据开始分表
24 | public abstract int oneTableMaxCount();
25 |
26 | @Override
27 | public final String realTableName()throws Exception {
28 | String realTableName = null;
29 | Table table = this.getClass().getAnnotation(Table.class);
30 | if(table != null){
31 | realTableName = table.tableName()+"_sharding_"+shardingFlag;
32 | return realTableName;
33 | }else{
34 | throw new Exception("no @Table annotation,so no real table name");
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/persistence/SqlResultProxy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.persistence;
25 |
26 | /**
27 | * Sql结果的代理接口
28 | * 所有Sql结果代理类,要实现此接口
29 | */
30 | public interface SqlResultProxy {
31 |
32 | public Object proxy(Object result);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/persistence/TableNameEditor.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_.persistence;
2 |
3 | /**
4 | * 表名修改器
5 | * 凡是实现此接口的Table实体类,都拥有在sql执行前,对表名最终确定的能力
6 | * @author CaiDongyu 2018/12/28
7 | */
8 | public interface TableNameEditor {
9 |
10 | /**
11 | * 最终的真实表名,可以是实体类类名
12 | */
13 | public String realTableName()throws Exception;
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/proxy/Proxy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.proxy;
25 |
26 | import org.axe.proxy.base.ProxyChain;
27 |
28 | /**
29 | * 代理借口
30 | * @author CaiDongyu on 2016/4/11.
31 | */
32 | public interface Proxy {
33 |
34 | /**
35 | * 执行链式代理
36 | */
37 | Object doProxy(ProxyChain proxyChain) throws Throwable;
38 | }
39 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_/type_convert/BaseTypeConvert.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_.type_convert;
25 |
26 | /**
27 | * 字段类型转换器
28 | */
29 | public interface BaseTypeConvert {
30 |
31 | /**
32 | * @param object 需要转换的对象值
33 | * @param args 携带的其他参数
34 | */
35 | public Object convert(Object object,Object ...args);
36 | }
37 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/mvc/HeaderFilter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_implement.mvc;
25 |
26 | import javax.servlet.http.HttpServletRequest;
27 | import javax.servlet.http.HttpServletResponse;
28 |
29 | import org.axe.bean.mvc.ExceptionHolder;
30 | import org.axe.bean.mvc.Handler;
31 | import org.axe.bean.mvc.Header;
32 | import org.axe.bean.mvc.Param;
33 | import org.axe.bean.mvc.ResultHolder;
34 | import org.axe.exception.RestException;
35 | import org.axe.interface_.mvc.Filter;
36 |
37 | /**
38 | * Header过滤器
39 | * 抽象类,需要继承并实现doFilter方法才可使用
40 | * @author CaiAdongyu
41 | */
42 | public abstract class HeaderFilter implements Filter {
43 |
44 | @Override
45 | public void init() {
46 |
47 | }
48 |
49 | @Override
50 | public int setLevel() {
51 | return 1;
52 | }
53 | /*
54 | @Override
55 | public Pattern setMapping() {
56 | return Pattern.compile("^.*$");
57 | }
58 |
59 | @Override
60 | public Pattern setNotMapping() {
61 | return null;
62 | }
63 | */
64 |
65 | @Override
66 | public boolean mapping(String requestMethod, String mappingPath) {
67 | return true;//匹配所有
68 | }
69 |
70 | @Override
71 | public final boolean doFilter(HttpServletRequest request, HttpServletResponse response, Param param, Handler handler)
72 | throws RestException {
73 | Header[] headers = headers();
74 |
75 | if(headers != null){
76 | for(Header header:headers){
77 | if(header != null){
78 | String value = request.getHeader(header.getName());
79 | header.setValue(value);
80 | }
81 | }
82 | }
83 |
84 | return doFilter(headers, request, response, param, handler);
85 | }
86 |
87 | @Override
88 | public void doEnd(HttpServletRequest request, HttpServletResponse response, Param param, Handler handler,
89 | ResultHolder resultHolder, ExceptionHolder exceptionHolder) {}
90 |
91 | //Header Filter的实现类必须实现如下
92 | public abstract Header[] headers();
93 |
94 | public abstract boolean doFilter(Header[] headers,HttpServletRequest request, HttpServletResponse response, Param param, Handler handler);
95 | }
96 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/mvc/Utf8CharSetFilter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.interface_implement.mvc;
25 |
26 | import java.io.UnsupportedEncodingException;
27 |
28 | import javax.servlet.http.HttpServletRequest;
29 | import javax.servlet.http.HttpServletResponse;
30 |
31 | import org.axe.bean.mvc.ExceptionHolder;
32 | import org.axe.bean.mvc.Handler;
33 | import org.axe.bean.mvc.Param;
34 | import org.axe.bean.mvc.ResultHolder;
35 | import org.axe.exception.RestException;
36 | import org.axe.interface_.mvc.Filter;
37 | import org.axe.util.LogUtil;
38 | /**
39 | * 默认字符集过滤器
40 | * 抽象类,需要被继承后才能使用
41 | * @author CiDongyu
42 | */
43 | public abstract class Utf8CharSetFilter implements Filter {
44 |
45 | @Override
46 | public void init() {
47 |
48 | }
49 |
50 | @Override
51 | public int setLevel() {
52 | return -1;
53 | }
54 | /*
55 | @Override
56 | public Pattern setMapping() {
57 | return Pattern.compile("^.*$");
58 | }
59 |
60 | @Override
61 | public Pattern setNotMapping() {
62 | return null;
63 | }
64 | */
65 |
66 | @Override
67 | public boolean mapping(String requestMethod, String mappingPath) {
68 | return true;//匹配所有
69 | }
70 |
71 | @Override
72 | public boolean doFilter(HttpServletRequest request, HttpServletResponse response, Param param, Handler handler)
73 | throws RestException {
74 | try {
75 | request.setCharacterEncoding("UTF-8");
76 | response.setCharacterEncoding("UTF-8");
77 | } catch (UnsupportedEncodingException e) {
78 | LogUtil.error(e);
79 | }
80 | return true;
81 | }
82 |
83 | @Override
84 | public void doEnd(HttpServletRequest request, HttpServletResponse response, Param param, Handler handler,
85 | ResultHolder resultHolder, ExceptionHolder exceptionHolder) {}
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/BigDecimal2DoubleConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.math.BigDecimal=>java.lang.Double
9 | */
10 | public final class BigDecimal2DoubleConvert implements BaseTypeConvert{
11 |
12 | @Override
13 | public Object convert(Object object,Object ...args) {
14 | return ((BigDecimal)object).doubleValue();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/BigDecimal2IntegerConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.math.BigDecimal=>java.lang.Integer
9 | */
10 | public final class BigDecimal2IntegerConvert implements BaseTypeConvert{
11 |
12 | @Override
13 | public Object convert(Object object,Object ...args) {
14 | return ((BigDecimal)object).intValue();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/BigInteger2LongConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigInteger;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.math.BigInteger=>java.lang.Long
9 | */
10 | public final class BigInteger2LongConvert implements BaseTypeConvert{
11 |
12 | public Long convert(Object arg,Object ...args){
13 | return ((BigInteger)arg).longValue();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Boolean2IntegerConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import org.axe.interface_.type_convert.BaseTypeConvert;
4 |
5 | /**
6 | * java.lang.Boolean=>java.lang.Integer
7 | */
8 | public final class Boolean2IntegerConvert implements BaseTypeConvert{
9 |
10 | public Integer convert(Object arg,Object ...args){
11 | return (Boolean)arg?1:0;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Double2BigDecimalConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.Double=>java.math.BigDecimal
9 | */
10 | public final class Double2BigDecimalConvert implements BaseTypeConvert{
11 |
12 | public BigDecimal convert(Object arg,Object ...args){
13 | return new BigDecimal((Double)arg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Integer2BigDecimalConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.Integer=>java.math.BigDecimal
9 | */
10 | public final class Integer2BigDecimalConvert implements BaseTypeConvert{
11 |
12 | public BigDecimal convert(Object arg,Object ...args){
13 | return new BigDecimal((Integer)arg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Integer2LongConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import org.axe.interface_.type_convert.BaseTypeConvert;
4 |
5 | /**
6 | * java.lang.Integer=>java.lang.Long
7 | */
8 | public final class Integer2LongConvert implements BaseTypeConvert{
9 |
10 | public Long convert(Object arg,Object ...args){
11 | return Long.valueOf(arg.toString());
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Long2BigDecimalConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.Long=>java.math.BigDecimal
9 | */
10 | public final class Long2BigDecimalConvert implements BaseTypeConvert{
11 |
12 | public BigDecimal convert(Object arg,Object ...args){
13 | return new BigDecimal((Long)arg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Long2DateConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.util.Date;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.Long=>java.util.Date
9 | */
10 | public final class Long2DateConvert implements BaseTypeConvert{
11 |
12 | public Date convert(Object arg,Object ...args){
13 | return new Date((Long)arg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Long2SqlDateConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.sql.Date;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.Long=>java.sql.Date
9 | */
10 | public final class Long2SqlDateConvert implements BaseTypeConvert{
11 |
12 | public Date convert(Object arg,Object ...args){
13 | return new Date((Long)arg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/SqlDate2DateConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.util.Date;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.sql.Date=>java.util.Date
9 | */
10 | public final class SqlDate2DateConvert implements BaseTypeConvert{
11 |
12 | public Date convert(Object arg,Object ...args){
13 | return (java.sql.Date)arg;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2BigDecimalConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.String=>java.math.BigDecimal
9 | */
10 | public final class String2BigDecimalConvert implements BaseTypeConvert{
11 |
12 | public BigDecimal convert(Object arg,Object ...args){
13 | return new BigDecimal((String)arg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2DateConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.util.Date;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.String=>java.util.Date
9 | */
10 | public final class String2DateConvert implements BaseTypeConvert{
11 |
12 | public Date convert(Object arg,Object ...args){
13 | return new Date(Long.parseLong((String)arg));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2DoubleConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import org.axe.interface_.type_convert.BaseTypeConvert;
4 |
5 | /**
6 | * java.lang.String=>java.lang.Double
7 | */
8 | public final class String2DoubleConvert implements BaseTypeConvert{
9 |
10 | public Double convert(Object arg,Object ...args){
11 | return Double.parseDouble((String)arg);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2IntegerConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import org.axe.interface_.type_convert.BaseTypeConvert;
4 |
5 | /**
6 | * java.lang.String=>java.lang.Integer
7 | */
8 | public final class String2IntegerConvert implements BaseTypeConvert{
9 |
10 | public Integer convert(Object arg,Object ...args){
11 | return Integer.parseInt((String)arg);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2LongConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import org.axe.interface_.type_convert.BaseTypeConvert;
4 |
5 | /**
6 | * java.lang.String=>java.lang.Long
7 | */
8 | public final class String2LongConvert implements BaseTypeConvert{
9 |
10 | public Long convert(Object arg,Object ...args){
11 | return Long.parseLong((String)arg);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2SqlDateConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.sql.Date;
4 |
5 | import org.axe.interface_.type_convert.BaseTypeConvert;
6 |
7 | /**
8 | * java.lang.String=>java.sql.Date
9 | */
10 | public final class String2SqlDateConvert implements BaseTypeConvert{
11 |
12 | public Date convert(Object arg,Object ...args){
13 | return new Date(Long.parseLong((String)arg));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/String2SqlTimestampConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.sql.Timestamp;
4 | import java.text.ParseException;
5 | import java.text.SimpleDateFormat;
6 | import java.util.regex.Pattern;
7 |
8 | import org.axe.interface_.type_convert.BaseTypeConvert;
9 |
10 | /**
11 | * java.lang.String=>java.sql.Timestamp
12 | */
13 | public final class String2SqlTimestampConvert implements BaseTypeConvert{
14 |
15 | public Timestamp convert(Object arg,Object ...args){
16 | String str = (String)arg;
17 | Pattern compile = Pattern.compile("^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2} [0-9]{2}\\:[0-9]{2}:[0-9]{2}\\.[0-9]+$");;
18 | if(compile.matcher(str).find()){
19 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
20 | try {
21 | return new Timestamp(sdf.parse(str).getTime());
22 | } catch (ParseException e) {
23 | throw new RuntimeException(e);
24 | }
25 | }else{
26 | return new Timestamp(Long.parseLong(str));
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/interface_implement/type_convert/Timestamp2DateConvert.java:
--------------------------------------------------------------------------------
1 | package org.axe.interface_implement.type_convert;
2 |
3 | import java.sql.Timestamp;
4 | import java.util.Date;
5 |
6 | import org.axe.interface_.type_convert.BaseTypeConvert;
7 |
8 | /**
9 | * java.sql.Timestamp=>java.util.Date
10 | */
11 | public final class Timestamp2DateConvert implements BaseTypeConvert{
12 |
13 | public Date convert(Object arg,Object ...args){
14 | return (Timestamp)arg;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/jetty/JettyManager.java:
--------------------------------------------------------------------------------
1 | package org.axe.jetty;
2 |
3 | import java.util.List;
4 |
5 | import org.axe.DispatcherServlet;
6 | import org.axe.util.CollectionUtil;
7 | import org.axe.util.LogUtil;
8 | import org.eclipse.jetty.server.Server;
9 | import org.eclipse.jetty.servlet.ServletContextHandler;
10 | import org.eclipse.jetty.servlet.ServletHolder;
11 |
12 | public final class JettyManager {
13 |
14 | /**
15 | * 不带参数的启动,默认启动jetty
16 | */
17 | public static void startJetty(int serverPort){
18 | startJetty(serverPort, "/", null);
19 | }
20 |
21 | /**
22 | * 带参数启动jetty
23 | * @param filterList 过滤器的链
24 | */
25 | public static void startJetty(int serverPort, String contextPath, List filterList){
26 | try {
27 | //启动jetty
28 | Server server = new Server(serverPort);
29 | ServletContextHandler context = new ServletContextHandler();
30 | //设置上下文地址
31 | context.setContextPath(contextPath);
32 | server.setHandler(context);
33 |
34 | //axe servlet
35 | ServletHolder axe = new ServletHolder(DispatcherServlet.class);
36 | axe.setInitOrder(1);//启动时加载
37 | context.addServlet(axe, "/*");
38 |
39 | //cross filter
40 | if(CollectionUtil.isNotEmpty(filterList)){
41 | for(JettyServletFilter filter:filterList){
42 | context.addFilter(filter.getHolder(), filter.getPathSpec(), filter.getDispatches());
43 | }
44 | }
45 |
46 | //启动
47 | server.start();
48 | server.join();
49 |
50 | LogUtil.log(">>>>>>>>>\t Jetty server started success! \t<<<<<<<<<<");
51 | } catch (Exception e) {
52 | LogUtil.error(e);
53 | System.exit(1);
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/jetty/JettyServletFilter.java:
--------------------------------------------------------------------------------
1 | package org.axe.jetty;
2 |
3 | import java.util.EnumSet;
4 |
5 | import javax.servlet.DispatcherType;
6 |
7 | import org.eclipse.jetty.servlet.FilterHolder;
8 |
9 | public final class JettyServletFilter {
10 |
11 | private FilterHolder holder;
12 | private String pathSpec;
13 | private EnumSet dispatches;
14 |
15 |
16 | public JettyServletFilter(FilterHolder holder, String pathSpec, EnumSet dispatches) {
17 | this.holder = holder;
18 | this.pathSpec = pathSpec;
19 | this.dispatches = dispatches;
20 | }
21 |
22 | public FilterHolder getHolder() {
23 | return holder;
24 | }
25 | public String getPathSpec() {
26 | return pathSpec;
27 | }
28 | public EnumSet getDispatches() {
29 | return dispatches;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/proxy/base/AspectProxy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.proxy.base;
25 |
26 | import java.lang.reflect.Method;
27 |
28 | import org.axe.interface_.proxy.Proxy;
29 |
30 | /**
31 | * 切面代理类
32 | * @author CaiDongyu on 2016/4/14.
33 | */
34 | public abstract class AspectProxy implements Proxy{
35 |
36 | // private static final Logger LOGGER = LoggerFactory.getLogger(AspectProxy.class);
37 |
38 | @Override
39 | public Object doProxy(ProxyChain proxyChain) throws Throwable {
40 | Object result = null;
41 | Class> cls = proxyChain.getTargetClass();
42 | Method method = proxyChain.getTargetMethod();
43 | Object[] params = proxyChain.getMethodParams();
44 | begin();
45 | try {
46 | if (intercept(cls,method,params)){
47 | before(cls,method,params);
48 | result = proxyChain.doProxyChain();
49 | after(cls,method,params,result);
50 | }else{
51 | result = proxyChain.doProxyChain();
52 | }
53 | }catch (Exception e){
54 | // LOGGER.error("proxy failure",e);
55 | error(cls,method,params,e);
56 | throw e;
57 | } finally {
58 | end();
59 | }
60 | return result;
61 | }
62 |
63 | public void begin(){
64 |
65 | }
66 |
67 | public boolean intercept(Class> cls,Method method,Object[] params) throws Throwable{
68 | return true;
69 | }
70 |
71 | public void before(Class> cls,Method method,Object[] params)throws Throwable{
72 |
73 | }
74 |
75 | public void after(Class> cls,Method method,Object[] params,Object result)throws Throwable{
76 |
77 | }
78 |
79 | public void error(Class> cls,Method method,Object[] params,Throwable e){
80 |
81 | }
82 |
83 | public void end(){
84 |
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/proxy/base/ProxyChain.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.proxy.base;
25 |
26 | import java.lang.reflect.Method;
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | import org.axe.interface_.proxy.Proxy;
31 |
32 | import net.sf.cglib.proxy.MethodProxy;
33 |
34 | /**
35 | * 代理链
36 | * @author CaiDongyu on 2016/4/11.
37 | */
38 | public final class ProxyChain {
39 |
40 | private final Class> targetClass;
41 | private final Object targetObject;
42 | private final Method targetMethod;
43 | private final MethodProxy methodProxy;
44 | private final Object[] methodParams;
45 |
46 | private List proxyList = new ArrayList();
47 |
48 | private ThreadLocal proxyIndex = new ThreadLocal(){
49 | protected Integer initialValue() {
50 | return 0;
51 | };
52 | };
53 |
54 | public ProxyChain(Class> targetClass, Object targetObject, Method targetMethod, MethodProxy methodProxy, Object[] methodParams, List proxyList) {
55 | this.targetClass = targetClass;
56 | this.targetObject = targetObject;
57 | this.targetMethod = targetMethod;
58 | this.methodProxy = methodProxy;
59 | this.methodParams = methodParams;
60 | this.proxyList = proxyList;
61 | }
62 |
63 | public Object getTargetObject() {
64 | return targetObject;
65 | }
66 |
67 | public Object[] getMethodParams(){
68 | return methodParams;
69 | }
70 |
71 | public Class> getTargetClass() {
72 | return targetClass;
73 | }
74 |
75 | public Method getTargetMethod() {
76 | return targetMethod;
77 | }
78 |
79 | public MethodProxy getMethodProxy() {
80 | return methodProxy;
81 | }
82 |
83 | public Object doProxyChain() throws Throwable{
84 | Object methodResult;
85 | if(!isLastProxy()){
86 | int proxyIndexNum = proxyIndex.get();
87 | proxyIndex.set(proxyIndexNum+1);
88 | methodResult = proxyList.get(proxyIndexNum).doProxy(this);
89 | } else {
90 | methodResult = methodProxy.invokeSuper(targetObject, methodParams);
91 | }
92 | return methodResult;
93 | }
94 |
95 | public boolean isLastProxy(){
96 | return proxyIndex.get() >= proxyList.size();
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/proxy/base/ProxyManger.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.proxy.base;
25 |
26 | import java.lang.reflect.Method;
27 | import java.util.List;
28 |
29 | import org.axe.interface_.proxy.Proxy;
30 |
31 | import net.sf.cglib.proxy.Enhancer;
32 | import net.sf.cglib.proxy.MethodInterceptor;
33 | import net.sf.cglib.proxy.MethodProxy;
34 |
35 | /**
36 | * 代理管理器
37 | * 负责创建代理对象
38 | * @author CaiDongyu on 2016/4/14.
39 | */
40 | public final class ProxyManger {
41 |
42 | @SuppressWarnings("unchecked")
43 | public static T createProxy(final Class targetClass, final List proxyList){
44 | return (T) Enhancer.create(targetClass,new MethodInterceptor() {
45 | @Override
46 | public Object intercept(Object targetObject, Method targetMethod, Object[] methodParams, MethodProxy methodProxy) throws Throwable {
47 | return new ProxyChain(targetClass,targetObject,targetMethod,methodProxy,methodParams,proxyList).doProxyChain();
48 | }
49 | } );
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/AjaxRequestUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.util;
25 |
26 | import java.util.ArrayList;
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 | import javax.servlet.http.HttpServletRequest;
31 |
32 | import org.axe.bean.mvc.FormParam;
33 | import org.axe.bean.mvc.Param;
34 |
35 | /**
36 | * 请求助手类
37 | * @author CaiDongyu on 2016/4/25.
38 | */
39 | public final class AjaxRequestUtil {
40 |
41 | private AjaxRequestUtil() {}
42 |
43 | @SuppressWarnings("unchecked")
44 | public static void initParam(Param param,HttpServletRequest request,String requestPath,String mappingPath)throws Exception{
45 | List formParamList = new ArrayList<>();
46 | formParamList.addAll(RequestUtil.parseParameter(request,requestPath,mappingPath));
47 | // String body = CodeUtil.decodeURL(StreamUtil.getString(request.getInputStream()));
48 | String body = "";
49 | try {
50 | body=StreamUtil.getString(request.getInputStream());
51 | } catch (Exception e) {}
52 | Map bodyParamMap = null;
53 | if(StringUtil.isNotEmpty(body)){
54 | body = body.trim();
55 | if(body.startsWith("[") && body.endsWith("]")){
56 | body = "{\"\":"+body+"}";
57 | }
58 | if(body.startsWith("{")){
59 | try {
60 | bodyParamMap = JsonUtil.fromJson(body, Map.class);
61 | } catch (Exception e){
62 | throw new Exception("read body to json failure",e);
63 | }
64 | }
65 | }
66 | param.init(body,formParamList,null,bodyParamMap);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/ArrayUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.util;
25 |
26 | import org.apache.commons.lang3.ArrayUtils;
27 |
28 | /**
29 | * 数组工具
30 | * @author CaiDongyu on 2016/4/11.
31 | */
32 | public final class ArrayUtil {
33 |
34 | private ArrayUtil() {}
35 |
36 | /**
37 | * 判断空
38 | */
39 | public static boolean isEmpty(Object[] ary){
40 | return ArrayUtils.isEmpty(ary);
41 | }
42 |
43 | /**
44 | * 判断非空
45 | */
46 | public static boolean isNotEmpty(Object[] ary){
47 | return !isEmpty(ary);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/CollectionUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.util;
25 |
26 | import org.apache.commons.collections4.CollectionUtils;
27 | import org.apache.commons.collections4.MapUtils;
28 |
29 | import java.util.ArrayList;
30 | import java.util.Arrays;
31 | import java.util.Collection;
32 | import java.util.Collections;
33 | import java.util.List;
34 | import java.util.Map;
35 |
36 | /**
37 | * 集合工具类
38 | * @author CaiDongyu on 2016/4/9.
39 | */
40 | public final class CollectionUtil {
41 |
42 | private CollectionUtil() {}
43 |
44 | /**
45 | * 判断 Collection 是否为空
46 | */
47 | public static boolean isEmpty(Collection> collection){
48 | return CollectionUtils.isEmpty(collection);
49 | }
50 |
51 | /**
52 | * 判断 Collection 是否非空
53 | */
54 | public static boolean isNotEmpty(Collection> collection){
55 | return !isEmpty(collection);
56 | }
57 |
58 | /**
59 | * 判断 Map 是否为空
60 | */
61 | public static boolean isEmpty(Map,?> map){
62 | return MapUtils.isEmpty(map);
63 | }
64 |
65 | /**
66 | * 判断 Map 是否非空
67 | */
68 | public static boolean isNotEmpty(Map,?> map) {
69 | return !isEmpty(map);
70 | }
71 |
72 | @SuppressWarnings({ "unchecked", "rawtypes" })
73 | public static List intersect(List ls, List ls2) {
74 | List list = new ArrayList(Arrays.asList(new Object[ls.size()]));
75 | Collections.copy(list, ls);
76 | list.retainAll(ls2);
77 | return list;
78 | }
79 |
80 | @SuppressWarnings({ "unchecked", "rawtypes" })
81 | public static List union(List ls, List ls2) {
82 | List list = new ArrayList(Arrays.asList(new Object[ls.size()]));
83 | Collections.copy(list, ls);
84 | list.addAll(ls2);
85 | return list;
86 | }
87 |
88 | @SuppressWarnings({ "unchecked", "rawtypes" })
89 | public static List diff(List ls, List ls2) {
90 | List list = new ArrayList(Arrays.asList(new Object[ls.size()]));
91 | Collections.copy(list, ls);
92 | list.removeAll(ls2);
93 | return list;
94 | }
95 |
96 | public static List convertList(@SuppressWarnings("unchecked") T... ary){
97 | List list = new ArrayList<>();
98 | for(T t:ary){
99 | list.add(t);
100 | }
101 | return list;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/JsonUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.util;
25 |
26 | import com.fasterxml.jackson.databind.DeserializationFeature;
27 | import com.fasterxml.jackson.databind.ObjectMapper;
28 |
29 | /**
30 | * JSON 工具类
31 | * @author CaiDongyu on 2016/4/11.
32 | */
33 | public final class JsonUtil {
34 | private JsonUtil() {}
35 |
36 | /**
37 | * 将 POJO 转为 JSON
38 | */
39 | public static String toJson(Object obj){
40 | String json;
41 | try {
42 | ObjectMapper OBJECT_MAPPER = new ObjectMapper();
43 | json = OBJECT_MAPPER.writeValueAsString(obj);
44 | } catch (Exception e){
45 | LogUtil.error(e);
46 | throw new RuntimeException(e);
47 | }
48 | return json;
49 | }
50 |
51 | /**
52 | * 将 JSON 转为 POJO
53 | */
54 | @SuppressWarnings("unchecked")
55 | public static T fromJson(String json, Class type){
56 | T pojo;
57 | try {
58 | ObjectMapper OBJECT_MAPPER = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
59 | if(String.class.equals(type)){
60 | pojo = (T) json;
61 | }else{
62 | String reg = "[ ]*\"[^\"]+\"[ ]*:[ ]*null[ ]*";
63 | json = json.replaceAll(""+reg+",", "");
64 | json = json.replaceAll(","+reg+"\\}", "}");
65 | json = json.replaceAll("\\{"+reg+"\\}", "{}");
66 | pojo = OBJECT_MAPPER.readValue(json,type);
67 | }
68 | } catch (Exception e){
69 | LogUtil.error(e);
70 | throw new RuntimeException(e);
71 | }
72 | return pojo;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/LogUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.util;
25 |
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 | /**
29 | * 日志工具
30 | * @author CaiDongyu
31 | */
32 | public final class LogUtil {
33 | private static final Logger LOGGER = LoggerFactory.getLogger(LogUtil.class);
34 |
35 | public static void error(Throwable error){
36 | LOGGER.error("Axe [ERROR]"+error.getMessage(), error);
37 | }
38 |
39 | public static void error(String error){
40 | LOGGER.error("Axe [ERROR]"+error, new Exception(error));
41 | }
42 |
43 | public static void log(String msg){
44 | LOGGER.error("Axe [MSG]"+msg);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/MD5Util.java:
--------------------------------------------------------------------------------
1 | package org.axe.util;
2 |
3 | import java.security.MessageDigest;
4 | import java.security.NoSuchAlgorithmException;
5 | /**
6 | * MD5 算法
7 | * @author 原作者以无从查实
8 | */
9 | public class MD5Util {
10 | // 全局数组
11 | private final static String[] strDigits = { "0", "1", "2", "3", "4", "5",
12 | "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
13 |
14 | // 返回形式为数字跟字符串
15 | private static String byteToArrayString(byte bByte) {
16 | int iRet = bByte;
17 | // LogUtil.log("iRet="+iRet);
18 | if (iRet < 0) {
19 | iRet += 256;
20 | }
21 | int iD1 = iRet / 16;
22 | int iD2 = iRet % 16;
23 | return strDigits[iD1] + strDigits[iD2];
24 | }
25 |
26 | // 转换字节数组为16进制字串
27 | private static String byteToString(byte[] bByte) {
28 | StringBuilder sBuffer = new StringBuilder();
29 | for (int i = 0; i < bByte.length; i++) {
30 | sBuffer.append(byteToArrayString(bByte[i]));
31 | }
32 | String result = sBuffer.toString();
33 | sBuffer.setLength(0);
34 | return result;
35 | }
36 |
37 | public static String getMD5Code(String strObj) {
38 | String resultString = null;
39 | try {
40 | resultString = new String(strObj);
41 | MessageDigest md = MessageDigest.getInstance("MD5");
42 | // md.digest() 该函数返回值为存放哈希值结果的byte数组
43 | resultString = byteToString(md.digest(strObj.getBytes()));
44 | } catch (NoSuchAlgorithmException e) {
45 | LogUtil.error(e);
46 | }
47 | return resultString;
48 | }
49 |
50 | /*public static void main(String[] args) {
51 | LogUtil.log(MD5Util.getMD5Code("000"));
52 | }*/
53 | }
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/StreamUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017 CaiDongyu
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package org.axe.util;
25 |
26 | import java.io.BufferedReader;
27 | import java.io.InputStream;
28 | import java.io.InputStreamReader;
29 | import java.io.OutputStream;
30 |
31 | /**
32 | * 流操作 工具类
33 | * @author CaiDongyu on 2016/4/11.
34 | */
35 | public final class StreamUtil {
36 | private StreamUtil() {}
37 |
38 | /**
39 | * 从输入流中获取字符串
40 | * @throws Exception
41 | */
42 | public static String getString(InputStream is) throws Exception{
43 | StringBuilder sb = new StringBuilder();
44 | BufferedReader reader = null;
45 | try {
46 | reader = new BufferedReader(new InputStreamReader(is));
47 | String line;
48 | while ((line = reader.readLine()) != null) {
49 | sb.append(line);
50 | }
51 | } catch (Exception e){
52 | // LOGGER.error("get String failure",e);
53 | throw e;
54 | } finally {
55 | if(reader != null){
56 | try {
57 | reader.close();
58 | } catch (Exception e2) {}
59 | }
60 | }
61 | return sb.toString();
62 | }
63 |
64 | /**
65 | * 将输入流复制到输出流
66 | */
67 | public static void copyStream(InputStream inputStream, OutputStream outputStream){
68 | try {
69 | int length;
70 | byte[] buffer = new byte[4*2014];
71 | while((length = inputStream.read(buffer,0,buffer.length)) != -1){
72 | outputStream.write(buffer,0,length);
73 | }
74 | outputStream.flush();
75 | } catch (Exception e){
76 | LogUtil.error(e);
77 | throw new RuntimeException(e);
78 | } finally {
79 | try {
80 | inputStream.close();
81 | } catch (Exception e){
82 | LogUtil.error(e);
83 | }
84 | try {
85 | outputStream.close();
86 | } catch (Exception e){
87 | LogUtil.error(e);
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/mail/MailSenderInfo.java:
--------------------------------------------------------------------------------
1 | package org.axe.util.mail;
2 |
3 | /**
4 | * 发送邮件需要使用的基本信息
5 | * @author 原作者以无法查实
6 | */
7 | import java.util.Properties;
8 |
9 | public final class MailSenderInfo {
10 |
11 | // 发送邮件的服务器的IP和端口
12 | private String mailServerHost;
13 | private String mailServerPort = "25";
14 |
15 | // 邮件发送者的地址
16 | private String fromAddress;
17 |
18 | // 登陆邮件发送服务器的用户名和密码
19 | private String userName;
20 | private String password;
21 |
22 | // 是否需要身份验证
23 | private boolean validate = false;
24 |
25 | // 邮件主题
26 | private String subject;
27 |
28 | // 邮件的文本内容
29 | private String content;
30 |
31 | // 邮件附件的文件名
32 | private String[] attachFileNames;
33 |
34 | /**
35 | * 获得邮件会话属性
36 | */
37 | public Properties getProperties() {
38 | Properties p = new Properties();
39 | p.put("mail.smtp.host", this.mailServerHost);
40 | p.put("mail.smtp.port", this.mailServerPort);
41 | p.put("mail.smtp.auth", validate ? "true" : "false");
42 | return p;
43 | }
44 |
45 | public String getMailServerHost() {
46 | return mailServerHost;
47 | }
48 |
49 | public void setMailServerHost(String mailServerHost) {
50 | this.mailServerHost = mailServerHost;
51 | }
52 |
53 | public String getMailServerPort() {
54 | return mailServerPort;
55 | }
56 |
57 | public void setMailServerPort(String mailServerPort) {
58 | this.mailServerPort = mailServerPort;
59 | }
60 |
61 | public boolean isValidate() {
62 | return validate;
63 | }
64 |
65 | public void setValidate(boolean validate) {
66 | this.validate = validate;
67 | }
68 |
69 | public String[] getAttachFileNames() {
70 | return attachFileNames;
71 | }
72 |
73 | public void setAttachFileNames(String[] fileNames) {
74 | this.attachFileNames = fileNames;
75 | }
76 |
77 | public String getFromAddress() {
78 | return fromAddress;
79 | }
80 |
81 | public void setFromAddress(String fromAddress) {
82 | this.fromAddress = fromAddress;
83 | }
84 |
85 | public String getPassword() {
86 | return password;
87 | }
88 |
89 | public void setPassword(String password) {
90 | this.password = password;
91 | }
92 |
93 | public String getUserName() {
94 | return userName;
95 | }
96 |
97 | public void setUserName(String userName) {
98 | this.userName = userName;
99 | }
100 |
101 | public String getSubject() {
102 | return subject;
103 | }
104 |
105 | public void setSubject(String subject) {
106 | this.subject = subject;
107 | }
108 |
109 | public String getContent() {
110 | return content;
111 | }
112 |
113 | public void setContent(String textContent) {
114 | this.content = textContent;
115 | }
116 | }
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/mail/MyAuthenticator.java:
--------------------------------------------------------------------------------
1 | package org.axe.util.mail;
2 |
3 | import javax.mail.Authenticator;
4 | import javax.mail.PasswordAuthentication;
5 |
6 | /**
7 | * 密码验证器
8 | * @author 原作者以无法查实
9 | */
10 | public final class MyAuthenticator extends Authenticator {
11 | String userName = null;
12 | String password = null;
13 |
14 | public MyAuthenticator() {
15 | }
16 |
17 | public MyAuthenticator(String username, String password) {
18 | this.userName = username;
19 | this.password = password;
20 | }
21 |
22 | protected PasswordAuthentication getPasswordAuthentication() {
23 | return new PasswordAuthentication(userName, password);
24 | }
25 | }
--------------------------------------------------------------------------------
/axe/src/main/java/org/axe/util/mail/SimpleMailSender.java:
--------------------------------------------------------------------------------
1 | package org.axe.util.mail;
2 |
3 | import java.util.Date;
4 | import java.util.Properties;
5 |
6 | import javax.mail.Address;
7 | import javax.mail.BodyPart;
8 | import javax.mail.Message;
9 | import javax.mail.Multipart;
10 | import javax.mail.Session;
11 | import javax.mail.Transport;
12 | import javax.mail.internet.InternetAddress;
13 | import javax.mail.internet.MimeBodyPart;
14 | import javax.mail.internet.MimeMessage;
15 | import javax.mail.internet.MimeMultipart;
16 |
17 | /**
18 | * 简单邮件(不带附件的邮件)发送器
19 | * @author 原作者以无法查实
20 | */
21 | public final class SimpleMailSender {
22 | /*public static void main(String[] args) {
23 | // 这个类主要是设置邮件
24 | MailSenderInfo mailInfo = new MailSenderInfo();
25 | mailInfo.setMailServerHost("smtp.163.com");
26 | mailInfo.setMailServerPort("25");
27 | mailInfo.setValidate(true);
28 | mailInfo.setUserName("axe_caidongyu@163.com");
29 | mailInfo.setPassword("NiveaLlwifUAUUi1");// 您的邮箱密码
30 | mailInfo.setFromAddress("axe_caidongyu@163.com");
31 | mailInfo.setToAddress("1157656909@qq.com");
32 | mailInfo.setSubject("系统日志");
33 | mailInfo.setContent("这是一封系统日志邮件 ");
34 | // 这个类主要来发送邮件
35 | // SimpleMailSender.sendTextMail(mailInfo);// 发送文体格式
36 | boolean success = SimpleMailSender.sendHtmlMail(mailInfo);// 发送html格式
37 | LogUtil.log(success);
38 | }*/
39 |
40 | /**
41 | * 以文本格式发送邮件
42 | *
43 | * @param mailInfo
44 | * 待发送的邮件的信息
45 | */
46 | public static void sendTextMail(MailSenderInfo mailSendInfo,String ...toAddress)throws Exception {
47 | Message mailMessage = buildMailMessage(mailSendInfo, toAddress);
48 | // 设置邮件消息的主要内容
49 | String mailContent = mailSendInfo.getContent();
50 | mailMessage.setText(mailContent);
51 | // 发送邮件
52 | Transport.send(mailMessage);
53 | }
54 |
55 | /**
56 | * 以HTML格式发送邮件
57 | *
58 | * @param mailSendInfo
59 | * 待发送的邮件信息
60 | */
61 | public static void sendHtmlMail(MailSenderInfo mailSendInfo,String ...toAddress)throws Exception {
62 | Message mailMessage = buildMailMessage(mailSendInfo, toAddress);
63 | // MiniMultipart类是一个容器类,包含MimeBodyPart类型的对象
64 | Multipart mainPart = new MimeMultipart();
65 | // 创建一个包含HTML内容的MimeBodyPart
66 | BodyPart html = new MimeBodyPart();
67 | // 设置HTML内容
68 | html.setContent(mailSendInfo.getContent(), "text/html; charset=utf-8");
69 | mainPart.addBodyPart(html);
70 | // 将MiniMultipart对象设置为邮件内容
71 | mailMessage.setContent(mainPart);
72 | // 发送邮件
73 | Transport.send(mailMessage);
74 | }
75 |
76 | private static Message buildMailMessage(MailSenderInfo mailSendInfo,String ...toAddress)throws Exception{
77 | // 判断是否需要身份认证
78 | MyAuthenticator authenticator = null;
79 | Properties pro = mailSendInfo.getProperties();
80 | // 如果需要身份认证,则创建一个密码验证器
81 | if (mailSendInfo.isValidate()) {
82 | authenticator = new MyAuthenticator(mailSendInfo.getUserName(), mailSendInfo.getPassword());
83 | }
84 | // 根据邮件会话属性和密码验证器构造一个发送邮件的session
85 | Session sendMailSession = Session.getDefaultInstance(pro, authenticator);
86 | // 根据session创建一个邮件消息
87 | Message mailMessage = new MimeMessage(sendMailSession);
88 | // 创建邮件发送者地址
89 | Address from = new InternetAddress(mailSendInfo.getFromAddress());
90 | // 设置邮件消息的发送者
91 | mailMessage.setFrom(from);
92 | // 创建邮件的接收者地址,并设置到邮件消息中
93 | Address[] toAry = new Address[toAddress.length];
94 | for(int i=0;i
2 |
5 | 4.0.0
6 |
7 | com.axe
8 | first_project
9 | 1.0-SNAPSHOT
10 | jar
11 |
12 |
13 |
14 |
15 |
16 | org.slf4j
17 | slf4j-log4j12
18 | 1.7.7
19 |
20 |
21 |
22 |
23 |
24 | org.axe
25 | axe
26 | 19.8.6
27 |
28 |
29 |
30 | org.apache.commons
31 | commons-dbcp2
32 | 2.0.1
33 |
34 |
35 |
36 |
37 |
38 |
39 | com.thetransactioncompany
40 | java-property-utils
41 | 1.9.1
42 |
43 |
44 |
45 | com.thetransactioncompany
46 | cors-filter
47 | 2.4
48 |
49 |
50 |
51 |
52 | org.eclipse.jetty
53 | jetty-servlet
54 | 9.4.20.v20190813
55 |
56 |
57 |
58 |
59 | javax.servlet
60 | javax.servlet-api
61 | 3.1.0
62 |
63 |
64 |
65 |
66 |
67 | first_project
68 |
69 |
70 | org.apache.maven.plugins
71 | maven-compiler-plugin
72 | 3.1
73 |
74 | 1.8
75 | 1.8
76 | utf8
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/first_project/src/main/java/com/axe/first_project/JettyStart.java:
--------------------------------------------------------------------------------
1 | package com.axe.first_project;
2 |
3 | import java.util.ArrayList;
4 | import java.util.EnumSet;
5 | import java.util.List;
6 |
7 | import javax.servlet.DispatcherType;
8 |
9 | import org.axe.jetty.JettyManager;
10 | import org.axe.jetty.JettyServletFilter;
11 | import org.eclipse.jetty.servlet.FilterHolder;
12 |
13 | import com.thetransactioncompany.cors.CORSFilter;
14 |
15 | public class JettyStart {
16 | public static void main(String[] args) {
17 | int port = 80;
18 | if(args != null && args.length>0){
19 | port = Integer.parseInt(args[0]);
20 | }
21 |
22 | FilterHolder holder = new FilterHolder(CORSFilter.class);
23 | holder.setInitParameter("cors.allowGenericHttpRequests", "true");
24 | holder.setInitParameter("cors.allowOrigin", "*");
25 | holder.setInitParameter("cors.allowSubdomains", "false");
26 | holder.setInitParameter("cors.supportedMethods", "POST, DELETE, PUT, GET, HEAD, OPTIONS");
27 | holder.setInitParameter("cors.supportedHeaders", "*");
28 | holder.setInitParameter("cors.supportsCredentials", "true");
29 | holder.setInitParameter("cors.maxAge", "3600");
30 |
31 | List filterList = new ArrayList<>();
32 | filterList.add(new JettyServletFilter(holder, "/*", EnumSet.of(DispatcherType.REQUEST)));
33 |
34 | JettyManager.startJetty(port, "/", filterList);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/first_project/src/main/java/com/axe/first_project/rest/TestRest.java:
--------------------------------------------------------------------------------
1 | package com.axe.first_project.rest;
2 |
3 | import org.axe.annotation.ioc.Controller;
4 | import org.axe.annotation.mvc.Request;
5 | import org.axe.annotation.mvc.RequestParam;
6 | import org.axe.constant.RequestMethod;
7 |
8 | @Controller(basePath="/hello_word",desc="HelloWord")
9 | public class TestRest {
10 |
11 | @Request(path="/first",method=RequestMethod.GET,desc="第一个接口")
12 | public String first(
13 | @RequestParam(name="name",required=true,desc="姓名")String name,
14 | @RequestParam(name="age",desc="年龄")Integer age
15 | ){
16 | return "姓名:"+name+" 年龄:"+(age == null?"不知道":age);
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/first_project/src/main/java/test/Test.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.util.HashSet;
4 | import java.util.Properties;
5 | import java.util.Set;
6 |
7 | import org.axe.Axe;
8 | import org.axe.constant.ConfigConstant;
9 | import org.axe.extra.timer.TimerTask;
10 | import org.axe.helper.base.ConfigHelper;
11 | import org.axe.helper.ioc.BeanHelper;
12 | import org.axe.helper.ioc.ClassHelper;
13 | import org.axe.interface_.mvc.AfterClassLoaded;
14 | import org.axe.interface_.mvc.AfterConfigLoaded;
15 | import org.axe.interface_.mvc.Listener;
16 | import org.axe.util.LogUtil;
17 |
18 | import com.axe.first_project.rest.TestRest;
19 |
20 | public class Test {
21 | public static void main(String[] args) {
22 | try {
23 | ConfigHelper.addAfterConfigLoadedCallback(new AfterConfigLoaded() {
24 | @Override
25 | public void doSomething(Properties config) {
26 | //修改一些测试时候的参数
27 | config.put(ConfigConstant.APP_BASE_PACKAGE, config.get(ConfigConstant.APP_BASE_PACKAGE)+",test");
28 | config.put("jdbc.datasource.axe-datasource-dbcp.auto_create_table", "true");
29 | config.put(ConfigConstant.JDBC_URL, "jdbc:mysql://192.168.199.45:3306/testdb?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE");
30 | }
31 | });
32 | ClassHelper.addAfterClassLoadedCallback(new AfterClassLoaded() {
33 | @Override
34 | public void doSomething(Set> classSet) {
35 | Set> classesRemove = new HashSet<>();
36 | for(Class> cls:classSet){
37 | //Listener不启动
38 | if(Listener.class.isAssignableFrom(cls)){
39 | classesRemove.add(cls);
40 | }
41 | //TimerTask不启动
42 | if(TimerTask.class.isAssignableFrom(cls)){
43 | classesRemove.add(cls);
44 | }
45 | }
46 |
47 | //不启动的都去除掉
48 | classSet.removeAll(classesRemove);
49 |
50 |
51 | //TODO:可以在这里添加你需要额外启动的
52 | }
53 | });
54 |
55 | //Axe.init()会完整的启动Axe所有功能,只是缺少Web容器
56 | //在这个工程里,我们使用了jetty来作为内置web容器,您可以去除jetty,只要pom.xml中删掉jetty依赖,并移除JettyStart类即可
57 | //去除jetty后,您可以使用您喜欢的任何servlet 容器比如Tomcat
58 | Axe.init();
59 |
60 | //BeanHelper.getBean可以获取到Axe托管的所有mvc对象
61 | //比如:@Controller注解的rest接口类
62 | //比如:@Service注解的 公共服务类,此种类一般携带事物切面
63 | //比如:@Dao注解的持久化接口,那么您可以方便的在这里调试你的sql语句业务逻辑
64 | //配合这些功能,你还可以结合junit来作方便的代码单元测试
65 |
66 | TestRest rest = BeanHelper.getBean(TestRest.class);
67 | System.out.println(rest.first("张三", null));
68 |
69 | } catch (Exception e) {
70 | LogUtil.error(e);
71 | }
72 | System.exit(0);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/first_project/src/main/resources/axe.properties:
--------------------------------------------------------------------------------
1 | #==================axe框架配置文件==================
2 |
3 | #------------------1.axe基础配置--------------------
4 |
5 | #框架扫描的包路径,多个路径用","号隔开
6 | #配置的包路径粒度越细越好,但是越细的粒度不利于开发时候类和包的新增与变更
7 | app.base_package=com.axe
8 |
9 | #如果工程内有jsp或者其他view层的静态文件,这里需要指定这些文件的路径
10 | # 比如src/main/webapp下,有static文件夹里放的是静态css、图片、js等文件
11 | # 比如src/main/webapp下,有view文件夹里放的是jsp文件
12 | #app.asset_path=/static
13 | #app.jsp_path=/view
14 |
15 | #文件上传大小限制
16 | #app.upload_limit=0
17 |
18 | #指定好邮箱,框架会将异常信息发送给这些邮箱,多个邮箱用","号分隔
19 | axe.email_notification=false
20 | #axe.email_server_host=smtp.163.com
21 | #axe.email_server_port=25
22 | #axe.email_server_user_name=xxxxxxx@163.com
23 | #axe.email_server_password=xxxxxxxxxxxxx
24 | #axe.email_title=your application name
25 | #axe.email_error_addressee=xxxxxxx@qq.com
26 |
27 | #是否可以访问axe后台,false表示关闭/axe的访问,建议只在本地和测试环境打开
28 | axe.home=true
29 |
30 | #------------------2.数据源配置--------------------
31 | #指定数据源
32 | # 可以指定多个,比如 jdbc.datasource=druid,api,united,pointsShop,aio,card
33 | # axe-datasource-dbcp是axe框架提供的默认数据源
34 | # 可以使用自己的数据源,用法参考README里的数据源一节
35 | # !如果不需要连接数据,则配置 jdbc.datasource= 即可,后续配置项需全部删除
36 | #jdbc.datasource=axe-datasource-dbcp
37 | jdbc.datasource=
38 |
39 | #是否自动建表
40 | #jdbc.datasource.axe-datasource-dbcp.auto_create_table=true
41 |
42 | #是否打印sql语句
43 | #jdbc.datasource.axe-datasource-dbcp.show_sql=true
44 |
45 | #数据库编码,支持emoji!MySql使用
46 | #jdbc.datasource.axe-datasource-dbcp.character=utf8mb4
47 |
48 | #数据库校验编码,支持emoji!MySql使用
49 | #jdbc.datasource.axe-datasource-dbcp.collate=utf8mb4_unicode_ci
50 |
51 | #如果使用axe-datasource-dbcp,需要在axe.properties里指定好jdbc的配置
52 | # 如果使用自己的数据源比如druid,则此段配置(从{到})不需要,可以另外写配置文件。
53 | # {
54 | #jdbc.username=
55 | #jdbc.password=
56 | #jdbc.url=jdbc:mysql://{{ip:port}}/{{databseName}}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE
57 | #jdbc.driver=com.mysql.jdbc.Driver
58 | #jdbc.connection_pool_size=10
59 | # }
--------------------------------------------------------------------------------
/first_project/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Configure logging for testing: optionally with log file
2 | #log4j.rootLogger=DEBUG, stdout, socket
3 | log4j.rootLogger=ERROR,stdout
4 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
5 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
6 | log4j.appender.stdout.layout.ConversionPattern=%d - %m%n
7 |
--------------------------------------------------------------------------------
/unpublished/unpublished.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DongyuCai/Axe/3b58ecd5384ad6c8ffeb23ae2948cb138944edd9/unpublished/unpublished.zip
--------------------------------------------------------------------------------