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

vpsdime7美元/月,美国达拉斯Windows VPS,2核4G/50GB SSD/2TB流量/Hyper-V虚拟化

vpsdime怎么样?vpsdime是2013年成立的国外VPS主机商,以大内存闻名业界,主营基于OpenVZ和KVM虚拟化的Linux套餐,大内存、10Gbps大带宽、大硬盘,有美国西雅图、达拉斯、新泽西、英国、荷兰机房可选。在上个月搞了一款达拉斯Linux系统VPS促销,详情查看:vpsdime夏日促销活动,美国达拉斯vps,2G内存/2核/20gSSD/1T流量,$20/年,此次推出一款Wi...

棉花云1折起(49元), 国内BGP 美国 香港 日本

棉花云官网棉花云隶属于江西乐网科技有限公司,前身是2014年就运营的2014IDC,专注海外线路已有7年有余,是国内较早从事海外专线的互联网基础服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务(SaaS),拥有丰富的国内BGP、双线高防...

RAKsmart推出7.59美元/月,云服务器产品Cloud Server,KVM架构1核1G内存40G硬盘1M带宽基础配置

近期RAKsmart上线云服务器Cloud Server产品,KVM架构1核1G内存40G硬盘1M带宽基础配置7.59美元/月!RAKsmart云服务器Cloud Server位于美国硅谷机房,下单可选DIY各项配置,VPC网络/经典网络,大陆优化/精品网线路,1-1000Mbps带宽,支持Linux或者Windows操作系统,提供Snap和Backup。RAKsmart机房是一家成立于2012年...

英文搜索引擎为你推荐
支付apple伺服器win7支持ipadipad上网ipad上网速度很慢怎么回事?谷歌sb在谷歌里搜SB为什么结果中第一个是百度icloudiphone苹果6显示已停用请连接itunes什么意思micromediamacromedia的中文名googleadsense我申请Google AdSense要怎样才能通过Google AdSense呀?css选择器CSS的常见选择器有哪几种firefoxflash插件安装火狐浏览器后,老是提示安装flash player?
greengeeks 外贸主机 edis tier l5520 nerd 空间打开慢 哈喽图床 双12活动 京东云擎 lamp配置 godaddy域名证书 域名转向 股票老左 美国免费空间 hktv t云 ca187 in域名 重庆电信服务器托管 更多