Search This Blog

Wednesday, October 26, 2005

Advantage of BMP over CMP Beans

Bean Managed persistence is an alternative to using container managed persistence. Just as the name implies, it allows the bean to persist the instance in which the bean developer must implement. The goals of bean managed persistence are slightly more nebulous. For example, anything you cannot accomplish in a container managed persistence bean, you can accomplish in a bean managed persistence component. Some of these include the following:
  • You might have specific JDBC features that are required for your DBMS vendor. For example, you might need to accomplish your persistence with stored procedures or bulk inserts. Note: Some vendors have added stored procedure communication to container managed persistence.

  • You might have proprietary object-to-relational mapping provided by another tool. For example, TopLink is a popular object mapping tool that generates the code for bean managed persistence.

  • You might need to encapsulate communicating to a nonrelational data store. For example, you might want to communicate to a mainframe or mini using a proprietary data store for a given application.

It is unlikely that you cannot accomplish all of an application's persistence requirements using container managed persistence. The EJB 2.0 specifications include many new features for CMP beans that make BMP almost obsolete in most occasions.

Goals for Having Container

* Free up the developer to work on business logic rather than persistence. This is accomplished by allowing the container to manage all the persistence and loading of data.

* Persistence services can be developed by persistence specialists. In other words, this means that persistence is most likely going to run faster, with more transactional safety, and scale better.

* CMP beans are portable across EJB containers and data sources. EJB containers that support the EJB 2.0 specification facilitate the movement of an entity bean from one container to another rather seamlessly. In fact, some containers even attempt to work in specific database vendor features for performance and scalability but still allowing portability.

Difference between CMP AND BMP Beans

Unlike session beans where the bean dies when the client model is closed. In a ENTITY BEAN the EJB survives beyond the client model.

Well then one might think what is the difference between CMP which is Container Managed Persistance and BMP which is Bean Managed Persistance.

Well then Container Managed Persistance, the container manages the Beans Persistance that Beans sorry Means that even after the client module is shut down the bean is persisted untill the container deicded to destroy the bean.

In Bean Managaed Persistance, the developer, are required to manage all the manipulation to your given data source.

Entity are a single representation unlike session that are multiple instance of data. When the client invokes the create() method on the home interface, the bean is then created and placed within the pool of available beans. This pool contains all currently instantiated entity beans of this type. In the sequence diagram, you will see that the transition from Does not exist to pooled varies between BMP and CMP.


At some point, the container may decide to "garbage" collect pooled beans. The container calls unsetEntityContext() to deallocate the current associated entity of data. The EJB specification does not define the frequency or trigger for this action to execute, only that the bean must have the capability to accomplish this. In other words, different vendors trigger the garbage collector at different times. For example, Borland's Enterprise Server executes it on the length of inactivity of the bean.

If the client then invokes one of the finder methods, the bean finds the instance of the data in the data source, copies the primary key into the instance's member variables, and finally returns the bean to the pool. In many instances, this does not cause the entire instance to be loaded into the entity bean. This happens when the ejbLoad() method is called to synchronize the data with the data source.


Thursday, October 20, 2005

RCA Lyra 256MB MP3 Player (RD1090)

RCA Lyra 256MB MP3 Player (RD1090)

----------------------------------------------------------------------------------------------




RD1090 Lyra (256MB, SD/MMC) mp3/mp3PRO/WMA Playback 256 MB Built-in Compact Flash Memory Digital FM Tuner with 10 Presets External SD/MMC Slot for Expandable Memory Backlit Multi-line LCD Display Fast USB Connection Full Accessory Kit Included Product Features RCA RD-1090 Lyra Personal Digital MP3 Player, RD1090 MP3/MP3 Pro/WMA playback 256 MB built-in CompactFlash® memory Digital FM tuner with 10 presets External Secure Digital Card™/MultiMediaCard™ slot for expandable memory Backlit multi-line LCD display Fast USB connection Includes full accessory kit

Creating and Working with an Entity CMP Bean in IBM WebSphere

Last week we worked with session beans in IBM WEBSPHERE. This week lets learn to create and work with an Entity CMP Bean.

STEP 1:
---------

First Create a Project J2EE Application project..that i have covered already in my last BLOG. I have named my project get.

After i click finish i get 3 files

a.)get
b.)getEJB
c.)getWEB

STEP 2:
---------

Next go to J2EE Hierarchy and Click on EJB Module

Click on getEJB then go to Entity Beans and Right Click and click on NEW Click on CMP Bean.


After this....

U will get New Enterprise Bean Screen here select the EJB Project for which u wan to create th Entity CMP Bean...in this case it is getEJB.


After this u will get a screen where u must name your bean..here the bean should be given the same name as your database table. Regarding this we need some classification.


Next u will get a screen where u must tick the include Remote Client View.


In this view itself u also have the option to add CMP Attributes.

I have added to attributes uname of type String and id of type int.
Next click on next and Finish.



STEP 3
--------

Double click on add in Queries and add a query that you will use.

Here i will retrieve the uname and provide the id as Paramater. Uname is my username and id my id.



Also select the Return Type...which in this case is com.login


Next click on Select a simple Query...here have selected
Find All Query which will select all data from the database.


Click on Finish

STEP 4 --------

Next we have to add EJB TO RDB Mapping which will map your EJB TO DATABASE.

For this come to EJB Module Right CLICK on Generate then select EJB TO RDB mapping.
Next in EJB TO RDB Mapping select Create a new Backened Folder and click next

Next u will get another screen here select Meet in the Middle.


Next u must give the connection name which is the Database Name in this case ecart.

Next Name the Database which is Ecart the UserId which is your db2admin username and Password which is db2admin for your db2admin.

Select Database Vendor Type which is DB2 Universal Database v7.1

Next u will get a List of DB2 Table here select the Table u will work with. I am working with Login table.

Next select Match ByName and Type

Click on Finish.

STEP 5
-------

Click on Project Navigator and select We Deployement Descriptor then go to
Web Library Projects here add JAR NAME AND create jar i have added getejb.JAR.

Now save your Space...that's is all u do now call your ejb from any JSP or servlet.

Monday, October 17, 2005

Part 2-Invoking the Bean and Testing it

Part Two-Working with the Bean and Incoking it.
----------------------------------------------------------

Last time around we Learnt how to Create a Bean. Now let us add a method and call that Bean.
Reach the Bean Class and add your Method

Save the file and Right Click on OUTLINE. Here u must Promote the method...Remotely and Locally.

Check to see if it has been promoted remotely one class under your session bean will have the remote method.

Next..
Select the Server u want to run the EJB on and click Next...
Will get an Option Deploy EJB Beans select the same...and click Finish.

Now sit back and


Next select Test EJB Remote Interface and click FINISH.


Next u will get The EJB Reference screen click on Invoke and then an Object should have been created that can be used to access the method.

Next use that object and access the method. That's how simple it is.
....Next Learn how to invoke the ejb from a JSP Page.




Thursday, October 13, 2005

Working with IBM WSAD Websphere Studio Application Developer

Hi friends anyone who is into J2EE must have come across WSAD atleast once....anyways this time around lets see how to create and call a simple EJB i.e Enterprise Java Bean from a JSP file inWSAD.
---------------------------------------
STEP ONE- Create a New Project
---------------------------------------


-----------------------------------------------------------------------------------------
STEP TWO- Select J2EE PROJECT under that select Enterprise Application Project
-----------------------------------------------------------------------------------------

Next select Create J2EE 1.3 Enterprise Application Project


Next select and give your Project a Cool Name...i will name mine Cart.
See that the name must not have been used previously.


Next u will get EAR Module Projects i this select New Module



Next u will get New Module Project window in this window uncheck unwanted features like Application Client Project and Connector Project



Then click Finish and then u will get a window that says this
KIND OF ROJECT IS ASSOCIATED WITH J2EE PERSPECTIVE. DO U WANT TO SWITCH TO THE PRESPECTIVE KNOW CLICK YES.

Next the project should have been created and one should get 3 files cart cart EJB cart WEB



Sunday, October 09, 2005

CEAT Speed Zone

Want to have FUN want to DRIVE like a Maniac want to Rock come to CEAT Speed Zone and go go-karting 10 kms from Bangalore for Rs100 u get 6 laps and we went once...then we got so addicted that we decided to go again and again.







After that we went for lunch and spent some time chatting then we moved on to Global Village an IT PARK near Mysore road that houses companies Like Mphasis,Mindtree,Ivega and many others.





We had great fun checking out the place. That way we spent 9th October Sunday...fun day.

Saturday, October 08, 2005

VINAY G S from GUBBI



Gubbi please STOP reading if u r.... . . . i do not mean a single thing i say here. . . Nice guy . funny guy . . understand jokes..... .. . . . . luv's Sardar jokes. . . good coder....and good person. . . funny guy . Gubbi u r great fun and nice person..simple boy from GUBBI who dreams to live opposite Superstar Upendra and hence sings his songs now and then. CELEBRATION TIME AT GUBBI'S BIRTHDAY.


Rohan

Meet my friend from GOA..Rohan.

Nice guy..first blog so i will say good things about him. He is very helpfull....helped us and is helping us plan our GOA trip..wht Rohan if u r reading this and SMILING look out as wht comes next will suprise u . . . . . . . . . nothing man like i said before nice simple guy from GOA and helpfull....getting to know him better now.

Gunda has arrived...RUN FOR YOUR LIVES

Want to meet Me........

.
.
.
.
.
.
.
.
.
.
.
.
U GOT TO BRIBE YOUR WAY....
AS
.
.
Entry to my cubicle is guarded by no other than
.
.
Mr Gautham....we call him GUNDA.
.
.
.
nice guy. Luv's ORKUT...Hi5..
reads Times of India, The Hindu, etc etc etc
.
.
.work's at times.
.
.
Luv to make new friends and most of all u can find him doing one thing that is
.
.
smi....................le.

Meet Mr Serious

He sits BANG next to me...Yeah any guesses......
come on some clues for u to guess

He Bugs me
He Loves Emacs.
Luv linux.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
believes in self appraisal...coins nick names for himself...like CODE RAJA...........................................
Still guessing..

.
.
.
i give up...have a LOOK.