ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Prices
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


IT Jobs

Office applications Toolkit

Using Java Beans to handle business logic

Jeff Hanson Builder.com

Published: 06 Mar 2003 14:21 GMT

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

The EJB component model conforms to most of the characteristics that we specified for software components:

  • Autonomous -- An EJB can perform its work independent of most other components or applications. However, an EJB must be executed inside of an EJB container.
  • Dynamically-discoverable -- EJB uses JNDI for locating home interfaces, business methods, and metadata.
  • Business process -- EJB components are encapsulated business processes by definition.
  • Consist of externally published interfaces -- EJB uses Java interfaces to specify its business methods.
  • Usable for building other components or applications -- As with basic software components, EJB can be aggregated to form more complex functionality.

The EJB component model also adds a number of important component-model features that make it even more appealing as a middleware component, such as transactions, security, and database connectivity.

Transaction points and data access points often surface around business logic components in a distributed system. These aspects make EJB a good technology to use for middleware business-logic components.

EJB and the mojo of POJO

EJB has traditionally been called upon when access to business logic was spread across physical boundaries or across JVM boundaries and remote procedure calls made sense. However, since the introduction of local interfaces to the EJB specification, EJB offers a convenient way to expose business logic to objects and components residing on the same physical tier and within the same JVM.

The flexibility of accessing an EJB component using a remote or local interface opens up a number of architectural possibilities. For example, depending upon our business needs, we can call EJB remotely from the presentation tier or locally from other plain-old Java objects (POJO) on the business tier, as Figure B illustrates.


Figure B

The flexibility of EJB access enables you to employ the composition principles to build logical components out of multiple JavaBeans and one or more POJO. Let's take a look at a simple EJB app that exposes a user account with one business method. The remote interface of the account JavaBean might look something like Listing A. The business-logic class would then look like Listing B. Finally, the client code might look like Listing C.

Imagine now that you want to expose multiple accounts to the presentation tier as one global account. Assuming that you have created EJB for each account, you could use the POJO in Listing D to instantiate each account EJB and present them as one logical account.

Conclusion

We've seen how JavaBeans can be used to build middle-tier business logic and how the EJB component model adds a number of important features for distributed component systems. Future articles will look at how EJB can be used to interact with other objects.


For a weekly round-up of the enterprise IT news, sign up for the Enterprise newsletter.

Tell us what you think in the Enterprise Mailroom.

Next

Previous

1 2


  • Email
  • Trackback
  • Clip Link
  • Print friendly Print with Dell

Did you find this article useful?
21 out of 39 people found this useful


Company/Topic Alerts

Create a new alert from the list below:





Related Jobs

Applications Management Analyst

To follow incident management processes in order to respond to support requests assigned by the helpdesk team within agreed SLAs. Business Objects / ...

Infrastructure Architect

Skills:- Technical: - Knowledge of enterprise class infrastructure components and architectures - Experience of producing bid-time proposal chapters ...

Applications Management Team Systems Support Analyst - 00059405

To follow incident management processes in order to respond to support requests assigned by the helpdesk team - To follow change management processes ...

Featured Talkback

Why do so many (virtually all) software packages think that they are so important that they have to be started automatically every time the computer boots? What is the largest number of "speed access", "update check", "camera download" and whatever other background programs you have ever seen running? Of those, how many did you really need?

By: J.A. Watson

Read full story:
Annoying software: a rogues' gallery

Discussions

pjc158 pjc158

Will Drizzle rain on Sun's MySql

Friday 25 July 2008, 5:30 PM

1 comment
pjc158 pjc158

Show me the money!

Friday 25 July 2008, 5:18 PM

5 comments

Vista Upgrade Blog

Microsoft's pre-modern message puts a...

Over at ZDNet.com, Ed Bott reports a first sighting of Microsoft's eagerly awaited $300 million ad campaign. Already the cause of much speculation, the consensus is that this will be... More

7 comments

A $40 CONSUMER-class router has create...

Believe it or not I don't work in IT, haven't for 7 years. Yes I work with Microsoft's Windows XP Embedded and as a result I have to know a lot about the OS, the kernal, Win API calls... More

Post a comment

Sick Puppy Redo

I generally follow a dispassionate investigative process when trying to discern what happened when a project goes bad. Although its a low priority item, it gets done simply because... More

Post a comment