InetSoft Product Information: Accessing EJB Data Sources

Enterprise JavaBeans™(EJB) introduced a new way of writing server side Java applications. Using application servers supporting the EJB platform, an application can concentrate on creating business logic, and rely on the application servers’ middle tier services, with little or no additional programming.

The Enterprise JavaBeans data source in the Data Modeler is designed to use the EJB API directly to access the application data model. Because it does not assume any particular implementation of the application server, it is fully portable and conforms fully to the EJB standard.

BI DemoRegister
Learn how InetSoft supercharges BI with Spark to make machine learning easy.

Enterprise JavaBeans Introduction

EJB beans are server-side components written in Java. The beans can contain business logic for an application, as well as for the application data model. There are two classes of EJB beans:

Session Beans

A session bean corresponds to the client of an EJB server. Each client communicates with the server by invoking session bean methods. The session bean keeps track of the session states. When the client terminates, the session bean is discarded. Therefore, it is a transient component, and does not have persistent states.

Entity Beans

An entity bean contains information for business objects. It is not tied to a particular session and is always persistent. The entity bean data can be stored in a database or in any persistent storage an application server chooses.

Each bean is placed in an EJB container. A container manages the beans. For entity beans, the container also provides methods for looking up entity beans using certain criteria. These methods are called finder methods.

Data Modeler’s EJB queries support the retrieval of information from entity beans. All entity beans are accessed through their container (home) using the finder methods. Session beans do not represent the application data model and cannot be used in the queries. However, session beans can be used with the Java Object data source (see below).

view demo icon
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software.

Define an EJB Data Source

Similar to the CORBA data source, requests in an EJB data source are created from the EJB home Java class. Therefore, the Data Modeler must be able to load the EJB home class file in order to analyze the methods.

Walkthrough

  1. Make sure the EJB classes are accessible from the CLASSPATH (j2ee.jar). The sample EJB (pre-compiled) is located in the ‘examples/ docExamples/datasource/ProductClient.jar’ file. Add this Jar file to the CLASSPATH. (The source code can be found in the ‘examples/ docExamples/datasource/ejb’ folder.)
  2. Click the ‘New Data Source’ button to create a new data source.
  3. Select ‘ejb’ as the data source type, and enter the data source name, “Product”.
  4. Enter the EJB home’s JNDI name, ‘ProductEJB’.
    • The JNDI name of the EJB home is specified when deploying a bean to the application server. The name entered here must match the name specified during deployment.
  5. Enter the EJB home class name, ‘ejb.ProductHome’, and enter the entity bean’s interface name, ‘ejb.Product’ ,and click ‘Finish’.
    • Each entity bean has two classes. The interface defines the API for the bean, and a class implementing the interface. The name entered here must be the entity bean interface name.
  6. Select ‘Import EJB’ to import the classes and analyze the API.

When the EJB home and entity bean interface are imported, the Data Modeler analyzes the class files to create the data source requests. Each EJB home finder method is converted to a request. The entity bean interface is used to create the output schema.

Two other options control which member of the classes is used when constructing a data tree from a Java object. The default settings include both public getter methods (methods starting with ‘get’) and public fields.

Once the classes are imported, the Data Modeler automatically creates a list of requests.

Previous: Defining CORBA Data Sources