外文基于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

RAKsmart(年79元),云服务器年付套餐汇总 - 香港 美国 日本云服务器

RAKsmart 商家从原本只有专注于独立服务器后看到产品线比较单薄,后来陆续有增加站群服务器、高防服务器、VPS主机,以及现在也有在新增云服务器、裸机云服务器等等。机房也有增加到拥有洛杉矶、圣何塞、日本、韩国、中国香港等多个机房。在年前也有介绍到RAKsmart商家有提供年付129元的云服务器套餐,年后我们看到居然再次刷新年付云服务器低价格。我们看到云服务器低至年79元,如果有需要便宜云服务器的...

NameCheap新注册.COM域名$5.98

随着自媒体和短视频的发展,确实对于传统的PC独立网站影响比较大的。我们可以看到云服务器商家的各种促销折扣活动,我们也看到传统域名商的轮番新注册和转入的促销,到现在这个状态已经不能说这些商家的为用户考虑,而是在不断的抢夺同行的客户。我们看到Namecheap商家新注册域名和转入活动一个接一个。如果我们有需要新注册.COM域名的,只需要5.98美元。优惠码:NEWCOM598。同时有赠送2个月免费域名...

[6.18]IMIDC:香港/台湾服务器月付30美元起,日本/俄罗斯服务器月付49美元起

IMIDC发布了6.18大促销活动,针对香港、台湾、日本和莫斯科独立服务器提供特别优惠价格最低月付30美元起。IMIDC名为彩虹数据(Rainbow Cloud),是一家香港本土运营商,全线产品自营,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非等地机房,CN2网络直连到中国大陆。香港服务器   $39/...

英文搜索引擎为你推荐
中國信託商業銀行j^=iáíá=fq~=OQJOU==aJPPNMO=m~dê~ó=generatingcss支持ipad支付apple支持ipad您的iphoneipad如何上网ipad怎么设置网络?ipad连不上wifi苹果ipad突然连不上网了,是怎么回事?网络是好的,手机能上网。win10关闭445端口win10家庭版怎么禁用445端口
免费网站空间申请 个人域名注册 阿里云搜索 美国主机论坛 idc测评网 l5520 gomezpeer 60g硬盘 数字域名 域名转向 135邮箱 佛山高防服务器 photobucket 群英网络 电信宽带测速软件 国内空间 闪讯网 七十九刀 石家庄服务器 开心online 更多