Writing Back-End Components


Writing Back-End Components

Back-end components are Java objects that implement the business logic behind Web service operations. Your two main choices are stateless session EJBs or Java classes. For guidance on which component might be more appropriate for your Web service, see the section "Understanding Design Considerations" earlier in this chapter. WebLogic's ServiceGen task can take written back-end components and generate Web services from them.

Stateless Session EJBs

Enterprise JavaBean classes used as back-end components are no different from any other EJB. The only special considerations are the following:

  • If you are using output parameters in your EJB methods , you must use the appropriate holder objects for those parameters.

  • If you are implementing a one-way service, maybe as part of an asynchronous service model, the EJB method must return void . See "Writing Asynchronous Web Services" later in this chapter for more information.

  • The ServiceGen task exposes all public methods (except the native bean methods such as ejbCreate , ejbPassivate , and so on) in your back-end EJB. If this is not your intent, either specify the nonexposed methods to be private in your EJB, or hand-tune the generated web-services .xml file and remove the undesired <operation> elements.

Java Classes

For lightweight business logic, you can use regular Java classes as Web service back end components. However, note the following limitations when doing so:

  • The Java class must define a zero-argument default constructor.

  • The Java class cannot start any threads, directly or indirectly. You must write thread-safe code because only one instance of a back-end Java class will be used (like a singleton) for all its service requests .

  • All public methods in the class will be exposed as Web service operations.



BEA WebLogic Platform 7
BEA WebLogic Platform 7
ISBN: 0789727129
EAN: 2147483647
Year: 2003
Pages: 360

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net