Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Architecture & Framework » Spring Framework  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Spring Core Intro
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-21 10:13 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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)


floater edited on 2005-11-12 12:04

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:floater]
davidself

猫哥

CJSDN高级会员


发贴: 1506
积分: 333
于 2005-04-21 10:49 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
floater居然用中文来交流,仅凭这一点就要支持。呵呵。

davidself edited on 2005-04-21 13:09

--108的上铺--
davidself@twitter
作者 Re:Spring Core Intro [Re:floater]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-21 11:11 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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, ^_~.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:floater]
wood





发贴: 122
积分: 1
于 2005-04-21 11:28 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
hooray!!


作者 Re:Spring Core Intro [Re:floater]
tier3





发贴: 228
积分: 120
于 2005-04-21 11:55 user profilesend a private message to usersend email to tier3search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.



作者 Re:Spring Core Intro [Re:floater]
glistar



CJSDN高级会员


发贴: 248
积分: 81
于 2005-04-21 13:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
cool


作者 Re:Spring Core Intro [Re:floater]
jigsaw

KK

CJSDN高级会员


发贴: 3666
积分: 93
于 2005-04-21 13:28 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
floater写中文。。。强。。。支持。。。

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



No one knows except both of us.
909090909090909090909090909090909090909090b8533ce76c8d6c241868968a0408c338b4ffbf
ISO/IEC 9899:1999
作者 Re:Spring Core Intro [Re:floater]
jigsaw

KK

CJSDN高级会员


发贴: 3666
积分: 93
于 2005-04-21 13:48 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
对于没有容器(web/ejb)的应用,app context放在system.getproperty
里面是个好办法吗?为什么java的static final不能呢。。。
static factory不会带来不方便的



No one knows except both of us.
909090909090909090909090909090909090909090b8533ce76c8d6c241868968a0408c338b4ffbf
ISO/IEC 9899:1999
作者 Re:Spring Core Intro [Re:floater]
jigsaw

KK

CJSDN高级会员


发贴: 3666
积分: 93
于 2005-04-21 14:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
总的来说。。。spring做了大量的抽象,把web开发中各个层次的问题都抽象了一遍,提取出了很多框架(这里的框架是狭义的),你可以直接使用它,
也可以抄袭它。从实践和理论两方面,都可以从中获益。
但是我个人更喜欢抄袭它而不是直接拿来用。。。赫赫。。。我想这可能是因为我参加过的项目中,凡是我能发言的,规模都不大的缘故。

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



No one knows except both of us.
909090909090909090909090909090909090909090b8533ce76c8d6c241868968a0408c338b4ffbf
ISO/IEC 9899:1999
作者 Re:Spring Core Intro [Re:floater]
leowu2000



版主


发贴: 258
积分: 50
于 2005-04-21 14:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Thumbs upThumbs upThumbs up


Eclipse邮件列表
作者 Re:Spring Core Intro [Re:jigsaw]
emarket

亢龙有诲

CJSDN高级会员


发贴: 460
积分: 82
于 2005-04-21 14:52 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
jigsaw wrote:
总的来说。。。spring做了大量的抽象,把web开发中各个层次的问题都抽象了一遍,提取出了很多框架(这里的框架是狭义的),你可以直接使用它,
也可以抄袭它。从实践和理论两方面,都可以从中获益。
但是我个人更喜欢抄袭它而不是直接拿来用。。。赫赫。。。我想这可能是因为我参加过的项目中,凡是我能发言的,规模都不大的缘故。

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


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



个人Blog http://agilespeaking.blogspot.com/

作者 Re:Spring Core Intro [Re:floater]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2005-04-21 20:37 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
敝人啃中文技術著作已覺不易
floater還來個寫的
要認真細讀了
並期待"第37-38頁"的丰富內容Big Smile

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



作者 Re:Spring Core Intro [Re:floater]
wes109

以梦为马

CJSDN高级会员


发贴: 857
积分: 60
于 2005-04-21 22:22 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
拜读完毕

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

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

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

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




作者 Re:Spring Core Intro [Re:floater]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-21 22:29 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:floater]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-21 22:55 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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...



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:wes109]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-21 23:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.


why edited on 2005-04-22 00:47

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:floater]
keron



CJSDN高级会员


发贴: 19
积分: 62
于 2005-04-23 12:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Good Job!
Big Smile



作者 Re:Spring Core Intro [Re:floater]
sunsonbaby





发贴: 82
积分: 0
于 2005-04-24 22:19 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
floater还会写中文?没听说过^_^


作者 Re:Spring Core Intro [Re:floater]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-25 00:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的京腔儿音可是没改的!


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:floater]
foxkind





发贴: 2
积分: 0
于 2005-04-28 10:23 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.



作者 Re:Spring Core Intro [Re:floater]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-28 10:32 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:floater]
foxkind





发贴: 2
积分: 0
于 2005-04-28 15:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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!!



作者 Re:Spring Core Intro [Re:floater]
netxray





发贴: 7
积分: 0
于 2005-05-19 17:43 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这本书写得真好,感谢floater,您太强了。 Big Smile


i love flyheart and cjsdn. [learing spring now...]
作者 Re:Spring Core Intro [Re:floater]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-11-12 12:10 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
上面的Spring core tutorial更新了, 加了一节,有些是这里的:
http://www.cjsdn.net/post/view?bid=20&id=158334&sty=1&tpg=1&age=0
另加了一个例子。

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



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Spring Core Intro [Re:netxray]
icewind0807





发贴: 1
积分: 0
于 2005-11-12 12:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
netxray wrote:
这本书写得真好,感谢floater,您太强了。 Big Smile


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




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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