|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
没有那个大公司会傻了吧唧用.net开发大型项目,开发了,那等于自己一半的生命线被微软握着呢。而.net不行,限制在window系统,又是捆绑,鄙视微软之!
2.在体系启动的时分,把一切的资本load到内存作为缓存
因为资本信息关于每一个项目来讲,绝对流动,以是我们能够将他们在体系启动的时分就load到内存作为缓存。这里做法良多,我给出的示例是将资本的寄存在servletContext中。
Java代码
publicclassServletContextLoaderListenerimplementsServletContextListener{
/*(non-Javadoc)
*@seejavax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
publicvoidcontextInitialized(ServletContextEventservletContextEvent){
ServletContextservletContext=servletContextEvent.getServletContext();
SecurityManagersecurityManager=this.getSecurityManager(servletContext);
Map<String,String>urlAuthorities=securityManager.loadUrlAuthorities();
servletContext.setAttribute("urlAuthorities",urlAuthorities);
}
/*(non-Javadoc)
*@seejavax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
publicvoidcontextDestroyed(ServletContextEventservletContextEvent){
servletContextEvent.getServletContext().removeAttribute("urlAuthorities");
}
/**
*GetSecurityManagerfromApplicationContext
*
*@paramservletContext
*@return
*/
protectedSecurityManagergetSecurityManager(ServletContextservletContext){
return(SecurityManager)WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("securityManager");
}
}
publicclassServletContextLoaderListenerimplementsServletContextListener{
/*(non-Javadoc)
*@seejavax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
publicvoidcontextInitialized(ServletContextEventservletContextEvent){
ServletContextservletContext=servletContextEvent.getServletContext();
SecurityManagersecurityManager=this.getSecurityManager(servletContext);
Map<String,String>urlAuthorities=securityManager.loadUrlAuthorities();
servletContext.setAttribute("urlAuthorities",urlAuthorities);
}
/*(non-Javadoc)
*@seejavax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
publicvoidcontextDestroyed(ServletContextEventservletContextEvent){
servletContextEvent.getServletContext().removeAttribute("urlAuthorities");
}
/**
*GetSecurityManagerfromApplicationContext
*
*@paramservletContext
*@return
*/
protectedSecurityManagergetSecurityManager(ServletContextservletContext){
return(SecurityManager)WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("securityManager");
}
}
<p>
Java的B/s开发是通常是javaweb开发,又叫J2EE开发,J2SE是手机开发。C#的C/s和B/s开发是说.net和Asp开发。。u在这里说明一点;资深一点的Java和C#程序员都明白一点 |
|