uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

17.1.4 Parameter types

The following table lists and describes the parameter types for which you can specify the Injection annotation. The table also describes whether you can use the types in combination with the DefaultValue annotation.

Table 17-8 Type of parameters supporting each annotation

No. Data type annotation
PathParam QueryParam MatrixParam CookieParam HeaderParam FormParam Context
1 Primitive int C Y#1 Y#1 Y#2 Y#1 Y#1 N
2 short C Y#1 Y#1 Y#2 Y#1 Y#1 N
3 long C Y#1 Y#1 Y#2 Y#1 Y#1 N
4 float C Y#1 Y#1 Y#2 Y#1 Y#1 N
5 double C Y#1 Y#1 Y#2 Y#1 Y#1 N
6 char C Y#1 Y#1 Y#2 Y#1 Y#1 N
7 byte C Y#1 Y#1 Y#2 Y#1 Y#1 N
8 boolean C Y#1 Y#1 Y#2 Y#1 Y#1 N
9 Wrapper class Integer C Y#1 Y#1 Y#2 Y#1 Y#1 N
10 Short C Y#1 Y#1 Y#2 Y#1 Y#1 N
11 Long C Y#1 Y#1 Y#2 Y#1 Y#1 N
12 Float C Y#1 Y#1 Y#2 Y#1 Y#1 N
13 Double C Y#1 Y#1 Y#2 Y#1 Y#1 N
14 Character N N N N N N N
15 Byte C Y#1 Y#1 Y#2 Y#1 Y#1 N
16 Boolean C Y#1 Y#1 Y#2 Y#1 Y#1 N
17 Type that contains a constructor with one String type argument C#7 Y#1,#7 Y#1,#7 Y#2,#7 Y#1,#7 Y#1,#7 N
18 Type that contains one String type argument and a static valueOf method that returns an instance of that type C#7 Y#1,#7 Y#1,#7 Y#2,#7 Y#1,#7 Y#1,#7 N
19 Type that contains one String type argument and a static fromString method that returns an instance of that type C#7 Y#1,#7 Y#1,#7 Y#2,#7 Y#1,#7 Y#1,#7 N
20 enum type that contains one String type argument and a static fromString method that returns an
instance of that type
C#3,#7 Y#1,#3,#7 Y#1,#3,#7 Y#2,#3,#7 Y#1,#3,#7 Y#1,#3,#7 N
21 Type other than the enum type that contains one String type argument and both the static valueOf and fromString methods that returns an instance of that type C#4,#7 Y#1,#4,#7 Y#1,#4,#7 Y#2,#4,#7 Y#1,#4,#7 Y#1,#4,#7 N
22 Other than the aforementioned N N N N N N N
23 List<T> When T is Integer C Y Y N Y Y N
24 When T is Short C Y Y N Y Y N
25 WhenC T is Long C Y Y N Y Y N
26 When T is Float C Y Y N Y Y N
27 When T is Double C Y Y N Y Y N
28 When T is Character N N N N N N N
29 When T is Byte C Y Y N Y Y N
30 When T is Boolean C Y Y N Y Y N
31 When T is a type that contains a constructor having one String type argument C#7 Y#7 Y#7 N Y#7 Y#7 N
32 When T is a type that contains one String type argument and a static valueOf method that returns an instance of that type C#7 Y#7 Y#7 N Y#7 Y#7 N
33 When T contains one String type argument and a static fromstring method that returns an instance of that type C#7 Y#7 Y#7 N Y#7 Y#7 N
34 When T is an enum type that contains one String type argument and a static fromString method that returns an instance of that type C#3,#7 Y#3,#7 Y#3,#7 N Y#3,#7 Y#3,#7 N
35 List<T> When T is a type other than the enum type that contains one String type argument and both the static valueOf and fromString methods that return an instance of that type C#4,#7 Y#4,#7 Y#4,#7 N Y#4,#7 Y#4,#7 N
36 Other than the aforementioned N N N N N N N
37 Set<T>#5 When T is Integer C Y Y N Y Y N
38 When T is Short C Y Y N Y Y N
39 When T is Long C Y Y N Y Y N
40 When T is Float C Y Y N Y Y N
41 When T is Double C Y Y N Y Y N
42 When T is Character N N N N N N N
43 When T is Byte C Y Y N Y Y N
44 When T is Boolean C Y Y N Y Y N
45 When T is a type that contains a constructor having one String type argument C#7 Y#7 Y#7 N Y#7 Y#7 N
46 When T contains one String type argument and a static valueOf method that returns an instance of that type C#7 Y#7 Y#7 N Y#7 Y#7 N
47 When T contains one String type argument and a static fromString method that returns an instance of that String type C#7 Y#7 Y#7 N Y#7 Y#7 N
48 Set<T>#3 When T is an enum type that contains one String type argument and both the static valueOf and fromString methods that return an instance of that type C#3,#7 Y#3,#7 Y#3,#7 N Y#3,#7 Y#3,#7 N
49 When T is a type other than the enum type that contains one String type argument and both the valueOf and formString methods that return an instance of that type C#4,#7 Y#4,#7 Y#4,#7 N Y#4,#7 Y#4,#7 N
50 When T is other than the beforementioned types N N N N N N N
51 Sorted
Set<T>#5, #6
When T is Integer C Y Y N Y Y N
52 When T is Short C Y Y N Y Y N
53 When T is Long C Y Y N Y Y N
54 When T is Float C Y Y N Y Y N
55 When T is Double C Y Y N Y Y N
56 When T is Character N N N N N N N
57 When T is Byte C Y Y N Y Y N
58 When T is Boolean C Y Y N Y Y N
59 When T is a type that contains a constructor having one String type argument C#7 Y#7 Y#7 N Y#7 Y#7 N
60 When T contains one String type argument and a static valueOf method that returns an instance of that type C#7 Y#7 Y#7 N Y#7 Y#7 N
61 Sorted
Set<T>#3, #4
When T contains one String type argument and a static fromString method that returns an instance of that type C#7 Y#7 Y#7 N Y#7 Y#7 N
62 When T is enum type that contains one String type argument and both the static valueOf and formString methods returning instance of that type C#3,#7 Y#3,#7 Y#3,#7 N Y#3,#7 Y#3,#7 N
63 When T is a type other than the enum type that contains one string argument and both the static valueOf and fromString methods that return an instance of that type C#4,#7 Y#4,#7 Y#4,#7 N Y#4,#7 Y#4,#7 N
64 When T is other than the before-mentioned types N N N N N N N
65 PathSegment C N N N N N N
66 Context type UriInfo N N N N N N C
67 HttpHeaders N N N N N N C
68 Request N N N N N N C
69 SecurityContext N N N N N N C
70 Providers N N N N N N C
71 ServletConfig N N N N N N C
72 ServletContext N N N N N N C
73 HttpServletRequest N N N N N N C
74 HttpServletResponse N N N N N N C

Legends:
Y: Indicates that you can use the injection annotation
N: Indicates that you cannot use the injection annotation
C : Indicates that you can use the injection annotation, but not in combination with the DefaultValue annotation.

#1
On receiving multiple parameters with the same name, the JAX-RS engine uses the value of only the first parameter.

#2
On receiving multiple parameters with the same name, the JAX-RS engine injects the value of only the last parameter.

#3
When a type contains one String type argument and both the static valueOf and static fromString methods returning instance of that type, the JAX-RS engine uses the value fromString method.

#4
When a type contains one String type argument and both the static valueOf and static fromString methods returning instance of that type, the JAX-RS engine uses the static valueOf method.

#5
For a type other than the enum type, the equals() method and hashCode() method of java.lang.Object must be appropriately implemented in the class or in the respective parent class to be specified in T in accordance with the rules of the Java language.

#6
For the type other than enum, the java.lang.Comparable interface must be implemented in the class or the respective parent class to be specified in T.

#7
In some cases, the valueOf method, fromString method, and constructors are invoked multiple times when initializing for validating the injection.

The error (KDJJ10006-E) occurs when you use any of the annotations for the types described in No. 22, No. 36, No. 50, No. 64, and No. 65 of the aforementioned table. The system returns t HTTP response with the HTTP status code 500 in the root resource class and throws java.lang.RuntimeException, which can be handled by the exception mapping provider.

However, if you use any of the annotations for the types described in No. 14, No. 28, No. 42, and No. 56 of the table, the system throws java.lang.RuntimeException, which can be handled by the exception mapping provider.