• 大小: 33.98MB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-06-13
  • 语言: 其他
  • 标签: OSGi  

资源简介

无需积分,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_title.png

     文件       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\meta-INF\MANIFEST.MF

     文件       6202  2009-05-16 09:55  OSGiBook Sources\第三章\PetStore\Bootstrap\meta-INF\resources\sql\petstore-hsqldb-dataload.sql

     文件         67  2009-05-17 17:57  OSGiBook Sources\第三章\PetStore\Bootstrap\meta-INF\resources\sql\petstore-hsqldb-schema-drop.sql

     文件       1022  2009-05-17 18:32  OSGiBook Sources\第三章\PetStore\Bootstrap\meta-INF\resources\sql\petstore-hsqldb-schema.sql

     文件       1548  2009-06-10 07:34  OSGiBook Sources\第三章\PetStore\Bootstrap\meta-INF\spring\bootstrap-osgi.xml

............此处省略1510个文件信息

评论

共有 条评论