Solved

How EJB Works

Posted on 2004-08-22
8
1,419 Views
Last Modified: 2012-05-05
Hi, I have been reading all the "concepts" and theory in the net regarding this EJB stuffs.

The most informative so far i think is this :

http://www.javaworld.com/javaworld/jw-12-2001/jw-1207-yesnoejb.html

But I have something no so clear about this EJB advantages.

Most of the people mentioned, EJB can help to achieve this stuffs, Scalability, Security and Transactions. But i wonder technically how this works....

If we talk about Scalability, how EJB can help in this sense?

If we mentioned security, isn't that the normal JavaBean-JSP stuff can perform authentication and authorization? How great is this EJB can help to mantain a better security senario?? Which part of the bean (entity or session or CMP or BMP) is working for this purpose?

Pretneding the transaction issues, hm... this is the real things about EJB, frommy point of view. In terms of technically how this works... i am not so sure.. any ideas..

On the reading from the URL above, i also notice this few words, on the "The Rule Book".
The author mentioned,
.... where you must preserve the ACID (Atomicity, consistency, isloation and durability)....

Anyone have any ideas what is this ACID mean for? Can EJB do this stuffs?

I am just confused...

Currently my company is looing forward to migrate all the application into EJB. I am leading the migration. I erally really need your professional advice on this.

Please suggest any Technical readup to me. I will be grateful if you can share with me you rules of thumbs when you learn this EJB stuffs..

THANK YOU sooo much.

0
Comment
Question by:fks
  • 4
  • 3
8 Comments
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 200 total points
ID: 11867822
> If we talk about Scalability, how EJB can help in this sense?

You can cluster EJB containers (such as JBoss), so you can add a new machine, and split the request handling between them

> How great is this EJB can help to mantain a better security senario?

It isn't necessarially better, but it is another layer of security

> In terms of technically how this works... i am not so sure.. any ideas..

You can set the transaction level of each function in the ejb layer, so that functions can be one of the following 6 levels (in EJB 2):

REQUIRED        Methods executed within a transaction.  If client provides transaction, it is used; if not, new transaction generated.  Commit at end of method.  Well-suited for EJB Sessions.
MANDATORY       Client of this EJB must create a transaction in which this method operates, otherwise an error. Well-suited for EJB Entitys.
REQUIRES_NEW       Methods executed within a transaction.  If client provides transaction, it is suspended.  A new transaction is generated, regardless.  Commit at end of method.
SUPPORTS       Transactions optional.
NOT_SUPPORTED       Transactions not supported; if provided, ignored..
BEAN_MANAGED       Code in the EJB responsible for explicit transaction control.

> Anyone have any ideas what is this ACID mean for?

http://www.unix.org.ua/orelly/java-ent/ebeans/ch08_01.htm#INDEX-1558

> Please suggest any Technical readup to me.

http://www.amazon.com/exec/obidos/tg/detail/-/0596002262/qid=1093245931/sr=8-1/ref=pd_ka_1/104-5638035-6198338?v=glance&s=books&n=507846

is a good book, and

http://www.jboss.org

is a good, free EJB container...

Hope I helped a bit :-)

Tim
0
 
LVL 11

Accepted Solution

by:
sompol_kiatkamolchai earned 300 total points
ID: 11867852
Hello fks,

I will answer your question one by one.

>>If we talk about Scalability, how EJB can help in this sense?
we can set a pool of EJB instances and when we start up EJB container, it will create a pool of EJB instances that ready to serve client request. The client will have a good response from server. When the request from client increase, EJB will decide to create more instance to be ready to server in a pool.

>>How great is this EJB can help to mantain a better security senario??
In EJB we can define security role to restrict access to each method in each EJB. It is defined in deployment descriptor(ejb-jar.xml) that mean it does not need for programming.

>>Which part of the bean (entity or session or CMP or BMP) is working for this purpose?
It just a declaration in deployment descriptor. in each type of EJB you can set this security per method and interface.

>>Pretneding the transaction issues, hm... this is the real things about EJB, frommy point of view. In terms of technically
Yes. it likes security. both security and transaction are infrastructure server that provide by J2EE container and it can be easily configured in deployment descriptor. The benefit that J2EE delcare this in deployment descirptor is we can change it without re-compile source code.

>>how this works... i am not so sure.. any ideas..
For transaction it used JTA(Java Transaction API)

>>what is this ACID mean for?
Atomicity, --> you can set transaction. for classical example, when you want to transfer money, you need to withdraw from one account and deposit to another one. If we can withdraw but we cannot deposit(It will cause by many reason such as connection to db have problem or target account does not exist...) so the money will lost from system. So you can do 2 operation as atomic. if 2 operation can do, the transaction will commit. If one of them have error, all will be discard.

consistency, --> it means that when concurrent access to EJB, how container manage consistency of data. one client may try to update and another one try to read. you can configure this behavior in deployment descriptor.

isloation --> Isolation is level of locking database. EJB allows us to set the level of isolation. the more level we set, the more integrity of data we have. but If we set it to the highest, the speed of access will slow down.
1.read uncommitted
2.read committed
3.repeatable read
4.serializable

and durability --> for stateful session bean or entity bean it can survive when the container crash becuase it can persist state to persistent storage such as database.

More info, please feel free to ask me..

Regards,

SoMpoL
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11867863
The standard infrastructure that container provide.
-distributed transaction management
-security management
-concurrent access to ejb
-persistent management in entity bean or stateful session bean
-resource pooling
-resource caching
-load balancing
-fail over.

Cheers,
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:fks
ID: 11877069
SoMpoL, can share your experience how you pick up this EJB stuffs?

Any particular web site , books you have ho through?

0
 

Author Comment

by:fks
ID: 11877071
TimYates, thanks for the URL, really thanks for the sample EJBbooks you have suggested.

TQ.
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11877344
I think the best reference for me is J2EE spec from Sun Microsystem. It may author not the best but it is the original source that I can check whether my understanding is true or not.

http://java.sun.com/products/ejb/docs.html

For other document you can find it at

http://www.theserverside.com

There are many good stuff here.
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 11878358
0
 

Author Comment

by:fks
ID: 11888327
thank you for your respond..

i think other than asking around here, i have to do dome R&D myself and get familiar with it.

sompol, Tim, thanks for the time.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
if statement not resolving in my code 5 55
Use tracing facilities in your browser steps 2 122
JavaScript parse form with colon separated values 2 78
login form jsp example 2 38
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question