[ת]JavaÖ®metadata(ÔªÊý¾Ý)Ïê½â
Ò²¿ÉÄܸÕÌýµ½ÔªÊý¾ÝÄã»áÓеãÄ°Éú£¬ÆäʵÈκÎÒ»¸öʹÓùýstruts£¬ejb»òÕßhibernateµÄ¿ª·¢ÈËÔ±¶¼ÔÚ²»Öª²»¾õÖÐʹÓÃÔªÊý¾Ý¡£ËùνµÄÔªÊý¾ÝÊÇÖ¸ÓÃÀ´ÃèÊöÊý¾ÝµÄÊý¾Ý£¬¸üͨË×Ò»µã¾ÍÊÇÃèÊö´úÂë¼ä¹Øϵ£¬»òÕß´úÂëÓëÆäËü×ÊÔ´£¨ÀýÈçÊý¾Ý¿â±í£©Ö®¼äÄÚÔÚÁªÏµµÃÊý¾Ý£¬¶ÔStrutsÀ´Ëµ¾ÍÊÇstruts-config.xml,¶ÔejbÀ´Ëµ¾ÍÊÇejb-jar.xmlºÍ³§ÉÌ×Ô¶¨ÒåµÄxmlÎļþ£¬¶ÔhibernateÀ´Ëµ¾ÍÊÇhbmÎļþ¡£
µ«ÊÇÏÖÓеÄËùÓеÄÒÔxml»òÕßÆäËü·½Ê½´æÔÚµÄÔªÊý¾ÝÎļþ¶¼ÓÐÒÔÏÂһЩ²»±ãÖ®´¦£¬µÚÒ»£¬Óë±»ÃèÊöµÄÎļþ·ÖÀ룬²»ÀûÓÚÒ»ÖÂÐÔά»¤¡£µÚ¶þ£¬ËùÓеÄÕâЩÎļþ¶¼ÊÇasciiÎļþ£¬Ã»ÓÐÏÔʾµÄÀàÐÍÖ§³Ö¡£»ùÓÚÔªÊý¾ÝµÄ¹ã·ºÓ¦ÓÃJDK1.5ÒýÈëÁËAnnotationµÄ¸ÅÄîÀ´ÃèÊöÔªÊý¾Ý¡£Ê¹Óùý.netµÄ¿ª·¢ÈËÔ±Ò»¶¨ºÜÊìϤԪÊý¾ÝµÄ¸ÅÄԪÊý¾ÝµÄ¸ÅÄîÔÚ.netÖгÉΪAttribute¡£
ÔÚJavaÖÐÔªÊý¾ÝÒÔ±êÇ©µÄÐÎʽ´æÔÚÓÚJava´úÂëÖУ¬ÔªÊý¾Ý±êÇ©µÄ´æÔÚ²¢²»Ó°Ïì³ÌÐò´úÂëµÄ±àÒëºÍÖ´ÐУ¬ËüÖ»ÊDZ»ÓÃÀ´Éú³ÉÆäËüµÄÎļþ»òÕëÔÚÔËÐÐʱ֪µÀ±»ÔËÐдúÂëµÄÃèÊöÐÅÏ¢¡£
×ÛÉÏËùÊö£º
µÚÒ»£¬ ÔªÊý¾ÝÒÔ±êÇ©µÄÐÎʽ´æÔÚÓÚJava´úÂëÖС£
µÚ¶þ£¬ ÔªÊý¾ÝÃèÊöµÄÐÅÏ¢ÊÇÀàÐÍ°²È«µÄ£¬¼´ÔªÊý¾ÝÄÚ²¿µÄ×ֶζ¼ÊÇÓÐÃ÷È·ÀàÐ͵ġ£
µÚÈý£¬ ÔªÊý¾ÝÐèÒª±àÒëÆ÷Ö®ÍâµÄ¹¤¾ß¶îÍâµÄ´¦ÀíÓÃÀ´Éú³ÉÆäËüµÄ³ÌÐò²¿¼þ¡£
µÚËÄ£¬ ÔªÊý¾Ý¿ÉÒÔÖ»´æÔÚÓÚJavaÔ´´úÂ뼶±ð£¬Ò²¿ÉÒÔ´æÔÚÓÚ±àÒëÖ®ºóµÄClassÎļþÄÚ²¿¡£
ÈçºÎ´´½¨ÔªÊý¾ÝÀàÐÍ
Ïñ¸÷ÖÖÀàÓпÉÒÔ¶¨Ò岻ͬµÄÀàÐÍÒ»Ñù£¬ÔÊý¾ÝÒ²¿ÉÒÔ¶¨Ò岻ͬµÄÀàÐÍ¡£ÏÖÔÚΪֹ£¬JavaÓïÑÔÖÐÒѾÓÐÁËËÄÖÖÖÖµÄÀàÐÍ£º¶ÔÏóÀࣨclass£©£¬Ã¶¾Ù£¨enum£©£¬½Ó¿Ú£¨interface£©ºÍÔªÊý¾Ý£¨@interface£©¡£ÆäʵJavaÖеÄÔªÊý¾ÝµÄ¸ÅÄî¼´ÎüÊÕÁË.NetÖÐAttributeµÄ¸ÅÄÓÐÎüÊÕÁË.netÖÐpropertyµÄ¸ÅÄî¡£
Annotation¶¨Òå
Annotation¶¨ÒåÓ﷨Ϊ£º
modifiers @interface AnnotationName
{
element declaration1
element declaration2
. . .
}
modifiersÖ¸£ºpublic£¬protected£¬private»òÕßĬÈÏÖµ£¨Ê²Ã´Ò²Ã»ÓУ©¡£
Ò»¸öÔªËصÄÉùÃ÷£¨element declaration£©Ö¸£º
type elementName();
»òÕß
type elementName() default value;
ÀýÈçÏÂÃæ´úÂ붨ÒåÁËÒ»¸öAnnotation£º
public @interface BugReport
{
String assignedTo() default "[none]";
int severity() = 0;
}
¶ø¿ÉÒÔͨ¹ýÒÔϵķ½Ê½À´ÉùÃ÷Annotation£º
AnnotationName(elementName1=value1, elementName2=value2, . . .)
ÔªÊýÉùÃ÷µÄ˳ÐòûÓйØϵ£¬ÓÐĬÈÏÖµµÄÔªËصÄÉùÃ÷¿ÉÒÔ²»ÁÐÔÚ³õʼ»¯±íÖУ¬´ËʱËûÃÇʹÓÃĬÈÏÖµ¡£ÀýÈ磬¸ù¾ÝÉÏÊö¶¨ÒåÈçϵÄÈý¸öAnnotationµÄÉùÃ÷Êǵȼ۵ģº
@BugReport(assignedTo="Harry", severity=0)
@BugReport(severity=0£¬ assignedTo="Harry")
@BugReport(assignedTo="Harry")
ÄÇЩֻÓÐÒ»¸öÔªËØ£¬ÇÒÔªËØÃû×Ö½ÐvalueµÄAnnotation¿ÉÒÔʹÓÃÈçϵķ½Ê½ÉùÃ÷£º
AnnotationName£¨¡°somevalue¡±£©
AnnotationÖÐÔªËصÄÀàÐͱØÐëÊÇÏÂÊöÀàÐÍ£¬»òÕßÕâЩÀàÐ͵Ä×éºÏ£º
l »ù±¾ÀàÐÍ (int, short, long, byte, char, double, float, or boolean)
l ×Ö·û´´£¨String£©
l ÀࣨClass (¿ÉÒÔÊÇÐÎÈç Class<? extends MyClass>)µÄ·ºÐÍÀࣩ
l ö¾ÙÀàÐÍ£¨enum£©
l Ò»¸öAnnotationÀàÐÍ£¨annotation£©
l ÉÏÊöÀàÐ͹¹³ÉµÄÊý×é
Èç¹ûAnnotationµÄÔªËØÊÇÊý×飬Ôò¿ÉÒÔ×öÈçÏÂÉùÃ÷£º
@BugReport(. . ., reportedBy={"Harry", "Carl"})
Èç¹ûÊý×éÖÐÖ»ÓÐÒ»¸öÔªËØʱ¿ÉÒÔ×öÈçÏÂÉùÃ÷£º
@BugReport(. . ., reportedBy="Joe") // OK, same as {"Joe"}
Èç¹ûAnnotationÔªËØÀàÐÍΪAnnotationʱ¿ÉÒÔ×öÈçÏÂÉùÃ÷£º
@BugReport(testCase=@TestCase(id="3352627"), . . .)
¿ÉÒÔ¶ÔÈç϶ÔÏóÌí¼ÓAnnotation£º
l Packages
l Classes (including enum)
l Interfaces (including annotation interfaces)
l Methods
l Constructors
l Instance fields (including enum constants)
l Local variables
l Parameter variables
ÍƼöÐÅÏ¢
- ÔÝÎ޼Ǽ
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- java urlÖØд¼¼Êõ(UrlReWriter)
- [ת]JavaµÄÊý×飨Array£©¡¢Vector¡¢ArrayLis....
- jsp»·¾³ÏÂajaxÂÒÂëÎÊÌâµÄ½â¾ö
- JSP¼¼Êõ Ö¸Áî ÂÒÂëÎÊÌâ ÔËÐÐÔÀíºÍ¾Å´óÒþʽ¶ÔÏó web¿ª·¢µÄË....
- JAVA ˮӡ ͼƬ ÎÄ×Ö
- java¶þ½øÖÆ£¬ÔÂë¡¢·´Âë¡¢²¹Â롢λÔËËã
- Java WebÓ¦ÓÃÆô¶¯¼ä¸ôÖ´ÐеijÌÐò
- jspÉú³ÉxmlÎļþʾÀý
- javaÖÐÀà±äÁ¿¡¢Àà·½·¨¡¢ÊµÀý±äÁ¿¡¢ÊµÀý·½·¨
- JSPÒ³ÃæµÄÎåÖÖÌøת·½·¨
ÆÀÂÛ