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

您没有登录

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

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:关于spring + ejb进行组合的一些疑问 [Re:macrochen]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-15 02:20 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
1. As long as you have a valid reason, you don't care: 这种行为在一些人的眼里看来是不够地道的做法.

2. Let's forget Spring for the time being, just talk EJB. When we build a SLSB(stateless session bean), what do we need to do? We need to write the class, and the xml file. Now if you want to use Spring as well, you need to load (ac)application context from somewhere. But you are in the ejb container, so you can't load a file. So we load it to JNDI. Once we have ac, we can set the dependencies. Then we can call it.

This is the normal case and we need to do this for every bean. So Spring comes up those classes to do the common part for you. If you don't want to use them, it's ok. Try not to use it, build 3 slsb's, find the common/repetitive work in developing them, then you should see why/what Spring does it(or maybe not, sometimes I couldn't figure out what they are doing either, quite complex, e.g., the classloader part, when you get several classloaders there, it's hard to keep track of them. In Struts, they can't make it work *all the time* either. But Spring folks can do it.)

This, and others, like jdbc support, web controllers, jms, are not about invasion or Ioc container at all, they are about the support for J2EE. You don't need to use them at all. If you do it without them, with just regular j2ee classes and IoC container, it works. But once you do it more than 3 times, you would find some repetitive work that you are doing over and over again. Natually, you want to isolate them so you just do it once. So does Spring team, so they did it for you, and more than that.

You have choices:
use j2ee only.
use j2ee, and Ioc only, without Spring's j2ee support.
use j2ee, Ioc, and Spring's j2ee support.

I would go with the last, because:
1. avoid repetitive work, e.g., hook ioc container with j2ee
2. spring team has more exp than me, so their practices are better than mine most of the time.
3. I don't need to maintain these hooks. If I go with J2EE version 8, they do the dirty work to upgrade, not me.

Yes, of course, the support part is invasive, because it hooks j2ee for you. They have to land somewhere, i.e., you can't just get j2ee for free(Ioc wise).

So you make the judgement.

My 2 cents. I sense that your logic is twisted, try to understand the purpose first and follow that direction. But I may be wrong. Just my opinion for discussion, no intention to disrespect anyone.



"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

话题树型展开
人气 标题 作者 字数 发贴时间
9687 关于spring + ejb进行组合的一些疑问 macrochen 1178 2005-04-15 00:55
9051 Re:关于spring + ejb进行组合的一些疑问 floater 2423 2005-04-15 02:20

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