外文基于Java的搜索引擎之面向主题英文翻译

英文搜索引擎  时间:2021-04-21  阅读:()

职场大变样社区www. z cdby. com下载毕业设计成品全套资料全部50元以下

学校代码 学 号

二○○八年六月

内蒙古工业大学本科毕业设计外文文献翻译

Architect Struts applications for Web services

Jero me Jo sep hraj

When you're converting an enterprise app for use with Web services, the simplestway to do it is to associate a single operation with a single enterprise service.Butthat's not necessarily the best idea. In this article,Jerome Josephraj shows you how tobuild Web services applications based on the tried and true Model-View-Controller(MVC)design pattern.To that end, he's adapted Struts, a popular open-source MVCframework, for use in the Web services arena.By examining the sample applicationoutlined here,you'll see how you can use Struts and Web services together.

have enabled software developers of various disciplines to create distributedcomputing applications that were previously possible only with relatively proprietarytools.Thus,while some development teams may choose to implement new systems inthe Java platform, others will create, enhance,and maintain applications using otherskills and then integrate them into an existing heterogeneous distributed application.This situation gives rise to an interoperability challenge.How can a new applicationinteract with an old one?The answer:Web services.Web services are the new holygrail of programming. They make it possible to share and coordinate dispersed,heterogeneous computing resources.

In this article, you'll learn one route to this goal.You'll see how to architect anapplication based on the open-source Struts framework that can integrate with Webservices.You should have some background in J2EE and Web services before youbegin; I'll briefly introduce the Struts framework and the Model-View-Controller(MVC)pattern here,but if you haven't encountered them before, you should checkout the Resources sectionbelow for more information.

1 The MVC pattern:Separating development roles

The MVC design pattern clearly demarcates the roles of programmers anddesigners. In other words, it untangles data from busine ss logic.This pattern allowsdesigners to concentrate on the display portion of an application and developers toconcentrate on developing the components required to drive the application'sfunctions.

1

内蒙古工业大学本科毕业设计外文文献翻译

There are several variations to the MVC pattern,but they are all based on thesame underpinning structure:an application's data models (the Model),presentationcode (the View), and program control logic (the Controller) should exist as distinctbut intercommunicating components.The Model component represents and processesapplication data.The View is the user interface; it reflects the Model data and presentsit to the user. The Controller maps actions performed on the View(for example,pressing a Submit button) to operations on the Model (for example, retrieving userdetails).After the Model is updated, the View is refreshed and the user can performmore actions.The MVC pattern clarifies code and facilitates code reuse; in addition,in many projects the View is frequently updated, and the MVC pattern insulates theModel and Controller against those changes.

2 Struts:A solid MVC-based framework

Struts is an open-source framework for building Web applications based on theMVC pattern. Struts encourages app lication architectures b ased on the MVC patternand provides services common to most Web applications.

In a Struts application,you can architect the Model layer so that the business anddata retrieval logic are easy to reuse. This layer is responsible for running theapplication's business logic and getting the relevant data (for example, running anSQLcommand or reading a flat file).

Struts encourages application architectures based on the Model-View-Controllerdesign paradigm. Struts provides its own Controller component (the ActionControllerclasses)and integrates with other technologies to provide the Model and the View.Forthe Model (Model classes), Struts can interact with any standard data accesstechnology, including Enterprise Java Beans technology, JDBC, and theObject-Relational Bridge.For the View(ActionForm classes),Struts works well withthe JavaServer Pages (JSP)environment and other presentation systems.

3A s imp le--and ine le gant --Web service s architecture

The simplest way to build Web services is to associate a single operation with asingle enterprise service, In this design, services that perform business logic andservices that perform data retrieval are intermingled.

Such a Web services architecture is easy to develop from existing business

2

内蒙古工业大学本科毕业设计外文文献翻译

components.However, it has a number of weaknesses: there is no single sign-on pointfor the user, the coupling between the provider and subscriber isn't very tight, andbusiness logic is not reused. In short, this isn't a very good architecture for a coherentsolution.

It's a better idea to base a Web services solution on the MVC pattern. In thecoming sections, you'll see how you can use Struts to do just that. I'll expand theexisting Struts framework with the WSManager layer,which exposes the Modelservice methods with Web services.

4Web services with Struts applications

You can augment a well-architected Struts application to support Web services infuture development.As noted, the Struts framework clearly demarcates a View, aController, and a Model. The Model contains all the business logic necessary toretrieve data from a persistent data store.You can build a simple Web service layer --call it the WSManager layer -- so that the Model can either provide or subscribe to aWeb service.An application that uses this architecture combines the best aspects ofcomponent-based development and the World Wide Web.

The following sections discuss in detail the different components used in thisarchitecture,paying particularly close attention to the WSManager layer, since that isthe truly new portion o f this architecture.

5 Struts Co ntro ller

The Controller portion of the MVC architecture is focused on receiving requestsfrom the client (typically a user running a Web browser),deciding what business logicfunction should be performed in response to those requests, and then delegatingresponsibility for producing the next phase of the user interface to an appropriateView component. In Struts, the primary component of the controller is a servlet ofc lass ActionServlet.

The ActionServlet is responsible for mapping URI requests to specific actionsthrough an XML file. This file contains a list of request URIs and tells theActionServlet how it should dispatch each of them.There are several advantages tothis approach:

1) he entire logical flow of the application is in a hierarchical text file.

3

内蒙古工业大学本科毕业设计外文文献翻译

2) he list in this format is easier to view and understand, especially for alarge application.

The ActionServlet decides the flow of the application.A number of Action classesextend ActionServlet.Each Action c las s:

1)Maps to a distinct process

2) Interacts with Struts JSPs through the Struts ActionController

3) Is mplemented as a Java class that extends the Struts Action class.

The Struts Action classes call the relevant methods in the WSManager classes tomake use of a Web service. The WSManager gets the required response -- or anexception, if one is raised--and passes it back to the Struts Controller.

6 The WSManager

The WSManager receives requests from a JAX-RPC endpoint.Method calls inthe WSManager classes are mapped to incoming client requests. These incomingclient requests are in the form of SOAP messages.The WSManager should performsecurity validations, transform parameters, and preprocess the parameters for theserequests before delegating the requests to the Model service.A request can containparameters in the form of Java objects, Java primitive parameters,XML documents,or even SOAP document fragments (for example, SOAP Element objects). Thesetypes should be transformed to an internally-supported schema (for example,predefined Java Data Access Objects).

While the WSManager can handle parameters bound to Java objects in astraightforward manner, it might need to take additional step s to deal with XMLdocuments.The fo llowing steps are recommended:

1)He WSManager classes should validate an incoming XML document against itssche ma.

2)The WSManager classes should then transform the XML document to theinternally supported schema.

3)Lastly, the WSManager should disassemble the document and potentially map itinto domain objects.

It is important that the WSManager perform the following tasks:

1)Authentication and authorization

4

内蒙古工业大学本科毕业设计外文文献翻译

2)Handling errors

3)Caching.

The WSManager also generates responses; this process consists of simplyconstructing the method call return values. By keeping this functionality in theWSManager,you can cache data to avoid extra trips to the Model service tier.You canalso centralize response assembly and XML document transformation,which isparticularly important if the document you'll return to the caller must conform to aschema different from the internal schema.

The WSManager handles all the incoming SOAP requests and delegates them tothe business logic exposed in the Model service. If the Model service is implementedas an EJB tier,you could potentially do this through a Session Façade design patternin the EJB tier. If you implement the WSManager using this pattern, you'll gainseveral advantages, since the WSManager will:

1)Manage the handling of requests and serves as the initial point ofcontact

2) Invoke security services, including authentication and authorization, to avoidany unnecessary layer trips

3)Delegate business processing(by using the Model service used by the Strutsapplication)

4)Cache the data at the WSManager layer to avoid any unnecessary database trips.

7 Publisher:Exposing a Web service

Each public method implemented in the WSManager classes will be published asa Web service. In other words,you'll be publishing a Web service description for theseclasses.A Web service description consists of the service's Web Services DescriptionLanguage(WSDL)description and any XML schemas referenced by it. (WSDL is thestandard language for describing a service.)

You can publish a Web service description on a public registry or on a corporateregistry within an enterprise.You can also publish XML schemas defined by the Webservice on the same corporate or public repository.A Java Web service client uses theJAXR APIs to look up the service description on the corporate or public registry.

You do not need to use a registry if all of your clients are dedicated partners.Instead,you canpublish your Web service description(the WSDLand XML schemas)

5

内蒙古工业大学本科毕业设计外文文献翻译

on the Web tier of your application or at a well-known location with the properprotection. For example, imagine a client application of a reseller who has anagreement with a particular supplier.The client application has been statically boundat development time to the supplier's Web service. Only authorized parties canreference the XML schemas or retrieve the service description from the Web tier togenerate the client code.You should implement such authentication and authorizationof valid clients in WSManager layer.

8 Subscriber:Using a Web service

A Struts application can make use of a Web service that is already either in thepublic registry or within an enterprise.The WSManager can have methods that parsethe necessary WSDL file and call the relevant operation to return a result.The StrutsController calls the relevant methods in the WSManager classes in order to use aparticular Web service.Data is passed back and forth between the WSManager andStruts Controller as predefined Data Access Objects.Any exceptions that occur whenaccessing the Web service are raised in the WSManager and propagated back to theStruts ActionController.

A service requester will search for Web services by using the service broker; if itfinds a Web service that it wants to use, it will try to set up a contract with the serviceprovider in order to consume the service,and thus do business.

To subscribe to a Web service,WSManager uses a WSDL document, a servername, a port name, and an operation name, along with any necessary requestparameters,which might include a Java primitive type,a Java array,a Java object,oran XML document.

If the target Web service is published in a UDDI registry, any Struts-based appcan subscribe to it using a broker service such as XMethods (see Resources).Afterexecuting the requested operation, the provider Web service returns the expectedresults.The WSManager can change the returned result to match the schema that theapplication is expecting; it could also amend the result based on the application'srequirements.After receiving the result from WSManager, the Struts ActionControllercan either process the result and forward it to the relevant View or call the relevantModel service to perform further processing.

6

内蒙古工业大学本科毕业设计外文文献翻译

9 Error handling

All error handling is taken care of in the WSManager layer; this eliminatesunnecessary server trips.This gives a particularly marked performance boost if theModel service is implemented as EJB Layers.

When acting as a provider, the WSManager throws any exception as aSOAPFaultException. It can also check an incoming request and throw exceptions forany missing mandatory fields.You can create a class to track and log these errors in adata sto re for future re fere nce.

When acting as a subscriber, the WSManager catches any SOAP exceptionsthrown by the service provider and changes them to the format that WSManagerrequires.The thrown error can be logged for any future references. The responsevalues can also be verified and thrown as exceptions if and when needed.You cancreate a class to log the exceptions for future reference.The WSManager can validatethe response value and canthrow it as an exception.

10Auditing

When acting as a provider, the WSManager can log details for future auditingpurposes.You can use this information for a number of purposes, such as:

1Billing a client based on the number of hits it receives

2 Collecting data for marketing purpo ses

3Determining if an application needs to be upgraded

4 Identifying and capturing rogue users.

11 Caching

Web service clients tend to be richer than clients in a typical client-serverarchitecture; thus, in a Web services architecture, the client can do more work, such ascaching.Web services can maximize performance by correctly using data caching.You should consider using caching in a Web service when the service's requestedinformation is primarily read-only or when that information changes at a slower ratethan that at which it is requested.

12Authentication and authorization

You can implement the authentication of any subscriber in the WSManager layer.Any client who wants to use the Web service should go through this authentication

7

内蒙古工业大学本科毕业设计外文文献翻译

logic.You can use basic user authentication or a digital certificate for this purpose.

13 Struts View

You would build the View portion of a Struts-based application using JSPtechnology. JSP pages can contain static HTML plus dynamic content that changesbased on the interpretation(at page request time) of special action tags. The JSPenvironment includes a set of standard action tags. In addition, there is a standardfacility that developers can use to define their own tags,which are organized intocusto m tag libraries.

The Struts framework includes an extensive custom tag library that facilitatesuser interfaces that are fully internationalized and interact gracefully with ActionFormbeans.The View layer is thin and supplies no business logic.The Struts View interactswith the Struts Contro ller through ActionForm.

14 Struts Ac tionF orm

ActionForms are nothing but Java classes extending the Struts-provided ActionFormclasses,which have accessor and mutator methods.These methods are called either byJSP pages or by Action classes to populate or retrieve data.

15Model services

The Model service is implemented as a set of Java classes.Each Model servicecomponent will offer a set of services, and the components collectively offer a set ofcommon services as well.The ActionController and WSManager classes pass data backand forth as predefined Data Access Objects. In the course of processing, theActionController or the WSManager can call the required methods in the relevant Modelservice components.These components pass the required data in the form of DataAccess Objects to the Model service,and the Model service performs any necessarybusiness logic processing and retrieves any necessary data from the persistent datastore.The Model service components populate the relevant predefined Data AccessObject, and pass it back to the ActionServlet or WSManager classes.Any error orvalidation messages are propagated back to the ActionServlet or WSManager layer.

You should apply the following design rules to your applications:

1 The Model service should not contain any View-related code (i.e., sessionhandling).

8

SunthyCloud阿里云国际版分销商注册教程,即可PayPal信用卡分销商服务器

阿里云国际版注册认证教程-免绑卡-免实名买服务器安全、便宜、可靠、良心,支持人民币充值,提供代理折扣简介SunthyCloud成立于2015年,是阿里云国际版正规战略级渠道商,也是阿里云国际版最大的分销商,专业为全球企业客户提供阿里云国际版开户注册、认证、充值等服务,通过SunthyCloud开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡就可以帮你开通、充值、新购、续费阿里云国际版,服务...

妮妮云,美国cera CN2线路,VPS享3折优惠

近期联通CUVIP的线路(AS4837线路)非常火热,妮妮云也推出了这类线路的套餐以及优惠,目前到国内优质线路排行大致如下:电信CN2 GIA>联通AS9929>联通AS4837>电信CN2 GT>普通线路,AS4837线路比起前两的优势就是带宽比较大,相对便宜一些,所以大家才能看到这个线路的带宽都非常高。妮妮云互联目前云服务器开放抽奖活动,每天开通前10台享3折优惠,另外...

ParkinHost:俄罗斯离岸主机,抗投诉VPS,200Mbps带宽/莫斯科CN2线路/不限流量/无视DMCA/55折促销26.4欧元 /年起

外贸主机哪家好?抗投诉VPS哪家好?无视DMCA。ParkinHost今年还没有搞过促销,这次parkinhost俄罗斯机房上新服务器,母机采用2个E5-2680v3处理器、128G内存、RAID10硬盘、2Gbps上行线路。具体到VPS全部200Mbps带宽,除了最便宜的套餐限制流量之外,其他的全部是无限流量VPS。ParkinHost,成立于 2013 年,印度主机商,隶属于 DiggDigi...

英文搜索引擎为你推荐
proprietaryios11城乡居民社会养老保险人脸识别生存认证重庆网通重庆联通网上营业厅手机版photoshop技术photoshop技术对哪些工作有用?ms17-010win10蒙林北冬虫夏草酒·10年原浆1*6 500ml 176,176是一瓶的价格还是一箱的价格iphonewifi苹果手机怎么扫二维码连wifixp系统关闭445端口xp中,如何关闭掉一些没有用的端口,请高手解答?联通iphone4联通iphone4跟苹果的iphone4有什么不一样? 比如少了什么功能? 还是什么的?googleadsenceGoogle AdSense 帐户状态是什么意思!迅雷下载速度为什么现在迅雷下载的速度比原来慢得多?
.cn域名注册 表格样式 win8.1企业版升级win10 web服务器架设软件 免费ftp空间申请 台湾谷歌网址 东莞数据中心 无限流量 空间首页登陆 qq金券 美国迈阿密 ssl加速 带宽测试 godaddyssl cdn免备案空间 studentmain paypal登陆 热云 iptables rsync 更多