Iterative Development of Enterprise JavaBeans 3.0 4-5
4.3.3 Serializing and Deserializing Business Objects
Business object serialization and deserialization are supported by the following interfaces, which are implemented by all business objects:
■
weblogic.ejb.spi.BusinessObject
■
weblogic.ejb.spi.BusinessHandle Use the BusinessObject._WL_getBusinessObjectHandle method to get the
business handle object and serialize the business handle object. To deserialize a business object, deserialize the business handle object and use the
BusinessHandle.getBusinessObject method to get the business object.
4.4 Program the Annotated EJB Class
The EJB bean class is the main EJB programming artifact. It implements the EJB business interface and contains the EJB metadata annotations that specify semantics
and requirements to the EJB container, request container services, and provide structural and configuration information to the application deployer or the container
runtime.
In the 3.0 programming model, there is only one required annotation: either javax.ejb.Stateful, javax.ejb.Stateless, or
javax.ejb.MessageDriven to specify the type of EJB. Although there are many other annotations you can use to further configure your EJB, these annotations have
typical default values so that you are not required to explicitly use the annotation in your bean class unless you want it to behave other than in the default manner. This
programming model makes it very easy to program an EJB that exhibits typical behavior.
For additional details and examples of programming the bean class, see Chapter 5,
Programming the Annotated EJB 3.0 Class.
4.5 Optionally Program Interceptors
An interceptor is a method that intercepts the invocation of a business method or a life cycle callback event.
You can define an interceptor method within the actual bean class, or you can program an interceptor class distinct from the bean class itself and associate it with the bean
class using the javax.ejb.Interceptor annotation.
See Section 5.3.5, Specifying Interceptors for Business Methods or Life Cycle Callback
Events for information on programming the bean class to use interceptors.
4.6 Compile Java Source
Once you have written the Java source code for your EJB bean class and optional interceptor class, you must compile it into class files. Typical tools to compile include:
■
weblogic.appc—The weblogic.appc Java class or its equivalent Ant task wlappc generates and compiles the classes needed to deploy EJBs and JSPs to
WebLogic Server. It validates the optional deployment descriptors for compliance with the current specifications at both the individual module level and the
application level. The application-level checks include checks between the application-level deployment descriptors and the individual modules as well as
4-6 Programming Enterprise JavaBeans, Version 3.0, for Oracle WebLogic Server
validation checks across the modules. See Building Modules and Applications Using wlappc in Developing Applications for Oracle WebLogic Server.
■
wlcompile Ant task—Invokes the javac compiler to compile your applications Java components in a split development directory structure. See Compiling
Applications Using wlcompile in Developing Applications for Oracle WebLogic Server.
■
javac —The javac compiler provided with the Sun Java J2SE SDK provides java compilation capabilities. See
http:java.sun.comdocs .
4.7 Optionally Create and Edit Deployment Descriptors