Clean up lifecycle methods
--------------------------
Key: JBCACHE-1045
URL:
http://jira.jboss.com/jira/browse/JBCACHE-1045
Project: JBoss Cache
Issue Type: Task
Security Level: Public (Everyone can see)
Affects Versions: 2.0.0.CR1
Reporter: Brian Stansberry
Assigned To: Manik Surtani
Looking at the lifecycle methods, they seem conceptually overly complex and easily
breakable:
1) create() sets some things up.
2) start() calls create() if it wasn't called. That's ok as a help to users, but
begs the question whether the stuff in create() should just be in start() with create()
just a no-op.
3) stop() undoes some of the stuff done in create(); i.e. nulls out the channel, stops
replQueue. Then sets a flag so a later call to start() will execute create() again. This
seems like an unhealthy mingling of concerns -- stop() should reverse stuff done in
start(), not stuff done in create().
Also, in create(), the cache is performing operations on services it depends on:
1) Looking up the TransactionManager in JNDI.
2) Creating a Channel using the injected ChannelFactory.
Both of these are violations of the rule that a service should not invoke on a dependency
in the create phase. The dependency only promises to be ready for invocations after it
has returned from start(), and the microcontainer is free to call create() on the cache
before calling start() on the dependency.
A likely solution to this is:
1) Move the transaction manager lookup, the channel creation and the replQueue creation to
start(). Move anything else I may have missed that stop() is reversing.
2) In stop, don't set createCalled = false. That flag only gets set to false in
destroy().
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira