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

IMIDC彩虹数据:日本站群多ip服务器促销;30Mbps带宽直连不限流量,$88/月

imidc怎么样?imidc彩虹数据或彩虹网络现在促销旗下日本多IP站群独立服务器,原价159美元的机器现在只需要88美元,而且给13个独立IPv4,30Mbps直连带宽,不限制月流量!IMIDC又名为彩虹数据,rainbow cloud,香港本土运营商,全线产品都是商家自营的,自有IP网络资源等,提供的产品包括VPS主机、独立服务器、站群独立服务器等,数据中心区域包括香港、日本、台湾、美国和南非...

易探云韩国云服务器仅50元/月,510元/年起

韩国云服务器哪个好?韩国云服务器好用吗?韩国是距离我国很近的一个国家,很多站长用户在考虑国外云服务器时,也会将韩国云服务器列入其中。绝大部分用户都是接触的免备案香港和美国居多,在加上服务器确实不错,所以形成了习惯性依赖。但也有不少用户开始寻找其它的海外免备案云服务器,比如韩国云服务器。下面云服务器网(yuntue.com)就推荐最好用的韩国cn2云服务器,韩国CN2云服务器租用推荐。为什么推荐租用...

无忧云:洛阳BGP云服务器低至38.4元/月起;雅安高防云服务器/高防物理机优惠

无忧云怎么样?无忧云,无忧云是一家成立于2017年的老牌商家旗下的服务器销售品牌,现由深圳市云上无忧网络科技有限公司运营,是正规持证IDC/ISP/IRCS商家,主要销售国内、中国香港、国外服务器产品,线路有腾讯云国外线路、自营香港CN2线路等,都是中国大陆直连线路,非常适合免备案建站业务需求和各种负载较高的项目,同时国内服务器也有多个BGP以及高防节点。一、无忧云官网点击此处进入无忧云官方网站二...

英文搜索引擎为你推荐
青岛市建设工程电子交易系统支持ipad支持ipad南京医科大学合同管理系统重庆电信网速测试电信100M下载速度多少M,为什么我家里电信100M下载速度最快5M美妙,是不是严重缩水win7关闭135端口如何用命令关闭135端口google分析怎样学会使用谷歌分析? 我自己想往网站分析走。phpemptyphp中 isset函数有什么功能android5.1android 5.1是什么意思winrar5.0winrar解压软件下载 winrar压缩软件下载
高防服务器租用 河北服务器租用 韩国vps俄罗斯美女 香港cdn 云图标 台湾谷歌地址 服务器维护方案 泉州电信 台湾google 路由跟踪 论坛主机 独立主机 lamp是什么意思 ledlamp cdn网站加速 徐州电信 googlevoice 美国asp空间 winds alexa世界排名 更多