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

您没有登录

» Java开发网 » Architecture & Framework  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 如何评价是否真正掌握了Spring
YuLimin

简单就是美

版主


发贴: 866
积分: 123
于 2005-04-25 12:25 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的掌握

MVC框架
  Spring MVC-----不懂
AOP、IOC
  Spring------精通

如何评价是否真正掌握了Spring


YuLimin edited on 2005-04-25 12:30

 当兵不后悔!后悔不当兵! 
超越黎明时空,追逐时代潮流!
人,是要靠自己的!简单就是美!
我的Java:http://www.Java2Class.net
我的Blog:http://YuLimin.ItEye.com
作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
jigsaw

KK

CJSDN高级会员


发贴: 3666
积分: 93
于 2005-04-25 13:24 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那样


No one knows except both of us.
909090909090909090909090909090909090909090b8533ce76c8d6c241868968a0408c338b4ffbf
ISO/IEC 9899:1999
作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
烂泥





发贴: 538
积分: 72
于 2005-04-25 21:54 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
YuLimin wrote:
有人这样回复对Spring的掌握

MVC框架
Spring MVC-----不懂
AOP、IOC
Spring------精通

如何评价是否真正掌握了Spring


问他读了基本Spring的书,然后随便考几个概念.



作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2005-04-25 22:51 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
是否要考考其人呢?

敝人覺得有不同層次的"精通"



作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-04-25 23:38 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 agree with why, it's really hard to define "精通Spring", or anything.

If someone says he is good at IoC, AOP, well just ask him a few common sense questions to see what he did. That's where the exp comes. Then you just count experience.

I am not "精通Spring" either, just have some experience with it. Maybe I go a little bit further, but that's all, nothing more than that.

I think we should put more weight on practice/experience, less chase on fasion, Tounge. If it's useful for you, use it, otherwise find something better.



"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 [Re:YuLimin]
alexwish





发贴: 46
积分: 3
于 2005-04-26 12:36 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 [Re:YuLimin]
tier3





发贴: 228
积分: 120
于 2005-04-26 18:13 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
真正成功地做成了项目或产品,并在其中使用了Spring就算是精通。Smile

无论是Struts, Spring, Hibernate,只是我们项目成功(自己满意,客户满意,小组成员满意),那我只用jsp, java bean也算成功。
只有成功地“应用”了某些技术,才是真正体现了这些技术的优势,这也是唯一说明精通的理由。Smile



作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
dissip

BigCat



发贴: 240
积分: 60
于 2005-04-28 11: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
as i think
spring is just a tool. so it is of not much use to say that 'i master spring'. it's the spring's concept/idea that really matters. the concept are not first invented by spring. but spring does provide an integrated implementation.
for us developers, it is just like a saying in the 武侠 novel :
first stage:手中有环
second stage:手中无环,心中有环
third stage:手中无环,心中也无环,人既是环,环既是人


dissip edited on 2005-05-09 10:57

To live is to fight.

作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
kenny68





发贴: 2
积分: 0
于 2005-04-30 10: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
我也觉得Spring不存在精通的问题,因为你先得有AOP,IOC的概念,才能做下去,Spring只是帮你更好地完成这些工作。

我从去年开始在项目中使用Spring、Hibernate,给我的感觉是一件很自然而然的事情,Spring完成我想做而没有做的工作。

当然因为能力关系,我肯定做不了那么好,但专门为我自己定制一套还是有可能的。



作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
YuLimin

简单就是美

版主


发贴: 866
积分: 123
于 2005-05-01 14:34 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
http://www.gpowersoft.com/tech/Spring/45.htm

Spring Framework之最佳实践一

Spring Framework从诞生之日起,受到了越来越多的关注。最近,新的开源项目大多支持Spring Framework。国内目前也有专门的网站(http://spring.jactiongroup.net/)。那它为什么如此受欢迎呢?

我想最重要的是,EJB让每个人都痛恨。要编写一个EJB,需要写LocalHome, RemoteHome, Bean, LocalInterface, RemoteInterface,需要一个标准描述符,一个特殊厂商描述符(Weblogic、WebSphere都不一样),如果是Entity Bean,还需要Mapping文件。如此之多,实在麻烦。但EJB最重要的是解决Transaction问题,没有Spring之前,没有其他方法能够描述式的解决它。每个人、每个公司为了解决Transaction的问题,编程的写法都不一样,百花齐放。于是,在最需要它的时候,Spring出现了。

Spring的功能非常多。但对于一个产品,最重要的是如何用好它的精华。Spring包含AOP、ORM、DAO、Context、Web、MVC几个部分组成。Web、MVC暂不用考虑,用成熟的Struts、JSP或Webwork更好。DAO由于目前Hibernate、JDO的流行,也可不考虑。因此最需要用的是AOP、ORM、Context。

Context中,最重要的是Beanfactory,它是将接口与实现分开,非常重要。以前我们写程序,如一个接口IDocument,一个实现类Document1。在写程序时,需写成IDocument doc = new Document1(),一旦我们的实现类需改变时,变为Document2,则程序需写成IDocument doc = new Document2(),所有用到的地方全需改。Beanfactory帮我们解决了这个问题,用context后,写法变为IDocument doc=(IDocument)beanFactory.getBean("doc")。如果实现类从Document1改为Document2,直接在配置文件改就可以了。Context是Bean factory的进一步抽象。很多人都喜欢用ApplicationConext,用Servlet把它Load。这样就把Bean Factory与Web绑定在一起。如果是Fat Client或Remote调用,则这些Bean factory就很难调用,实际是将表现层与业务层绑定的太紧。推荐的方法是SingletonBeanFactoryLocator。具体为:

BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance();
BeanFactoryReference bf = bfLocator.useBeanFactory("beanFactory");
// now use some bean from factory
return bf.getFactory().getBean(name);



<beans>

<bean id="beanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>dataAccessContext.xml</value>
<value>securityContext.xml</value>
<value>...</value>
</list>
</constructor-arg>
</bean>

</beans>

这样,就可随时动态扩展,实现组件式的开发。



 当兵不后悔!后悔不当兵! 
超越黎明时空,追逐时代潮流!
人,是要靠自己的!简单就是美!
我的Java:http://www.Java2Class.net
我的Blog:http://YuLimin.ItEye.com
作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
YuLimin

简单就是美

版主


发贴: 866
积分: 123
于 2005-05-01 14:36 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
http://www.gpowersoft.com/tech/Spring/46.htm

Spring Framework之最佳实践二

Spring Framework最得以出名的是与Hibernate的无缝链接,基本上用Spring,就会用Hibernate。可惜的是Spring提供的HibernateTemplate功能显得不够,使用起来也不是很方便。我们编程序时,一般先写BusinessService,由BusinessService调DAO来执行存储,在这方面Spring没有很好的例子,造成真正想用好它,并不容易。

我们的思路是先写一个BaseDao,仿照HibernateTemplate,将基本功能全部实现:

public class BaseDao extends HibernateDaoSupport{

private Log log = LogFactory.getLog(getClass());

public Session openSession() {
return SessionFactoryUtils.getSession(getSessionFactory(), false);
}

public Object get(Class entityClass, Serializable id) throws DataAccessException {
Session session = openSession();
try {
return session.get(entityClass, id);
}
catch (HibernateException ex) {
throw SessionFactoryUtils.convertHibernateAccessException(ex);
}
}

public Serializable create(Object entity) throws DataAccessException {
Session session = openSession();
try {
return session.save(entity);
}
catch (HibernateException ex) {
throw SessionFactoryUtils.convertHibernateAccessException(ex);
}
}

...

其它的DAO,从BaseDao继承出来,这样写其他的DAO,代码就会很少。

从BaseDao继承出来EntityDao,专门负责一般实体的基本操作,会更方便。

public interface EntityDao {

public Object get(Class entityClass, Serializable id) throws DataAccessException;

public Object load(Class entityClass, Serializable id) throws DataAccessException;

public Serializable create(Object entity) throws DataAccessException;
...}

/**
* Base class for Hibernate DAOs. This class defines common CRUD methods for
* child classes to inherit. User Sping AOP Inteceptor
*/
public class EntityDaoImpl extends BaseDao implements EntityDao{

}

为了Transaction的控制,采用AOP的方式:

public interface EntityManager {

public Object get(Class entityClass, Serializable id);

public Object load(Class entityClass, Serializable id);

public Serializable create(Object entity);
...

}

/**
* Base class for Entity Service. User Sping AOP Inteceptor
*/
public class EntityManagerImpl implements EntityManager {

private EntityDao entityDao;

public void setEntityDao(EntityDao entityDao) {
this.entityDao = entityDao;
}

public Object get(Class entityClass, Serializable id) {
return entityDao.get(entityClass, id);
}

public Object load(Class entityClass, Serializable id) {
return entityDao.load(entityClass, id);
}
...

}

这样我们就有了一个通用的Hibernate实体引擎,可以对任何Hibernate实体实现基本的增加、修改、删除、查询等。

其它的BusinessService就可以继承EntityManager,快速实现业务逻辑。

具体XML配置如下:

<!-- Oracle JNDI DataSource for J2EE environments -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>java:comp/env/jdbc/testPool</value></property>
</bean>

<!-- Hibernate SessionFactory for Oracle -->
<!-- Choose the dialect that matches your "dataSource" definition -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<value>user-hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.Provider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>

<!-- AOP DAO Intecepter -->
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<bean id="entityDaoTarget" class="com.gpower.services.entity.dao.EntityDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<bean id="entityDao" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.gpower.services.entity.dao.EntityDao</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
<value>entityDaoTarget</value>
</list>
</property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
<!--
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
-->

<!-- Transactional proxy for the Application primary business object -->
<bean id="entityManagerTarget" class="com.gpower.services.entity.EntityManagerImpl">
<property name="entityDao">
<ref bean="entityDao"/>
</property>
</bean>

<bean id="entityManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="entityManagerTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_SUPPORTS</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>



 当兵不后悔!后悔不当兵! 
超越黎明时空,追逐时代潮流!
人,是要靠自己的!简单就是美!
我的Java:http://www.Java2Class.net
我的Blog:http://YuLimin.ItEye.com
作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
jigsaw

KK

CJSDN高级会员


发贴: 3666
积分: 93
于 2005-05-01 18: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
说实话EJB不是因为“写起来麻烦”而挨骂的
写起来其实一点也不麻烦 主流ide都有wizard帮你写那些interface/xml
发布起来也不麻烦 要么写好ant 要么给wsad之类的大块头帮你发布
我们公司的几个千万级的大项目 虽说我认为不成功 但是在发布这方面,我觉得做到了对初级开发者透明的地步,刚进公司的新人没几天工夫也能编译发布整个app勒
EJB挨骂无非是倚重remote太厉害了 还有开始吹牛太多了

其实context, transaction, interceptor这些概念在EJB里面体现得很漂亮

EJB唯一做错的就是一开始把自己绑在重量级+remote这个东西上面了
唉。。。但愿EJB3能雄起



No one knows except both of us.
909090909090909090909090909090909090909090b8533ce76c8d6c241868968a0408c338b4ffbf
ISO/IEC 9899:1999
作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2005-05-02 02: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

我想最重要的是,EJB让每个人都痛恨。要编写一个EJB,需要写 LocalHome, RemoteHome, Bean, LocalInterface, RemoteInterface,需要一个标准描述符,一个特殊厂商描述符(Weblogic、WebSphere都不一样),如果是Entity Bean,还需要Mapping文件。如此之多,实在麻烦。但EJB最重要的是解决Transaction问题,没有Spring之前,没有其他方法能够描述式的解决它。每个人、每个公司为了解决Transaction的问题,编程的写法都不一样,百花齐放。于是,在最需要它的时候,Spring出现了。

1. As jigsaw said, the development of EJB is much better now.
2. EJB最重要的是解决Transaction问题 - no, it's *distributed* transaction problem. If it's not distributed, just over one connection, local transaction is not a problem.
3. EJB's problem is the assumption of *distributing* computing everywhere, this is typically the ignorance of architects.


Spring的功能非常多。但对于一个产品,最重要的是如何用好它的精华。Spring包含AOP、ORM、DAO、Context、Web、MVC几个部分组成。Web、MVC暂不用考虑,用成熟的Struts、 JSP或Webwork更好。DAO由于目前Hibernate、JDO的流行,也可不考虑。因此最需要用的是AOP、ORM、Context。

There is no such thing as 最佳实践, 精华, it's just a damn tool, use it or not. In fact, Spring's MVC is more flexible. 成熟的Struts is really not well designed at all.



"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 [Re:YuLimin]
YuLimin

简单就是美

版主


发贴: 866
积分: 123
于 2005-05-03 11: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
EJB的思想还是要学习的。


 当兵不后悔!后悔不当兵! 
超越黎明时空,追逐时代潮流!
人,是要靠自己的!简单就是美!
我的Java:http://www.Java2Class.net
我的Blog:http://YuLimin.ItEye.com
作者 Re:如何评价是否真正掌握了Spring [Re:YuLimin]
ftang



版主


发贴: 214
积分: 38
于 2005-05-05 00: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
The major problem of EJB is too heavy...

the reason of too heavy is because of the over-design...

in the real life...there ar not so many case we have to use EJB....

so at the beginning of J2EE....sun over-design the EJB, and us as app-developer over-design our project...

and one day...

someone waked up...say "wait a minute, do we really need EJBs?" ...

then there is russian-american come up with 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