001package springdao; 002 003import java.lang.annotation.Documented; 004import java.lang.annotation.ElementType; 005import java.lang.annotation.Inherited; 006import java.lang.annotation.Retention; 007import java.lang.annotation.RetentionPolicy; 008import java.lang.annotation.Target; 009 010/** 011 * Inject a {@link RepositoryManager} into a annotated 012 * {@link RepositoryManager}.<br/> 013 * 注入{@link RepositoryManager} 到有注釋的{@link RepositoryManager}.<br/> 014 * Usage(用法):<br/> 015 * Initializate a {@link DaoAnnotationBeanPostProcessor} bean in your spring 016 * context.<br/> 017 * 在您的Spring環境內建立一個{@link DaoAnnotationBeanPostProcessor} bean 就可以了.<br/> 018 * <pre style="color:blue"> 019 * @DaoManager(Entity.class) public RepositoryManager<Entity> entityManager; 020 * </pre> Will inject and create a RepositoryManager implementation innto 021 * entityManager.<br/> 022 * 將會建立一個RepositoryManager實例並插入 entityManager. 023 * 024 * @author Kent Yeh 025 */ 026@Retention(RetentionPolicy.RUNTIME) 027@Target({ElementType.FIELD, ElementType.METHOD}) 028@Documented 029@Inherited 030public @interface DaoManager { 031 032 public static String LOCK_READ = "READ"; 033 public static String LOCK_WRITE = "WRITE"; 034 public static String LOCK_OPTIMISTIC = "OPTIMISTIC"; 035 public static String LOCK_OPTIMISTIC_FORCE_INCREMENT = "OPTIMISTIC_FORCE_INCREMENT"; 036 public static String LOCK_PESSIMISTIC_READ = "PESSIMISTIC_READ"; 037 public static String LOCK_PESSIMISTIC_WRITE = "PESSIMISTIC_WRITE"; 038 public static String LOCK_PESSIMISTIC_FORCE_INCREMENT = "PESSIMISTIC_FORCE_INCREMENT"; 039 public static String LOCK_NONE = "NONE"; 040 041 /** 042 * Class assoicated with {@link RepositoryManager}.<br/> 043 * {@link RepositoryManager} 相關的一般化類別 044 * 045 * @return name of Dao manager. 046 */ 047 Class value() default Object.class; 048 049 /** 050 * Naming object to be turned into a Spring bean in case of an autodetected 051 * component.<br/> 052 * 註聞為Spring bean., 若已存在則取用,若不存在則建立 053 * 054 * @return name of spring bean. 055 */ 056 String name() default ""; 057 058 /** 059 * Naming dao object to be turned into a Spring bean in case of an 060 * autodetected component.<br/> 061 * 將 dao 註聞為Spring bean, 若已存在則取用,若不存在則建立 062 * 063 * @return name of dao spring bean. 064 */ 065 String daoName() default ""; 066 067 /** 068 * 069 * @return {@link RepositoryManager RepositoryManager} 070 */ 071 Class<? extends RepositoryManager> baseManagerType() default RepositoryManager.class; 072 073 /** 074 * Auto register bean with {@link #value() value}'s simple class name suffix 075 * with "Manager" if not assigned {@link #name() name}, also 076 * register dao bean with {@link #value() value}'s simple class name suffix 077 * with "Dao" if not assigned {@link #daoName() daoName}<br/> 078 * 如果沒有指定{@link #name() name},則自動以{@link #value() value}的類別名稱加上"Manager"註冊, 079 * 同樣地,若未指定{@link #daoName() daoName},亦會以{@link #value() value}的類別名稱加上"Dao"註冊, 080 * 081 * @return spring bean's name 082 */ 083 boolean autoRegister() default true; 084}