Hi Sergey,

I've had a closer look to your suggested contribution. This would
break existing API where ExecuteListeners are registered in Settings,
with the possibility of loading ExecuteListener configuration from an
XML configuration file. Settings is the right place for
ExecuteListeners.

Do you see any other solution that would remain compatible?

Cheers
Lukas

2012/7/5 Lukas Eder <[email protected]>:
> Hi Sergey
>
> Thanks for this report. I will CC this E-Mail to the user group as
> there had been a recent, related discussion with Aaron Digulla
> concerning this part of the logic. The related discussion was about
> performance, and Aaron suggested to post a patch idea here on the user
> group. Maybe that patch would also resolve your class-loading issue.
>
> I will consider your suggestion later this week
>
> Cheers
> Lukas
>
> 2012/7/4 Sergey Epik <[email protected]>:
>> Hello Lukas,
>>
>> We had a problem to use ExecuteListener's in OSGI environment.
>>
>> JOOQ creates ExecuteListener instances in Util.getListener method and keep
>> them in private static final Map.
>> In our application jOOQ library and client code are in separate bundles, so
>> they have different classloaders (according to OSGI).
>> So Util class is unable to create instance of ExecuteListener from another
>> bundle using Class.forName.
>>
>> We found the following solution:
>> 1. Add private List<ExecuteListener> executeListeners;
>> with setters/getters to Factory.java
>> 2.
>> Add
>>>
>>>     List<ExecuteListener> getExecuteListeners();
>>>
>>>     void setExecuteListeners(List<ExecuteListener> listeners);
>>
>> to  Configuration.java
>> 3. Remove from Util.java
>>>
>>>     /**
>>>      * A cache for {@link ExecuteListener} classes
>>>      */
>>>     private static final Map<String, Class<?>> EXECUTE_LISTENERS = new
>>> ConcurrentHashMap<String, Class<?>>();
>>
>> 4. Change Util.getListeners:
>>>
>>>     static final List<ExecuteListener> getListeners(Configuration
>>> configuration) {
>>>         List<ExecuteListener> result = new ArrayList<ExecuteListener>();
>>>
>>>         if (!FALSE.equals(configuration.getSettings().isExecuteLogging()))
>>> {
>>>             result.add(new StopWatchListener());
>>>             result.add(new LoggerListener());
>>>         }
>>>
>>>         if (configuration.getExecuteListeners() != null) {
>>>             result.addAll(configuration.getExecuteListeners());
>>>         }
>>>         return result;
>>>     }
>>
>>
>> These changes allow us to instantiate ExcecuteListener instances outside
>> jOOQ and inject them to Factory implementation.
>>
>>
>> Best regards,
>> Sergey Epik

Reply via email to