Topic: Spring Core Intro

  Print this page

1.Spring Core Intro Copy to clipboard
Posted by: floater
Posted on: 2005-04-21 10:13

Here is an intro for Spring Core/LWC, comments are welcome.

I am crazy enough to write this in chinese, considering I haven't written anything in Chinese for 15 years. There are still some terms that I don't know how to translate, or don't like the general perception of certain terms, so I just use english. For instance, I saw the translation of the word "scalability", that's totally irrelevent to the english meaning:可测性。

While I don't pretend to be a Spring expert, I do intend to explore some of the powerful features in Spring and illustrate how to use them in reality.

However, due to time constraint, I can finish only the core part for now. Not sure will have time to do other parts. The good news are that xiaxin and his fellows are writing a book about Spring, and yanger and his fellows translated spring doc.

Spring Core Tutorial.rar (492.39k)

2.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: davidself
Posted on: 2005-04-21 10:49

floater居然用中文来交流,仅凭这一点就要支持。呵呵。

3.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: floater
Posted on: 2005-04-21 11:11

really tough.

hehe, I use the content to shield out things that don't belong to core. Otherwise, I could run 20 threads, just hard to manage them.

xiexie, ^_~.

4.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: wood
Posted on: 2005-04-21 11:28

hooray!!

5.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: tier3
Posted on: 2005-04-21 11:55

thanks a lot for the convenient chinese version. I suggest cjsdn pay you some money for you continuous contribution to the forum Smile

I have another concern, it was said that AOP + Use Case should be a new revolutionary trend for software development, Ivar Jacobson said it in his new book <aspect oriented software development with use case>, did you read the book? what is your standpoint for it?

A lot of people use 'Use Case', and now many people are intesreted in Aspect, but maybe a merge of them could boost the industry growth tremendously.

6.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: glistar
Posted on: 2005-04-21 13:02

cool

7.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: jigsaw
Posted on: 2005-04-21 13:28

floater写中文。。。强。。。支持。。。

顺便说一下,感觉spring把某些逻辑从java里面搬到xml里面,这样会让代码
很简洁,而且从代码来说,系统看起来不会有大量的依赖关系。
但是这种简洁的代价是加入xml,而且依赖关系依旧存在,只是藏在xml里面了。
依赖关系存在于xml里面---这样的好处是可以不用编译已经存在的代码,deploy可能会更容易/灵活
但是这样的坏处是丧失了编译器的检测
而且,一个大的系统,至少都是每天要全部ant跑一次的,多编译几次和少编译几次,我个人感觉没有区别。
而且我个人对java要敏感一些,看xml的时候就觉得脑袋费力一些。。。哪怕看
opcode都觉得比xml舒服得多。。。
如果spring一直都保持在一个微内核的层次上,(譬如pico),我会更喜欢它。

8.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: jigsaw
Posted on: 2005-04-21 13:48

对于没有容器(web/ejb)的应用,app context放在system.getproperty
里面是个好办法吗?为什么java的static final不能呢。。。
static factory不会带来不方便的

9.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: jigsaw
Posted on: 2005-04-21 14:03

总的来说。。。spring做了大量的抽象,把web开发中各个层次的问题都抽象了一遍,提取出了很多框架(这里的框架是狭义的),你可以直接使用它,
也可以抄袭它。从实践和理论两方面,都可以从中获益。
但是我个人更喜欢抄袭它而不是直接拿来用。。。赫赫。。。我想这可能是因为我参加过的项目中,凡是我能发言的,规模都不大的缘故。

另一方面,现在的ioc容器都说自己没有侵入性。我这里就问一句:
用spring架构的一个app,要花多大的代价来转移到pico/hivemind上去?

10.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: leowu2000
Posted on: 2005-04-21 14:35

Thumbs upThumbs upThumbs up

11.Re:Spring Core Intro [Re: jigsaw] Copy to clipboard
Posted by: emarket
Posted on: 2005-04-21 14:52

jigsaw wrote:
总的来说。。。spring做了大量的抽象,把web开发中各个层次的问题都抽象了一遍,提取出了很多框架(这里的框架是狭义的),你可以直接使用它,
也可以抄袭它。从实践和理论两方面,都可以从中获益。
但是我个人更喜欢抄袭它而不是直接拿来用。。。赫赫。。。我想这可能是因为我参加过的项目中,凡是我能发言的,规模都不大的缘故。

另一方面,现在的ioc容器都说自己没有侵入性。我这里就问一句:
用spring架构的一个app,要花多大的代价来转移到pico/hivemind上去?


需要做的只是做一个新的 component config file而已

12.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: why
Posted on: 2005-04-21 20:37

敝人啃中文技術著作已覺不易
floater還來個寫的
要認真細讀了
並期待"第37-38頁"的丰富內容Big Smile

順便建議把 A tutorial for Spring Web 稍修STYLE重印
令大作排版風格一致Smile

13.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: wes109
Posted on: 2005-04-21 22:22

拜读完毕

提几点建议吧(泼点凉水,嘿嘿)

大作中的Ioc原理或者一些简单使用,对偶的兴趣不大
其中的面向对象的准则部分,也是老朽长谈,不太新鲜了
还有一些其它的介绍,都比较基础了

我比较希望看到一些经验性的东西
譬如:
1、比较大的项目中,配置文件如何管理了?
2、在项目中感受到的spring的优点和缺点了?
3、好的项目实践了?
等等
其实就是实践的多一些,基础的东西少一些了

至于jigsaw说的,配置文件的问题,我觉得并不是很大的问题
用spring后,虽然要写配置文件,但犯错的机会还是比较小的
大点的项目可以对配置文件进行分拆,如公共部分的,各个模块的等等
不会成为很大的障碍
相反
用spring后,类文件明显变小了,测试简单了,用起来很舒服
很多基础的东西都有了,只要配置一下就OK了
至于可移植性,我觉得这个问题总是被夸大了
谁闲着没事经常移植来移植去的呀?哈哈

14.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: floater
Posted on: 2005-04-21 22:29

Yea, I want to rewrap them too, but my daughter doesn't like me to sit there at all, Tounge. I'll find time to do that, in fact, I want to add more too.

Most of time, I don't want to change or copy them - 更喜欢抄袭它, because when I do that, I'll have to maintain them. Using jars are much easier, you can just drop off a new jar whenever new stable versions are available. Of course, I have to make sure they are "good" jars.

用spring架构的一个app,要花多大的代价来转移到pico/hivemind上去?
This is more than container migration. If you use just the container, all you need to change is the XML file(+ the difference between containers). However, most of the time we are building j2ee, this means we are using a lot of things above container + j2ee, something built on top of containers and j2ee, like spring jdbc, jms, remoting, etc. Then we are depending on Spring. I posted something here to answer another question earlier too.

对于没有容器(web/ejb)的应用,app context放在system.getproperty
里面是个好办法吗?为什么java的static final不能呢。。。
static factory不会带来不方便的
The problem is not creating it, but how to reference it, where to store it.
I feel we need to spend more time on this one if needed(so far, I am ok since I am working on j2ee and thus have somewhere to store and don't need to reference it at all).

但是这种简洁的代价是加入xml,而且依赖关系依旧存在,只是藏在xml里面了。
Yes, still there, but more flexible, in xml, or in java code, or mock.

15.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: floater
Posted on: 2005-04-21 22:55

No, I haven't read this book, but it's on the list.

I think Aspect is a good thinking, but the tools to carry out whatever we need to do are still arguable. The big issue is encapsulation, seems nobody cares about it anymore, doesn't sound right.

And I am still learning too...

16.Re:Spring Core Intro [Re: wes109] Copy to clipboard
Posted by: floater
Posted on: 2005-04-21 23:12

wes109 wrote:
1、比较大的项目中,配置文件如何管理了?
This is in my last chapter, which is not written yet, Smile.
Basically, there are two ways, one is to build everything, and choose during runtime; or build to that particular env. The former is discussed in my doc, the later is of a build option.

2、在项目中感受到的spring的优点和缺点了?The tradeoff, in a large scope, is in my doc 1.2. The small goodies are everywhere, hard to list them all. The drawbacks are not many, the worst one is the learning curve. That's why I put OOP in the front.

3、好的项目实践了?There is no particular 好的项目实践 because every 项目 looks good. The only thing that looks worse is the managers, because they have more no-clues.

至于jigsaw说的,配置文件的问题,我觉得并不是很大的问题
用spring后,虽然要写配置文件,但犯错的机会还是比较小的
大点的项目可以对配置文件进行分拆,如公共部分的,各个模块的等等
不会成为很大的障碍
相反
用spring后,类文件明显变小了,测试简单了,用起来很舒服
很多基础的东西都有了,只要配置一下就OK了
至于可移植性,我觉得这个问题总是被夸大了
谁闲着没事经常移植来移植去的呀?哈哈

可移植性 - Sometimes, it's not for real, just to give another dimension to abstract the essentials.

17.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: keron
Posted on: 2005-04-23 12:35

Good Job!
Big Smile

18.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: sunsonbaby
Posted on: 2005-04-24 22:19

floater还会写中文?没听说过^_^

19.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: floater
Posted on: 2005-04-25 00:16

我的京腔儿音可是没改的!

20.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: foxkind
Posted on: 2005-04-28 10:23

I have a question for floater. I think your writing very wonderful and thank you for your work. But i am in puzzle for sth in the article, such as at the end of section 2.1.1, you say:
"If you want to look at the infomation from the spring, you can set the JDK's Logging or Log4j as Debug."
The question is : How can i do to get the information from the spring.
I have add a log4j.jar to the classpath, and a log4j.properties, and also set the level as debug.
But I can only get the infomation added by myself.
please help me.

21.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: floater
Posted on: 2005-04-28 10:32

Here is the log4j.properties that I am using:

log4j.rootLogger=debug, stdout, R

log4j.appender.debug=org.apache.log4j.ConsoleAppender
log4j.appender.debug.layout=org.apache.log4j.PatternLayout
log4j.appender.debug.layout.ConversionPattern=%5p [%t] (%c:%L) - %m%n

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log

log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n


The output is something like this:

INFO [main] (XmlBeanDefinitionReader.java:119) - Loading XML bean definitions from file [C:\cui\springcore\co
DEBUG [main] (XmlBeanDefinitionReader.java:123) - Using JAXP implementation [org.apache.crimson.jaxp.DocumentB
DEBUG [main] (BeansDtdResolver.java:50) - Trying to resolve XML entity with public ID [-//SPRING//DTD BEAN//EN
DEBUG [main] (BeansDtdResolver.java:54) - Trying to locate [spring-beans.dtd] under [/org/springframework/bean
DEBUG [main] (BeansDtdResolver.java:60) - Found beans DTD [c:/cui/springcore/config/spring-beans.dtd] in class
DEBUG [main] (DefaultXmlBeanDefinitionParser.java:163) - Loading bean definitions

DEBUG [main] (DefaultXmlBeanDefinitionParser.java:170) - Default lazy init 'false'

DEBUG [main] (DefaultXmlBeanDefinitionParser.java:171) - Default dependency check 'none'

DEBUG [main] (DefaultXmlBeanDefinitionParser.java:172) - Default autowire 'no'

DEBUG [main] (DefaultXmlBeanDefinitionParser.java:194) - Found 2 <bean> elements defining beans

INFO [main] (AbstractBeanFactory.java:217) - Creating shared instance of singleton bean 'simplebeanfromxml'

DEBUG [main] (AbstractAutowireCapableBeanFactory.java:280) - Creating instance of bean 'simplebeanfromxml' wit
DEBUG [main] (CachedIntrospectionResults.java:138) - Getting BeanInfo for class [springsamples.springcore.Pers
DEBUG [main] (CachedIntrospectionResults.java:154) - Caching PropertyDescriptors for class [springsamples.spri
DEBUG [main] (CachedIntrospectionResults.java:162) - Found property 'age' of type [int]

DEBUG [main] (CachedIntrospectionResults.java:162) - Found property 'belongings' of type [[Ljava.lang.String;]
DEBUG [main] (CachedIntrospectionResults.java:162) - Found property 'class' of type [java.lang.Class]

DEBUG [main] (CachedIntrospectionResults.java:162) - Found property 'name' of type [java.lang.String]

DEBUG [main] (CachedIntrospectionResults.java:162) - Found property 'spouse' of type [springsamples.springcore
DEBUG [main] (CachedIntrospectionResults.java:85) - Class [springsamples.springcore.Person] is cache-safe

DEBUG [main] (AbstractAutowireCapableBeanFactory.java:963) - Resolving reference from property 'spouse' in bea
INFO [main] (AbstractBeanFactory.java:217) - Creating shared instance of singleton bean 'spousebean'

DEBUG [main] (AbstractAutowireCapableBeanFactory.java:280) - Creating instance of bean 'spousebean' with merge
DEBUG [main] (CachedIntrospectionResults.java:96) - Using cached introspection results for class [springsample
DEBUG [main] (AbstractAutowireCapableBeanFactory.java:963) - Resolving reference from property 'spouse' in bea
DEBUG [main] (AbstractBeanFactory.java:184) - Returning cached instance of singleton bean 'simplebeanfromxm


Just make sure both jar and properties are in the classpath.

22.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: foxkind
Posted on: 2005-04-28 15:02

Thank you very much.
by comparing your log4j.properties with mine, i found that the level for my
log4j.rootCategory is set as "info". So i change it to debug, and get the right
answer.

Thank you again!!

23.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: netxray
Posted on: 2005-05-19 17:43

这本书写得真好,感谢floater,您太强了。 Big Smile

24.Re:Spring Core Intro [Re: floater] Copy to clipboard
Posted by: floater
Posted on: 2005-11-12 12:10

上面的Spring core tutorial更新了, 加了一节,有些是这里的:
http://www.cjsdn.net/post/view?bid=20&id=158334&sty=1&tpg=1&age=0
另加了一个例子。

早就想加了,再不做就找不到头绪了。

25.Re:Spring Core Intro [Re: netxray] Copy to clipboard
Posted by: icewind0807
Posted on: 2005-11-12 12:12

netxray wrote:
这本书写得真好,感谢floater,您太强了。 Big Smile


很佩服你对spring的理解。
所有的项目都是好的项目,只要可以很好的管理。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923