Intro4u2u

Intro4u2u, News, Travel, Technology, Engineering, Airline, Sports, google, yahoo, msn

Archive for January, 2007


Database Management System

A collection of programs that enables you to store, modify, and extract information from a database. There are many different types of DBMSs, ranging from small systems that run on personal computers to huge systems that run on mainframes. The following are examples of database applications:
# computerized library systems

* automated teller machines

# flight reservation systems

* computerized parts inventory systems

From a technical standpoint, DBMSs can differ widely. The terms relational, network, flat, and hierarchical all refer to the way a DBMS organizes information internally. The internal organization can affect how quickly and flexibly you can extract information.

Requests for information from a database are made in the form of a query, which is a stylized question. For example, the query

SELECT ALL WHERE NAME = “SMITH” AND AGE > 35

requests all records in which the NAME field is SMITH and the AGE field is greater than 35. The set of rules for constructing queries is known as a query language. Different DBMSs support different query languages, although there is a semi-standardized query language called SQL (structured query language). Sophisticated languages for managing database systems are called fourth-generation languages, or 4GLs for short.

The information from a database can be presented in a variety of formats. Most DBMSs include a report writer program that enables you to output data in the form of a report. Many DBMSs also include a graphics component that enables you to output information in the form of graphs and charts.

Database management system

A database management system (DBMS) is computer software designed for the purpose of managing databases. Typical examples of DBMSs include Oracle, Microsoft SQL Server, MySQL, and FileMaker. DBMSs are typically used by Database administrators in the creation of Database systems.

A DBMS is a complex set of software programs that controls the organization, storage and retrieval of data in a database. A DBMS includes:

1. A modeling language to define the schema of each database hosted in the DBMS, according to the DBMS data model.
* The three most common organizations are the hierarchical, network and relational models. A database management system may provide one, two or all three methods. Inverted lists and other methods are also used. The most suitable structure depends on the application and on the transaction rate and the number of inquiries that will be made.
The dominant model in use today is the ad hoc one embedded in SQL, a corruption of the relational model by violating several of its fundamental principles. Many DBMSs also support the Open Database Connectivity API that supports a standard way for programmers to access the DBMS.
2. Data structures (fields, records and files) optimized to deal with very large amounts of data stored on a permanent data storage device (which implies very slow access compared to volatile main memory).
3. A database query language and report writer to allow users to interactively interrogate the database, analyse its data and update it according to the users privileges on data.
* It also controls the security of the database.
* Data security prevents unauthorised users from viewing or updating the database. Using passwords, users are allowed access to the entire database or subsets of it called subschemas. For example, an employee database can contain all the data about an individual employee, but one group of users may be authorized to view only payroll data, while others are allowed access to only work history and medical data.
* If the DBMS provides a way to interactively enter and update the database, as well as interrogate it, this capability allows for managing personal databases. However, it may not leave an audit trail of actions or provide the kinds of controls necessary in a multi-user organisation. These controls are only available when a set of application programs are customised for each data entry and updating function.
4. A transaction mechanism, that ideally would guarantee the ACID properties, in order to ensure data integrity, despite concurrent user accesses (concurrency control), and faults (fault tolerance).
* It also maintains the integrity of the data in the database.
* The DBMS can maintain the integrity of the database by not allowing more than one user to update the same record at the same time. The DBMS can help prevent duplicate records via unique index constraints; for example, no two customers with the same customer numbers (key fields) can be entered into the database. See ACID properties for more information (Redundancy avoidance).

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

When a DBMS is used, information systems can be changed much more easily as the organization’s information requirements change. New categories of data can be added to the database without disruption to the existing system.

Organizations may use one kind of DBMS for daily transaction processing and then move the detail onto another computer that uses another DBMS better suited for random inquiries and analysis. Overall systems design decisions are performed by data administrators and systems analysts. Detailed database design is performed by database administrators.

Database servers are specially designed computers that hold the actual databases and run only the DBMS and related software. Database servers are usually multiprocessor computers, with RAID disk arrays used for stable storage. Connected to one or more servers via a high-speed channel, hardware database accelerators are also used in large volume transaction processing environments.

DBMS’s are found at the heart of most database applications. Sometimes DBMSs are built around a private multitasking kernel with built-in networking support although nowadays these functions are left to the operating system.

Features and Abilities Of DBMS: One can characterize a DBMS as an “attribute management system” where attributes are small chunks of information that describe something. For example, “color” is an attribute of a car. The value of the attribute may be a color such as “red”, “blue”, “silver”, etc. Lately databases have been modified to accept large or unstructured (pre-digested or pre-categorized) information as well, such as images and text documents. However, the main focus is still on descriptive attributes.

DBMS roll together frequently-needed services or features of attribute management. This allows one to get powerful functionality “out of the box” rather than program each from scratch or add and integrate them incrementally. Such features include:

Persistence

Attributes are permanently stored on a hard-drive or other fast, reliable medium until explicitly removed or changed. Alternatively stated,this signifies that the degree of confidence embedded in such a type of system is high.

Query Ability

Querying is the process of requesting attribute information from various perspectives and combinations of factors. Example: “How many 2-door cars in Texas are green?”

Concurrency

Many people may want to change and read the same attributes at the same time. If there are not organized, predetermined rules for sharing changes, then the attributes may grow inconsistent or misleading. For example, if you change the color attribute of car 7 to be “blue” at the very same time somebody is changing it to “red”, then you may not see your change when you go to view the attributes of the car you thought you just changed. DBMS provide various tools and techniques to deal with such issues. “Transactions” and “locking” are two common techniques for concurrency management.

Backup and Replication

Often copies of attributes need to be made in case primary disks or other equipment fails. A periodic copy of attributes may also be created for a distant organization that cannot readily access the original. DBMS usually provide utilities to facilitate the process of extracting and disseminating attribute sets.

When data is replicated between database servers, so that the information remains consistent throughout the database system and users cannot tell or even know which server in the DBMS they are using, the system is said to exhibit replication transparency.

Rule Enforcement

Often one wants to apply rules to attributes so that the attributes are clean and reliable. For example, we may have a rule that says each car can have only one engine associated with it (identified by Engine Number). If somebody tries to associate a second engine with a given car, we want the DBMS to deny such a request and display an error message. (However, with new technology such as hybrid gas-electric cars, such rules may need to be relaxed. Ideally such rules should be able to be added and removed as needed without significant data layout redesign.).

Security

Often it is desirable to limit who can see or change which attributes or groups of attributes. After all, you don’t want anybody on the street to be able to change your license plate number in government automobile databases.

Computation

There are common computations requested on attributes such as counting, summing, averaging, sorting, grouping, cross-referencing, etc. Rather than have each computer application implement these from scratch, they can rely on the DBMS to supply such calculations.

Change and Access Logging

Often one wants to know who accessed what attributes, what was changed, and when it was changed. Logging services allow this by keeping a record of access occurrences and changes.

Automated optimization

If there are frequently occurring usage patterns or requests, some DBMS can adjust themselves to improve the speed of those interactions. In some cases the DBMS will merely provide tools to monitor performance, allowing a human expert to make the necessary adjustments after reviewing the statistics collected.

Meta-data Repository

Meta-data is information about information. For example, a listing that describes what attributes are allowed to be in data sets is called “meta-information”.

Modeling Tool

A DBMS can also act as a modeling tool. It can be used to model various nouns found in the environment by describing the attributes associated with such nouns and how the nouns and attributes relate to each other

Multimedia Technologies

The Multimedia Technologies department participates in Research and Development related to state of the art Multimedia Communications applications. The department serves as a corporate center of expertise and provides strategic guidance in these areas, proposes and implements related new product ideas, and keep abreast of technology and market trends. The main focus of the department has been on digital video and image technologies for the broadcast industry and the PC market with a particular emphasis on MPEG-2 based video compression, interactive digital television applications, and the digital set-top box. The department is organized into two groups each addressing different aspects of multimedia technology.

Deploying the Auction Application

With the auction application tested, debugged, and tuned, you are ready to deploy it. Deployment involves bundling the application files, moving the application files to their production locations, installing Java Plug-In so auction administrators can run the Administration applet from their browsers, and installing the Administration applet policy file. Java Plug-In is needed because the Administration applet is written with Java Development Kit (JDK) 1.2 APIs, but the administrators’ browsers might run an earlier version of the Java Runtime Environment (JRE) software.

This chapter explains how to use the Java Archive (JAR) file format to bundle and deploy the application files, and how to install Java Plug-In and a security policy file for the Solaris and Win32 platforms to run the Administration applet.

* Java Archive File Format
* Solaris Platform
* Win32 Platform

In a Rush?

This table links you directly to specific topics.

Topic Section
JAR File Format
Solaris Platform
Win32 Platform

Debugging Applets, Applications, and Servlets

An unwritten law of programming states you will spend 10 percent of your time on the first 90 percent of a project, and the other 90 percent of your time on the remaining 10 percent. If this sounds like any of your projects, you are probably spending that last 10 percent on debugging and integration. While there are plenty of books and people to help you start a project, there are far fewer resources available to help you finish it.

The good news is this chapter focuses completely on debugging and fixing to get your project out on time. It uses real-world examples to walk you through the simple steps to debugging and fixing your programs. By the time you finish, you should be an expert at troubleshooting programs written in the Java language–applets, applications, and servlets–of all shapes and sizes.

* Collecting Evidence
* Running Tests and Analyzing
* Servlet Debugging
* AWT Event Debugging
* Analyzing Stack Traces
* Version Issues

In a Rush?

If you have a pressing problem you need an answer to right now, this table might help. It tells you where to find answers for common problems so you can go directly to the information.

Problem Section
Program hangs or crashes Analyzing Stack Traces
Problem in a running program Getting Behind the Seat with jdb
Java Web Server problems Servlet Debugging and
Analyzing Stack Traces

Examining a Container-Managed Bean

This section walks through the RegistrationBean.java code to show how easy it is to have the container manage persistent data storage to an underlying medium such as a database (the default). Chapter 3 modifies RegistrationBean to use Bean-managed persistence to handle database access and manage transactions.

  • Member Variables
  • Create Method
  • Entity Context Methods
  • Load Method
  • Store Method
  • Connection Pooling
  • Deployment Descriptor

Member Variables

A container-managed environment needs clues about which variables are for persistent storage and which are not. In the Java programming language, the transient keyword indicates variables to not include when data in an object is serialized and written to persistent storage. In the RegistrationBean.java class, the EntityContext variable is marked transient to indicate that its data not be written to the underlying storage medium.

EntityContext data is not written to persistent storage because its purpose is to provide information on the container’s runtime context. It, therefore, does not contain data on the registered user and should not be saved to the underlying storage medium. The other variables are declared public so the container in this example can discover them using the Reflection API.

protected transient EntityContext ctx;
public String theuser, password, creditcard,
emailaddress;
public double balance;

Create Method

The Bean’s ejbCreate method is called by the container after the client program calls the create method on the remote interface and passes in the registration data. This method assigns the incoming values to the member variables that represent user data. The container handles storing and loading the data, and creating new entries in the underlying storage medium.

public RegistrationPK ejbCreate(String theuser,
String password,
String emailaddress,
String creditcard)
throws CreateException, RemoteException {

this.theuser=theuser;
this.password=password;
this.emailaddress=emailaddress;
this.creditcard=creditcard;
this.balance=0;


Entity Context Methods

An entity Bean has an associated EntityContext instance that gives the Bean access to container-managed runtime information such as the transaction context.

public void setEntityContext(
javax.ejb.EntityContext ctx)
throws RemoteException {
this.ctx = ctx;
}

public void unsetEntityContext()
throws RemoteException{
ctx = null;
}


Load Method

The Bean’s ejbLoad method is called by the container to load data from the underlying storage medium. This would be necessary when BidderBean or SellerBean need to check a user’s ID or password against the stored values.

Note: Not all Bean objects are live at any one time. The Enterprise JavaBeans server might have a configurable number of Beans that it keeps in memory.

This method is not implemented because the Enterprise JavaBeans container seamlessly loads the data from the underlying storage medium for you.

public void ejbLoad() throws RemoteException {}

Store Method

The Bean’s ejbStore method is called by the container to save user data. This method is not implemented because the Enterprise JavaBeans container seamlessly stores the data to the underlying storage medium for you.

public void ejbStore() throws RemoteException {}

Connection Pooling

Loading data from and storing data to a database can take a lot time and reduce an application’s overall performance. To reduce database connection time, the BEA Weblogic server uses a JDBC connection pool to cache database connections so connections are always available when the appalication needs them.

However, you are not limited to the default JDBC connection pool. You can override the Bean-managed connection pooling behaviour and substitute your own. Chapter 8: Performance Techniques explains how.

Deployment Descriptor

The remaining configuration for a container-managed persistent Beans occurs at deployment time. The following is the text-based Deployment Descriptor used in a BEA Weblogic Enterprise JavaBeans server.

Text Deployment Descriptor

(environmentProperties

(persistentStoreProperties
persistentStoreType          jdbc

(jdbc
tableName                  registration
dbIsShared                 false
poolName                   ejbPool
(attributeMap
creditcard               creditcard
emailaddress             emailaddress
balance                  balance
password                 password
theuser                  theuser
); end attributeMap
); end jdbc
); end persistentStoreProperties
); end environmentProperties


The deployment descriptor indicates that storage is a database whose connection is held in a JDBC connection pool called ejbPool. The attributeMap contains the Enterprise Bean variable on the left and the associated database field on the right.

XML Deployment Descriptor

In Enterprise JavaBeans 1.1, the deployment descriptor uses XML. The equivalent configuration in XML is as follows:

Container
creditcard

emailaddress

balance

password

theuser


registration
javax.sql.DataSource
Container


The container managed-fields here map directly to their counterpart names in the database table. The container resource authorization (res-auth) means the container handles the database login for the REGISTRATION table.

Entity and Session Beans

The example uses two entity Beans and two session Beans. The entity Beans, AuctionItemBean and RegistrationBean, represent persistent items that could be stored in a database, and the session Beans, SellerBean and BidderBean, represent short-lived operations with the client and data.

The session Beans are the client interface to the entity beans. The SellerBean processes requests to add new auction items for sale. The BidderBean processes requests to retrieve auction items and place bids on those items. Changing and adding to the database data in a container-managed Bean is left to the entity Beans.

* Auction Servlet
* Entity Beans
* Session Beans
* Container Classes

AuctionServlet

The AuctionServlet is essentially the second tier in the application and the focal point for auction activities. It accepts end user input from the browser by way of hypertext transfer protocol (HTTP), passes the input to the appropriate Enterprise Bean for processing, and displays the processed results to the end user in the browser.

Here is a Unified Modeling Language (UML) class diagram for the AuctionServlet class.

The AuctionServlet methods shown above invoke business logic that executes on the server by looking up an Enterprise Bean and calling one or more of its methods. When the servlet adds HTML codes to a page for display to the user, that logic executes on the client.

For example, the listAllItems(out) method executes code on the client to dynamically generate an HTML page to be viewed by the client in a browser. The HTML page is populated with the results of a call to BidderBean that exeuctes logic on the server to generate a list of all auction items.

private void listAllItems(ServletOutputStream out)
throws IOException{

//Put text on HTML page
setTitle(out, "Auction results");
String text = "Click Item number for description
and to place bid.";
try{
addLine("
"+text, out);
//Look up Bidder bean home interface.
BidderHome bhome=(BidderHome) ctx.lookup("bidder");
//Create Bidder bean remote interface.
Bidder bid=bhome.create();
//Call Bidder bean method through remote interface.
Enumeration enum=(Enumeration)bid.getItemList();

if(enum != null) {
//Put retrieved items on servlet page.
displayitems(enum, out);
addLine("", out);
}
} catch (Exception e) {
//Pring error on servlet page.
addLine("AuctionServlet List All Items error",out);
System.out.println("AuctionServlet
:"+e);
}
out.flush();
}


Entity Beans

AuctionItemBean and RegistrationBean are entity Beans. AuctionItemBean adds new auction items to the database and updates the bid amount as users bid on the item. RegistrationBean adds information to the database on registered users. Both Beans consist of the classes described here.

AuctionItem Entity Bean

Here are the AuctionItemBean classes. Remember that these Enterprise Beans are distributed objects that use the Remote Method Invocation (RMI) API, so when an error occurs, an RMI remote exception is thrown.

  • AuctionItem.java
  • AuctionItemHome.java
  • AuctionItemBean.java
  • AuctionItemPk.java

AuctionItem is the remote interface. It describes what the Bean does by declaring the developer-defined methods that provide the business logic for this Bean. These methods are the ones used by the client to interact with the Bean over the remote connection. Its name maps to the AUCTIONITEMS table shown just below.

AuctionItemHome is the home interface. It describes how the Bean is created in, found in, and removed from its container. The Enterprise Bean server deployment tools will provide the implementation for this interface.

AuctionItemBean is the Enterprise Bean. It implements EntityBean, provides the business logic for the developer-defined methods, and implements EntityBean methods for creating the Bean and setting the session context. This is a class that the Bean developer needs to implement. Its field variables map to fields in the AUCTIONITEMS table shown just below.

AuctionItemPK is the primary key class. The Enterprise JavaBeans server requires a container-managed entity Bean to have a primary key class with a public primary key field (or fields, if using composite primary keys). The Bean developer implements this class. The ID field is the primary key in the AUCTIONITEMS table shown just below, so the id field is a public field in this class. The id field is assigned a value when the primary key class is constructed.

You can request the container manage database persistence for an Enterprise Bean or write the code to manage the persistence yourself. In this chapter, all beans (entity and session) are container-managed. With container-managed Beans, all you do is specify which fields are container managed and let the Enterprise JavaBeans server do the rest. This is great for simple applications, but if you are coding something that is fairly complex, you might need more control.

How to override the underlying Enterprise JavaBeans services to gain more control or provide similar services for non-Enterprise JavaBean applications is covered in Chapter 3.

Auction Items Table

Here is the AUCTIONITEMS table.

create table AUCTIONITEMS (SUMMARY VARCHAR(80) ,
ID INT ,
COUNTER INT ,
DESCRIPTION VARCHAR(1000) ,
STARTDATE DATE ,
ENDDATE DATE ,
STARTPRICE DOUBLE PRECISION ,
INCREMENT DOUBLE PRECISION ,
SELLER VARCHAR(30) ,
MAXBID DOUBLE PRECISION,
BIDCOUNT INT,
HIGHBIDDER VARCHAR(30) )


Registration Entity Bean

RegistrationBean consists of the same kinds of classes and database table as the AuctionItem Bean, except the actual business logic, database table fields, and primary key are somewhat different. Rather than describe the classes, you can browse them and refer back to the AuctionItem Bean discussion if you have questions.

  • Registration.java
  • RegistrationHome.java
  • RegistrationBean.java
  • RegistrationPK.java

Registration Table

Here is the REGISTRATION table.

create table REGISTRATION (THEUSER VARCHAR(40) ,
PASSWORD VARCHAR(40) ,
EMAILADDRESS VARCHAR(80) ,
CREDITCARD VARCHAR(40) ,
BALANCE DOUBLE PRECISION )


Session Beans

BidderBean and SellerBean are the session Beans. BidderBean retrieves lists of auction items, searches for an item, checks the user ID and password when someone places a bid, and stores new bids in the database. SellerBean checks the user ID and password when someone posts an auction item, and adds new auction items to the database.

Both session Beans are initially deployed as stateless Beans. A stateless Bean does not keep a record of what the client did in a previous call; whereas, a stateful Bean does. Stateful Beans are very useful if the operation is more than a simple lookup and the client operation depends on something that happened in a previous call.

Bidder Session Bean

Here are the BidderBean classes. Enterprise Beans use the Remote Method Invocation (RMI) API, so when an error occurs, an RMI remote exception is thrown.

There is no primary key class because these Beans are transient and no database access is involved. To retrieve auction items from the database, BidderBean creates an instance of AuctionItemBean, and to process bids, it creates an instance of RegistrationBean.

  • Bidder.java
  • BidderHome.java
  • BidderBean.java
  • Auction.java

Bidder is the remote interface. It describes what the Bean does by declaring the developer-defined methods that provide the business logic for this Bean. These methods are the ones that the client calls remotely.

BidderHome is the home interface. It describes how the Bean is created in, found in, and removed from its container.

BidderBean is the Enterprise Bean. It implements SessionBean, provides the business logic for the developer-defined methods, and implements SessionBean methods for creating the Bean and setting the session context.

Auction.java contains a small class that declares variables used by BidderBean.

Seller Session Bean

SellerBean consists of the same kinds of classes as BidderBean, except the business logic is different. Rather than describe the classes, you can browse them and refer back to the BidderBean discussion if you have questions.

  • Seller.java
  • SellerHome.java
  • SellerBean.java

Container Classes

The classes needed by the container to deploy an Enterprise Bean onto a particular Enterprise JavaBeans server are generated with a deployment tool. The classes include _Stub.class and _Skel.class classes that provide the RMI hooks on the client and server respectively.These classes are used for marshaling (moving) data between the client program and the Enterprise JavaBeans server. In addition, implementation classes are created for the interfaces and deployment rules defined for our Bean.

The Stub object is installed on or downloaded to the client system and provides a local proxy object for the client. It implements the remote interfaces and transparently delegates all method calls across the network to the remote object.

The Skel object is installed on or downloaded to the server system and provides a local proxy object for the server. It unwraps data received over the network from the Stub object for processing by the server.

A Multi-Tiered Application with Enterprise Beans

The proliferation of internet- and intranet-based applications has created a great need for distributed transactional applications that leverage the speed, security, and reliability of server-side technology. One way to meet this need is to use a multitiered model where a thin-client application invokes business logic that executes on the server.

Normally, thin-client multitiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex low-level details. And to compound the difficulties, you have to rework this code every time you write an application because the code is so low-level it is not reusable.

If you could use someone’s prebuilt and pretested transaction management code or even reuse some of your own code, you would save a lot of time an energy that you could better spend solving the business problem. Well, Enterprise JavaBeans technology can give you the help you need. The Enterprise JavaBeans technology makes distributed transactional applications easy to write because it separates the low-level details from the business logic. You concentrate on creating the best business solution and leave the rest to the underlying architecture.

This chapter describes how to create the example auction application using the services provided by the Enterprise JavaBeans platform. Later chapters will show how you can customize these services and integrate these features into existing non-EJB applications.

Enterprise Beans Defined

An Enterprise Bean is a simple class that provides two types of methods: business logic and lifecycle. A client program calls the business logic methods to interact with the data held on the server. The container calls the lifecycle methods to manage the Bean on the server. In addition to these two types of methods, an Enterprise Bean has an associated configuration file, called a deployment descriptor, that is used to configure the Bean at deployment time.

As well as being responsible for creating and deleting Beans the Enterprise JavaBeans server also manages transactions, concurrency, security and data persistence. Even the connections between the client and server are provided by using the RMI and JNDI APIs and servers can optionally provide scalabilty through thread management and caching.

The auction house example implements a complete Enterprise JavaBeans solution by providing only the business logic and using the underlying services provided by the architecture. However, you may find that the container managed services, although providing maximum portability, do not meet all your application requirements. The next chapters will show how you can provide these services in your Bean instead and also use these services in non-Enterprise Bean applications.

Thin-Client Programs

A thin client is a client program that invokes business logic running on the server. It is called thin because most of the processing happens on the server. In the figure below, the servlet is the thin client. It invokes Enterprise Beans that run on the Enterprise JavaBeans server. It also executes logic that creates web pages that appear in the browser.

Multitiered Architecture

Multitier architecture or three-tier architecture extends the standard two-tier client and server model by placing a multithreaded application server between the client and the database.

Client programs communicate with the database through the application server using high-level and platform independent calls. The application server responds to the client requests, makes database calls as needed into the underlying database, and replies to the client program as appropriate.

The three tiers in the web-based auction house example consists of the thin-client servlet, the Enterprise JavaBeans server (the application server), and the database server as shown in the figure.

Entity and Session Beans

There are two types of Enterprise Beans: entity Beans and session Beans. An Enterprise Bean that implements a business entity is an entity Bean, and an Enterprise Bean that implements a business task is a session Bean.

Typically, an entity Bean represents one row of persistent data stored in a database table. In the auction house example, RegistrationBean is an entity Bean that represents data for one registered user, and AuctionItemBean is an entity Bean that represents the data for one auction item. Entity Beans are transactional and long-lived. As long as the data remains, the entity Bean can access and update that data. This does not mean you need a Bean running for every table row. Instead, Enterprise Beans are loaded and saved as needed.

A session Bean might execute database reads and writes, but it is not required. A session Bean might invoke the JDBC calls itself or it might use an entity Bean to make the call, in which case the session Bean is a client to the entity Bean. A session Bean’s fields contain the state of the conversation and are transient. If the server or client crashes, the session Bean is gone. A session Bean is often used with one or more entity Beans and for complex operations on the data.

Session Beans Entity Beans
Fields contain conversation state. Represents data in a database.
Handles database access for client. Shares access for multiple users.
Life of client is life of Bean. Persists as long as data exists.
Can be transaction aware. Transactional.
Does not survive server crashes. Survives server crashes.
Not fine-grained data handling Fine-grained data handling

Note: In the Enterprise Java Beans specification, Enterprise JavaBeans Server support for session Beans is mandatory. Enterprise JavaBeans server support for entity Beans was optional, but is mandatory for version 2.0 of the specification.

Auction House Workings

The diagram shows the Enterprise Beans for the auction house application and their relationship to the Enterprise JavaBeans server. The thin-client server invokes business logic in the four Enterprise Beans through their home and remote interfaces. The Enterprise JavaBeans server in this example handles the low-level details including database read and write operations.

The four Enterprise Beans in the example are:

  • AuctionItemBean is an entity Bean that maintains information for an auction item.
  • RegistrationBean is an entity Bean that stores user registration information.
  • BidderBean is a session Bean that uses AuctionItemBean to retrieve a list of all auction items, only new items, items due to close, and items whose summary matches a search string from the database. It also checks the user ID and password when someone places a bid, and stores new bids in the database.
  • SellerBean is a session Bean that uses RegistrationBean to check the user ID and password when someone posts an auction item, and AuctionItemBean to add new auction items to the database.

As depicted in the figure above, an entity or session Bean is really a collection of interfaces and classes. All entity and session Beans consist of a remote interface, home interface, and the Bean class. The servlet looks up the Beans’s home interface running in the Enterprise JavaBeans server, uses the home interface to create the remote interface, and invokes Bean methods through the remote interface.

  • An Enterprise Bean’s remote interface describes the Bean’s methods, or what the Bean does. A client program or another Enterprise Bean calls the methods defined in the remote interface to invoke the business logic implemented by the Bean.
  • An Enterprise Bean’s home interface describes how a client program or another Enterprise Bean creates, finds (entity Beans only), and removes that Enterprise Bean from its container.
  • The container, shown in light blue (cyan), provides the interface between the Enterprise Bean and the low-level platform-specific functionality that supports the Enterprise Bean.

Developing and Running Applications

Deployment tools and an Enterprise JavaBeans server are essential to running Enterprise JavaBeans applications. Deployment tools generate containers, which are classes that provide an interface to the low-level implementations in a given Enterprise JavaBeans server. The server provider can include containers and deployment tools for their server and will typically publish their low-level interfaces so other vendors can develop containers and deployment tools for their server.The auction house example uses the Enterprise JavaBeans server and deployment tools created by BEA Weblogic.

Because everything is written to specification, all Enterprise Beans are interchangeable with containers, deployment tools, and servers created by other vendors. In fact, you might or might not write your own Enterprise Beans because it is possible, and sometimes desirable, to use Enterprise Beans written by one or more providers that you assemble into an Enterprise JavaBeans application.

How Multitiered Applications Work

The goal in a multitiered application is that the client be able to work on application data without knowing at build time where the data is stored. To make this level of transparency possible, the underlying services in a multitiered architecture use lookup services to locate remote server objects (the Bean’s remote interface object), and data communication services to move data from the client, through the remote server object, to its final destination in a storage medium.

Lookup Service

To find remote server objects at runtime, the client program needs a way to look them up. One way to look remote server objects up at runtime is to use the Java Naming and Directory Interface (JNDI) API. JNDI is a common interface to existing naming and directory interfaces. The Enterprise JavaBeans containers use JNDI as an interface to the Remote Method Invocation (RMI) naming service.

At deployment time, the JNDI service registers (binds) the remote interface with a name. As long as the client program uses the same naming service and asks for the remote interface by its registered name, it will be able to find it. The client program calls the lookup method on a javax.naming.Context object to ask for the remote interface by its registered name. The javax.naming.Context object is where the bindings are stored and is a different object from the Enterprise JavaBeans context, which is covered later.

Data Communication

Once the client program gets a reference to a remote server object, it makes calls on the remote server object’s methods. Because the client program has a reference to the remote server object, a technique called data marshalling is used to make it appear as if the remote server object is local to the client program.Data marshalling is where methods called on the remote server object are wrapped with their data and sent to the remote server object. The remote server object unwraps (unmarshalls) the methods and data, and calls the Enterprise Bean. The results of the call to the Enterprise Bean are wrapped again, passed back to the client through the remote server object, and unmarshalled.

The Enterprise JavaBeans containers use RMI services to marshal data. When the Bean is compiled, stub and skeleton files are created. The stub file provides the data wrapping and unwrapping configuration on the client, and the skeleton provides the same information for the server.

The data is passed between the client program and the server using serialization. Serialization is a way to representat Java objects as bytes that can be sent over the network as a stream and reconstructed on the other side in the same state they were in went originally sent.

Types of Bearings

Types of Bearings
There are many types of bearings, each used for different purposes. These include ball bearings, roller bearings, ball thrust bearings, roller thrust bearings and tapered roller thrust bearings.

Ball Bearings
Ball bearings, as shown below, are probably the most common type of bearing. They are found in everything from inline skates to hard drives. These bearings can handle both radial and thrust loads, and are usually found in applications where the load is relatively small.

In a ball bearing, the load is transmitted from the outer race to the ball, and from the ball to the inner race. Since the ball is a sphere, it only contacts the inner and outer race at a very small point, which helps it spin very smoothly. But it also means that there is not very much contact area holding that load, so if the bearing is overloaded, the balls can deform or squish, ruining the bearing.

Roller Bearings
Roller bearings like the one illustrated below are used in applications like conveyer belt rollers, where they must hold heavy radial loads. In these bearings, the roller is a cylinder, so the contact between the inner and outer race is not a point but a line. This spreads the load out over a larger area, allowing the bearing to handle much greater loads than a ball bearing. However, this type of bearing is not designed to handle much thrust loading.

A variation of this type of bearing, called a needle bearing, uses cylinders with a very small diameter. This allows the bearing to fit into tight places.

Ball Thrust Bearing
Ball thrust bearings like the one shown below are mostly used for low-speed applications and cannot handle much radial load. Barstools and Lazy Susan turntables use this type of bearing.

Roller Thrust Bearing
Roller thrust bearings like the one illustrated below can support large thrust loads. They are often found in gearsets like car transmissions between gears, and between the housing and the rotating shafts. The helical gears used in most transmissions have angled teeth — this causes a thrust load that must be supported by a bearing.

Tapered Roller Bearings
Tapered roller bearings can support large radial and large thrust loads.

Photo courtesy The Timken Company
Cutaway view of (left) a spherical roller thrust bearing and (right) a radial tapered roller bearing

Tapered roller bearings are used in car hubs, where they are usually mounted in p

Howstuffworks “How Bearings Work”

A ball bearing is a common type of rolling-element bearing, a kind of bearing.

The term ball bearing sometimes means a bearing assembly which uses spherical bearings as the rolling elements. It also means an individual ball for a bearing assembly. The remainder of this entry uses the term ball for the individual component and ball bearing or just “bearing” for the assembly.

Ball bearings typically support both axial and radial loads and can tolerate some misalignment of the inner and outer races. Also, balls are relatively easy to make cheaply compared to other kinds of rolling elements. Ball bearings tend to have lower load capacity for their size than other kinds of rolling-element bearings due to the smaller contact area that spherical shapes provide.

Common designs

There are several common designs of ball bearings, each offering various tradeoffs.

* A radial ball bearing uses axially symmetric inner and outer races that are shaped so a radial load passes radially through the bearing. Most radial designs also support modest axial loads.

* An angular contact ball bearing uses axially asymmetric races. An angular load passes in a straight line through the bearing, whereas a radial load takes an oblique path that tends to separate the races axially. So the angle of contact on the inner race is the same as that on the outer race. Angular contact bearings allow ‘combined loads’ (loading in both the radial and axial directions) and the contact angle of the bearing should be matched to the relative proportions of each. The larger the contact angle (typically in the range 10 to 45 degrees), the higher the axial load supported, but the lower the radial load. In high speed applications, such as turbines, jet engines, dentistry equipment, the centrifugal forces generated by the balls will change the contact angle at the inner and outer race. Ceramics such as silicon nitride are now regularly used in such applications due to its low density (40% of steel - and so significantly reduced centrifugal force), its ability to function in high temperature environments, and the fact that it tends to wear in a similar way to bearing steel (rather than cracking or shattering like glass or porcelain).

* An axial ball bearing uses side-by-side races. An axial load is transmitted directly through the bearing, while a radial load is poorly-supported, tends to separate the races, and anything other than a small radial load is likely to damage the bearing.

* A deep-groove radial bearing is one in which the race dimensions are close to the dimensions of the balls that run in it. Deep-groove bearings have higher load ratings for their size than shallow-groove bearings, but are also less tolerant of misalignment of the inner and outer races. A misaligned shallow-groove bearing may support a larger load than a similar deep-groove bearing with similar misalignment.

[edit] Construction types

* A Conrad bearing is assembled by placing the inner and outer races radially offset, so the races touch at one point and have a large gap on the radially opposite side. The bearing is then filled by placing balls in to the large gap, then distributing them around the bearing assembly. The act of distributing the balls causes the inner and outer races to become concentric. If the balls were left free, the balls could resume their offset locations and the bearing could disassemble itself. Thus, a cage is inserted to hold the balls in their distributed positions. The cage supports no bearing load; it serves to keep the balls located. Conrad bearings have the advantage that they take both radial and axial loads, but the disadvantage they cannot be filled to a full complement and thus have reduced load-carrying capacity compared to a full-complement bearing. The Conrad bearing is named for its inventor, Robert Conrad, who got British patent 12,206 in 1903 and U.S. patent 822,723 in 1906.

* A slot fill radial bearing is one in which the inner and outer races are notched so that when they are aligned, balls can be slipped in the slot in order to fill the bearing. A slot-fill bearing has the advantage that the entire groove is filled with balls, called a full complement. A slot-fill bearing has the disadvantages that it handles axial loads poorly, and the notches weaken the races. Note that an angular contact bearing can be disassembled axially and so can easily be filled with a full complement.

* The outer race may be split axially or radially, or a hole drilled in it for filling. These approaches allow a full complement to be used, but also limit the orientation of loads or the amount of misalignment the bearing can tolerate. Thus, these designs find much less use.

* Most ball bearings are single row designs. Some double row designs are available but they need better alignment than single-row bearings.

Probably the most familiar industrial ball bearing is the deep-groove Conrad style. Most bicycles use angular-contact bearings in the headsets because the forces on these bearings are in both the radial and axial direction. The angular-contact bearing is able to withstand such a combined load, as well as small misalignments which often occurs, due to the flexibility of the front fork.

Caged bearings typically have fewer balls than a full complement, and thus have reduced load capacity. However, cages keep balls from scuffing directly against each other and so can reduce the drag of a loaded bearing. Caged roller bearings were invented by John Harrison in the mid 1700s as part of his work on chronographs.

  • Advertisement

  • Web Contents


Intro4U2U

Advanced Search Preferences Language Tools

SEARCH THE WEB