Java Annotation ½éÉÜ£¨×ª£©
×÷Õß:cleverpig(×÷ÕßµÄBlog:http://blog.matrix.org.cn/page/cleverpig)
ÔÎÄ:http://www.matrix.org.cn/resource/article/44/44055_Java+Annotation+Reflect.html
¹Ø¼ü×Ö:java,annotation,reflect
Ç°ÑÔ£º
ÔÚÉÏƪÎÄÕ¡¶Java AnnotationÈëÃÅ¡·ÖиÅÒªÐԵĽéÉÜÁËAnnotationµÄ¶¨Ò塢ʹÓ㬷¶Î§º¸Ç½Ï¹ã£¬µ«ÊÇÉî¶È²»¹»¡£ËùÒÔ×÷ÕßÔÚ¡¶Java AnnotationÈëÃÅ¡·ºó£¬¼ÌÐøÕûÀíÁËAnnotationµÄ¸ÅÄîºÍ֪ʶµã£¬Óëϲ»¶researchµÄÅóÓÑÃǹ²Ïí¡£
ÔĶÁÌáʾ£ºÎÄÖÐÌáµ½µÄ³ÌÐò³ÉÔ±»òÕß³ÌÐòÔªËØÊÇÒ»¸ö¸ÅÄָ×é³É³ÌÐò´úÂëµÄµ¥Ôª£ºÈçÀà¡¢·½·¨¡¢³ÉÔ±±äÁ¿¡£
Ò»¡¢Annotation¾¿¾¹ÊÇʲô£¿
Annotation ÌṩÁËÒ»ÌõÓë³ÌÐòÔªËعØÁªÈκÎÐÅÏ¢»òÕßÈκÎÔªÊý¾Ý£¨metadata£©µÄ;¾¶¡£´ÓijЩ·½Ãæ¿´£¬annotation¾ÍÏñÐÞÊηûÒ»Ñù±»Ê¹Ó㬲¢Ó¦ÓÃÓÚ°ü¡¢ÀàÐÍ¡¢¹¹Ôì·½·¨¡¢·½·¨¡¢³ÉÔ±±äÁ¿¡¢²ÎÊý¡¢±¾µØ±äÁ¿µÄÉùÃ÷ÖС£ÕâЩÐÅÏ¢±»´æ´¢ÔÚannotationµÄ“name=value”½á¹¹¶ÔÖС£ annotationÀàÐÍÊÇÒ»ÖÖ½Ó¿Ú£¬Äܹ»Í¨¹ýjava·´ÉäAPIµÄ·½Ê½Ìṩ¶ÔÆäÐÅÏ¢µÄ·ÃÎÊ¡£
annotationÄܱ»ÓÃÀ´ÎªÄ³¸ö³ÌÐòÔªËØ£¨Àà¡¢·½·¨¡¢³ÉÔ±±äÁ¿µÈ£©¹ØÁªÈκεÄÐÅÏ¢¡£ÐèҪעÒâµÄÊÇ£¬ÕâÀï´æÔÚ×ÅÒ»¸ö»ù±¾µÄDZ¹æÔò£ºannotaion²»ÄÜÓ°Ïì³ÌÐò´úÂëµÄÖ´ÐУ¬ÎÞÂÛÔö¼Ó¡¢É¾³ý annotation£¬´úÂ붼ʼÖÕÈçÒ»µÄÖ´ÐС£ÁíÍ⣬¾¡¹ÜһЩannotationͨ¹ýjavaµÄ·´Éäapi·½·¨ÔÚÔËÐÐʱ±»·ÃÎÊ£¬¶øjavaÓïÑÔ½âÊÍÆ÷ÔÚ¹¤×÷ʱºöÂÔÁËÕâЩannotation¡£ÕýÊÇÓÉÓÚjavaÐéÄâ»úºöÂÔÁËannotation£¬µ¼ÖÂÁËannotationÀàÐÍÔÚ´úÂëÖÐÊÇ“²»Æð×÷ÓԵģ»Ö»ÓÐͨ¹ýijÖÖÅäÌ׵Ť¾ß²Å»á¶ÔannotationÀàÐÍÖеÄÐÅÏ¢½øÐзÃÎʺʹ¦Àí¡£±¾ÎÄÖн«º¸Ç±ê×¼µÄannotationºÍmeta- annotationÀàÐÍ£¬Åã°éÕâЩannotationÀàÐ͵Ť¾ßÊÇjava±àÒëÆ÷£¨µ±È»ÒªÒÔijÖÖÌØÊâµÄ·½Ê½´¦ÀíËüÃÇ£©¡£
ÓÉÓÚÉÏÊöÔÒò£¬annotationÔÚʹÓÃʱʮ·Ö¼ò±ã¡£Ò»¸ö±¾µØ±äÁ¿¿ÉÒÔ±»Ò»¸öÒÔNonNullÃüÃûµÄannotationÀàÐÍËù±ê×¢£¬À´×÷Ϊ¶ÔÕâ¸ö±¾µØ±äÁ¿²»Äܱ»¸³ÓènullÖµµÄ¶ÏÑÔ¡£¶øÎÒÃÇ¿ÉÒÔ±àдÓëÖ®ÅäÌ×µÄÒ»¸öannotation´úÂë·ÖÎö¹¤¾ß£¬Ê¹ÓÃËüÀ´¶Ô¾ßÓÐÇ°Ãæ±äÁ¿µÄ´úÂë½øÐнâÎö£¬²¢ÇÒ³¢ÊÔÑéÖ¤Õâ¸ö¶ÏÑÔ¡£µ±È»ÕâЩ´úÂë²¢²»±Ø×Ô¼º±àд¡£ÔÚJDK°²×°ºó£¬ÔÚJDK/binĿ¼ÖпÉÒÔÕÒµ½ÃûΪ“apt”µÄ¹¤¾ß£¬ËüÌṩÁË´¦ÀíannotationµÄ¿ò¼Ü£ºËüÆô¶¯ºóɨÃèÔ´´úÂëÖеÄannotation£¬²¢µ÷ÓÃÎÒÃǶ¨ÒåºÃµÄannotation´¦ÀíÆ÷Íê³ÉÎÒÃÇËùÒªÍê³ÉµÄ¹¤×÷£¨±ÈÈçÑé֤ǰÃæÀý×ÓÖеĶÏÑÔ£©¡£Ëµµ½ÕâÀ annotationµÄÇ¿´ó¹¦ÄÜËƺõ¿ÉÒÔÌæ´úXDocletÕâÀàµÄ¹
Ïà¹ØÎĵµ£º
Web Service¸ÅÊö
ʲôÊÇWeb Service
Web ServiceÊÇÄܹ»»ùÓÚÍøÂ磬ÓÈÆäÊÇ»ùÓÚÍòάÍø£¨World Wide
Web£©Ö±½Óµ÷ÓõÄÄܹ»´¦ÀíÀëÉ¢ÈÎÎñ»òÁ¬ÐøÈÎÎñµÄÈí¼þÄ£ÐÍ¡£Ä¿Ç°½ÏΪÁ÷ÐеÄÓ¦ÓÃÊÇ£¬ÓÉÒ»¼Ò¹«Ë¾¶ÔÆäרÓÐÊý¾Ý½øÐзâ×°£¬ÌṩWeb
Service£¬È»ºóÆäËü¹«Ë¾¾Í¿ÉÒÔͨ¹ýInternetÀ´¶¯Ì¬Ê¹ÓÃÕâÐ ......
ÏÂÃæµÄ³ÌÐòÔÚÑ°³£µÄHello world³ÌÐòÖÐÌí¼ÓÁËÒ»¶Î²»Ñ°³£µÄÇúÕÛ²Ù×÷¡£ÄÇô£¬Ëü½«»á´òÓ¡³öʲôÄØ£¿
public class HelloGoodbye {
public static void main(String[] args) {
try {
System.out.println("Hello world");
System.exit(0);
} finally {
System.o ......
µÚÒ»Õ ¸ÅÊö
°æȨÉùÃ÷
´ËÎĵµÓɱ¾È˸ºÔðÕûÀí×ܽᣬ²¢¶Ô¸ÃÎĵµ±£ÓÐÓÐÏÞÔðÈÎȨÀû£¬´ËÎĵµÖ»ÄÜÓÃÓÚѧϰÒÔ¼°½Ìѧ£¬ÇëÎðÓÃ×÷ÉÌÒµÓÃ;£¬Òò´Ë¶ø
²úÉúµÄ·¨ÂÉÎÊÌ⣬±¾ÈËÒ»¸Å²»¸ºÔð¡£ ±¾ÈËÉùÃ÷£¬´ËÎĵµ×ÊÁÏΪ±¾È˽Ìѧ¾ÑéºÍÍøÂç×ÊÁÏÊÕ¼¯ºÏ²¢Ö®³É¹û ......
Java·´Éä»úÖÆ
ÕªÒª
Reflection ÊÇJava±»ÊÓΪ¶¯Ì¬£¨»ò×¼¶¯Ì¬£©ÓïÑÔµÄÒ»¸ö¹Ø¼üÐÔÖÊ¡£Õâ¸ö»úÖÆÔÊÐí³ÌÐòÔÚÔËÐÐʱ͸¹ýReflection APIsÈ¡µÃÈκÎÒ»¸öÒÑÖªÃû³ÆµÄclassµÄÄÚ²¿ÐÅÏ¢£¬°üÀ¨Æämodifiers£¨ÖîÈçpublic, static µÈµÈ£©¡¢superclass£¨ÀýÈçObject£©¡¢ÊµÏÖÖ®interfaces£¨ÀýÈçCloneable£©£¬Ò²°üÀ¨fieldsºÍmethodsµÄËùÓÐÐÅÏ¢£¬² ......