欢迎来到天天文库
浏览记录
ID:39465335
大小:48.50 KB
页数:10页
时间:2019-07-04
《liferay静态化》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、我作了一个测试,把Liferay中cms部分增加了生成html的功能,提供给用户访问,这样在一定程度上可以减少10%数据库的负载,因为在互联网中匿名者访问占50%,其余的50%主要是做那些互动的操作,比如blog,bbs,电子商务.我们把一些page让用户在可选择的情况下进行generatingstaticHTML,当匿名者访问这个页面的时候,我们就把html的urlresponse给browser.我的这个测试这样做的首先把工具类做成一个监听服务ServletContextListener,在portal.properties设置一个values来确定howlo
2、ngagainruntheServletContextListener.然后admin根据需要选择guestgroup中的页面在pagesetting的功能中选择generatingstaticHTML,如图..最后,就是看我们的生成的页面了...这样,用户在使用liferay的情况下,当访问量很大的情况下,就能有效降低服务器的负载.首先增加一个自动生成代码的调度。。 1 2packagecom.blueauk.util; 3importjavax.servlet.*; 4 5/** 6*自动监听器 7*@authorstephen 8* 9*/10publicc
3、lassGeneratingListenerimplementsServletContextListener {11 12 /**13 *自动监听时钟14 */15 privateGeneratingTimerrt=null;16 17 publicvoidcontextInitialized(ServletContextEventevent){18 Stringstatus="Propertieslistenerstart.";19 event.getServletContext().log(status);20 Sys
4、tem.out.println(status);21 22 //激活自动监听时钟23 rt=newGeneratingTimer(15,event.getServletContext());24 rt.start();25 }26 27 publicvoidcontextDestroyed(ServletContextEventevent){28 Stringstatus="Propertieslistenerstop.";29 event.getServletContext().log(status);30
5、 System.out.println(status);31 32 //停止自动监听时钟33 if(rt!=null){34 rt.stop();35 }36 }37}1 2packagecom.blueauk.util; 3 4importjava.util.*; 5importjavax.servlet.*; 6 7/** 8*自动监听时钟 9*@authorstephen10*11*/1213publicclassGeneratingTimer{14 privatefinalTimertimer=new
6、Timer();15 privatefinalintsec;16 privateServletContextcontext=null;1718 publicGeneratingTimer(intseconds,ServletContextcontext){19 sec=seconds;20 this.context=context;21 }2223 /**24 *启动自动监听任务25 */26 publicvoidstart(){2728 //取得当前日期时间29 Datedate=newDate();3031
7、 //执行自动监听计划32 timer.schedule(newGeneratingTask(this.context),date,60*60*1000);33 }3435 /**36 *停止自动监听任务37 */38 publicvoidstop(){39 timer.cancel();4041 }4243} 2packagecom.blueauk.util; 3importjava.io.IOException; 4importjava.io.*; 5importjava.util.*; 6 7importja
8、vax.s
此文档下载收益归作者所有