On Thu, Feb 5, 2009 at 1:43 PM, David Pollak
<feeder.of.the.be...@gmail.com>wrote:

>
>
> On Thu, Feb 5, 2009 at 12:13 PM, Kris Nuttycombe <
> kris.nuttyco...@gmail.com> wrote:
>
>> David, I'm a little confused by how to use registerCleanupFunc after your
>> most recent set of changes. It now appears to be package-private, so what is
>> the recommended way to register a cleanup func for a RequestVar? Previously,
>> I'd implemented my JNDIResource class for use with the JPA stuff like this:
>>
>> object JNDIResource {
>>   val context = new InitialContext()
>> }
>>
>> abstract class JNDIResource[T](val name: String) extends
>> RequestVar[T](context.lookup(name).asInstanceOf[T]) {
>>
>
> The onShutdown method will always be called:
>
> override protected def onShutdown(session: CleanUpParam): Unit = {
>   dispose(this.is)
> }
>
> If you are putting something in the RequestVar that needs cleanup, you
> should register the cleanup method on the session:
>
> S.session.foreach(_.addSessionCleanup(session => cleanup))
>

I don't think I understand this - will the RequestVar onShutdown hook get
not called at the end of the processing of each HTTP request?

Thanks,

Kris


>
>>
>>   // This is way too dependent upon an implementation detail of the
>> superclass.
>>   override def cleanupFunc : Box[() => 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
>>    */
>>   protected def initialize(resource : T) {
>>   }
>>
>>   /**
>>    * Subclasses should override this method to provide initialization
>>    */
>>   protected def dispose(resource: T) {
>>   }
>> }
>>
>> Using the cleanupFunc like this was of course a complete hack to add the
>> ability to do additional delgated initialization to the variable retrieved
>> from the JNDI context. I can handle the initialization part by overriding
>> setFunc in my new implementation, but how can I set up the delegation to
>> dispose?
>>
>> Thanks,
>>
>> Kris
>
>

--~--~---------~--~----~------------~-------~--~----~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to