|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
最初被命名为Oak,目标设定在家用电器等小型系统的编程语言,来解决诸如电视机、电话、闹钟、烤面包机等家用电器的控制和通讯问题。
看上面的类:
HibernateSessionFactory.java
packagezy.pro.wd.util;
importnet.sf.hibernate.HibernateException;
importnet.sf.hibernate.Session;
importnet.sf.hibernate.cfg.Configuration;
/**
*ConfiguresandprovidesaccesstoHibernatesessions,tiedtothe
*currentthreadofexecution. FollowstheThreadLocalSession
*pattern,see{@linkhttp://hibernate.org/42.html}.
*/
publicclassHibernateSessionFactory{
/**
*Locationofhibernate.cfg.xmlfile.
*NOTICE:LocationshouldbeontheclasspathasHibernateuses
*#resourceAsStreamstylelookupforitsconfigurationfile.That
*isplacetheconfigfileinaJavapackage-thedefaultlocation
*isthedefaultJavapackage.
*Examples:
*CONFIG_FILE_LOCATION="/hibernate.conf.xml".
*CONFIG_FILE_LOCATION="/com/foo/bar/myhiberstuff.conf.xml".
*/
privatestaticStringCONFIG_FILE_LOCATION="/hibernate.cfg.xml";
/**HoldsasingleinstanceofSession*/
privatestaticfinalThreadLocalthreadLocal=newThreadLocal();
/**Thesingleinstanceofhibernateconfiguration*/
privatestaticfinalConfigurationcfg=newConfiguration();
/**ThesingleinstanceofhibernateSessionFactory*/
privatestaticnet.sf.hibernate.SessionFactorysessionFactory;
/**
*ReturnstheThreadLocalSessioninstance. Lazyinitialize
*theSessionFactoryifneeded.
*
* @returnSession
* @throwsHibernateException
*/
publicstaticSessioncurrentSession()throwsHibernateException{
Sessionsession=(Session)threadLocal.get();
if(session==null){
if(sessionFactory==null){
try{
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory=cfg.buildSessionFactory();
}
catch(Exceptione){
System.err.println("%%%%ErrorCreatingSessionFactory%%%%");
e.printStackTrace();
}
}
session=sessionFactory.openSession();
threadLocal.set(session);
}
returnsession;
}
/**
* Closethesinglehibernatesessioninstance.
*
* @throwsHibernateException
*/
publicstaticvoidcloseSession()throwsHibernateException{
Sessionsession=(Session)threadLocal.get();
threadLocal.set(null);
if(session!=null){
session.close();
}
}
/**
*Defaultconstructor.
*/
privateHibernateSessionFactory(){
}
}
<p>
到时我们不用学struts,不用学spring,不用学Hibernate,只要能把jsf学会了,完全可以替代所有的框架,包括AJAX,都知道AJAX并不是新技术,虽说我没深入学习jsf但我认为jsf应该已经能通过其它技术替代AJAX,实现无缝刷新。 |
|