構建springmvc+mybatis+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 {
}.net

3. 編寫sso單點登陸認證的annotion類,IsLogin.java內容以下:xml

package com.sml.sz.common.annotation;get

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 {

}
4. 編寫Bean的中文註解:

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分佈式平臺》,但願你們持續關注後面的文章!

相關文章
相關標籤/搜索