基于OSGi和Spring开发Web应用Word文档格式.docx

上传人:b****5 文档编号:19769587 上传时间:2023-01-10 格式:DOCX 页数:17 大小:414.78KB
下载 相关 举报
基于OSGi和Spring开发Web应用Word文档格式.docx_第1页
第1页 / 共17页
基于OSGi和Spring开发Web应用Word文档格式.docx_第2页
第2页 / 共17页
基于OSGi和Spring开发Web应用Word文档格式.docx_第3页
第3页 / 共17页
基于OSGi和Spring开发Web应用Word文档格式.docx_第4页
第4页 / 共17页
基于OSGi和Spring开发Web应用Word文档格式.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

基于OSGi和Spring开发Web应用Word文档格式.docx

《基于OSGi和Spring开发Web应用Word文档格式.docx》由会员分享,可在线阅读,更多相关《基于OSGi和Spring开发Web应用Word文档格式.docx(17页珍藏版)》请在冰豆网上搜索。

基于OSGi和Spring开发Web应用Word文档格式.docx

!

"

;

}

}

接下来,我需要将这个实现类发布成为一个OSGI服务:

在工程新一个目录OSGI-INF,并新建一个components.xml文档。

<

?

xmlversion="

1.0"

encoding="

UTF-8"

>

componentname="

ShowMsgInfo"

immediate="

true"

<

implementationclass="

com.infotech.test.service.ShowMsgInfo"

/>

service>

<

provideinterface="

mon.IShowMsgInfo"

/service>

/component>

打开这个接口bundle工程的MANIFEST.MS文件,添加一行

Service-Component:

OSGI-INF/components.xml

四、接下来,我们创建一个WEB应用bundle:

.1.新建一个网页bundle工程:

2.在工程目录中创建WEB-INF/lib、WEB-INF/classes两个目录

并在WEB-INF目录中,创建Spring、jsf、及web配置文件:

3.在MANIFEST.MF文件中的配置项:

Runtime/Classpath中添加刚才创建的两个目录。

4.点击Add添加我们将要使用的jar包

5.新建一个网页就的Bean类TestBean

packagecom.infotech.test.bean;

importcom.infotech.test.control.TestBeanControl;

publicclassTestBean{

privateTestBeanControltestControl;

publicStringgetShowMsg(){

returntestControl.getShowMsg();

publicTestBeanControlgetTestControl(){

returntestControl;

publicvoidsetTestControl(TestBeanControltestControl){

this.testControl=testControl;

6.创建一下控制类TestBeanControl

packagecom.infotech.test.control;

publicclassTestBeanControl{

privatestaticIShowMsgInfomsginfoService;

returnmsginfoService.GetMsgInfo();

publicvoidsetMsginfoService(IShowMsgInfomsginfoService){

this.msginfoService=msginfoService;

publicvoidunsetMsginfoService(IShowMsgInfomsginfoService){

if(this.msginfoService==msginfoService)

this.msginfoService=null;

7.打开这个接口bundle工程的MANIFEST.MS文件,在Dependencies/ImportedPackages中添加上面新建的接口服务类及WEB服务类

8.新建一个OSGI-INF/components.xm文件,我们来引用上面发布出来的OSGI服务

TestBean"

com.infotech.test.control.TestBeanControl"

referencename="

msginfoService"

interface="

bind="

setMsginfoService"

unbind="

unsetMsginfoService"

cardinality="

0..1"

policy="

dynamic"

9.打开这个接口bundle工程的MANIFEST.MS文件,添加一行

10.

修改Application-test.xml

DOCTYPEbeansPUBLIC"

-//SPRING//DTDBEAN//EN"

"

http:

//www.springframework.org/dtd/spring-beans.dtd"

beans>

beanid="

TestControl"

class="

/bean>

/beans>

修改faces-config.xml

DOCTYPEfaces-configPUBLIC

-//SunMicrosystems,Inc.//DTDJavaServerFacesConfig1.1//EN"

faces-config>

application>

message-bundle>

xmanager_web_resources<

/message-bundle>

locale-config>

<

default-locale>

zh_CN<

/default-locale>

/locale-config>

variable-resolver>

org.springframework.web.jsf.DelegatingVariableResolver

/variable-resolver>

/application>

managed-bean>

managed-bean-name>

TestBean<

/managed-bean-name>

managed-bean-class>

com.infotech.test.bean.TestBean<

/managed-bean-class>

managed-bean-scope>

session<

/managed-bean-scope>

managed-property>

property-name>

testControl<

/property-name>

value>

#{TestControl}<

/value>

/managed-property>

/managed-bean>

navigation-rule>

description>

index<

/description>

from-view-id>

*<

/from-view-id>

navigation-case>

from-outcome>

/from-outcome>

to-view-id>

/index.jsp<

/to-view-id>

redirect/>

/navigation-case>

/navigation-rule>

/faces-config>

修改web.xml

web-appid="

WebApp_ID"

version="

2.4"

xmlns="

xmlns:

xsi="

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

display-name>

XmanagerWeb<

/display-name>

context-param>

param-name>

javax.faces.CONFIG_FILES<

/param-name>

param-value>

/WEB-INF/faces-config.xml<

/param-value>

/context-param>

org.apache.myfaces.DETECT_JAVASCRIPT<

false<

org.apache.myfaces.PRETTY_HTML<

true<

org.apache.myfaces.AUTO_SCROLL<

contextConfigLocation<

/WEB-INF/Application*.xml<

listener>

listener-class>

org.springframework.web.context.ContextLoaderListener

/listener-class>

/listener>

filter>

filter-name>

MyFacesExtensionsFilter<

/filter-name>

filter-class>

org.apache.myfaces.webapp.filter.ExtensionsFilter

/filter-class>

init-param>

maxFileSize<

100m<

/init-param>

/filter>

filter-mapping>

servlet-name>

FacesServlet<

/servlet-name>

/filter-mapping>

url-pattern>

/faces/myFacesExtensionResource/*<

/url-pattern>

SetCharacterEncoding<

org.springframework.web.filter.CharacterEncodingFilter

encoding<

UTF-8<

*.jsf<

servlet>

servlet-class>

javax.faces.webapp.FacesServlet<

/servlet-class>

load-on-startup>

1<

/load-on-startup>

/servlet>

servlet-mapping>

/servlet-mapping>

welcome-file-list>

welcome-file>

index.jsf<

/welcome-file>

index.jsp<

/welcome-file-list>

/web-app>

11.导入三个工程:

Catalina.config

Server.config

Org.springframework.osgi.log4j.config

12.好了,写一个测试页:

index.jsp

%@pagelanguage="

java"

contentType="

text/html;

charset=UTF-8"

pageEncoding="

%>

%@taglibprefix="

f"

uri="

%>

h"

x"

//myfaces.apache.org/tomahawk"

c"

t"

html>

head>

metahttp-equiv="

Content-Type"

content="

charset=utf-8"

title>

/title>

/head>

body>

f:

view>

h:

outputTextvalue="

#{TestBean.showMsg}"

/h:

outputText>

/f:

/body>

/html>

13.最后我创建一个Debug环境

运行结果:

定时下载任务:

下载文件,设置超时,若长时间下载不成功,则取消下载

下载文件后,对其进行解压缩,

判断解压缩后的文件是否为XML文件,若是,则先删除老文件,将其移到至新文件夹,并存储文件信息到数据库。

若不是,则直接删除整个文件夹不予更新。

上传文件

判断文件是为XML文件还是ZIP文件,

若为XML文件则转移到新文件夹,记录到数据库

若为ZIP文件,则解压缩,则解压缩后的文件

读取XML文件,将相关信息读取出来存储

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1