Business Logic Services

As we will see over the course of this book, the various technologies we can use for our web-based applications all have benefits and limitations. Not every technology is appropriate for every circumstance and no one tool is the right one to go with. Some of the technologies are good for displaying (or presenting ) data, and are generally classified under the category Presentation Services. Other technologies are better for holding application logic, and are generally classified under Business Logic Services. That s not to say these technologies are mutually exclusive ”you could put your business logic into a technology designed for presenting data (like a JSP application) if you wanted to ”but the Presentation and Business Logic Services were designed with the idea of separating the code that drives the business from the code that controls how the end user interacts with data, and the intent of making applications easier to maintain and enhance, particularly in a collaborative environment where numerous programmers with different skill sets will be working on a single project.

Traditionally, the technology used for web-based Business Logic Services were Enterprise JavaBeans. Enterprise JavaBeans technology is the server-side component architecture for the Java 2 Platform, Enterprise Edition (J2EE) platform. EJB technology enables development of distributed, transactional, secure, and portable applications based on Java technology. The EJB specification is one of the several Java APIs in the J2EE platform. The specification details how an Application Server provides server-side objects with:

  • Web Services

  • Persistence

  • Transactions

  • Concurrency control

  • Events using JMS (Java messaging service)

  • Naming and directory services

  • Security

  • Deployment of components in an application server

Might want to disclude this from the list, or lower it. CORBA support isn t exactly the shining star of te J2EE platform. Maybe add Web Services or something else.

If you search for a definition of persistence on the Internet, you ll find so many different variations that you ll probably be more confused after searching than you were before. The one that most closely matches my idea of persistence comes from the unlikely source http://www.posc.org: That quality of an instance of data related to its existence beyond and outside of the life of its creating process or the lives of other processes that use it. In this context, persistence is normally used in describing the life of objects relative to sessions; that is, whether or not they live beyond sessions. See the discussion of TopLink later in this chapter under the section Persistence Layer Services for more information on Oracle s strategic direction regarding persistence implementation for OC4J.

Additionally, the EJB specification defines the roles played by the EJB container and the EJBs, as well as how to deploy the EJBs in a container.

Central to the understanding of EJBs in the concept of patterns; Sun Microsystems defines a pattern as a recurring solution to a problem in a context. A context is the environment, surroundings, situation, or interrelated conditions within which something exists. A problem is an unsettled question, something that needs to be investigated and solved . A problem can be specified by a set of causes and effects. Typically, the problem is constrained by the context in which it occurs. Finally, the solution refers to the answer to the problem in a context that helps resolve the issues. A solution to a problem is not considered a pattern unless there is some way to show that the solution can be applied to recurring types of problems in the solution s definition. Patterns are described by five main characteristics: context, problem, solution, forces, and consequences.

EJBs, however, are notoriously difficult to program and maintain. In response to this, Oracle created a business logic service framework called Oracle Business Components for Java (BC4J), which seeks to remove much of the complexity of EJBs while it continues to provide all of the EJBs functionality. With BC4J, developers can author and test object-oriented business logic in components that automatically integrate with relational databases, reuse business logic through multiple views of data, and access and update those views from servlets or JSPs.

You may be asking yourself why it is even necessary to store business logic in the middle tier : Don t most Oracle-based applications store their business logic in database packages, procedures, functions, and triggers? There are several reasons for implementing business logic via BC4J:

  • You do not want to mix object-oriented and relational paradigms in your application.

  • You will be accessing the database only through clients using Business Components for Java.Your programming staff is skilled in Java and not in PL/SQL.

  • You will be accessing both Oracle and non-Oracle databases.

Some companies may not want to be locked into Oracle ”that is, they want to have database vendor freedom. This is generally a bad practice (for example, you won t maximize the performance of your Oracle application), but if you have a generic product (i.e., Peoplesoft, SAP, etc.), this may make sense.

Designing, authoring, debugging, documenting, delivering, and maintaining a J2EE design pattern framework takes a significant amount of time and effort. BC4J implements patterns for developers, giving them a significant advantage in getting their J2EE applications built, deployed, and enhanced more quickly.

It is not a requirement, of course, to store your business logic in the middle tier. Traditionally, Oracle developers have stored their business logic inside the Oracle database in the form of packages, procedures, functions, triggers, and constraints. To assist in the development of web-based applications, Oracle provides an Apache module called mod_plsql that allows you to make requests to stored procedures in the database directly from the browser. As of Oracle 8.1.7, a group of packages called the PL/SQL Web Toolkit has been included as part of the built-in paackages in the database. By using the toolkit, you can generate web pages; query, retrieve, and display data from an Oracle database; dynamically calculate the contents of web pages; and much more. The details of using the PL/SQL Web Toolkit are discussed in Chapter 7.

Oracle also provides an installation script that can be run against databases prior to 8.1.7 to install the PL/SQL Web Toolkit packages.

Another place business logic can be stored is within an Oracle Form. Oracle Application Server 10 g , when installed with the Business Intelligence and Forms option, can serve Oracle Forms over the Web to a client s web browser where the form is displayed as a Java applet containing the user interface for the forms run-time engine. When you submit a URL to launch an Oracle Forms-based application, the web listener accepts the request and downloads the Oracle Forms applet to your browser. The Oracle Forms applet then establishes a persistent connection to an Oracle Forms run-time engine. All processing takes place between the Oracle Forms applet and the Oracle Forms Services run-time engine, which seamlessly handles any queries or commits to the database. The Oracle Forms Server can be configured to use Application Server 10 g ˜s single sign-on (SSO) and OID capabilities to secure access. Oracle Forms can also be integrated into Oracle Portal to use its publishing capabilities. SSO and OID are discussed in 11. Figure 1-6 shows an Oracle Form served up to a web browser.

click to expand
Figure 1-6: An Oracle Form viewed through a web browser


Oracle Application Server 10g Web Development
Oracle Application Server 10g Web Development (Oracle Press)
ISBN: 0072255110
EAN: 2147483647
Year: 2004
Pages: 192

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