(八) 构建Springmvc+dubbo分布式平台-maven构建ant-framework核心代码annotation

上一篇咱们介绍《构建dubbo分布式平台-maven构建ant-framework框架的pom.xml文件配置》,子项目的基础框架已经构建完成,今天重点讲解的是ant-framework核心代码的编写过程。java

其中ant-framework是ant分布式框架的基础核心框架,其中包括CRUD,MVC等一系列基类和模板。另外定义了spring,mybatis,wink等底层框架扩展项目,具体内容包括:spring

1. annotation相关注解:数据签名注解、用户是否走sso登陆注解等,今天咱们着重讲解一下annotation的编写。mybatis

提醒:自定义annotation能够有效的将咱们须要注解的类、方法、字段根据业务所需进行定义可配置化。框架

2. 编写数字签名的annotaion的类,DataSign.java内容以下:maven

package com.sml.sz.common.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 数据签名注解
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DataSign {
}分布式

3. 编写sso单点登陆认证的annotion类,IsLogin.java内容以下:学习

package com.sml.sz.common.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 登陆注解
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface IsLogin {

}xml

4. 编写Bean的中文注解:get

package com.sml.sz.common.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* bean中文名注解
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface FieldName {
String value();
}源码

文章内容不写太多,但愿你们可以掌握每个知识点,这里的注解后面会所有定义在方法上,具体的业务和实现后面会讲解到。更多详细源码参考来源

欢迎你们跟我一块儿学习《构建dubbo分布式平台》,但愿你们持续关注后面的文章!

愿意了解框架技术或者源码的朋友直接求求交流分享技术:2042849237分布式的一些解决方案,有愿意了解的朋友能够找咱们团队探讨

相关文章
相关标签/搜索