Annotation-based programming tags are used within your
EJB Projects or Web projects as providers of metadata that is then
used to generate other application artifacts as required. Annotation
tags are added to the comments section at the top of a Java™ file.
Adding annotation tags to a Java bean
- You can automatically generate an annotated bean class using the Create
an Enterprise Bean page. Select Generate an
annotated bean class, and it creates a default annotated
bean class for you.
- Create or import a Java package
and its required classes into the project.
- Add any required annotation tags to the comment section at the
top of the Java file. When creating
a Web service from a Java bean,
the only required annotation tag is @WebSphere.WebService.
Example: The following Java code
creates a Web service that uses document literal encoding and style,
and contains an operation called "Bye."
Adding annotation tags to an EJB bean
- Adding annotation tag support can be done using the New
EJB Project wizard. On the New EJB Project page,
click Show Advanced. Select the Add
support for annotated Java classes check box.
- Create or import a Java package
and its required classes into the project.
- Add any required annotation tags to the comment section at the
top of the Java file. When creating
an EJBWeb service from a Java bean,
the required annotation tags are @WebSphere.WebService and @ejb.session.
Example: The following Java code
creates a stateless session EJB Web service that uses document literal
encoding and style, and contains an operation called "sayhello."