Thank very much for your reply. But, there is still one unclear thing.
Sure, stateful don't mean persistent, but during one session the attributs of a bean shall be retained.
Do it means, that the plateform creates for each call of my program a new session for me?

Arved Sandstrom wrote:

 "Stateful" in "stateful session bean" does not mean "persistent". What it means is that state, say your Collection, is retained in between method calls to that session bean.To answer your last question, stateful session beans are not persistent because they were not intended to be. That's what entity beans are for. Or you can add JDBC to the SB.Hope this clarifies things.Arved Sandstrom
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Kuno Baeriswyl
Sent: Wednesday, October 18, 2000 12:32 PM
To: Orion-Interest
Subject: Cart example is not stateful!?
 
Hi all,

I need to implementing a stateful Session Bean. So, I took the Cart-example and added the following thinks to look the values of a stateful bean who shall be in the container (because by first call of this program, I added some beans).
But, all Beans are destroyed. I can't see the STATEFUL beans of the last program-call!
Why there not persistent?

Client:
--------

  // init Context
   java.util.Properties p = new java.util.Properties();
   p.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationClientInitialContextFactory");
   p.put(Context.PROVIDER_URL,"ormi://localhost/caddie");
   p.put(Context.SECURITY_PRINCIPAL,"admin");
   p.put(Context.SECURITY_CREDENTIALS,"metrocine");
   Context context = new InitialContext(p);

// get Cart bean
   Object homeObject = context.lookup("java:comp/env/Cart");
   CartHome home = (CartHome)PortableRemoteObject.narrow(homeObject, CartHome.class);
   Cart cart = (Cart)PortableRemoteObject.narrow(home.create("kuno"), Cart.class);

// print-out of all item stored in the stateful bean
   java.util.Collection items = cart.getItems();
   java.util.Iterator iterator = items.iterator();

   while(iterator.hasNext()){
    System.out.println((String)iterator.next());
   }

   // Add some new items to the Cart.
   cart.add("Milk");
   cart.add("Apples");
   cart.add("Pizza");

ejb-jar.xml
----------
<ejb-jar>
 <display-name>Caddie for the shop of Metrocine</display-name>
 <description>prototype v1.0</description>
 <enterprise-beans>
  <session>
   <display-name>Shopping Cart</display-name>
   <description>A simple shopping cart.</description>
   <ejb-name>Cart</ejb-name>
   <home>metrocine.caddie.interfaces.CartHome</home>
   <remote>metrocine.caddie.interfaces.Cart</remote>
   <ejb-class>metrocine.caddie.ejb.CartEJB</ejb-class>
   <session-type>Stateful</session-type>
   <transaction-type>Container</transaction-type>
  </session>
 </enterprise-beans>
 <assembly-descriptor/>
</ejb-jar>

 

--

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

--  http://zap.to/kuno     - Homepage  -    http://www.eif.ch         --

--    026/ 494.19.56        - Telefon -      026/ 429.66.11           --

--     [EMAIL PROTECTED]           - eMail -       [EMAIL PROTECTED]          --

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

--

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

--  http://zap.to/kuno     - Homepage  -    http://www.eif.ch         --

--    026/ 494.19.56        - Telefon -      026/ 429.66.11           --

--     [EMAIL PROTECTED]           - eMail -       [EMAIL PROTECTED]          --

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

Reply via email to