YOUR FEEDBACK
shirley wrote: As an ISV and service provider, we specialise in .NET based collaboration soluti...
Cloud Computing Conference
March 22-24, 2009, New York
Register Today and SAVE !..

2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


EJB
EJB

This month, we'll study for the EJB portion of the BEA WebLogic Server 6.0 Certification Test.

Now, I know I was also supposed to talk about JDBC this month, but I just didn't have enough room to squeeze it in. EJB is by far the most widely covered topic on the test, and I didn't want to take any attention away from it. I'll be sure to cover JDBC next month.

Let me say it again: EJB is the biggest topic of the test. With that said, it should be the topic that you know best. I'll try to summarize the portions of EJB that you should be familiar with. We'll start with the general interfaces you need to build EJBs.

For the purposes of the test, there are four primary interfaces to know when building Enterprise JavaBeans. These interfaces are the Remote interface, the Home interface, the MessageListener interface, and the implementation class interface.

To implement the Remote interface, you need to implement the EJBObject interface. The aptly named EJBHome interface must be implemented to create the Home interface. The MessageListener interface is used only for message-driven beans. It informs the bean that a message has been received from a JMS Queue or Topic. Since each type of EJB performs a different job, there are different types of interfaces for the implementation class interface. More details about how all of these interfaces work for each type of EJB are discussed below.

Entity Beans
You'll create the Remote interface by extending EJBObject. The Remote interface should primarily reflect your business methods in the implementation class. All Remote interface methods must be defined as throwing RemoteException.

Create the Home interface by extending EJBHome. Please note: you must provide a findByPrimaryKey() method and may provide zero or more createXXX() or findXXX() methods (where XXX is anything).

In order to create the implementation class, you must implement the EntityBean interface. You must make sure the class is public - not marked as static, final, or abstract - and does not contain a finalizer method. The class must provide an implementation of every method listed in the Remote interface and an ejbFindByPrimaryKey() method that corresponds to the findByPrimaryKey() method in the Home interface. In addition, it must provide an implementation of every creation and finder method listed in the Home interface. Be sure to review Table 1, which lists some entity bean methods of note.

Stateless Session Beans
As with entity beans, create the Remote interface by extending EJBObject. The Remote interface should primarily reflect your business methods and the methods must be defined as throwing RemoteException.

Create the Home interface by extending EJBHome. Please note: you must provide a create() method. This method must not contain any input parameters and cannot be overloaded.

To create the implementation class, you must implement the SessionBean interface and make sure your class is public - not marked as static, final, or abstract - and doesn't contain a finalizer method. The class must provide an implementation of every method listed in the Remote interface and an ejbCreate() method that corresponds to the create() method in the Home interface. Table 2 lists some stateless session bean methods of note.

Stateful Session Beans
The Remote interface of a stateful session bean is constructed the same as a stateless session bean, but the Home interface is slightly different. You create the Home interface by extending EJBHome. Please note: you must provide at least one create() method; you may provide additional create methods, using the createXXX() syntax (where XXX is anything).

In order to create the implementation class, you must implement the SessionBean interface. Again, make sure the class is public, not marked as static, final or abstract. It should not contain a finalizer method and should provide an implementation of every business method listed in the Remote interface. The class should also contain an ejbCreateXXX() method that corresponds to each createXXX() method in the Home interface. Table 3 lists some stateful session bean methods you should know for the test.

Message-Driven Beans
If you're unfamiliar with message-driven beans, you just need to know that they're similar in function to a stateless session bean, yet the processing is done asynchronously. The business methods are executed based on messages received from a single JMS Queue or Topic. For more information on message-driven beans, see http://e-docs.bea.com/wls/docs60/ejb/message_beans.html.

Also, unlike the other EJBs, a message-driven bean doesn't have a Remote or Home interface, because it's never invoked directly by the client. Given this, the methods of a message-driven bean do not have return values or propagate exceptions back to the client.

The MessageListener interface provides the ability for the bean to realize that it has consumed a message. The onMessage() method takes an input of type Message, which can be a BytesMessage, ObjectMessage, TextMessage, StreamMessage, or MapMessage.

To create the implementation class, you must implement the MessageDrivenBean interface. As with all the other implementation classes, make sure the class is public - not marked as static, final, or abstract - and doesn't contain a finalizer method. Table 4 lists message-driven bean methods of importance.

EJB Exceptions
In studying for the test, you should know how different types of EJB exceptions are processed. The first thing to know is that application exceptions are propagated back to the caller, but the EJB container will intercept and handle a system exception. At this point, generally, the container will throw a RemoteException back to the caller. Table 5 lists the important exceptions used by EJB.

EJB Utility Classes
Several utility classes that you need to be familiar with are associated with EJBs.

The SessionContext interface allows the session bean to access properties of the EJB container. Understanding that SessionContext is passed into a Session Bean at creation time and is maintained until the bean is destroyed is important. Similarly, the EntityContext interface allows the entity bean to access properties of the EJB container. The EntityContext is passed into an entity bean at creation time and is maintained until the bean is destroyed.

The last utility class to know for the test is the SessionSynchronization interface. This interface notifies a session bean of important transaction-related events. Table 6 summarizes the events.

Deployment
You need to understand the EJB application file structure. The EJB application should contain the class (or java) files, the ejb-jar.xml file, and weblogic-ejb-jar.xml file.

The ejb-jar.xml and weblogic-ejb-jar.xml files must reside in the \META-INF subdirectory of the jar file. The class (or java) files should reside in the package-relative location. Table 7 shows the structure of an EJB application.

The ejb-jar.xml file contains a large number of deployment descriptors, which are important to know for the test. Some of these are listed in Table 8; a sample ejb-jar.xml file is shown in Listing 1.

The weblogic-ejb-jar.xml file contains more information about the EJBs being deployed. The information in this file is specific to WebLogic Server. Some important descriptors are listed in Table 9 and a sample file is shown in Listing 2.

Next month, I'll look at JDBC in addition to the transactions and clustering topics of the test. Before you take the sample test, though, I'd like to mention another resource to help you study for the test! Be sure to check out the BEA WebLogic Server 6.1 Bible; it can be used as a valuable study aid for the test.

Good luck on the test!

Sample Test
1. Which JMS acknowledgement mode increases message throughput by responding to messages when processor time is available?
a) DUPS_AUTO_ACKNOWLEDGE
b) DUPS_NO_ACKNOWLEDGE
c) DUPS_OK_ACKNOWLEDGE
d) DUPS_IMMED_ACKNOWLEDGE

2. An EJB created using EJB version 2.0 must throw what type of exception?
a) RemoteException
b) EJBException
c) NetworkException
d) None of the Above

3. Which interface are you most likely to use to retrieve properties of a session bean's EJB container?
a) SessionSynchronization
b) SessionContext
c) EJBContext
d) EJBContainer

4. What statement illustrates a difference between creating an entity bean and a session bean?
a) A session bean Home interface does not have a create method.
b) An entity bean does not have a Home interface.
c) An entity bean Home interface does not have a create method.
d) A session bean Home interface does not have any finder methods.

5. Which subdirectory does the ejb-jar.xml file reside in?
a) WEB-INF
b) META-INF
c) Application Directory
d) Root Directory

6. What is a good reason to use a message-driven bean instead of a session bean?
a) Asynchronous Processing
b) Synchronous Processing
c) Exceptions are not propagated to the client
d) Can consume messages from multiple Queues and Topics

7. What interface do you extend to create the EJB's remote interface?
a) EJBObject
b) EJBRemote
c) EJBHome
d) BeanRemote

8. What interface do you extend to create a stateful session bean's implementation class?
a) StatefulSessionBean
b) EJBObject
c) EJBHome
d) SessionBean

9. What interface do you extend to create a stateless session bean's implementation class?
a) StatelessSessionBean
b) EJBObject
c) EJBHome
d) SessionBean

10. What interfaces do you need to implement to build a message- driven bean?
a) ServerSessionPool and MessageBean
b) MessageDrivenBean and EJBObject
c) MessageListener and MessageDrivenBean
d) MessageListener and EJBObject

Answer Key
1. a, 2. b, 3. b, 4. d, 5. b, 6. a, 7. a, 8. d, 9. d, 10. C

About Dave Cooke
David Cooke is an experienced software developer, currently working for Ness Technologies, Inc. a consulting firm located in Dulles, VA. In his current position, Mr. Cooke utilizes Java and BEA WebLogic Server 6.0 to build J2EE-compliant e-commerce systems for a variety of clients. Mr. Cooke has a bachelor's degree in Computer Science from George Mason University and maintains Microsoft, Java and BEA developer certifications.

BEA WEBLOGIC LATEST STORIES
Okay, here's the deal. When you observe the big software guys and see how quickly they adopt emerging technologies, which will change IT the way we know it today, here is what we see. Larry Ellison invested millions in old SaaS / cloud companies, which gave him zippo in return, and he ...
SYS-CON Events announced today that more than 40 Cloud technology providers, as well as Virtualization and SOA companies will exhibit at the upcoming 1st International Cloud Computing Conference & Expo (www.CloudComputingExpo.com), November 19-21, in San Jose, California. The conferenc...
SYS-CON Events announced today that the leading global SOA, Virtualization, Cloud Computing and Open Source technology provider FreedomOSS named "Gold Sponsor" of SYS-CON's SOA World Conference & Expo which will take place November 19-21, 2008, at the Fairmont Hotel in the heart of Sil...
Cassatt, the company started by BEA founder Bill Coleman, is redirecting its data center widgetry into creating internal clouds comparable to Amazon or Google out of infrastructure customers already have in-house. Coleman observed that most IT professionals aren’t comfortable outsour...
Just as people begin to understand the difference between web ops and IT, we are entering a period where clouds promise "Ops-Free" computing. Because it’s easy, scalable, available and disposable, the cloud is well on its way to becoming “technology’s next big thing.” However, ...
As far as the software industry goes, these tough economic days give the biggest business advantage to those companies who contribute directly to the solution of the big global problem and they will be the first to flourish as we dig ourselves from the ditch. Call that the new Y2K prob...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING NEWS FROM THE WIRES

Active Endpoints, Inc. (Dec. 2, 2008 09:17 AM