資源簡介
無需積分,OSGi原理與最佳實踐完整版+源碼
代碼片段和文件信息
package?org.osgichina.petstore.bootstrap;
import?java.io.IOException;
import?java.util.ArrayList;
import?java.util.Collections;
import?java.util.Comparator;
import?java.util.List;
import?java.util.Map;
import?java.util.concurrent.ConcurrentHashMap;
import?javax.servlet.ServletOutputStream;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
import?org.osgi.framework.BundleContext;
import?org.osgi.framework.ServiceEvent;
import?org.osgi.framework.ServiceListener;
import?org.osgi.framework.ServiceReference;
import?org.osgi.service.http.HttpService;
import?org.osgichina.petstore.bootstrap.actionhandler.ActionHandler;
import?org.osgichina.petstore.bootstrap.actionhandler.ActionHandlerMap;
import?org.osgichina.petstore.bootstrap.pagetemplate.DefaultPage;
import?org.osgichina.petstore.bootstrap.pagetemplate.PageFooter;
import?org.osgichina.petstore.bootstrap.pagetemplate.PageHeader;
import?org.springframework.osgi.context.BundleContextAware;
/**
?*?總控的Servlet,空置整個頁面的生成
?*?@author?chris
?*
?*/
public?class?ControllerServlet?extends?HttpServlet?implements?BundleContextAware?ServiceListener{
private?static?final?long?serialVersionUID?=?1L;
/**
?*?注入的BundleContext
?*/
private?BundleContext?bundleContext;
/**
?*?注入的頁腳對象,負責頁腳的渲染
?*/
private?PageFooter?pageFooter;
/**
?*?注入的頁眉對象,負責頁眉的渲染
?*/
private?PageHeader?pageHeader;
/**
?*?HttpService的服務引用
?*/
private?ServiceReference?ref;
/**
?*?保存請求路徑和對應ActionHandler的Map
?*/
private?ConcurrentHashMap?actionHandlerMap?=?new?ConcurrentHashMap();
/**
?*?所有加載的模塊的提供的默認頁面列表
?*/
private?List?defaultPages?=?new?ArrayList();
/**
?*?Web應用的請求URI前綴
?*/
private?String?servletPath;
/**
?*?Web應用的資源URI的前綴
?*/
private?String?resourcePath;
public?String?getServletPath()?{
return?servletPath;
}
public?void?setServletPath(String?servletPath)?{
this.servletPath?=?servletPath;
}
public?String?getResourcePath()?{
return?resourcePath;
}
public?void?setResourcePath(String?resourcePath)?{
this.resourcePath?=?resourcePath;
}
/**?
?????*?Web?GET?Method?
?*/
????public?void?doGet(HttpServletRequest?request??HttpServletResponse?response)
????????throws?IOException{???
???? StringBuilder?sb?=?new?StringBuilder();
???? PageFooter?pageFooter?=?this.pageFooter;
???? PageHeader?pageHeader?=?this.pageHeader;
????
???? //獲取請求的路徑信息
???? String?pathInfo?=?request.getPathInfo();
????
???? ActionHandler?actionHandler?=?null;
????
???? //請求類似于http://localhost:8080/petstore或者http://localhost:8080/petstore/productlist
???? //這里petstore就是我們設定的servletPath,而pathInfo就是/petstore后面的部分
???? //對于http://localhost:8080/petstore這個請求,pathInfo就是null
???? //對于http://localhost:8080/petstore/productlist這個請求,pathInfo就是productlist
???? if(p
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????611??2009-05-19?17:03??OSGiBook?Sources\第三章\PetStore\Bootstrap\.classpath
?????文件????????670??2009-05-05?08:09??OSGiBook?Sources\第三章\PetStore\Bootstrap\.project
?????文件????????330??2009-05-05?08:09??OSGiBook?Sources\第三章\PetStore\Bootstrap\.settings\org.eclipse.jdt.core.prefs
?????文件????????152??2009-05-05?08:09??OSGiBook?Sources\第三章\PetStore\Bootstrap\.settings\org.eclipse.pde.core.prefs
?????文件????????641??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\css\petstore-common.css
?????文件???????1495??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\css\petstore-homepage.css
?????文件???????2813??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\bg_topline.png
?????文件???????2612??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\btn_login.png
?????文件????????153??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\dot_transparent.png
?????文件???????1827??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\logo_alibaba.gif
?????文件??????93715??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\logo_petstore_big.png
?????文件??????25469??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\logo_petstore_small.png
?????文件??????18735??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\logo_webx.png
?????文件???????6075??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\logo_webx_small.png
?????文件???????2964??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\petstore_ti
?????文件???????2926??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\tab_left.png
?????文件????????139??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\tab_mid.png
?????文件???????2929??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\tab_right.png
?????文件???????2895??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\tab_selected_left.png
?????文件????????135??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\tab_selected_mid.png
?????文件???????2907??2009-04-29?08:05??OSGiBook?Sources\第三章\PetStore\Bootstrap\bin\home\images\tab_selected_right.png
?????文件????????154??2009-05-12?08:10??OSGiBook?Sources\第三章\PetStore\Bootstrap\build.properties
?????文件?????121757??2007-12-03?16:37??OSGiBook?Sources\第三章\PetStore\Bootstrap\lib\commons-dbcp-1.2.2.jar
?????文件??????87077??2008-08-01?13:01??OSGiBook?Sources\第三章\PetStore\Bootstrap\lib\commons-pool-1.4.jar
?????文件?????641570??2008-07-21?14:14??OSGiBook?Sources\第三章\PetStore\Bootstrap\lib\hsqldb-1.8.0.5.jar
?????文件????????839??2009-05-20?10:57??OSGiBook?Sources\第三章\PetStore\Bootstrap\me
?????文件???????6202??2009-05-16?09:55??OSGiBook?Sources\第三章\PetStore\Bootstrap\me
?????文件?????????67??2009-05-17?17:57??OSGiBook?Sources\第三章\PetStore\Bootstrap\me
?????文件???????1022??2009-05-17?18:32??OSGiBook?Sources\第三章\PetStore\Bootstrap\me
?????文件???????1548??2009-06-10?07:34??OSGiBook?Sources\第三章\PetStore\Bootstrap\me
............此處省略1510個文件信息
評論
共有 條評論