On Oct 13, 3:48 am, Lawrence Louie <[email protected]> wrote:
> Hi,
>
> Can you please provide some sample in terms of how the main program
> will actually get used the member annotation? Thx.
There numerous case of usage of annotations with values. You would
have already seen one of them:
@SuppressWarnings({"unchecked"})
public void someMethodWhichIssueAnUncheckedWarning(...)
Now, in Java 1.6, the annotations have been extended. There are used
for declaring operation in Web Services for example:
@WebMethod(operationName = "add")
public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int
j) {
return i + j;
}
Another example for declaring servlet:
@WebServlet(urlPatterns = "/AsyncServlet", asyncSupported = true)
public class AsyncServlet extends HttpServlet {
To declare constraints on Beans:
@Size(max=40)
String address;
In GWT, for example to mark parametrized or not String as to be
internationalized:
@DefaultMessage("{0}, life is worth living with... Passion!")
String alertMessage(String userName);
etc, etc...
There are really used about everywhere as soon as you enter the Java
EE world.
Michèle Garoche
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en