2006年3月16日

整理P大点儿的硬盘空间居然整理出来俺曾经做过的几个东东,哎呀,想当年啊……成长历程啊。
第一个正把经的个人网站的首页
 进步了一些的第二版个人主页

又做了一些小东东而且跟着DFLYING大虾学会PHP以后,开始接校内的小活做……一个团委旗下网站
加入Enwell.net开始栏目制作。其中一个,Enwell商城。

成立Enwell Studio
做的第一个商业网站,反而不知道咋做了
又陆续写了一些PHP以后,进入Hywave多媒体开始写Delphi和ASP.NET,为hywave改版提出两套方案
ASP.NET写了一些,包括一个巨恶心的OA以后开始和差沙,范例华写J2ME,要不是因为期末没时间了,俺们相信疯狂坦克对打网络版肯定能产出,差沙小伙儿一个星期就把是男人就下一百层从无到有写出来了(以前从来不做JAVA何况J2ME)
开始写DELPHI以后俺就成了一个职业的程序员了,和页面没关系了……就走进了JAVA的世界。也不知道现在开始写SAP ABAP是不是对得起自己。sigh,好多东西翻不到了,都是大学逃课的心血啊……

posted @ 2006-07-31 22:47 BlueO2 阅读(456) | 评论 (0)编辑 收藏

我很早以前便开始使用bloglines的订阅服务。在那里我订阅了很多常去的技术站点和一些朋友们的blog,使用总发现了一些不便之处也产生了自己的一些想法,今天偶然看keso的一篇blog发现了抓虾网以及rojo,眼前为之一亮,很多想法,这两个网站已经替我实现了。
rss订阅服务衍生的门户
在bloglines这样的纯粹订阅服务来说,用户群的大小,用户群订阅的内容的相似度,用户的阅读频率对网站产生不了任何贡献。这实在是大大的浪费。我当时就想,如果在每个种子旁边有个方便的"顶"也就是digg it功能,那么,将用户顶的最多的story聚合起来,分门别类,这就是一个dzone.com这样的网站啊。现在类似dzone以及更加出名的digg我都认为是rss订阅服务网站的失败之处,他们完全有优势快速聚合出来一个这样的小型门户。现在抓虾网以及rojo都有这样的服务了,也都由此衍生出了一个热文排行样式的东西,但是我感觉做得还不够,这样太杂。泛泛的讲内容一列。应该根绝用户订阅时此feed的tag做分析,整理出来分类,做类似daqi.com或者qihoo.com一样的布局。
rss订阅衍生出来的朋友圈
web20有一点很重要,就是社会网络。就拿豆瓣网来说,我通过豆瓣提供的以书会友的功能认识了几个志趣相投的朋友。豆瓣会根据你喜欢读的书,看的电影,听得音乐,推荐给你和你兴趣相投的人,rss订阅也应该这样。比如Bloglines可以查看都有谁订阅了这个feed,可是为什么不更近一步,将两个人的订阅内容作比较,做匹配呢?通过在你的网站提供的 rss订阅服务我可以认识朋友,这也是网站粘性之一。否则像我现在可以毫无顾忌的从bloglines搬家到rojo和抓虾网。而更多自取相同的人可以组成圈子。甚至衍生更广一点,大家通过查看你的profile,浏览你的Blog,决定跟你做朋友的时候,你会得到一个vote的分数,在朋友圈的聚合门户上排名考前,这个不就是联络家么?
推荐给我其他读物
当我用豆瓣的时候,还有一个功能特别贴心,就是它会推荐给我相类似的图书。比如我读兄弟,它会在旁边给我推荐活着,许三关卖血等等……rss的小门户,可以根据每个人的兴趣不同,推荐在此类别中背digg次数最多的blog给我,省得我总是感慨:哎呀,怎么没早点看到这个网站呢?
信息筛选
订阅了好多rss feed的人都有此种经历,那就是有的时候忙,你好久没看了,突然以上来,成百上千的新条目,当即晕倒。贴心的筛选是很必要的,rss订阅服务网站完全可以根据其他用户的digg rank来按照重要程度给我排序,大家认为重要的先看,大家认为不重要的后看……我想,群众的眼睛还是雪亮的。
冗余的剔除
订阅了大量rss的人来说,有一些种子可能已经坏掉了,或者作者更新频率很低,或者过了一段时间以后,你已经不太认为那个对你有价值了(这个可以从你digg it和收藏的频率来判断),但是因为我们进行了大量的订阅,要把它剔除需要花费时间的。RSS订阅服务只需要替订阅者看着点坏掉的种子,统计下订阅者对其的关注度,然后建议剔除哪些没有价值的feed,这将给我带来巨大的方便。
抓虾与rojo相比bloglines的改进
rojo有一点很好,当你大开一个feed的时候,他们显示的是title,只有当点击小十字查看具体内容,它才认为你读过了,下次你再打开这个种子,这个条目便不会显示出来。之前用bloglines有的条目很多,一天可能看不完,下一次再打开就看不到了,因为你之前的打开被bloglines认为是阅读过的表现。而有些条目我们认为是很有价值的,rojo和抓虾都提供了收藏的功能。此外rojo对bloglines对feed死板的分类功能进行了改善,替代的是tag,就是说一个feed可以属于多个tag,你甚至可以对条目进行tag,这样更加有利于小门户分门别类的聚合。
更进一步
我一直感觉blog的互动性还不够,这个不动不是指comment。而是无法像BBS一样,对一个讨论形成一个有主线的跟进。大家对一些东西都有自己的看法,可是都是零敲碎打,自己说自己的,对别人的想法可能不了解。仅仅靠track back是无法串联起来的。如果你的rss订阅服务能够有足够的粘性,那么用户基本都从你这里获得信息,当他要发表对某个条目的看法,让用户登陆他自己的 Blog,快捷的引用到自己的blog里面,而订阅服务网站将通过某种方式将用户的评论内容得到。这样,将众多的用户的内容整理出来,类似BBS讨论的形式,聚合在门户里。这样,Blog之间才形成了有效的互动。可惜,这个想法,似乎还不知道怎么实现。
我的页面&&个人门户
几乎这种rss订阅服务网站都提供我收藏的feed的展示,我感觉这个是不够的。而还应该展示的则是跟我上面所说的有联系的,最近digg的条目,最近收藏的条目,以及我最近评论的条目,以及我的朋友圈等等。这才形成了真正的“我的页面”。
用keso的话说,rss阅读器的技术门槛很高啊。

posted @ 2006-07-27 10:26 BlueO2 阅读(464) | 评论 (0)编辑 收藏

public   class  Artist  {
    
    String[] others;
    
/**  Creates a new instance of Artist  */
    
public  Artist()  {
    }

    
public  Artist(String name,String  others) {
        
for (String other : others) {
            System.out.println(other);
        }

        
this .others  =  others;
    }

    
public   void  wildestMethod(Object  objs) {
    
// this method will accept any arguments
    }

    
public   static   void  main(String[] args) {
        Artist artist 
=   new  Artist( " You " " 1 " " 2 " );
        artist.wildestMethod(
1 3.5 " AA " new  Artist());
    }

    
}

posted @ 2006-06-26 20:25 BlueO2 阅读(380) | 评论 (0)编辑 收藏

public   class  AutoBoxing  {
    
    
/**  Creates a new instance of AutoBoxing  */
    
public  AutoBoxing()  {
    }

    
public   void  boxingDemo() {
        
// auto boxing
        Integer i  =   0 ;
        
float  f  =   1.66f ;
        Float F 
=  f;
        
// auto unboxing
        Integer I  =   new  Integer( 1 );
        
int  i2  =  I;
        
// null value test, it will case NullPointerException
        Integer I2  =   null ;
        
int  i3  =  I2;
    }

    
public   void  testOperator() {
        Integer i 
=   1 ;
        
while ( true ) {
            i
++ ;
            System.out.println(
" Counter: " + i);
            
if (i > 5 break ;
        }

    }

    
public   void  testCompare() {
        
// it's equal because -127~127 are immutable objects
        Integer i  =   1 ;
        Integer i2 
=   1 ;
        
if (i  ==  i2) System.out.println( " 1:Equal " );
        
else  System.out.println( " 1:Not Equal " );
        
// it's not equal because j and j2 are different objects
        Integer j  =   200 ;
        Integer j2 
= 200 ;
        
if (j  ==  j2) System.out.println( " 200:Equal " );
        
else  System.out.println( " 200:Not Equal " );
    }

    
public   void  testControl() {
        Boolean flag 
=   true ;
        Integer i 
=   20 ;
        Integer j 
=   30 ;
        
if (flag) {
            System.out.println(
" Boolean affects " );
        }

        
if (i < j)
            System.out.println(
" Integer affects " );
    }

    
public   void  testMethod( double  arg) {
        System.out.println(
" public void testMethod(double arg) is invoked " );
    }

    
public   void  testMethod(Integer arg) {
        System.out.println(
" public void testMethod2(Integer arg) is invoked " );
    }

    
public   static   void  main(String args[]) {
        AutoBoxing auto 
=   new  AutoBoxing();
        auto.testCompare();
        auto.testOperator();
        auto.testControl();
        
int  i  =   1 ;
        
//  public void testMethod(Integer arg) wouldn't be invoked
        
// because  public void testMethod(double arg) will be invoked in JDK1.4
        
// Java tiger consider the backward capability
        auto.testMethod(i);
        auto.boxingDemo();
    }

    
}

posted @ 2006-06-22 18:34 BlueO2 阅读(378) | 评论 (0)编辑 收藏

public   enum  User  {
    Admin,User,Guest,Unknown   
}

public   class  Login  {
    
    
private  User user;
    EnumMap
< User,String >  userName  =   new  EnumMap < User, String > (User. class );
    
/**  Creates a new instance of Login  */
    
public  Login()  {
        userName.put(User.Admin, 
" Administrator " );
        userName.put(User.User, 
" David " );
        userName.put(User.Guest, 
" Steve " );
    }

    
public   boolean  isAdmin(User user) {
        
if (user.equals(User.Admin)) {
            
return   true ;
        }

        
return   false ;
    }

    
public   void  printUserRole() {
        User[] users 
=  user.values();
        
for (User u : user.values()) {
            System.out.println(u.toString());
        }

    }

    
public   void  isRole(User user) {
        
switch (user) {
            
case  Admin:
                System.out.println(
" admin " );
                
break ;
            
case  User:
                System.out.println(
" User " );
                
break ;
            
case  Guest:
                System.out.println(
" Guest " );
                
break ;
            
default :
                System.out.println(
" unknow " );
        }

    }

    
public   static   void  main(String[] args) {
        Login login 
=   new  Login();
        System.out.println(login.isAdmin(User.Admin));
        login.printUserRole();
        login.isRole(User.User);
    }

    
}

posted @ 2006-06-22 18:22 BlueO2 阅读(336) | 评论 (0)编辑 收藏

     摘要: public   class  Generic  {         /** */ /**  Creates a new instance of Generic  */ ...  阅读全文

posted @ 2006-06-20 18:18 BlueO2 阅读(384) | 评论 (0)编辑 收藏

Rasmus Lerdorf, creator of the PHP langauge, has a new tutorial on his site today that looks at the creation of a "no-framework PHP MVC framework" using PHP5, the Yahoo! User Interface Library, and JSON.

He steps through the entire process of working up the "non-framework" - the goals of the project, why to go with the MVC approach for the structure, and, of course, the code.

That arose the PHP's own MVC Pattern discussion in PHP Community.But i have my own view.Here is my response in one of most famous PHP community:


其实我认为由于lerdorf演示的是一个PHP AJAX应用,所以其实很难跟cid的方案有什么对比。由于AJAX应用的特殊性,lerdorf这个所谓的controller根本不需要考虑进行完了相关的操作以后View到底应该去哪里,应该转向哪里?因为直接push给客户端JSON对象就好了,完全不用操心到a.php还是b.php
另外,虽然lerdorf说以后可能可以多个请求Include一个xxx.inc就是他的controller,但是目前的状况,即使成为MVC也是page controller,而cid想要做的是一个Front controller做请求委派,Front Controller的复杂的明显要比PC要高,考虑的问题也多。但是并不是说FC就好,asp.net不就是典型的page controller模式么?
但是说句我的真实感受:读完之后我把它看作PHP AJAX应用示例教程更合适,lerdorf的标题起的有点大了,而且读完以后没有给我任何架构上启示性的东西……
而且那个if(isset($_POST[''])){}在里面做相关操作,我还是认为挺简陋甚至丑陋的。如果一个挺复杂的view采用此种方式,还是不优雅。
所以AJAX应用的controller有一部分应该放在View里面,一个页面a.html不一定非要请求到a.php,叶面里面的操作也是要有不同逻辑划分的,但是目前没有成熟的应用示例和解决方案。大家有没有自己的尝试?

文章来源:http://blueoxygen.dflying.net/3/archive/42_lerdorfs_no-framework_php_mvc_framework.html

posted @ 2006-03-16 11:19 BlueO2 阅读(465) | 评论 (0)编辑 收藏

一场精彩的CMMI论战 Here
quoted from o6z's post:
文档最忌讳繁琐无比,事无巨细的都要说明,如果是这样我直接去看代码好了。实际上多数人都默认文档的抽象程度比代码级别高,看文档比看代码省事。但是如果你的文档过于细节化,那么你的代码很难做到同步于文档。这将是一个巨大的威胁。很多人抱怨要看一堆没文档的代码,但是他们很少真的看到过合适的文档。实际上文档的作用应该是让阅读者快速找的代码的位置,而不是用文字说明代码的作用,那些应该是单元测试的事情。
人员的流动带来的最大问题,实际是知识的流失。文档可以固定下一部分的知识,但是如果文档的抽象层次不够,这些知识并不能很容易的被掌握,那么这些就是无用功。



文章来源:http://blueoxygen.dflying.net/3/archive/45_working_software_over_comprehensive_documentation.html

posted @ 2006-03-16 11:19 BlueO2 阅读(344) | 评论 (0)编辑 收藏

本来还要自己写一个auto-complete,但是大多数此类功能并没有提供类似google suggest提供的键盘选择功能,auto-complete便失去了一大半的交互改善。于是前两天还特意扒了google suggest来看ac.js 发现google定是用了混淆器。虽然代码没有压缩,但是代码的回车空行和函数名字全部混乱。正在要自己写的时候发现了此中国自产的AutoAssist。Very Cool!


AutoAssist is an auto completion web widget that written in pure JavaScript. It can help enhance the accessibility of existing website, let the users to work effective and feel comfortable. AutoAssist Javascript only and is built upon prototype and rico. Its main features are :

* improve the User Experience
* Don't require an Ajax experience
* pretty managed JavaScript, easy to understand and customize
* works well on Mozilla/FireFox, IE and Opera
* have a nice solution for fast user typing, reduce a lot of corresponding server loading (20% - 80% *)

autoassist.png

The code for the screenshot is very simple :

var foo = function() {
var tt = new AutoAssist("t", {setRequestOptions: function() {
var pars = "name=" + this.txtBox.value;
return { url: "/country.php", parameters: pars };
}});
}
Event.observe(window, "load", foo);

You can find a ten minutes tutorial for AutoAssist explaining in details how to use this script to create an auto-complete list based on country data.

By the way,script.aculo.us also has it's impelmention:http://demo.script.aculo.us/ajax/autocompleter


文章来源:http://blueoxygen.dflying.net/3/archive/53_ajax_auto-complete_component.html

posted @ 2006-03-16 11:19 BlueO2 阅读(894) | 评论 (0)编辑 收藏

See DFlying's finding:
Yep,No Block Scope concept in JavaScript.Only the global and function Scope.You can use "var" to declare a global variable and use "var" agian to declare a homonymous variable in a function.In the function ,the second one works.But there is no Block scope.
Check the codes below,it's a demo for "NO BLOCK SCOPE"
function test(o) {var i = 0; // i is defined throughout functionif (typeof o == "object") {var j = 0; // j is defined everywhere, not just blockfor(var k = 0; k < 10; k++) { // k is defined everywhere, not just loopdocument.write(k);

}document.write(k); // k is still defined: prints 10}document.write(j); // j is defined, but may not be initialized}

But,You still need to care javascript's FUNCTION SCOPE.Also see code snippet:
var scope = "global";

function f( ) {alert(scope); // Displays "undefined", not "global"var scope = "local"; // Variable initialized here, but defined everywherealert(scope); // Displays "local"}f( );
Right,thought you alert(scope) first and then define a new functin scope variable scope.However,once you define a function scope vriable,it will hide the global variable in the function body,whatever the definition order.



文章来源:http://blueoxygen.dflying.net/3/archive/68_variables_scope_in_javascript.html

posted @ 2006-03-16 11:19 BlueO2 阅读(485) | 评论 (0)编辑 收藏

Two useful liks:
http://jibbering.com/faq/faq_notes/closures.html#clMem
http://javascript.weblogsinc.com/2005/03/07/javascript-memory-leaks/

文章来源:http://blueoxygen.dflying.net/3/archive/69_no_more_crap_about_ie_memeory_leak.html

posted @ 2006-03-16 11:19 BlueO2 阅读(288) | 评论 (0)编辑 收藏

Venkman is a Javascript Debugger as a FireFox extenstion.It's at least powerful than IE's default script debugger(not Visual InterDev's).You can watch varaiable,set breakpoint and use "step over" "step into" "step out" "continue" buttons to debug your niffy javascript codes.
It's ease to use.And tutorial is HERE:http://www.svendtofte.com/code/learning_venkman/index.php

文章来源:http://blueoxygen.dflying.net/3/archive/75_ajax_tool_box---venkman.html

posted @ 2006-03-16 11:19 BlueO2 阅读(386) | 评论 (0)编辑 收藏

eclipsePOJO used by Hibernate needs to implement hashCode() and equals() method.That's a kind of stuffy work and will be done many many times during development.Some IDEs support automatical generation feature such as IDEA.Eclipse famous plug-in--MyElipse also suppots but it's not free of charge.
I think nearly all JAVAers know Apache Commons open source project.We can use Commons lib to generate hashCode() and equals() method.I wanna tell you that there is also a plugin for Eclipse called Commons4E which help you generate hasCode() and equals().
It also can generate toString() and compareTo() method.That's a smart plugin.Enjoy it.Link



文章来源:http://blueoxygen.dflying.net/3/archive/79_hibernate_pojos_good_assistant-commons_for_eclipse.html

posted @ 2006-03-16 11:19 BlueO2 阅读(431) | 评论 (0)编辑 收藏

Hibernate and Lazy Initialization

Hibernate object relational mapping offers both lazy and non-lazy modes of object initialization. Non-lazy initialization retrieves an object and all of its related objects at load time. This can result in hundreds if not thousands of select statements when retrieving one entity. The problem is compounded when bi-directional relationships are used, often causing entire databases to be loaded during the initial request. Of course one could tediously examine each object relationship and manually remove those most costly, but in the end, we may be losing the ease of use benefit sought in using the ORM tool.

The obvious solution is to employ the lazy loading mechanism provided by hibernate. This initialization strategy only loads an object's one-to-many and many-to-many relationships when these fields are accessed. The scenario is practically transparent to the developer and a minimum amount of database requests are made, resulting in major performance gains. One drawback to this technique is that lazy loading requires the Hibernate session to remain open while the data object is in use. This causes a major problem when trying to abstract the persistence layer via the Data Access Object pattern. In order to fully abstract the persistence mechanism, all database logic, including opening and closing sessions, must not be performed in the application layer. Most often, this logic is concealed behind the DAO implementation classes which implement interface stubs. The quick and dirty solution is to forget the DAO pattern and include database connection logic in the application layer. This works for small applications but in large systems this can prove to be a major design flaw, hindering application extensibility.


Being Lazy in the Web Layer

Fortunately for us, the Spring Framework has developed an out of box web solution for using the DAO pattern in combination with Hibernate lazy loading. For anyone not familiar with using the Spring Framework in combination with Hibernate, I will not go into the details here, but I encourage you to read Hibernate Data Access with the Spring Framework. In the case of a web application, Spring comes with both the OpenSessionInViewFilter and the OpenSessionInViewInterceptor. One can use either one interchangeably as both serve the same function. The only difference between the two is the interceptor runs within the Spring container and is configured within the web application context while the Filter runs in front of Spring and is configured within the web.xml. Regardless of which one is used, they both open the hibernate session during the request binding this session to the current thread. Once bound to the thread, the open hibernate session can transparently be used within the DAO implementation classes. The session will remain open for the view allowing lazy access the database value objects. Once the view logic is complete, the hibernate session is closed either in the Filter doFilter method or the Interceptor postHandle method. Below is an example of the configuration of each component:

Interceptor Configuration

<beans> 
  <bean id="urlMapping"     
     class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">    
       <property name="interceptors">
         <list>
              <ref bean="openSessionInViewInterceptor"/>
         </list>
       </property>
       <property name="mappings">
  ...
  </bean>
  ...
  <bean name="openSessionInViewInterceptor"  
    class="org.springframework.orm.hibernate.support.OpenSessionInViewInterceptor">
       <property name="sessionFactory"><ref bean="sessionFactory"/></property>
  </bean>
</beans>
 

Filter Configuration

<web-app>
 ...      
  <filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>
      org.springframework.orm.hibernate.support.OpenSessionInViewFilter
    </filter-class>
   </filter>
  ...      
  <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
     <url-pattern>*.spring</url-pattern>
  </filter-mapping>
  ...
</web-app>

Implementing the Hibernate DAO's to use the open session is simple. In fact, if you are already using the Spring Framework to implement your Hibernate DAO's, most likely you will not have to change a thing. The DAO's must access Hibernate through the convenient HibernateTemplate utility, which makes database access a piece of cake. Below is an example DAO.

Example DAO

public class HibernateProductDAO extends HibernateDaoSupport implements ProductDAO  {      
 
       public Product getProduct(Integer productId) {
              return (Product)getHibernateTemplate().load(Product.class, productId);
       }
 
       public Integer saveProduct(Product product) {
              return (Integer) getHibernateTemplate().save(product);
       }       
 
       public void updateProduct(Product product) {
              getHibernateTemplate().update(product);
       }
 }

Being Lazy in the Business Layer

Even outside the view, the Spring Framework makes it easy to use lazy load initialization, through the AOP interceptor HibernateInterceptor. The hibernate interceptor transparently intercepts calls to any business object configured in the Spring application context, opening a hibernate session before the call, and closing the session afterward. Let's run through a quick example. Suppose we have an interface BusinessObject:

public interface BusinessObject { 
     public void doSomethingThatInvolvesDaos(); 
}</pre><p><font size="2">The class BusinessObjectImpl implements BusinessObject:</font></p>
<p />
<pre>public class BusinessObjectImpl implements BusinessObject {
    public void doSomethingThatInvolvesDaos() {
        // lots of logic that calls
        // DAO classes Which access 
        // data objects lazily
    }
}

Through some configurations in the Spring application context, we can instruct the HibernateInterceptor to intercept calls to the BusinessObjectImpl allowing it's methods to lazily access data objects. Take a look at the fragment below:

<beans>
    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate.HibernateInterceptor">
         <property name="sessionFactory">
           <ref bean="sessionFactory"/>
         </property>
    </bean>
    <bean id="businessObjectTarget" class="com.acompany.BusinessObjectImpl">
       <property name="someDAO"><ref bean="someDAO"/></property>
    </bean>
    <bean id="businessObject" class="org.springframework.aop.framework.ProxyFactoryBean">
         <property name="target"><ref bean="businessObjectTarget"/></property>
         <property name="proxyInterfaces">
           <value>com.acompany.BusinessObject</value>
         </property>
         <property name="interceptorNames">
           <list>
              <value>hibernateInterceptor</value>
           </list>
         </property>
     </bean>            
</beans>
 
 

When the businessObject bean is referenced, the HibernateInterceptor opens a hibernate session and passes the call onto the BusinessObjectImpl. When the BusinessObjectImpl has finished executing, the HibernateInterceptor transparently closes the session. The application code has no knowledge of any persistence logic, yet it is still able to lazily access data objects.

Being Lazy in your Unit Tests

Last but not least, we'll need the ability to test our lazy application from J-Unit. This is easily done by overriding the setUp and tearDown methods of the TestCase class. I prefer to keep this code in a convenient abstract TestCase class for all of my tests to extend.

public abstract class MyLazyTestCase extends TestCase {
 
        private SessionFactory sessionFactory;
        private Session session;
	
        public void setUp() throws Exception {
	    super.setUp();
	    SessionFactory sessionFactory = (SessionFactory) getBean(\"sessionFactory&quot<img alt=";)" src="http://www.dflying.net/plugins/smileys/icons/default/wink_smile.gif" />;
	    session = SessionFactoryUtils.getSession(sessionFactory, true);
	    Session s = sessionFactory.openSession();
	    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(s));
 
        }
 
        protected Object getBean(String beanName) {
            //Code to get objects from Spring application context
        }
	
        public void tearDown() throws Exception {
	    super.tearDown();
	    SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
	    Session s = holder.getSession(); 
	    s.flush();
	    TransactionSynchronizationManager.unbindResource(sessionFactory);
	    SessionFactoryUtils.closeSessionIfNecessary(s, sessionFactory);
        }
}


文章来源:http://blueoxygen.dflying.net/3/archive/84_hibernate_performance_tuning.html

posted @ 2006-03-16 11:19 BlueO2 阅读(652) | 评论 (0)编辑 收藏

写了一些sample在我的Blog上面。还没入门的朋友可以看看
http://blueoxygen.dflying.net/3/archive/20_prototype_samples.html

posted @ 2006-03-16 11:18 BlueO2 阅读(270) | 评论 (0)编辑 收藏


posts - 29, comments - 3, trackbacks - 0, articles - 0

Copyright © BlueO2