Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Beans  RSS feed

 
Smita Chopra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me

1. What are Java Beans.
2. What is the difference between Java Beans and Enterprise Java Beans

Thanks
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaBeans are special kinds of Java classes that are written so as to conform to a particular specification (most often recognized by private instance variables with public "getXXX" and "setXXX" methods).

EJBs are special kinds of Java classes that function as reusable software components (also written to a specification) and are designed to run within a special environment (an EJB container).
 
Smita Chopra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve Morrow:
JavaBeans are special kinds of Java classes that are written so as to conform to a particular specification (most often recognized by private instance variables with public "getXXX" and "setXXX" methods).

EJBs are special kinds of Java classes that function as reusable software components (also written to a specification) and are designed to run within a special environment (an EJB container).


Thanks for replying.
I had read somewhere that Java Beans are reusable components and as you mentioned above EJBs are also reusable components. So is the only difference between the two is that EJBs run in EJB container while Java Beans do not?
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is the only difference between the two is that EJBs run in EJB container while Java Beans do not?
There's a little more to it than that...

Here are a some articles that may help you with the distinction.

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBConcepts.html
http://java.sun.com/docs/books/tutorial/javabeans/

http://www.javaworld.com/channel_content/jw-ejbs-index.shtml
http://www.javaworld.com/channel_content/jw-javabeans-index.shtml

http://www.javaranch.com/newsletter/July2003/TouringTheCommonsPart1.html
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Smita Chopra:


Thanks for replying.
I had read somewhere that Java Beans are reusable components and as you mentioned above EJBs are also reusable components. So is the only difference between the two is that EJBs run in EJB container while Java Beans do not?


Yes Java Beans are reusable components and EJBs are distributed components. There is no link between Java Beans and EJBs.
 
anshuman roy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi smita,
java beans are nothing but just general java classes with fields and corresponding getters and setters methods in them.
for e.g. int age;//if this is the instance variable
void setAge(int age){
this.age=age;
}//this is the setter that sets the age
int getAge(){
return this.age;
}//this is the getter

to use it simply create an object and then use them to set and get the age..


where as enterprise java beans are simply a different story. ejb are java components preferably known as business objects. they are deployed using an application server such as jboss, weblogic, etc... they have nothing to do with java beans. they have call back methods and so on... i think u have to do a bit of more researching for ejb....

cheers


Ansuman
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!