Spring3教程

准备好好读一下Spring3

皮皮书屋上下载了一本《Spring in Action, 3rd Edition》,最近的目标是把它通读一遍,写点读后感。

Spring 通过POJO-oriented development, DI, AOP, templates来attack complexity!

 

书中的生单词:

flock蜂拥而至

当java刚出来的时候大家很看好它,码农们纷纷flock to the language.

 

unlease释放,发泄

unleash the power of POJOs

EJB2就是个菜,SessionBean 中定义了一堆以ejb开头的与业务无关的方法需要developer实现,到底谁在用谁?

Spring很牛逼,最大程度的unleash了POJO的威力。

 

Damsel少女!

营救少女的骑士DamelRescuingKnight!

 

embark开始行动

只要quest到达,knight就要embarkOnQuest

 

repertoire某人的全部技能

紧耦合(RescueDamselQuest)  limit了knight的quest-embarking repertoire,因为Knight不光只会营救少女。

 

slay杀死
BraveKnight不只会营救少女,还能执行屠龙任务(SlayDragonQuest),  使圆桌子更圆任务(MakeRoundTableRounderQuest)。

 

blissfully幸福地

it's blissfully unaware of the fact that。。。无忧无虑地都不知道(Knight接口最后用了哪个实现)。

We're blissfully happy. 我们非常幸福快乐。

 

chronicle记录,

骑士的英勇事迹 were chronicled in song

 

minstrel歌手,艺人
它们是传说中的切面(aspect)

在骑士embark前会唱fa la la(4-6-6), 在骑士embark quest后会唱 Tee hee hee (7-7-7)


boilerplate code
样板代码
Spring通过aop声明Minstrel为切面,为knight唱赞歌。
Spring提供xxxTemplate这样的boilerplate code,让你在处理CRUD时更省心。

 

appease平息,安抚
我们在写JDBC代码时,为了appease JDBC's anger, 得自己处理抛出的异常

stir搅动,激起
更要命的是,即使在给JDBC擦屁股(各种close)时,同样会stir JDBC's anger,同样需要再一次处理抛出的异常。

cater to the demand of ..
迎合某某的要求

from cradle to grave
Spring负责管理Bean的生命周期,如果一定要加上期限,那么就是from cradle to grave(or from new to finalize())

 

 enclosing外围的,enclosing object宿主对象
如果Bean实现了ApplicationContextAware接口,那么Spring会将enclosing application context通过setApplicationContext的参数传给Bean.

Likewise,同样地
我只会用Similarly,以后尝试多用Likewise

 

第2章装配Bean

 第1章还蛮好看。第2章2.1,2.2我比较熟,直接从2.3看起:后面的故事情节基于2.1,2.2所以还是要欣赏一下

spring portfolio公文包,文件夹,投资组合。

我觉得翻译成“Spring家族“比较靠谱

If you own more than one security, you have an investment portfolio.

如果多于一种股票(证券)那么您就拥有一个投资组合

 Spring Idol偶像

翻译成"Spring达人秀”怎么样?

 

contestant选手,竞争者

set the stage布置舞台(想起了我的wedding ceremony)

conspicuously明显地
以前只会用obviously, apparently,以后多用conspicuously

juggler杂技演员,杂耍,欺骗

 beanbag ,我们小时候玩的(丢)沙包,在本书中的玩法是杂技演员将沙包掷向空中并用手接住(看谁保持在空中的沙包最多,杂耍的时间最长)

为使Stage保持单例,使用了如下技术:

initialization on demand holder


dispense分配,分发
If someone dispenses something that they own or control, they give or provide it to a number of people

 counterfeit伪造

we can be assured that可以确保。。。

out of the box开箱即用, a handful of一把,一小撮,少数

In addtion to prototype,Spring offers a handful of other scoping options out of the box.

以前老用besides,今后多用in addition to, 以前老用provider以后多用offer,out of the box开箱即用

astute精明的,狡猾的

auditorium观众席,礼堂

the details of what takes place within the turnOnLights() and turnOffLights() methods isn't terribly important.

以前老用happen,以后多用take place,以前老用very/fucking important,以后多用terribly important

 instrumentalist乐器演奏家

daunting望而生畏,
angle brackets <>尖括号
curly brackets{}花括号
square brackets[]中括号


the choice between xx and yy is up to  you,they work equally well

由你决定

terse简洁的

 

SpEL has a lot of tricks up its sleeves,锦囊妙计

 

SpEL一览:
#{...}

 

第3章,简化XML的配置.

(1)加上<context:annotation-config />, Spring才能识别@Autowired标记,需要手动在XML中注册<bean>

(2)而<context:component-scan base-package="" />是(1)的增强版。除了能识别@Autowired,还能识别

@Component,加在任何需要Spring管理的Bean上

@Controller,加在Spring MVC中的Controller上

@Repository,加在DAO层上

@Service,加在Service层

用了<context:component-scan>后,就不必再使用<context:annotation-config />, 也不用在xml中注册需要Spring管理的Bean。

 

第4章AOP
ancillary辅助的,附属的
虽然每个模块(XxxService,YyyService)的主要功能是provide services for its particular domain,但它们都需要 similar ancillary funtionalities(比如security 和 transaction)

如何重用这些公共的模块?OO的解决方式是通过使用inheritance和delegation,

如果整个应用使用同一个基类,那么继承lead to a brittle(脆弱的)object hierarchy

而代理can be cubersome因为对delegate object的复杂调用在所难免。

 

 第7章MVC

<mvc:annotation-driven/>这个标记有啥用?我就是不写,直到出错为止

作用是:JSR303-validation, message conversion, field-formattting看起来都用不上


entice诱使,怂恿
hopefully(有望) enticing the vistors to join in other conversation

 pertinent相关的,切题的

as it's most pertinent to our discussion of diplaying the home page.

spittle口水,唾沫 spitter吐口水的人

crux关键

Aside from除了

 

 



 

 

 

 

 

 

 

http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.javax.inject&version=1.0.0

posted @ 2012-08-10 17:45  松柏长青  阅读(715)  评论(0编辑  收藏  举报