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

舍利云30元/月起;美国CERA云服务器,原生ip,低至28元/月起

目前舍利云服务器的主要特色是适合seo和建站,性价比方面非常不错,舍利云的产品以BGP线路速度优质稳定而著称,对于产品的线路和带宽有着极其严格的讲究,这主要表现在其对母鸡的超售有严格的管控,与此同时舍利云也尽心尽力为用户提供完美服务。目前,香港cn2云服务器,5M/10M带宽,价格低至30元/月,可试用1天;;美国cera云服务器,原生ip,低至28元/月起。一、香港CN2云服务器香港CN2精品线...

Sharktech云服务器35折年付33美元起,2G内存/40G硬盘/4TB流量/多机房可选

Sharktech又称SK或者鲨鱼机房,是一家主打高防产品的国外商家,成立于2003年,提供的产品包括独立服务器租用、VPS云服务器等,自营机房在美国洛杉矶、丹佛、芝加哥和荷兰阿姆斯特丹等。之前我们经常分享商家提供的独立服务器产品,近期主机商针对云虚拟服务器(CVS)提供优惠码,优惠后XS套餐年付最低仅33.39美元起,支持使用支付宝、PayPal、信用卡等付款方式。下面以XS套餐为例,分享产品配...

易探云330元/年,成都4核8G/200G硬盘/15M带宽,仅1888元/3年起

易探云服务器怎么样?易探云是国内一家云计算服务商家,致力香港云服务器、美国云服务器、国内外服务器租用及托管等互联网业务,目前主要地区为运作香港BGP、香港CN2、广东、北京、深圳等地区。目前,易探云推出的国内云服务器优惠活动,国内云服务器2核2G5M云服务器低至330元/年起;成都4核8G/200G硬盘/15M带宽,仅1888元/3年起!易探云便宜vps服务器配置推荐:易探云vps云主机,入门型云...

英文搜索引擎为你推荐
可現場列印的全自動單面和雙面印相機IOJsios8支持ipad支持ipad支持ipad支持ipad支持ipadipad如何上网苹果ipad无线上网卡怎么设置?win10关闭445端口如何进入注册表修改关闭445端口360chrome360浏览器和谷歌chrome比哪个好用
jsp虚拟空间 虚拟主机服务商 域名主机空间 腾讯云盘 便宜域名 wordpress技巧 空间打开慢 godaddy域名优惠码 directadmin debian6 免费全能空间 php空间推荐 中国网通测速 空间登陆首页 东莞主机托管 乐视会员免费领取 博客域名 apachetomcat 建站论坛 远程登录 更多