日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Project Student:维护Webapp(只读)

發布時間:2023/12/3 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Project Student:维护Webapp(只读) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

這是Project Student的一部分。 其他職位包括帶有Jersey的 Web服務 客戶端,帶有Jersey的 Web服務服務器 , 業務層 , 具有Spring數據的持久性 ,分片集成測試數據 , Webservice集成和JPA標準查詢 。

當我開始這個項目時,我有四個目標。 他們沒有特別的次序:

  • 了解jQuery和其他AJAX技術。 為此,我需要一個了解的REST服務器,
  • 捕獲最近獲得的有關球衣和掛毯的知識,
  • 創建一個我可以用來了解其他技術(例如spring MVC,restlet,netty)的框架,以及
  • 在工作面試中有什么要討論的

如果對其他人有用–太好了! 這就是為什么它在Apache許可下可用。

(不言而喻,可接受的用途不包括在沒有適當歸因的情況下將“ Project Student”變成學生項目!)

學習AJAX的問題在于,我一開始會不確定問題的根源。 jQuery不好嗎? 不良的REST服務? 還有嗎 廣泛的單元和集成測試是一個好的開始,但始終會存在一些不確定性。

另一個考慮因素是,在現實世界中,我們經常需要對數據庫的基本視圖。 它不會供公眾使用,而是當我們遇到WTF時刻時供內部使用。 它也可以用于維護我們不想通過公共界面管理的信息,例如下拉菜單中的值。

對此可以稍作改動,以提供適度的可伸縮性。 將大型服務器用于數據庫和REST服務,然后讓N臺前端服務器運行常規的Web應用程序,充當用戶和REST服務之間的中介。 前端服務器可以是相當輕量的,并且可以根據需要旋轉。 將緩存服務器放置在前端和REST服務器之間的加分點,因為將讀取壓倒性的點擊量。

這種方法無法擴展到Amazon或Facebook的規模,但是對于許多站點來說已經足夠了。

維護Webapp

這將我們帶到了webapp onion的可選層上-傳統的webapp充當REST服務的前端。 由于各種原因,我在應用程序中使用Tapestry 5 ,但這是一個任意決定,我不會花很多時間研究Tapestry特定的代碼。

您可以使用創建新的掛毯項目

$ mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org

我已經在http://jumpstart.doublenegative.com.au/jumpstart/examples/找到了有價值的示例。 在適當的地方,我會注明出處。

稍后,我還將創建webapp的第二個可選層-使用Selenium和WebDriver (即Selenium 2.0)進行功能和回歸測試。

局限性

只讀 –分解webapp需要大量工作,因此初始版本將僅提供對簡單表的只讀訪問。 沒有更新,沒有一對多映射。

用戶身份驗證 –尚未進行身份驗證的工作。

加密 –尚未對通信進行加密。

數據庫鎖 –我們在休眠版本中使用機會鎖定,而不是顯式數據庫鎖定。 安全說明:根據最少公開的原則,除非需要,否則我們不想使該版本可見。 一個好的規則是,您將看到它是否請求一個特定的對象,但看不到列表中的對象。

REST客戶端 -每種類型的默認GET處理程序非常粗糙-它僅返回對象列表。 我們需要更復雜的響應(例如,記錄數,起始索引和結束索引,狀態碼等),并將讓UI驅動它。 現在,我們真正需要的只是一個計數,我們可以只請求列表并計數元素的數量。

目標

我們需要一個列出數據庫中所有課程的頁面。 它不必擔心分頁,排序等問題。它應該具有用于??編輯和刪除記錄的鏈接(可能是無效的)。 它不需要添加新課程的鏈接。

該頁面應如下所示:

課程模板

Tapestry頁面上列出的課程很簡單–基本上只是修飾的值網格 。

(有關Layout.tml等信息,請參見掛毯原型。)

<html t:type="layout" title="Course List"t:sidebarTitle="Framework Version"xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"xmlns:p="tapestry:parameter"><!-- Most of the page content, including <head>, <body>, etc. tags, comes from Layout.tml --><t:zone t:id="zone"> <p>"Course" page</p><t:grid source="courses" row="course" include="uuid,name,creationdate" add="edit,delete"><p:name><t:pagelink page="CourseEditor" context="course.uuid">${course.name}</t:pagelink></p:name><p:editcell><t:actionlink t:id="edit" context="course.uuid">Edit</t:actionlink></p:editcell><p:deletecell><t:actionlink t:id="delete" context="course.uuid">Delete</t:actionlink></p:deletecell><p:empty><p>There are no courses to display; you can <t:pagelink page="Course/Editor" parameters="{ 'mode':'create', 'courseUuid':null }">add some</t:pagelink>.</p></p:empty></t:grid></t:zone><p:sidebar><p>[<t:pagelink page="Index">Index</t:pagelink>]<br/>[<t:pagelink page="Course/List">Courses</t:pagelink>]</p></p:sidebar> </html>

具有的屬性文件

title=Courses delete-course=Delete course?

我已經包括了用于編輯和刪除的操作鏈接,但是它們不起作用。

GridDataSources

我們的頁面需要顯示值的來源。 這需要兩個類。 第一個定義了上面使用的課程屬性。

package com.invariantproperties.sandbox.student.maintenance.web.tables;import com.invariantproperties.sandbox.student.business.CourseFinderService;public class GridDataSources {// Screen fields@Propertyprivate GridDataSource courses;// Generally useful bits and pieces@Injectprivate CourseFinderService courseFinderService;@InjectComponentprivate Grid grid;// The codevoid setupRender() {courses = new CoursePagedDataSource(courseFinderService);} }

實際的實現是

package com.invariantproperties.sandbox.student.maintenance.web.tables;import com.invariantproperties.sandbox.student.business.CourseFinderService; import com.invariantproperties.sandbox.student.domain.Course; import com.invariantproperties.sandbox.student.maintenance.query.SortCriterion; import com.invariantproperties.sandbox.student.maintenance.query.SortDirection;public class CoursePagedDataSource implements GridDataSource {private int startIndex;private List<Course> preparedResults;private final CourseFinderService courseFinderService;public CoursePagedDataSource(CourseFinderService courseFinderService) {this.courseFinderService = courseFinderService;}@Overridepublic int getAvailableRows() {long count = courseFinderService.count();return (int) count;}@Overridepublic void prepare(final int startIndex, final int endIndex, final List<SortConstraint> sortConstraints) {// Get a page of courses - ask business service to find them (from the// database)// List<SortCriterion> sortCriteria = toSortCriteria(sortConstraints);// preparedResults = courseFinderService.findCourses(startIndex,// endIndex - startIndex + 1, sortCriteria);preparedResults = courseFinderService.findAllCourses();this.startIndex = startIndex;}@Overridepublic Object getRowValue(final int index) {return preparedResults.get(index - startIndex);}@Overridepublic Class<Course> getRowType() {return Course.class;}/*** Converts a list of Tapestry's SortConstraint to a list of our business* tier's SortCriterion. The business tier does not use SortConstraint* because that would create a dependency on Tapestry.*/private List<SortCriterion> toSortCriteria(List<SortConstraint> sortConstraints) {List<SortCriterion> sortCriteria = new ArrayList<>();for (SortConstraint sortConstraint : sortConstraints) {String propertyName = sortConstraint.getPropertyModel().getPropertyName();SortDirection sortDirection = SortDirection.UNSORTED;switch (sortConstraint.getColumnSort()) {case ASCENDING:sortDirection = SortDirection.ASCENDING;break;case DESCENDING:sortDirection = SortDirection.DESCENDING;break;default:}SortCriterion sortCriterion = new SortCriterion(propertyName, sortDirection);sortCriteria.add(sortCriterion);}return sortCriteria;} }

應用模塊

現在有了GridDataSource,我們可以看到它的需求– CourseFinderService。 雖然有Tapestry-Spring集成,但我們希望保持維護Webapp盡可能的薄,所以現在我們使用標準的Tapestry注入。

package com.invariantproperties.sandbox.student.maintenance.web.services;import com.invariantproperties.sandbox.student.business.CourseFinderService; import com.invariantproperties.sandbox.student.business.CourseManagerService; import com.invariantproperties.sandbox.student.maintenance.service.impl.CourseFinderServiceTapestryImpl; import com.invariantproperties.sandbox.student.maintenance.service.impl.CourseManagerServiceTapestryImpl;/*** This module is automatically included as part of the Tapestry IoC Registry,* it's a good place to configure and extend Tapestry, or to place your own* service definitions.*/ public class AppModule {public static void bind(ServiceBinder binder) {binder.bind(CourseFinderService.class, CourseFinderServiceTapestryImpl.class);binder.bind(CourseManagerService.class, CourseManagerServiceTapestryImpl.class);}.... }

請注意,我們正在使用標準的CourseFinderService接口以及特定于掛毯的實現。 這意味著我們可以直接使用標準實現,只需要對配置文件進行一點改動即可!

CourseFinderServiceTapestryImpl

CourseFinderService接口的本地實現必須使用REST客戶端而不是Spring Data實現。 使用早期使用的由外而內的方法,Tapestry模板的需求應推動服務實現的需求,進而驅動REST客戶端和服務器的需求。

package com.invariantproperties.sandbox.student.maintenance.service.impl;public class CourseFinderServiceTapestryImpl implements CourseFinderService {private final CourseFinderRestClient finder;public CourseFinderServiceTapestryImpl() {// resource should be loaded as tapestry resourcefinal String resource = "http://localhost:8080/student-ws-webapp/rest/course/";finder = new CourseFinderRestClientImpl(resource);// load some initial datainitCache(new CourseManagerRestClientImpl(resource));}@Overridepublic long count() {// FIXME: grossly inefficient but good enough for now.return finder.getAllCourses().length;}@Overridepublic long countByTestRun(TestRun testRun) {// FIXME: grossly inefficient but good enough for now.return finder.getAllCourses().length;}@Overridepublic Course findCourseById(Integer id) {// unsupported operation!throw new ObjectNotFoundException(id);}@Overridepublic Course findCourseByUuid(String uuid) {return finder.getCourse(uuid);}@Overridepublic List<Course> findAllCourses() {return Arrays.asList(finder.getAllCourses());}@Overridepublic List<Course> findCoursesByTestRun(TestRun testRun) {return Collections.emptyList();}// method to load some test data into the database.private void initCache(CourseManagerRestClient manager) {manager.createCourse("physics 101");manager.createCourse("physics 201");manager.createCourse("physics 202");} }

我們的JPA Criteria查詢可以快速計數,但是我們的REST客戶端尚不支持。

包起來

完成艱苦的工作后,我們將獲得一個維護文件.war。 我們可以使用webservice .war將其部署在我們的應用服務器上,也可以不部署。 除了Web服務的臨時硬編碼URL外,這兩個.war文件沒有理由必須位于同一系統上。

我們首先應該轉到http:// localhost:8080 / student-maintenance-webapp / course / list。 我們應該看到如上所示的簡短課程清單。 (在那種情況下,我已經重新啟動了webapp三次,因此每個條目都會重復三倍。)

現在,我們應該訪問位于http:// localhost:8080 / student-ws-webapp / rest / course的webservice webapp,并驗證我們是否也可以通過瀏覽器獲取數據。 經過一點清理后,我們應該看到:

{"course":[{"creationDate":"2013-12-28T14:40:21.369-07:00","uuid":"500069e4-444d-49bc-80f0-4894c2d13f6a","version":"0","name":"physics 101"},{"creationDate":"2013-12-28T14:40:21.777-07:00","uuid":"54001b2a-abbb-4a75-a289-e1f09173fa04","version":"0","name":"physics 201"},{"creationDate":"2013-12-28T14:40:21.938-07:00","uuid":"cfaf892b-7ead-4d64-8659-8f87756bed62","version":"0","name":"physics 202"},{"creationDate":"2013-12-28T16:17:54.608-07:00","uuid":"d29735ff-f614-4979-a0de-e1d134e859f4","version":"0","name":"physics 101"},....] }

源代碼

  • 源代碼位于https://github.com/beargiles/project-student [github]和http://beargiles.github.io/project-student/ [github頁面]。

參考: 項目學生: Invariant Properties博客上來自JCG合作伙伴 Bear Giles的Maintenance Webapp(只讀) 。

翻譯自: https://www.javacodegeeks.com/2014/01/project-student-maintenance-webapp-read-only.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的Project Student:维护Webapp(只读)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲成人久久久久 | 强开乳罩摸双乳吃奶羞羞www | 日日摸日日碰夜夜爽av | 国产精品扒开腿做爽爽爽a片唱戏 | 天天色综合av| 亚洲涩色 | 午夜视频导航 | 久久精品视频网 | 黄色资源在线播放 | 色欲狠狠躁天天躁无码中文字幕 | 在线激情视频 | 国产卡一卡二卡三无线乱码新区 | 成人午夜高清 | 精品久久久久久久久久久 | 日韩激情床戏 | 猛男大粗猛爽h男人味 | 久久亚洲综合 | 男人日女人逼 | 青青草视频免费观看 | av黄色片 | 一卡二卡三卡四卡 | 欧美综合网站 | 精品一区二区三区视频日产 | 爱爱视频日本 | 久久国产欧美日韩精品 | 黑人又大又粗又长 | 成人欧美一区二区 | 好吊视频一区二区三区 | 青娱乐极品视频在线 | 精品在线不卡 | 91快射| 日韩亚洲一区二区 | 永久免费黄色片 | 成年人在线免费观看网站 | 欧美影院久久 | 丁香婷婷色 | 欧美高清hd19 | 欧美激情国产一区 | 无码日韩人妻精品久久蜜桃 | 日本xx视频免费观看 | 日本视频中文字幕 | 激情九月婷婷 | 少妇性高潮视频 | 亚洲av女人18毛片水真多 | 日韩精品字幕 | 污污的视频在线免费观看 | 亚洲一卡一卡 | 亚洲色图狠狠干 | 亚洲激情偷拍 | 亚洲天堂免费在线 | 亚洲国产精品av | 大陆极品少妇内射aaaaaa | 青青在线精品 | 免费看黄色网 | 国产伦一区二区三区 | 久久久久久久久久久久久久国产 | 欧美成人黄色 | 久久精品视频网站 | 女女互慰吃奶互揉调教捆绑 | 海角社区id:1220.7126,10. | 人人射| yjizz视频网| 一本大道av | 久久人人艹 | 欧美草b | 超碰精品在线观看 | 超碰av人人| 亚洲涩网| 亚洲视频在线免费播放 | 日日天天干 | 亚洲av无码片一区二区三区 | 无码人妻丰满熟妇啪啪 | 制服.丝袜.亚洲.中文.综合懂 | aaa国产视频 | 亚洲一区视频网站 | 五月婷婷综合久久 | 国产成人手机在线 | 超级砰砰砰97免费观看最新一期 | 国产又粗又猛又爽又黄又 | 亚洲精品视频91 | 少妇高潮淫片免费观看 | 按摩毛片 | 无码精品人妻一二三区红粉影视 | 国产妻精品一区二区在线 | 一道本av| 91视频99| av免费网站观看 | 久久久久一区 | 国产手机看片 | 亚洲欧美在线播放 | 亚洲乱码国产乱码精品精大量 | 久久婷婷综合国产 | 91精品国产高清一区二区三区蜜臀 | 亚洲视频国产精品 | 国产高清在线视频观看 | 亚洲少妇中文字幕 | 理论毛片 | 国产三区在线播放 | 欧美一区二区三区在线观看视频 |