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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java官方 jax rs_jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档

發布時間:2024/7/19 java 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java官方 jax rs_jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原文:https://docs.jboss.org/author/display/AS7/Java+API+for+RESTful+Web+Services+(JAX-RS)

Content

Tutorial Overview

This chapter describes the Java API for RESTful web services (JAX-RS, defined in?JSR331).?RESTEasy?is an portable implementation of this specification which can run in any Servlet container. Tight integration with JBoss Application Server is available for optimal user experience in that environment. While JAX-RS is only a server-side specification, RESTeasy has innovated to bring JAX-RS to the client through the RESTEasy JAX-RS Client Framework.

Detailed documentation on RESTEasy is available?here.

The source for this tutorial is in github repository?git://github.com/tdiesler/javaee-tutorial.git

OpenShift, is a portfolio of portable cloud services for deploying and managing applications in the cloud. This tutorial shows how to deploy a RESTful web service on the free OpenShift Express JavaEE cartridge that runsJBossAS 7.

An application running on?Android?shows how to leverage JBoss technology on mobile devices. Specifically, we show how use the RESTEasy client API from an Android device to integrate with a RESTful service running on a JBossAS 7 instance in the cloud.

The following topics are addressed

What are RESTful web services

Creating a RESTful server endpoint

Deploying a RESTful endpoint to a JBossAS instance in the cloud

RESTEasy client running on an Android mobile device

What are RESTful Web Services?

Coming Soon

This section is still under development.

RESTful web services are designed to expose APIs on the web. REST stands for?Representational?State?Transfer. It aims to provide better performance, scalability, and flexibility than traditinoal web services, by allowing clients to access data and resources using predictable URLs. Many well-known public web services expose RESTful APIs.

The Java 6 Enterprise Edition specification for RESTful services is JAX-RS. It is covered by JSR-311 (http://jcp.org/jsr/detail/311.jsp). In the REST model, the server exposes APIs through specific URIs (typically URLs), and clients access those URIs to query or modify data. REST uses a stateless communication protocol. Typically, this is HTTP.

The following is a summary of RESTful design principles:

A URL is tied to a resource using the?@Path?annotation. Clients access the resource using the URL.

Create, Read, Update, and Delete (CRUD) operations are accessed via?PUT,?GET,?POST, and?DELETE?requests in the HTTP protocol.

PUT?creates a new resource.

DELETE?deletes a resource.

GET?retrieves the current state of a resource.

POST?updates a resources's state.

Resources are decoupled from their representation, so that clients can request the data in a variety of different formats.

Stateful interactions require explicit state transfer, in the form of URL rewriting, cookies, and hidden form fields. State can also be embedded in response messages.

Creating a RESTful endpoint

A RESTful endpoint is deployed as JavaEE web archive (WAR). For this tutorial we use a simple library application to manage some books. There are two classes in this application:

Library

Book

The Book is a plain old Java object (POJO) with two attributes. This is a simple Java representation of a RESTful entity.

The Library is the RESTful Root Resource. Here we use a set of standard JAX-RS annotations to define

The root path to the library resource

The wire representation of the data (MIME type)

The Http methods and corresponding paths

The Library root resource uses these JAX-RS annotations:

AnnotationDescription

@Path

Identifies the URI path that a resource class or class method will serve requests for

@Consumes

Defines the media types that the methods of a resource class can accept

@Produces

Defines the media type(s) that the methods of a resource class can produce

@GET

Indicates that the annotated method responds to HTTP GET requests

@PUT

Indicates that the annotated method responds to HTTP PUT requests

@POST

Indicates that the annotated method responds to HTTP POST requests

@DELETE

Indicates that the annotated method responds to HTTP DELETE requests

For a full description of the available JAX-RS annotations, see the?JAX-RS API?documentation.

Package and build the endpoint

To package the endpoint we create a simple web archive and include a web.xml with the following content

Review

AS7-1674?Remove or explain why web.xml is needed for RESTful endpoints

The root context is defined in jboss-web.xml

The code for the JAX-RS part of this tutorial is available on?https://github.com/tdiesler/javaee-tutorial/tree/master/jaxrs. In this step we clone the repository and build the endpoint using?maven. There are a number of JAX-RS client tests that run against a local JBossAS 7 instance. Before we build the project, we set the JBOSS_HOME environment variable accordingly.

Arquillian, the test framework we use throughout this tutorial, can manage server startup/shutdown. It is however also possible to startup the server instance manually before you run the tests. The latter allows you to look at the console and see what log output the deployment phase and JAX-RS endpoint invocations produce.

Deploy the endpoint to OpenShift

First we need to create a free?OpenShift Express?account and select the JavaEE cartridge that runs JBossAS 7. Once we have received the confirmation email from OpenShift we can continue to create our subdomain and deploy the RESTful endpoint. A series of videos on the OpenShift Express page shows you how to do this. There is also an excellent?quick start document?that you have access to after login.

For this tutorial we assume you have done the above and that we can continue by creating the OpenShift application. This step sets up your JBossAS 7 instance in the cloud. Additionally a?Git?repository is configured that gives access to your deployed application.

Next, we can clone the remote Git repository to our local workspace

Because we want to deploy an already existing web application, which we'll build in the next step, we can safely remove the source artefacts from the repository.

Now we copy the JAX-RS endpoint webapp that we build above to the 'deployments' folder and commit the changes.

You can now use curl or your browser to see the JAX-RS endpoint in action. The following URL lists the books that are currently registered in the library.

Building the mobile client

The source associated with this tutorial contains a fully working mobile client application for the Android framework. If not done so already please follow steps described in?Installing the SDK. In addition to the Android SDK, I recommend installing the?m2eclipse?and the?EGit?plugin to?Eclipse.

First, go to File|Import... and choose "Existing Maven Projects" to import the tutorial sources

You project view should look like this

Then go to File|New|Android Project and fill out the first wizard page like this

Click Finish. Next, go to Project|Properties|Build Path|Libraries and add these external libraries to your android project.

You final project view should look like this

To run the application in the emulator, we need an Android Virtual Device (AVD). Go to Window|Android SDK and AVD Manager and create a new AVD like this

Now go to Run|Configuration to create a new run configuration for the client app.

Now you should be able to launch the application in the debugger. Right click on the javaee-tutorial-jaxrs-android project and select Debug As|Android Application. This should launch the emulator, which now goes though a series of boot screens until it eventually displays the Android home screen. This will take a minute or two if you do this for the first time.

When you unlock the home screen by dragging the little green lock to the right. You should see the the running JAX-RS client application.

Finally, you need to configure the host that the client app connects to. This would be the same as you used above to curl the library list. In the emulator click Menu|Host Settings and enter the host address of your OpenShift application.

When going back to the application using the little back arrow next to Menu, you should see a list of books.

You can now add, edit and delete books and switch between your browser and the emulator to verify that the client app is not cheating and that the books are in fact in the cloud on your JBossAS 7 instance.

In Eclipse you can go to the Debug perspective and click on the little Android robot in the lower right corner. This will display the LogCat view, which should display log output from that Android system as well as from this client app

Exploring the mobile client

There is a lot to writing high quality mobile applications. The goal of this little application is to get you started with JBossAS 7 / Android integration. There is also a portable approach to writing mobile applications. A popular one would be through?PhoneGap. With PhoneGap you write your application in HTML+CSS+Java Script. It then runs in the browser of your mobile device. Naturally,?not the full set?of mobile platform APIs would be available through this approach.

The JAX-RS client application uses an annotated library client interface

There are two implementations of this interface available.

LibraryHttpclient

LibraryResteasyClient

The first uses APIs that are available in the Android SDK natively. The code is much more involved, but there would be no need to add external libraries (i.e. resteasy, jackson, etc). The effect is that the total size of the application is considerably smaller in size (i.e. 40k)

The second implementation uses the fabulous RESTEasy client proxy to interact with the JAX-RS endpoint. The details of Http connectivity and JSON data binding is transparently handled by RESTEasy. The total size of the application is considerably bigger in size (i.e. 400k)

Stay tuned for an update on a much more optimized version of the RESTEasy mobile client. Feasible is also a RESTEasy JavaScript library that would enable the portable PhoneGap approach.

總結

以上是生活随笔為你收集整理的java官方 jax rs_jboss7 Java API for RESTful Web Services (JAX-RS) 官方文档的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 亚洲一区二区三区三州 | 中文国语毛片高清视频 | 永久免费精品视频 | 亚洲一区福利视频 | 日韩在线免费 | 91精品国产高清91久久久久久 | 黄色一级免费网站 | 三级av| 91蜜桃婷婷狠狠久久综合9色 | 免费在线观看av | 亚洲欧洲一二三区 | 成人涩涩视频 | 婷婷另类小说 | 日本黄在线观看 | 97精品| 四虎永久在线视频 | 精品999视频| 成人精品视频在线 | 无码精品一区二区三区在线 | 青青青手机在线视频 | 我们的2018在线观看免费高清 | 国产91综合一区在线观看 | 日本黄色特级片 | 国产传媒av | 久久天堂网 | 天天操天天干天天插 | 免费啊v在线观看 | 黑白配在线观看免费观看 | 欧美性视频播放 | 粉嫩av一区二区三区免费观看 | 亚洲一区二区三区国产 | 黄色视屏免费 | 久久国产视频一区 | 浓精喷进老师黑色丝袜在线观看 | 日韩中文字幕久久 | 国产又大又粗又爽的毛片 | 97夜夜| 欧美激情在线一区 | 蜜臀av一区二区三区激情综合 | 黄色网页在线观看 | 欧美一区二区最爽乱淫视频免费看 | 东北少妇高潮抽搐 | 久久亚洲精品国产精品黑人v | 国产系列精品av | 蜜桃视频在线观看www | 久久久视 | 影音先锋亚洲一区 | 成人在线视频观看 | 婷婷久 | 欧美一区二区三区在线免费观看 | 欧美激情视频一区二区三区不卡 | 无码一区二区三区在线 | 美女久久视频 | 全国男人的天堂网 | 欧美高清在线观看 | 青娱乐最新官网 | 久久久一区二区三区 | 在线一区| 天天干夜夜怕 | 亚洲福利在线播放 | www.四虎.| 九九综合九九综合 | 男女性生活毛片 | 91av入口| 中文字幕第一页久久 | 性欧美丰满熟妇xxxx性 | 成人欧美一区二区三区 | 中国精品久久久 | 黄色特级片 | 色翁荡息又大又硬又粗又爽 | 日韩精品v | 久久国 | 自拍露脸高潮 | 青青操av在线 | 深夜视频在线观看免费 | 毛片毛片毛片毛片毛片毛片 | 深夜久久久 | 精品人妻一区二区三区久久嗨 | 欧美在线你懂的 | 国产一区二区片 | 爱av导航| 一区二区国产在线 | 麻豆伊甸园 | 中文字幕有码在线 | 欧美熟女一区二区 | 91av视频在线观看 | 中文字幕25页| 丰满少妇乱子伦精品看片 | 免费看久久 | 美日韩精品 | 97小视频 | 免费国产精品视频 | r级无码视频在线观看 | 男人扒女人添高潮视频 | 国产suv精品一区二区68 | 97精品一区二区 | 久久午夜电影网 | 亚洲精品视频播放 | 中国女人内谢69xxxx免费视频 |