Colin Wong's Library tagged → View Popular
使用struts+spring+hibernate组装你的web应用架构 - otto - 博客园
-
摆在开发者面前有很多问题:要考虑是怎样建立用户接口?在哪里处理业务逻辑? 怎样持久化的数据。 而这三层构架中,每一层都有他们要仔细考虑的。 各个层该使用什么技术? 怎样的设计能松散耦合还能灵活改变? 怎样替换某个层而不影响整体构架?应用程序如何做各种级别的业务处理(比如事务处理)?
-
一个好框架具备以下几点: 减轻开发者处理复杂的问题的负担("不重复发明轮子"); 内部有良好的扩展; 并且有一个支持它的强大的用户团体。 好的构架一般有针对性的处理某一类问题,并且能将它做好(Do One Thing well)
- 20 more annotations...
用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
-
- 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.
使用business delegate pattern的主要原因:
英文程度不高,所以不亂翻譯了。
自己認為,使用Manager(business delegate)的好處就是可以將業務邏輯完全的抽象出來,至於功能的實現Manager完全不用理會,Manager只是調用一個或多個DAO提供的功能來完成業務。
DAO針對數據處理,Manager針對業務邏輯。
robbin的口水 -JavaEye技术社区 - Mozilla Firefox
-
2.0的一个非常大的改进是引入了XML Schema的namespace,因而可以将bean的配置文件做大幅度的简化
-
在Spring2.0里面XML Schema语法的配置可以在相当程度上降低配置文件的复杂程度和烦琐程度,可以视为Spring的重大改进之一。但是我们也必须看到XML Schema并没有从根源上面解决XML配置复杂的问题,而只是减轻。
- 5 more annotations...
robbin的口水 -JavaEye技术社区 - Mozilla Firefox
-
但是Hibernate不够易用,而且有一些明显的缺陷:one-to-one必须通过bytecode enhancement才能lazy loading;不支持多态关联;怪异的inverse配置和维护;DetachedCriteria有明显的bug;many-to-one的eager fetch设置不够灵活
-
我们已经听到太多对于spring的xml bean配置文件的抱怨。也许配置文件不是太大的问题,spring已经开始尝试引入annotation。但是spring的致命问题是无法方便的对动态创建的bean进行依赖注入。Google Guice的出现让我们看到了其实prototype的bean和动态创建的bean其实也可以很容易的管理。spring自身的缺陷事实上造成了很难进行rich domain model架构的实现。
Hibernate 學習筆記 - Mozilla Firefox
-
為了能夠重複使用Criteria物件,在Hibernate
3中新增了DetchedCriteria,您可以先建立DetchedCriteria實例,並加入各種查詢條件,並於需要查詢時再與Session綁
定,獲得一個綁定Session的Criteria物件
Hibernate 學習筆記 - Mozilla Firefox
-
然而如果是在網路上的系統,同時間會有許多連線,如果每一次讀取資料都造成鎖定,其後繼的存取就必須等
待,這將造成效能上的問題,造成後繼使用者的長時間等待。 -
在不實行悲觀鎖定策略的情況下,資料不一致的情況一但發生,有幾個解決的方法,一種是先更新為主,一種是後更新的為主,比較複雜的就是檢查發生變動的資料
來實現,或是檢查所有屬性來實現樂觀鎖定。 - 3 more annotations...
Hibernate 學習筆記 - Mozilla Firefox
-
悲觀鎖定(Pessimistic
Locking)一如其名稱所示,悲觀的認定每次資料存取時,其它的客戶端也會存取同一筆資料,因此對該筆資料進行鎖定,直到自己操作完成後解除鎖定。 -
用Query或
Criteria的setLockMode()方法來設定要鎖定的表或列(Row)及其鎖定模式 - 3 more annotations...
Hibernate 學習筆記 - Mozilla Firefox
-
Hibernate本身沒有交易管理功能,它依賴於JDBC或JTA的交易管理功能,預設是使用JDBC交易管理,可以在配置文件中加上
hibernate.transaction.factory_class屬性來指定Transaction的工廠類別 -
Session是lazy的,也就是在一開始的openSession()取得Session時,並不會馬上取得Connection,在beginTransaction()時,才會真正取得JDBC的Connection實例,並設定AutoCommit為false,在
操作過程中,最後要commit
(),否則的話對資料庫的操作不會有作用,在commit()之後,Connection與Session脫勾,如果使用Session再度
beginTransaction()的話,會重新取得Connection,如果操作過程中因發生例外,則最後commit()不會被執行,之前的操作
取消,執行rollback()可撤
消之前的操作 - 1 more annotations...
Hibernate 學習筆記 - Mozilla Firefox
-
Query上有list()與iterate()方法,兩者的差別在於開啟Query快取之後,list()方法在讀取資料時,會利用到Query快取,
而iterate()則不會使用到Query快取功能,而是直接從資料庫中再查詢資料
Hibernate 學習筆記 - Mozilla Firefox
-
您的資料庫表格中的資料很少變動,在
使用Query查詢資料時,如果表格內容沒有變動,您希望能重用上一次查詢的結果,除非表格內容有變動才向資料庫查詢 -
因為要使用Query的快取功能必須在兩次查詢時所使用的SQL相同,且兩次查詢之間表格沒有任何資料變動下才有意義
- 2 more annotations...
Hibernate 學習筆記 - Mozilla Firefox
-
Hibernate二級快取可以跨越數個Session,二級快取由同一個SessionFactory所建立的Session所共享,因而又稱為
SessionFactory level快取。
Hibernate本身並未提供二級快取的實現,而是藉由第三方(Third-party)產品來實現,Hibernate預設使用EHCache作為其
二級快取的實現,在最簡單的情況下,您只需在Hibernate下撰寫一個ehcache.xml作為EHCache的資源定義檔,可以在
Hibernate下載檔案中的etc目錄下找到一個已經撰寫好的ehcache.xml -
Session會先在Session
level快取中查詢看有無資料,如果沒有就試著從二級快取中查詢資料 - 3 more annotations...
Hibernate 學習筆記 - Mozilla Firefox
-
快取(Cache)是資料庫在記憶體中的臨時容器,從資料庫中讀取的資料在快取中會有一份臨時拷貝,當您查詢某個數據時,會先在快取中尋找是否有相對應的
拷貝,如果有的話就直接返回資料,而無需連接資料庫進行查詢,只有在快取中找不到資料時,才從資料庫中查詢資料,藉由快取,可以提昇應用程式讀取資料時的
效能。 -
在Hibernate中快取分作兩個層級:Session
level與SessionFactory level(又稱Second level快取)。 - 5 more annotations...
Sponsored Links
Top Contributors
Groups interested in spring
-
Bakhtin
This is the preliminary lis...
Items: 11 | Visits: 44
Created by: bloggingprof 2b
-
Java
Mostly related to java tech...
Items: 3 | Visits: 62
Created by: Srinivas Raghu
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo

