package sample;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import com.google.inject.Injector;
import com.google.inject.Guice;
import com.wideplay.warp.persist.PersistenceService;
import com.wideplay.warp.persist.UnitOfWork;
import com.wideplay.warp.persist.TransactionStrategy;
public class BlogAppContextListener implements ServletContextListener
{
private static Injector injector;
public void contextInitialized(ServletContextEvent servletContextEvent)
{
//Based on code examples in the the Warp-persist guide here
injector = Guice.createInjector(new BlogModule(), PersistenceService
.usingJpa()
.across(UnitOfWork.REQUEST)
.addAccessor(BlogAccessor.class)
.transactedWith(TransactionStrategy.LOCAL)
.buildModule());
}
public static <T> T getInstance(java.lang.Class<T> aClass) {
assert injector!=null : "contextInitialized is expected to be called before invoking this method";
return injector.getInstance(aClass);
}
public void contextDestroyed(ServletContextEvent servletContextEvent)
{
//$Fixme!$ stop persistence service here..
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
A sample Java web application that demonstrates how <br><br>Deployment :<br> * Install Dekoh desktop<br> * Start dekoh in interactive mode by executing dekoh_shell.bat / dekoh_shell.sh in directory C:\Dekoh\server\bin on Windows /home/${user.home}/Dekoh/server/bin<br> * At the shell prompt type 'deploy <file path to WAR>'<br> * Start your favorite browser and type http://localhost/blogreader
资源推荐
资源详情
资源评论
收起资源包目录
blogreadersample_src_oct13.zip (23个子文件)
blog
guice_dekoh
doc-root
index.jsp 1KB
pramati-j2ee-server.xml 589B
createBlog.jsp 766B
WEB-INF
web.xml 784B
classes
sample
Blog.class 2KB
BlogAppContextListener.class 2KB
BlogAccessor.class 845B
BlogModule$MyInitializer.class 919B
BlogModule.class 1KB
CreateBlog.class 1007B
resources
META-INF
persistence.xml 1KB
guice_dekoh.iml 3KB
src
sample
BlogAccessorWithJPAQueries.java 1KB
BlogAppContextListener.java 1KB
BlogModule.java 896B
BlogAccessor.java 934B
Blog.java 1KB
CreateBlog.java 945B
blog.xml 11KB
blog.iws 40KB
blog.ipr 17KB
blog.properties 56B
README 611B
共 23 条
- 1
资源评论
jipinceo
- 粉丝: 5
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功