Why not use good old runonce from lancet?
(defn runonce
"Create a function that will only run once. All other invocations
return the first calculated value. The function can have side effects.
Returns a [has-run-predicate, reset-fn, once-fn]"
[function]
(let [sentinel (Object.)
result (atom sentinel)
reset-fn (fn [] (reset! result sentinel) nil)
has-run? #(not= @result sentinel)]
[has-run?
reset-fn
(fn [& args]
(locking sentinel
(if (= @result sentinel)
(reset! result (function))
@result)))]))
--Robert McIntyre
On Sun, Nov 28, 2010 at 11:28 PM, Stuart Campbell <[email protected]> wrote:
> Ah, OK. We just use Tomcat 6 for everything here :)
>
> On 29 November 2010 12:16, <[email protected]> wrote:
>>
>> Yep but some app servers have bugs with this interface (GlassFish 2,
>> jetty 6.1, tomcat 5.5, ...) and the interface is not called appropriately.
>> There are less problems reported with the load-on-startup flag.
>>
>> Of course if you know your app server's behavior regarding this feature,
>> it might not be a problem.
>>
>> I got caught once so I prefer a safer mechanism, we are not always using
>> the same app server here. Might work in dev and not in prod... oups...
>>
>> Luc P.
>>
>> Stuart Campbell <[email protected]> wrote ..
>> > On 28 November 2010 16:51, <[email protected]> wrote:
>> >
>> > > We use a dedicated servlet for every web app to make sure all
>> > > prerequisites
>> > > are met. Since it's loaded first, we can find problems by looking at a
>> > > single
>> > > piece of the log files just after the container messages announcing
>> > > that
>> > > it's loading the app.
>> > >
>> >
>> > There's also ServletContextListener (
>> >
>>
>> http://download.oracle.com/javaee/5/api/javax/servlet/ServletContextListener.html),
>> > which is configured in web.xml too.
>> >
>> > Regards,
>> > Stuart
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to [email protected]
>> > Note that posts from new members are moderated - please be patient with
>> > your first
>> > post.
>> > To unsubscribe from this group, send email to
>> > [email protected]
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>> Luc P.
>>
>> ================
>> The rabid Muppet
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en