´«ÖDz¥¿Íjavaѧϰ Spring³õ²½
ÎÒ½ñÌìѧϰÁËÐìÀÏʦ½²µÄSpring֪ʶ£¬ÎÒ×öÁ˼òµ¥µÄ±Ê¼Ç£º
·´Ïò¿ØÖÆ(IOC)
£º
bean¹¤³§:×î¼òµ¥µÄÈÝÆ÷£¬ÌṩÁË»ù´¡µÄÒÀÀµ×¢ÈëÖ§³Ö¡£´´½¨¸÷ÖÖÀàÐ͵ÄBean.
Ó¦ÓÃÉÏÏÂÎÄ:½¨Á¢ÔÚbean¹¤³§»ù´¡Ö®ÉÏ£¬Ìṩϵͳ¼Ü¹¹·þÎñ¡£
ClassPathXmlApplicationContext:´ÓÀà·¾¶ÖмÓÔØ¡£
FileSystemXmlApplicationContext:´ÓÎļþϵͳ¼ÓÔØ¡£
XmlWebApplicationContext:´ÓwebϵͳÖмÓÔØ¡£
Ó¦ÓÃÉÏÏÂÎÄÓëbean
¹¤³§µÄÇø±ð£º
bean¹¤³§ÑÓ³Ù¼ÓÔØËùÓÐbean£¬Ö±µ½getBean()·½·¨±»µ÷Óá£
Ó¦ÓÃÉÏÏÂÎÄ»áÔÚÆô¶¯ºóÔ¤ÔØÈëËùÓе¥Àýbean.ÕâÑù¿ÉÈ·±£Ó¦Óò»ÐèÒªµÈ´ýËûÃDZ»´´½¨¡£
bean
µÄÉúÃüÖÜÆÚ
bean±»ÔØÈëµ½ÈÝÆ÷ÖÐʱ£¬ËûµÄÉúÃüÖÜÆھͿªÊ¼ÁË¡£bean¹¤³§ÔÚÒ»¸öbean¿ÉÒÔʹÓÃÇ°Íê³ÉºÜ¶à¹¤×÷£º
1.ÈÝÆ÷Ñ°ÕÒbeanµÄ¶¨ÒåÐÅÏ¢²¢ÊµÀý»¯¡£
2.ʹÓÃÒÀÀµ×¢È룬spring°´bean¶¨ÒåÐÅÏ¢ÅäÖÃbeanµÄËùÓÐÊôÐÔ¡£
3.ÈôbeanʵÏÖÁËBeanNameAware½Ó¿Ú£¬¹¤³§µ÷ÓÃBeanµÄsetBeanName
£¨£©·½·¨´«µÝbeanµÄID¡£
4.ÈôbeanʵÏÖÁËBeanFactoryAware½Ó¿Ú£¬¹¤³§µ÷ÓÃsetBeanFactory£¨£©
·½·¨´«È빤³§×ÔÉí¡£
5.ÈôBeanPostProcessorºÍbean¹ØÁª£¬ÔòËüÃǵÄ
postProcessBeforeInitialization()·½·¨±»µ÷Óá£
6.ÈôbeanÖ¸¶¨ÁËini-method·½·¨¡¢£¬Ëü½«±»µ÷Óá£
7.×îºó£¬ÈôÓÐBeanPostProcessorºÍbean¹ØÁª£¬ÔòËüÃǵÄ
postProcessAfterInitialization()·½·¨±»µ÷Óᢡ£
½«bean´Ó¹¤³§ÖÐɾµôÓÐÁ½ÖÖ·½·¨£º
1.ÈôbeanʵÏÖÁËDisposableBean½Ó¿Ú£¬
distroy()·½·¨±»µ÷Óá£
2.Èç¹ûÖ¸¶¨Á˶¨ÖƵÄÏú»Ù·½·¨£¬¾Íµ÷ÓÃÕâ¸ö·½·¨¡£
beanÔÚÓ¦ÓÃÉÏÏÂÎÄÖеÄÉúÃüÖÜÆÚºÍÔÚbean¹¤³§
µÄÉúÃüÖÜÆÚΨһ²»Í¬µÄÊÇ£ºÈôbeanʵÏÖÁË
ApplicationContextAware()½Ó¿Ú£¬
setApplicationContext()·½·¨»á±»µ÷Óá£
¶Ôbean
¹¤³§½øÐкó´¦Àí£º
BeanPostProcessorÔÚbeanÔØÈëºó£¬¶Ôbean½øÐÐһЩºó´¦Àí¹¤×÷¡£¶øBeanFactoryPostProcessorÔÚbean¹¤³§ÔØÈëËùÓÐbeanµÄ¶¨Òåºó£¬ÊµÀý»¯bean֮ǰ£¬¶ÔBean¹¤³§×öһЩºó´¦Àí¹¤×÷¡£
¡¡ public
interface BeanFactoryPostProcessor{
public void postProcessorBeanFactory(…);
}
Èç¹ûʹÓõÄÊÇÓ¦ÓÃÉÏÏÂÎIJ»ÐèÒ
Ïà¹ØÎĵµ£º
2. ²»Òª×öÖظ´µÄ¹¤×÷¡£
ʹÓó£¼ûµÄ¡¢¾¹ý֤ʵµÄ¿ò¼Ü£¬Èç Apache Struts¡¢JavaServer Faces ºÍ Eclipse RCP¡£Ê¹Óþ¹ý֤ʵµÄģʽ¡£
»Øµ½ÎÒÃÇ¿ªÊ¼°ïÖú¿Í»§Ê¹ÓøճöÏÖµÄ Java EE ±ê×¼µÄʱºò£¬ÎÒÃÇ·¢ÏÖ£¨ºÍÐí¶àÆäËûÈËÒ»Ñù£©£¬Í¨¹ýÖ±½ÓʹÓûù´¡µÄ Servlet ºÍ JSP ¹æ·¶¹¹½¨ UI Ó¦ÓóÌÐòÀ´¿ª·¢Óû§½Ó¿Ú¿ª·¢¿ò¼Ü£¬¿ÉÒÔ¼«´óµØÌḠ......
³¢ÊÔÓÃDOM4j½âÎöspringÅäÖÃÎļþʱ,µÚÒ»²½¶ÁÈ¡Îļþʱ£¬»ñȡ·¾¶¾ÍÓöµ½ÁËÎÊÌ⣬¡£¡£¡£¾¹ýgoogleÁËn+log n ´Î¸öÒ³Ã棬²ÅËãÓÐÁ˸ö´ÖdzµÄÈÏʶ£¬ÏÂÃæ¾ÍÈÃÎÒÓüò¶ÌµÄ»°ÓïÀ´×ܽáһϣ¨ºÃÏñÕâ¶Î¾ÍÈ«ÊÇ·Ï»°¡£¡£¡££©¡£¡£¡£
1¡¢springµÄÅäÖÃÎļþ´æ·ÅλÖÃÓÉweb.xmlÀïµÄcontextConfigLocationÀ´È·¶¨£¬Ò»°ãÊÇ·ÅÔÚweb-inf»òÕßÊÇsrc¸ùÄ¿Â¼Ï ......
Ö»Õë¶Ô²»Õý³£µÄÌõ¼þ²ÅʹÓÃÒì³£
Òì³£Ö»Ó¦¸Ã±»ÓÃÓÚ²»Õý³£µÄÌõ¼þ£¬ËüÃÇÓÀÔ¶²»Ó¦±»ÓÃÓÚÕý³£µÄ¿ØÖÆÁ÷¡£
ÏÂÃæÊÇÒ»¸öÓÃÒì³£×÷±éÀú½áÊøÌõ¼þµÄÀÄÓÃÒì³£µÄÀý×Ó£º
//horrible abuse of exceptions. Don't ever do this!
try{
int i=0;
while(true)a[i++].f();
}catch(ArrayIndexOutOfBoundsException e){
......
JAVAÓкöණ¶«
Ç°¼¸Ìì¿´ÁË¿´ ûÔõôͨÃ÷°×
½ñÌìÔ糿3µã45¿´ÁË»á ¹ú¼ÊÃ×À¼ ¿Í³¡ÌôÕ½ ÇжûÎ÷µÄ±ÈÈü
°¥Ñ½ ºÜˬ
ħÁ¦ÄñÖØ·µË¹Ì¹¸£ÇÅ
ÎÒ¾ÍÏë°¡ ÕâJAVA²»ÊÇÓиö»Ø·ÃµÄº¯ÊýÂð
ºÇºÇ ÍüÁ˽ÐɶÁË
°²ÇÐÂåµÙÔÚÃ×À¼Ê±ÆÚ¾³£±»¶¯µÄ°¤µ½Ä§Á¦ÄñµÄ¹ú¼ÊÃ×À¼µÄ´òѹ
ÕâºÎ³¢²»ÊÇJAVAÀïÃæµÄÄǸö¼Ì³ÐÂð
»¹ÓÐ ½ñÌì¹úÃ×ÔÚ·æÏßÉÏʹ ......
Ò»¡¢Ê²Ã´ÊÇ·´É䣺
·´ÉäµÄ¸ÅÄîÊÇÓÉSmithÔÚ1982ÄêÊ×´ÎÌá³öµÄ£¬Ö÷ÒªÊÇÖ¸³ÌÐò¿ÉÒÔ·ÃÎÊ¡¢¼ì²âºÍÐÞ¸ÄËü±¾Éí״̬»òÐÐΪµÄÒ»ÖÖÄÜÁ¦¡£ÕâÒ»¸ÅÄîµÄÌá³öºÜ¿ìÒý·¢Á˼ÆËã»ú¿ÆѧÁìÓò¹ØÓÚÓ¦Ó÷´ÉäÐÔµÄÑо¿¡£ËüÊ×Ïȱ»³ÌÐòÓïÑÔµÄÉè¼ÆÁìÓòËù²ÉÓÃ,²¢ÔÚLispºÍÃæÏò¶ÔÏó·½ÃæÈ¡µÃÁ˳ɼ¨¡£ÆäÖÐLEAD/LEAD++ ¡¢OpenC+ ......