Skip to main content

Colin Wong

Colin Wong's Public Library

19 Aug 07

不要重复编写DAO - HuDon的专栏 - CSDNBlog

  • DAO 不负责处理事务、会话或连接。这些不由 DAO 处理是为了实现灵活性。

使用struts+spring+hibernate组装你的web应用架构 - otto - 博客园

  • 摆在开发者面前有很多问题:要考虑是怎样建立用户接口?在哪里处理业务逻辑? 怎样持久化的数据。 而这三层构架中,每一层都有他们要仔细考虑的。 各个层该使用什么技术? 怎样的设计能松散耦合还能灵活改变? 怎样替换某个层而不影响整体构架?应用程序如何做各种级别的业务处理(比如事务处理)?
  • 一个好框架具备以下几点: 减轻开发者处理复杂的问题的负担("不重复发明轮子"); 内部有良好的扩展; 并且有一个支持它的强大的用户团体。 好的构架一般有针对性的处理某一类问题,并且能将它做好(Do One Thing well)
  • 20 more annotations...

以前写的一个Design Pattern的文章-企业应用-Java -JavaEye做最棒的软件开发交流社区

  • Design Pattern(设计模式)的目标是,把共通问题中的不变部分和变化部分分离出来。不变的部分,就构成了Design Pattern(设计模式)。这一点和Framework(框架)有些象
  • 我们来看看在Java中如何实现这种灵活而强大的排序。

用spring 实现观察者设计模式 — IT技术 - 赛迪网

  • 观察者设计模式其实就是一种发布预订的设计模式,大家都知道JMS里面有发布预订的模式,也就是有一个一对多的关系,一个发布者,然后有N多个消费者,一旦发布者发出消息,那么所有预订的消费者都将收到消息。

直接召唤系与IoC fashion使用Spring — IT技术 - 赛迪网

  • .直接召唤系--Singleton的Application Context
          最简单的,就像在UnitTest里那样,直接构造Application Context:

    ApplicationContext ctx = new ClasspathXmlApplicationContext("ApplicationContext.xml");
       
          在Web环境里,会使用ContextLoader构造ApplicationContext后,压进Servlet Context。
          由ContextLoaderListener或ContextLoaderServlet,在Web应用启动时完成。
          然后在Jsp/Servelet中,可以通过Servlet Context取得ApplicationContext: ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);

    • 但像Singleton类或者EJB中,就没有Servlet Context可用了。
            如果全部像UnitTest那样直接构造,速度就会很不堪。自然的,就想到把ApplicationContext做成单例。
            Spring提供了ContextSingletonBeanFactoryLocator这样的物体。
            先搞一个beanRefFactory.xml,里面写上所有的applcationContext-*.xml文件名,并把Context命名为"default-context":
       
         
            applicationContext.xml
  • 1 more annotations...

Spring: Creating Objects So You Don't Have To







  • <!-- ---- OAS AD '120x60-1' end ---- -->





    <!-- OAS ad tag end -->







    This code creates a Person object and calls the setEmail() method, passing in the string defined as a value.


    It is good practice to default your classes to being immutable until you have a reason to make them mutable. Constructor-based injection will allow you to take advantage of dependency-injection while still permitting immutability. If your classes are meant to be immutable, then it is probably best to stick with constructor-based injection.

  • This feature is meant to save you from having to explicitly type out the names of the beans that you reference. I personally favor explicitness in order to make the bean definitions more readable, thus I choose not to use Spring's autowiring functionality, but you may find it useful.
  • 3 more annotations...

Spring: Creating Objects So You Don't Have To

  • Spring provides a core factory pattern, which eliminates the need to manually program factory objects (usually realized as singletons). It also, as the documentation explains, "allows you to decouple the configuration and specification of dependencies from your actual program logic."
  • The fundamental benefit of the Spring framework is its ability to act as a factory to create objects. Spring reads a schematic defined in an external configuration file, creates and wires the objects together using reflection, and then passes the objects back to you. Think of Spring as a factory that you don't have to write any code for.

Spring: Creating Objects So You Don't Have To

  • Spring's object linking is defined in XML files, thus you can plug-in different components during runtime, or for different application configurations. This is particularly useful for applications that do unit testing or applications that deploy different configurations for different customers.
  • The terms 'dependency injection' and 'inversion of control' are often used interchangeably. Martin Fowler recently elaborated on the terminology, stating that dependency injection is a specific type of inversion of control. Specifically, dependency injection is a pattern where the responsibility for object creation and object linking is removed from the objects themselves and moved into a factory. Thus, dependency injection inverts the control for object creation and linking.
  • 1 more annotations...

Spring和Hibernate學習筆記02 - 白色黑暗 - 澳門 BBS 澳門論壇 - powered by X-Space

    • 使用business delegate pattern的主要原因:


      • Most presentation tier components execute a unit of business logic. It's best to put this logic in a non-web class so a web-service or rich platform client can use the same API as a servlet.
      • Most business logic can take place in one method, possibly using more than one DAO. Using a business delegate allows you to use Spring's declarative transactions feature at a higher "business logic" level.

      英文程度不高,所以不亂翻譯了。


      自己認為,使用Manager(business delegate)的好處就是可以將業務邏輯完全的抽象出來,至於功能的實現Manager完全不用理會,Manager只是調用一個或多個DAO提供的功能來完成業務。


      DAO針對數據處理,Manager針對業務邏輯。

SourceForge.net: - Mozilla Firefox

  • An Object Relational mapper maps Objects to database entities directly. In the case of Hibernate, all SQL is generated based on those mappings. Custom SQL is handled via HSQL, an Object Oriented query language that basically facades real SQL.
  • n the case of iBATIS SQL Maps, you can think of it as SQL embedded in XML. 
  • 2 more annotations...

robbin的口水 -JavaEye技术社区 - Mozilla Firefox

  • Hibernate在查询时,面对很多映射有时候显得很苍白。



    例如有个业务场景,Department和Employee是一对多关系。现在我对Department进行分页查询,要求在显示的页面上同时显示每个Department中Employee的数量。这是一个很简单的业务场景,但是想象一下如何用hibernate进行映射?



    首先否定一种做法:hql:FROM Department department。然后针对每个department,去做department.getEmployees().size()。这样不仅会发送n+1条SQL,而且性能太低。



    我们肯定希望采用一句HQL解决问题,但是此时问题来了,当你试图做SELECT department, count(employee.id) FROM .....这样的HQL时,在Java端,发现没有一个合适的对象可以映射。



    从OO的角度,其实可以在Department这个类中加一个employeeSize来表示这种业务场景。但是好像Hibernate无法去做类似的映射。而iBatis在这个方面却灵活的多。

1 - 20 of 379 Next › Last »
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo