软件实验室申请书.docx

上传人:b****7 文档编号:11102754 上传时间:2023-02-25 格式:DOCX 页数:19 大小:23.57KB
下载 相关 举报
软件实验室申请书.docx_第1页
第1页 / 共19页
软件实验室申请书.docx_第2页
第2页 / 共19页
软件实验室申请书.docx_第3页
第3页 / 共19页
软件实验室申请书.docx_第4页
第4页 / 共19页
软件实验室申请书.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

软件实验室申请书.docx

《软件实验室申请书.docx》由会员分享,可在线阅读,更多相关《软件实验室申请书.docx(19页珍藏版)》请在冰豆网上搜索。

软件实验室申请书.docx

软件实验室申请书

青岛农业大学

大学生创新教育立项申请书

项目名称JAVA后台服务程序

申请人程显聪(20102743)贺远鹏()

专业班级电子信息工程2010级

指导教师刘金梅

 

申请日期2012年3月28日

 

一、人员结构:

项目人员情况

项目主持人

姓名

性别

年龄

学院

专业班级

专长、发表文章及奖励

承担的工作

程显聪

21

理信

通信工程10级2班

暂无

组员

项目组主要成员

姓名

性别

年龄

学院

专业班级

专长、发表文章及奖励

承担的工作

程显聪

21

理信

通信工程10级2班

暂无

组员

贺远鹏

理信

通信工程10级1班

组员

指导教师情况

姓名

性别

年龄

学历学位

职称

学院

研究方向

刘金梅

33

硕士

讲师

理学与信息

图像处理

指导教师情况简介(包括专长、曾发表文章、奖励情况、指导学生情况等):

刘金梅,女,1979年7月出生,汉族,中国海洋大学硕士,讲师。

主讲《模拟电子技术》、《高频电子线路》。

近年来,主持省级自然科学基金联合专向:

基于多特征的遥感图像分类和识别研究(AR2009GL008);参与了山东省中青年科学家奖励基金:

基于边缘的图像检索研究(2001SD521);国家863项目:

参与海底管道的外探测装置及其检测技术-水下激光成像系统(2001AA602022)的图像采集、预处理工作。

2004年8月参加了在珠海召开的"第五届世界信息与计算科学学术研讨会"。

2006年8月参加了在大连召开的"第六届世界信息与计算科学学术研讨会"。

2011年3月参加了在深圳召开的"第一届数字信号处理与通讯工程国际会议"。

发表如下论文:

1.JinmeiLiu,GuoyuWang.Anewapproachoflocalfeaturecodingforcontent-basedimageretrieval.JournalofInformation&ComputationalScience.2004.(12):

163-167.

2.刘金梅,王国宇.一种基于块划分颜色特征的图像检索方法.中国海洋大学学报.2005.

(2):

330-334.

3.JinmeiLiu,Guoyuwang.Anovelpartition-basedcolorimageretrieval.JournalofInformation&ComputationalScience.2006.(12):

811-816.

4.XiaJun,LiuJinmei,WangGuoyu,LiJizhong.TheClassificationofLandCoverDerivedfromHighResolutionRemoteSensingImagery.IEEE,ICICTA.2011,

(2):

742-744

5.JinmeiLiu,GuoyuWang.ARefinedQuadtree-basedAutomaticC1assiflcationMethodforRemoteSensingImage.IEEE,ICCSNT2011.1703-1706

6.XiaJun,LiuJinmei,WangGuoyu.Anovelautomaticclassificationmethodbasedonmulti-spectrumremotesensingimagery.IEEE,CSQRWC.2011.

 

二、创新项目论证

(一)研究的目的、意义(包括立项依据、研究现状、目的意义等)

在许多大型软件项目中,后台服务程序都扮演着极为重要的角色。

它们无处不在,例如操作系统的内核程序处理各种对操作系统的内部调用;数据库系统的核心管理进程处理各种对数据库的读写操作和进程、资源的管理;大型ERP软件的内核管理程序要完成各种应用模块的资源、通讯管理等等。

它们使系统的各种服务、资源与应用的表示之间形成了一个松耦合关系,这样就极大地增加了软件系统的稳定性和伸缩性。

后台服务程序也就是相当于软件系统的管理调度中心,它是软件系统的中央处理器,是保证应用高效运行的内核程序。

在不同的软件系统中,由于软件的复杂程度和功能的不同使得各种软件系统的后台服务程序都有存在较大的差异。

但是后台服务程序还是有很多共同的特点,一个基本的后台服务程序大概可以由四个部分构成:

通用服务器框架、服务与监听、服务控制、服务器实现。

(二)研究的主要内容(包括方案、技术路线或手段、进程计划、目标等)

1.研究的方案:

使用具体的代码来实现一个基本的后台服务器程序,“中国自学编程网”整理通用服务器框架。

2.技术路线:

通过去图书馆和网上查阅JAVA语言技术的相关信息,再通过老师的指导自学好JAVA语言编程技术。

在实践中巩固加强这门技术,争取能够自己编写出性能合格的软件。

3,进程计划:

在开发后台服务程序中,首先实现一个通用服务器框架类,它能在多个端口提供多线程的服务(由多个Service对象定义),并且能够在系统运行时动态地调用和实例化Service类并加载新的服务或卸除已加载的服务。

下面是一个服务器框架的JAVA源码:

importjava.util.*;

importjava.io.*;

import.*;

publicclassServer

{

protectedMapservices;Setconnections;

intmaxConnections;

intfreeConn;

ThreadGroupthreadGroup;

privateintcurrentConn;

privatePrintWriterlog=newPrintWriter(System.out,true);

publicbooleanconnected=false;

publicPropertiesproPort,proNum;

publicsynchronizedvoidsetControlFlag()

{connected=true;}

publicsynchronizedvoidremoveControlFlag()

{connected=false;

}

publicvoidsetProperty(PropertiesproPort,PropertiesproNum)

{this.proPort=proPort;this.proNum=proNum;

}

publicServer(intmaxConn)

{this.maxConnections=maxConn;

this.freeConn=maxConnections;

this.threadGroup=newThreadGroup(Server.class.getName());

currentConn=0;

this.services=newHashMap();this.connections=newHashSet(maxConnections);

}

publicsynchronizedvoidaddService(Serviceservice,intport,intmaxConn)throwsIOException

{

Stringservicename=service.getClass().getName();

Integerkey=newInteger(port);

if(services.get(key)!

=null)thrownewIllegalArgumentException("端口:

"+port+"已经被占用!

");

if(getfreeConnections(maxConn)>=0)

{Listenerlistener=newListener(this,port,service,maxConn);

services.put(key,listener);

log.println("启动"+servicename+"服务在"+port+"端口上");

listener.start();

}

else{System.err.println("系统并发连接限制已经达到最大值!

");

System.err.println("服务"+servicename+"启动失败!

");

}

}publicsynchronizedvoidaddService(Serviceservice,intport)

throwsIOException{this.addService(service,port,10);

}

publicsynchronizedbooleanremoveService(intport)

{Integerkey=newInteger(port);intmaxConn=10;

finalListenerlistener=(Listener)services.get(key);

if(listener==null)

{log.println("Service"+"isn’tstartedonport"+port);returnfalse;

}

services.remove(key);

listener.pleaseStop();

freeConn+=listener.maxConn;log.println("Close"+listener.service+"onport"+port);

returntrue;

}

publicsynchronizedvoiddisplayStatus(PrintWriterout)

{

Iteratorkeys=services.keySet().iterator();

while(keys.hasNext())

{Integerport=(Integer)keys.next();

Listenerlistener=(Listener)services.get(port);

out.println("服务"+listener.service+"运行"+port+"n");

}

out.println("连接限制为"+maxConnections);

Iteratorconns=connections.iterator();

while(conns.hasNext())

{Sockets=(Socket)conns.next();intsport=s.getLocalPort();

Listenerlisten=(Listener)services.get(newInteger(sport));

Stringservicename=listen.service;out.println(servicename+"响应请求在"+s.getInetAddress().getHostAddress()+"的"+sport+"端口上");

}

out.println("当前连接数为"+currentConn);out.println("当前系统空闲连接数为"+freeConn);

}

privatesynchronizedintgetfreeConnections(intmaxConn){intnum=-1;

if(freeConn>=maxConn){

freeConn-=maxConn;num=freeConn;

}

returnnum;

}

publicsynchronizedintgetConnections()

{

returncurrentConn;

}

publicsynchronizedintaddConnections(Sockets)

{connections.add(s);

returncurrentConn++;

}

publicsynchronizedintremoveConnections(Sockets)

{connections.remove(s);

try{s.close();

}

catch(Exceptione){System.out.println(e.getMessage());

}

returncurrentConn--;

}

publicsynchronizedintgetConnections(intconnections)

{intnum=0;

if((num=freeConn-connections)>=0)

{freeConn=num;}elsenum=-1;

returnnum;

}

privatesynchronizedintgetFreeConn(){returnfreeConn;}

}

其次,服务器框架类Server主要是通过端口到监听器影射的散列表services来管理服务对象,Server类的几个主要方法说明如下:

addService方法:

此方法能够在特定的端口上创建新的服务,即在指定端口上运行指定的Service对象。

removeService方法:

此方法使服务器停止指定端口上的服务,并不终止连接,仅使服务器停止接受新的连接。

displayStatus方法:

此方法用于打印指定流上服务器的状态信息。

服务与监听

每个服务都对应着一个监听对象,监听指定端口的连接并在获得连接请求时调用addConnection(Sockets,Serviceservice)方法来取得(释放)一个连接。

一个监听类文件的源码如下:

importjava.util.*;

importjava.io.*;

import.*;

publicclassListenerextendsThread

{

privateServerSocketlistener;

privateintport;Stringservice;

Setconnections;

privateServicerunService;privatebooleanstop_flag=false;intmaxConn;

privatePrintWriterlog=newPrintWriter(System.err,true);

privateThreadGroupgroup;

privateintcurrentConnections=0;

Serverserver;Socketclient=null;publicListener(Serverserver,

intport,Serviceservice,intmaxConn,booleanbl)throwsIOException

{

this.server=server;

this.port=port;

this.service=service.getClass().getName();

this.maxConn=maxConn;this.group=server.threadGroup;

this.connections=server.connections;listener=newServerSocket(this.port);

if(bl==false)listener.setSoTimeout(600000);

this.runService=service;

if(!

stop_flag)

{

for(inti=0;i

{ConnectionHandlercurrentThread=newConnectionHandler(server,logStream);

newThread(this.group,currentThread,this.service+this.port+i).start();

this.logStream.realLog("向线程组"+group.toString()+"添加一个线程"+this.service+this.port+i);

}

}

elsethrownewIllegalArgumentException("系统并发连接限制已经超过最大值!

");

}

publicListener(Serverserver,intport,Serviceservice,intmaxConn)throwsIOException{this(server,port,service,maxConn,false);

}

publicvoidpleaseStop()

{

this.stop_flag=true;

try{listener.close();

}

catch(Exceptione){this.interrupt();

}

publicvoidrun()

{while(!

stop_flag)

{try{client=listener.accept();addConnection(client,runService);

}

catch(Exceptione){}}try{client.close();

}c

atch(IOExceptione){}}

privatesynchronizedvoidaddConnection(Sockets,Serviceservice){ConnectionHandler.requestToHandler(s,service);

}}

在实际处理过程中,Listener对象通过在指定端口上与指定服务的绑定实现监听过程,主要的几个方法说明如下:

pleaseStop:

以礼貌的方法停止接受连接。

addConnection:

把指定要处理的服务放到线程池中,以等待空闲的线程处理服务。

监听对象通过传递一个Service对象并唤醒它的serve()方法才真正提供了服务。

下就来实现一个具体的服务:

服务接口Service只有一个抽象方法serve(InputStreamin,OutputStreamout),它所有服务实现所必须重写的一个方法。

如下,一个Service接口的定义:

importjava.io.*;

import.*;

publicinterfaceService{

publicvoidserve(InputStreamin,OutputStreamout)throwsIOException;

}

一个简单的显示时间服务类Timer.java其源代码:

importjava.util.*;

importjava.text.*;

importjava.io.*;

import.*;

publicclassTimerimplementsService

{

publicTimer()

{}

publicvoidserve(InputStreamin,OutputStreamout)throwsIOException

{

StringtimeFormat="yyyy-MM-ddhh:

mm:

ss";

SimpleDateFormattimeFormatter=newSimpleDateFormat(timeFormat);

BufferedReaderfrom_client=newBufferedReader(newInputStreamReader(in));

PrintWriteroutPrint=newPrintWriter(out);

StringsDate=timeFormatter.format(newDate());

outPrint.println("当前时间是:

"+sDate);

outPrint.flush();

try{from_client.close();

outPrint.close();

}catch(Exceptione)

{}

}

}

通过实现Service接口可以编写很多的服务实现提供各种不同的服务

服务控制是在服务器运行时动态地操作控制服务器,如系统运行时,动态地装载(卸载)服务,显示服务器的状态信息等等。

为了简化基本后台服务系统的复杂程度,我们采用创建一个ControlService服务实例来在运行时管理服务器。

ControlService实现了基于命令的协议,可用密码保护操纵服务器,代码如下所示:

服务控制类文件ControlService.java源代码:

importjava.io.*;

importjava.util.*;

import.*;

importdvb.kuanshi.kssms.util.*;

importdvb.kuanshi.kssms.server.Server;publicclassControlServiceimplementsService{Serverserver;Stringpassword;publicControlService(Serverserver,Stringpassword)

{this.server=server;this.password=password;

}

publicvoidserve(InputStreamin,OutputStreamout)throwsIOException

{booleanauthorized=false;

BufferedReaderfrom_client=newBufferedRe

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

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

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

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