• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What's the main difference between regular Java Beans and EJB ?

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I would like to know
whats the difference between regular java classes and Java Beans
is the naming convention the only thing that makes them different ?
And what about java beans and EJB, where does this "enterprise" difference resides on?

Are java beans persistent by nature ?
Well . . . thanks for your answers.
=============
SCJP Zkr Ryz
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The difference between a 'regular' bean and Enterprise bean relates to scope of the bean object- being 'enterprise' wide probably means that objects/methods are interacting across clients and even servers, so must handle locking/threading, and remote identification of objects. Then, within enterprise beans, some are identified as 'session' beans (transactions, business logic dealing with a particular client) and 'enterprise' (persist over the 'life' of a server session, representing data in a database)
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJB's are beans that have enterprise support. They run in an appserver with support for transactions, distributed computing, container managed persistence, resource allocation from the appserver... to name a few. You have basically 2 types of EJB's: session and entity. Session can be stateless or have state and are used to process business rules. Entity are used to map data to persistent storage like a DB. Message Driven Beans are a new type of EJB that are used to interact with a message source like a JMS queue.
Regular Java beans don't have this underlying structure for enterprise support. A bean in the java lingo is basically a contained piece of executable code, maybe something you can reuse in another project. so in parlay an EJB is a contained piece of executable code built for the enterprise.
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Neil Goldsmith:
EJB's are beans that have enterprise support. They run in an appserver with support for transactions, distributed computing, container managed persistence, resource allocation from the appserver... to name a few. You have basically 2 types of EJB's: session and entity. Session can be stateless or have state and are used to process business rules. Entity are used to map data to persistent storage like a DB. Message Driven Beans are a new type of EJB that are used to interact with a message source like a JMS queue.
Regular Java beans don't have this underlying structure for enterprise support. A bean in the java lingo is basically a contained piece of executable code, maybe something you can reuse in another project. so in parlay an EJB is a contained piece of executable code built for the enterprise.


.....and whats the difference between normal classes and java beans ?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well that's somewhat correct. For a Java Bean class the naming convention is strictly enforced. Beans do differ by the fact that they must follow a naming convention. This naming convention makes it possible for them to be manipulated in a visual development environment. The naming convention gives makes the Bean easy to manipulate via properties. A Bean should also be made easy to use for the novice programmer. Meaning the properties should be complete but intuitive to the layman.
Most Java Beans are not persistent by nature. An Enterprise Java Bean is a flavor of Java Bean that is persistent. Meaning that the object state can be stored in a database.
 
Neil Goldsmith
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regular java classes are the base construct in the Java language. They can be as simple or complex as you make them, and can do anything you want with the right coding. There are "no rules" beyond the language syntax.
Java beans have kinda adapted somewhat over the years. The spec states they are "a reusable software component that can be manipulated visually in a builder tool". That may have been the original intention, but not all java beans are visual. The goal of java beans is to make them interoperable with many frameworks. Beans are an attempt to put some structure around classes. They have naming, packaging conventions and programming conventions.
So in reality a bean is just some component that conforms to some rules. This enables various frameworks to better understand the bean which makes it more portable and reusable.
 
Neil Goldsmith
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Most Java Beans are not persistent by nature. An Enterprise >Java Bean is a flavor of Java Bean that is persistent. Meaning >that the object state can be stored in a database.
That's not necessarily true. Not all EJB's are meant to be stored in a DB. Session EJB's may have no state at all. Entity EJB's are meant for storage. EJB's in general are meant for distributed enterprise applications and have full support from the appserver for a whole host of features mentioned above.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic