Juliano Junio Viana wrote:
>
> Hi,
>
> I am pretty new to ejb, but i think this issue was not adressed on this
> list before ( if it is a issue at all :) )
> I have some BMP entity ejb�s that do *not*  store information on
> JDBC-aware databases.
> One such creature is a ejb that represents a virtual domain. The virtual
> domain�s  configuration is stored in a configuration file  used by the
> web server, and the ejb parses the file on ejbLoad() and changes the
> file on ejbStore().
> I have found a problem with this approach:  the entity beans are never
> notified of a tranaction rollback. So, if i have method calls on several
> beans in the same transaction, when i commit the transaction my bean
> will receive a ejbStore() call, but if the transaction is rolled back it
> will never know ( and therefore never be able to roll back the change).
> In the spec�s sequence diagrams, the rollback notification goes to the
> database(as a resource registered with the transaction coordinator ),
> but in this case there is no " database" .
> Any sugestions on how can i make my ejb transaction aware in this case?

I believe you're correct, this issue hasn't been raised in this group before.
As I understand it, the "right" way to handle this in the EJB universe is
to, in essence, turn your configuration file into a transactional resource,
and to have *it* (not the bean) participate in the transaction manager's commit
and rollback protocols.  In essence, you'll implement a wrapper object
for the configuration file, that implements the XAResource interface,
and that is registered with the TM when the bean first accesses the
configuration
file during a transaction.  The wrapper object will be responsible for
keeping the old state of the file around as the file is being updated
(or, alternatively, for keeping the new state around in-memory) until
the commit, and for rolling back the changes on rollback (in response
to the XAResource calls from the transaction manager).

Note that, as of EJB1.1, you pretty much have to do it this way anyway,
because beans are not allowed to write directly to files (Sect. 18.2.1.1,
page 271 of the EJB 1.1 spec).

Hope this helps ...
                                                        -Larry Allen
                                                         SilverStream Software

P.S. By the way, it's not completely clear how the wrapper object is
supposed to register itself with the TM at first use.  Presumably, it should
use the methods in the javax.transaction.Transaction interface, by
calling the method getTransaction() on the TranactionManager -- but, how
does it find the TransactionManager?  There's no public, portable way to
do this ... which means that your wrapper object will have to have some
server-specific code in it.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to