?
Solved

make change from session-type as stateless to statefulsessionbean

Posted on 2004-11-19
6
Medium Priority
?
239 Views
Last Modified: 2013-11-24
hi

in our application statelessbeans were written;


in the ejb-jar.xml if i make change from session-type as stateless to statefulsessionbean;

what problems will i get from the application?





0
Comment
Question by:chaitu chaitu
  • 2
  • 2
  • 2
6 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12632302
you will not get any problem, but u do this to create a state of ur EJB, which means that their is Serializable member fields in ur EJB that u want to maintain their state, also the Client using the beans will handle them differently, in order of the client to stay connected to the EJB state, they must keep the local or remote reference alife until unneeded, and when it is no more needed u must call remote.remove() ( or local.remove() ) or the bean will be passivated (the state is stored on App. Server storage) or in memory for ever
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 12632539
i didnt understand much can u explain more in detail;
0
 
LVL 3

Expert Comment

by:vikraman_b
ID: 12633156
As he said u wont get any problem..
only thro ejb-jar.xml the container will know whether it is statefull or stateless.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:vikraman_b
ID: 12633190
Also u  can put code in ejbActivate() or ejbPasivate(),regardless of whether the ben is stateless or statefl,even though it will never be called it the bean is stateless.
Think about it ,Look at the sessionBean interface notice that there is not a StatelessSeesion Bean and StatefulSeesionBean interface ,there is just a SessionBean and both stateless and stateful session bean implement it .so,there is nothing in ur class that specifically says ur bean is stateless,its only deploy time,when you tell the deployment desciptor(ejb-jar.xml) tht the bean is stateless or stateful,that it actually matters.
Infact ,you could write a bean that has a no-arg create,and keeps no client state,and you can deploy it with either setting -stateless or stateful- and it will work,as long as you've taken care of passivation and activation.
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 12633229
----"Think about it ,Look at the sessionBean interface notice that there is not a StatelessSeesion Bean and StatefulSeesionBean interface"

in entity bean interface also that there is not a BMP and CMP

But there was certain difference between them;

in BMP we will implement the methods where as CMP container will do that.

but in the case of stateful client state will be maintained  and in stateless there is no state maintained and no there is no activation and passivation;

How these scenarios(activation and passivation) will be helpful for stateful sessionbean.
0
 
LVL 13

Accepted Solution

by:
petmagdy earned 375 total points
ID: 12633484
in case on stateful, activation and passivation is useful to open/close connections like database connections or conections to Legacy systems or maybe connection to Backend like calendar or email
a good example of a stafeful session bean is for example a shopping cart bean, user keep navigating throught the site and add items to shopping cart hence it is stateful operation, but in usually in case like this Servlet sessions is more popular to use.

returning to activation and passivation u may do domething like this:

public void activate()
{
Connection conn = getConnection();
}


public void passivate()
{
 conn.close();
 conn = null;
}

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

809 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