Kris, You are correct that RequestVar and SessionVar reference the same underlying data no matter what instances they are part of. There are a bunch of design reasons for this. If you have a bunch of instance variables that have different things that need cleaning up, I'd suggest not using RequestVar.
Sorry, David On Sat, Sep 27, 2008 at 11:34 AM, Kris Nuttycombe <[EMAIL PROTECTED] > wrote: > > For the record, here's my ugly-ass workaround, depending upon the fact > that cleanupFunc is called to obtain the cleanup function at the same > time that the default value is set. > > import javax.naming.InitialContext > import net.liftweb.util.{Can,Full,Log} > import net.liftweb.http.RequestVar > > object JNDIResource { > val context = new InitialContext() > } > > import JNDIResource._ > > abstract class JNDIResource[T](val name: String) extends > RequestVar[T](context.lookup(name).asInstanceOf[T]) { > > // This is way too dependent upon an implementation detail of the > superclass. > override def cleanupFunc : Can[() => Unit] = { > Log.debug("Initializing JNDI resource " + name + "(" + this.is + ")") > initialize(this.is) //this will result in a recursive call, but > the the order of operations is such that it will take the other > branch. > > Full(() => { > Log.debug("Releasing JNDI resource " + name + "(" + this.is + ")") > dispose(this.is) > }) > } > > /** > * Subclasses should override this method to provide initialization > of the resource > */ > protected def initialize(resource : T) { > } > > /** > * Subclasses should override this method to provide cleanup on the > resource > */ > protected def dispose(resource: T) { > } > } > > > > -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---