签证
同样是旅游签证,各个国家的要求会有所区别,其反应出来的事国家的实力和国家的态度。
马来西亚签证,费用很低,在澳洲申请13AUD,在欧洲申请9EURO,但是手续很麻烦。审查时间需要10天,还要提供机票,银行账单等。
越南签证,费用很高,在澳洲要70AUD,在英国要38GBP,但是手续要求很少。四天可以出结果,除了申请单什么都不要。
同样是旅游签证,各个国家的要求会有所区别,其反应出来的事国家的实力和国家的态度。
马来西亚签证,费用很低,在澳洲申请13AUD,在欧洲申请9EURO,但是手续很麻烦。审查时间需要10天,还要提供机票,银行账单等。
越南签证,费用很高,在澳洲要70AUD,在英国要38GBP,但是手续要求很少。四天可以出结果,除了申请单什么都不要。
觉得和假期没有什么多大的区别,最后一个学期了,最后的三个月!
在Baillieu呆了一个多星期了,充分的一个感觉就是, 黄皮肤的特别喜欢扎堆。看到的老外们,除了情侣之外,很少是一起来学习的。凡是一起的,要么就是Group Discussion,要么就是到外面玩去了。而黄皮肤来的,或者说是长的像华人的人们,往往特别喜欢占据2搂那一张张很大的桌子。桌子上铺满了各种各样的书本,材料,然后就开始轻声细语的聊天,直到声音逐渐变大,吸引旁人的注意,抵达波谷。然后再不久,又开始向波峰前进,这样一个波浪的过程。
麻烦你们能不能稍微安静点呢,到图书馆好好看书可以么?楼下不是遍地的Discussion Room吗?
当用Netbeans部署一个项目出现状况的时候,往往尝试着重新启动Glassfish,而这个时候更有可能你会发现Glassfish无法启动了,等待了很久之后报出了如下一段错误:
The Sun Java System Application Server could not start.
More information about the cause is in the Server log file.
Possible reasons include:
- IDE timeout: refresh the server node to see if it’s running now.
- Port conflicts. (use netstat -a to detect possible port numbers already used by the operating system.)
- Incorrect server configuration (domain.xml to be corrected manually)
- Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file. In this case, domain.xml needs to be modified).
- Invalid installation location.
See the server log for details.
BUILD FAILED (total time: 5 minutes 20 seconds)
你甚至会发现无论你如何卸载重新安装Glassfish, Netbeans,你的服务器仍然无法顺利启动。
其实问题的关键不是在这里,而是在你的domain之下。找到\domains\domain1\imq\instances\imqbroker这个文件目录下,你会发现一个lock文件。将它删除掉,Glassfish就顺利复原了。
至于原因是什么,我在GOOGLE上也没搜出个大概,先知其然而不知其所以然吧。
Chapter 1
Introduction to RESTful Web Services and Jersey
1. What are RESTful Web Services?
RESTful - REpresentational State Transfer is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web.
Data and functionality are considered resources, and these resources are accessed using URIs (Unifomr Resource Identifiers), typically links on the web.
The REST architectural style constrains an architecture to a client-server architecture, and is designed to use a stateless communication protocol, typically HTTP. Clients and servers exchange representations of resources using a standardized interface and protocol.
RESTful web services typically map the four main HTTP methods to the operations they perform: create, retrieve, update and delete.
GET — Get a resource; POST — Create a resource and other operations, as it has no defined semantics; PUT — Create or update a resource; DELETE — delete a resource
2. How does Jersey fit in?
Jersey is Sun’s production quality reference implementation for JSR 311: JAX-RS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and Java JVM. Jersey also adds additional features not specified by the JSR.
Chapter 3
Creating a RESTful resource class
Root resource classes are POJOs that are either annotated with @Path or have at least one method annotated with @Path or a request method designator such as @GET, @PUT, @POST, or @DELETE.
Resource methods are methods of a resource class annotated with a request method designator.
1. Developing RESTful web services with Jersey
Developers decorate Java programming language class files with HTTP-specific annotations to define resources and the actions that can be performed on those resources. Jersey annotations are runtime annotations, therefore, runtime reflection will generate the helper classes and artifacts for the resource, and then the collection of classes and artifacts will be built into a WAR. The resources are exposed to clients by deploying the WAR to a Java EE or web server.
@Path annotation’s value is a relative URI path. What makes JAX-RS so useful is that you can embed variables in the URIs. URI path templates are URIs with variables embedded within the URI syntax.
@GET annotation is a request method designator, along with @POST, @PUT, @DELETE, and @HEAD, that is defined by JAX-RS, and which correspond to the similarly named HTTP methods.
@Produces annotation is used to specify the MIME media types of representations a resource can produce and send back to the client.
@Consumes annotation is used to specify the MIME media types of representations a resource can consume that were sent by the client.
2. What are some of the annotations defined by JAX-RS?
| Annotations | Description |
| @Path | The @Path annotation’s value is a relative URI path indicating where the Java class will be hosted, for example, /helloworld. You can also embed variables in the URIs to make a URI path template. For example, you could ask for the name of a user, and pass it to the application as a variable in the URI, like this, /helloworld/{username}. |
| @GET | The @GET annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP GET requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. |
| @POST | The @POST annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP POST requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. |
| @PUT | The @PUT annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP PUT requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. |
| @DELETE | The @DELETE annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP DELETE requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. |
| @HEAD | The @HEAD annotation is a request method designator and corresponds to the similarly named HTTP method. The Java method annotated with this request method designator will process HTTP HEAD requests. The behavior of a resource is determined by the HTTP method to which the resource is responding. |
| @PathParam | The @PathParam annotation is a type of parameter that you can extract for use in your resource class. URI path parameters are extracted from the request URI, and the parameter names correspond to the URI path template variable names specified in the @Path class-level annotation. |
| @QueryParam | The @QueryParam annotation is a type of parameter that you can extract for use in your resource class. Query parameters are extracted from the request URI query parameters. |
| @Consumes | The @Consumes annotation is used to specify the MIME media types of representations a resource can consume that were sent by the client. |
| @Produces | The @Produces annotation is used to specify the MIME media type of representations a resource can produce and send back to the client, for example, “text/plain”. |
| @Provider | The @Provider annotation is used for anything that is of interest to the JAX-RS runtime, such as MessageBodyReader and MessageBodyWriter. For HTTP requests, the MessageBodyReader is used to map an HTTP request entity body to method parameters. On the response side, a return value is mapped to an HTTP response entity body using MessageBodyWriter. If the application needs to supply additional metadata, such as HTTP headers or a different status code, a method can return a Response that wraps the entity, and which can be built using Response.ResponseBuilder. |
3. The @Path annotation and URI path templates.
The @Path annotation identifies the URI path template to which the resource responds, and is specified at the class level of a resource. URI path templates are URIs with variables embedded within the URI syntax. These variables are substituted at runtime in order for a resource to respond to a request based on the substituted URI. Variables are denoted by curly braces.
@Path (”/users/{username}”)
if user entered user name as Galileo, the web service will respond to the following URL: http://example.com/users/Galileo
The @PathParam annotation may be used on the method parameter of a request method to obtain the value of the username variable.
public class UserResource{
@GET
@Produces(”text/xml”)
public String getUser(@PathParam(”username”) String userName){
…
}
}
By default, there is no difference between @Path value begin or not begin with a forward slash(/) and end with a forward slash(/) as well. However, Jersey has a redirection mechanism, if enabled, will perform redirection.
4. Responding to HTTP Resources
The behavior of a resource is determined by the HTTP methods (typically GET, POST, PUT, and DELETE) to which the resource is responding.
By default, the JAX-RS runtime will automatically support the methods HEAD and OPTIONS if not explicitly implemented. For HEAD, the runtime will invoke the implemented GET method (if present) and ignore the response entity (if set). For OPTIONS, the Allow response header will be set to the set of HTTP methods support by the resources. In addition Jersey will return a WADL document describing the resource.
Method decorated with request method designators must return void, a Java programming language type, or a javax.ws.rs.core.Response object. Multiple parameters may be extracted from the URI using the PathParam or QueryParam annotations. Conversion between Java types and entity body is the responsibility of an entity provider, such as MessageBodyReader or MessageBodyWriter. Methods that need to provide additional metadata with a response should return an instance of Response. The ResponseBuilder class provides a convenient way to create a Response instance using a builder pattern. The HTTP PUT and POST methods expect an HTTP request body, so you should use a MessageBodyReader for methods that respond to PUT and POST requests.
5. Using entity providers to map HTTP response and request entity bodies.
Entity providers supply mapping services between representations and their associated Java types.
The following list contains the standard types that are supported automatically for entities. You only need to write an entity provider if you are not choosing one of the following standard types.
6. Using @Consumes and @Produces to customize requests and responses
The @Produces annotation is used to specify the MIME media types or representations a resource can produce and send back to the client. If @Produces is applied at the class level, all the methods in a resource can produce the specified MIME types by default. If it is applied at the method level, it overrides any @Produces annotations applied at the class level.
If no methods in a resource are able to produce the MIME type in a client request, the Jersey runtime sends back an HTTP “406 Not Acceptable” error.
The value of @Produces is an array of String of MIME types.
If a resource class is capable of producing more than one MIME media type, the resource method chosen will correspond to the most acceptable media type as declared by the client. More specifically, the Accept header of the HTTP request declared what is most acceptable.
The @Consumes annotation is used to specify which MIME media types of representations a resource can accept, from the client. If @Consumes is applied at the class level, all the response methods accept the specified MIME types by default. If @Consumes is applied at the method level, it overrides any @Consumes annotations applied at the class level.
If a resource is unable to consume the MIME type of a client request, the Jersey runtime sends back an HTTP “415 Unsupported Media Type” error.
The value of @Consumes is an array of String of acceptable MIME types.
7. Extracting Request Parameters
Parameters of a resource method may be annotated with parameter-based annotations to extract information from a request. There are six types of parameters you can extract for use in your resource class: query parameters, URI path parameters, form parameters, cookie parameters, header parameters, and matrix parameters.
Query parameters are extracted from the request URI query parameters, and are specified by using the javax.rs.QueryParam annotation in the method parameter arguments.
@QueryParam and @PathParam can only be used on the following Java types: all primitive types except char, all wrapper class of primitive types except Character, have a constructor that accepts a single String argument, any class with the static method named valueOf(String) that accpets a single String argument, any class with a constructor that takes a single String as a parameter, List<T>, Set<T>, or SortedSet<T>, where T matches the already listed criteria. Sometimes parameters may contain more than one value for the same name. If this is the case, these types may be used to obtain all values.
If @DefaultValue is not used in conjunction with @QueryOaram, and the query parameter is not present in the request, then value will be an empty collection for List, Set, or SortedSet; null for other object types; and the Java-defined default for primitive types.
URI path parametes are extracted from the request URI, and the parameter names correspond to the URI path template variable names specified in the @Path class-level annotation. URI parameters are specified using the javax.ws.rs.PathParam annotation in the method paraeter arguments.
Form parameters extract information from a request representation that is of the MIME media type application/x-www-form-urlencoded and conforms to the encoding specified by HTML forms.
@Context can be used to obtain contextual Java types related to the request or response.
发现这篇文章很基础,但是讲的算是比较清楚。先把链接贴上来,有兴趣的大家可以去看看。尽管有点老了。看完之后,再来谈谈自己对于REST的一些想法。
http://www.letrails.cn/archives/6
Updated 16:21, 感觉自己对J2EE的理解还非常的肤浅,非常非常的肤浅。尽管今天看上去顺利地解决了改解决的问题,但是还有几个地方概念是非常模糊的。下面几点是要在接下来几天里着重解决的:
1. Annotation,这个东西尽管看上去很高级,但是实际上在很多很多的场合都是用的非常的多。但是因为我没有深入地看过Spring,对这一概念仍然是十分混淆。
2. JAXB, 无论是DOM还是SAX,都是很久远的技术,现在的流行时JAXB。要说我有多懂这个概念,谈不上。但是发现他的确是非常神奇,到了今天自己才碰上他,说明我对JAVA阵营真的是落寞很久了。
3. Ruby on Rails,记得我还在读大四的时候,这个概念已经开始炒作了。但是没有跟上去,于是现在就落伍了。但是只落伍了两年,还不算太晚。在就业之前,把这些好好地补一补吧。
今天安装了暴风,然后发现他不支持标准的unicode规范,于是在英文操作系统下无法正常显示,全部是乱码。加上前不久发生的暴风门事件,于是想想决定放弃这个软件。安装了韩国的KMPlayer。
结果安装以后发现KMPlayer竟然什么都播放不了,报错是找不到pncrt.dll文件。这可是系统的一个重要的文件,专门用来解码real系列格式的啊。在网上好好一搜索发现,原来暴风在安装了以后,就把这个文件占为己有。如果你卸载暴风的话,这个文件很自然的就被删除掉了。于是你在装任何的播放器,都会出现同样的问题。
下定决心坚决不在用这个垃圾,每次系统展开就自动运行,还不知道怎么禁止。在系统进程了,他一个人就占了三个。摆脱他的骚扰!
首先,安装了英文操作系统之后,你的电脑是无法直接显示中文的,直接的结果就是中文会变成一个个的小方格子。要想能够显示中文,你必须在操作系统中加入支持中文的包。
方法为:Control Panel - Regional and Language Options - Languages - Install files for East Asian Languages.
这一部搞定之后,大部分的软件都没有问题。但是会有少数的仍然显示不了中文,比如暴风影音,比如FOXMAIL。其原因在于他们没有依据unicode的规范编写程序,而在 Control Panel - Regional and Language Options - Advanced - Select a language to match the language version of the non-unicode programs you want to use 的默认值是 English。在这种情况下,只要将其改为 Chinese - PRC,其乱码问题就可以解决掉了。
You are currently browsing the Featheast Lee 李羽东 blog archives for July, 2009 .