This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Allow RequestProcessor to propagate default Lookup. In case the thread submits a request to the RequestProcessor the thread context should be propagated to the RequestProcessor thread.
I have good experience with BrwsrCtx from the HTML/Java API: http://bits.netbeans.org/html+java/1.0/net/java/html/BrwsrCtx.html It has a method to get the current context and also change the context for the time when provided code is being executed. It seems to work OK. Based on that experience I think we should introduce public static void Lookups.execute(Lookup globalLookup, Runnable r); which could be used by clients (like a servlet handling a request) to associate own lookup with currently executing code. Moreover the RequestProcessor would be modified to remember the Lookup at the time of posting a request and use the execute method before starting the task in the other thread.
Created attachment 149924 [details] Introducing Lookups.execute - please review. One question I am not sure about is whether we should really change the instance returned from Lookup.getDefault() or always return a proxy of Lookup.getDefault() and only change its content.
Seems good to me. In the java4tailwind we have ExecutionContext.executeWith() method similar to the Lookups.execute and we change the default lookup instance. We can try to simply change the instance we can change it later on.
(In reply to Jaroslav Tulach from comment #2) > One question I am not sure about is whether we should really change the > instance returned from Lookup.getDefault() or always return a proxy of > Lookup.getDefault() and only change its content. I've faced similar decision in server_split branch, and decided to go with multiple Lookup.getDefault() instances. The reason was that each instance was specific to the Lookup.getDefault() caller's context (whatever the context is) and the caller may save it for later processing in a different thread or so. Combined with executeWith() the saved context can be re-established - e.g. a code acting on behalf of an user etc.
OK. Let's stick with changing instances. The success of my change would be, if you can remove your own executeWith and use Lookups.execute directly. Btw. if you want I can change the name of the method to executeWith so you have easier migration path ;-)
No need to call it "executeWith" as we have single usage of this method so far.
Unless there are objections, let's integrate on Wednesday.
Thanks Jardo!
At the end I go with Lookups.executeWith. The original patch needed more tweaks, as it deadlocked. Hopefully, after 30ab399d18aa the build with succeed.
Integrated into 'main-silver', will be available in build *201410290913* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/0d9ec5d8e2b4 User: Jaroslav Tulach <jtulach@netbeans.org> Log: #247930: Lookups.executeWith(...)