Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

"Persisting" an entity bean in memory (via BMP)

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I currently am developing a J2EE-based trading simulation, in which clients should be able to concurrently access a certain set of server-side objects that always reside in memory (i.e., they are not persisted to, or retrieved from, a database). Examples of these objects are a "Market" object and a "TradeManager" object, which start at the beginning of the simulation, then run for the simulation�s duration.
It seems obvious that session beans cannot represent these components, because concurrent access to the same session bean is prohibited. Moreover, because these components must always exist in memory but are never persisted in a database, entity beans via CMP are not suitable.
I was told that the preferred way to store a bean to memory (for the duration of the simulation) is to implement it as an entity bean via BMP by providing an empty ejbLoad/ejbStore implementation, allowing ejbCreate to initialize the entity bean�s variables, and requiring ejbFindByPrimaryKey to return a copy of the bean�s primary key.
However, when I use this strategy, I find that the bean does not persist in memory after its creation, so I am unable to retrieve an instance of this bean in the future. I have a stateless session bean create the entity bean, but the entity bean�s reference is lost when the session bean is destroyed. I was wondering if this "lost reference" is the reason why I am unable to retrieve the bean (what with Java's garbage collection and all...). Although, it was my understanding that an entity bean�s data can be destroyed only by invoking that bean�s remove method. No clients ever invoke this method, so I wonder why they are unable to retrieve an instance of this bean (via findByPrimaryKey) in subsequent methods.
(If it is at all useful, I am developing these components using JBuilder 8.0 and deploying them in WebLogic 7.0.)
I would appreciate any suggestions on how to implement this, or on what I am doing incorrectly. (Is this even the preferred way to represent these types of components?)
Thanks,
-Jon
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set up the BMP to use "Commit Option A" as described in the EJB spec. If you do a Google search or a search of JavaRanch you will find how to do this for WebLogic.
Kyle
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic