Gemini JPA Package Refresh [message #759020] |
Fri, 25 November 2011 15:42 |
|
Hi,
Gemini JPA is performing a package refresh right after my bundle is
started. This is problematic because the bundle is started twice. I
wonder if the behavior is required or can be avoided.
Looking through the code I found an option to turn it off (with the
default being ON). However, the comment says that it may only be turned
ON if waving is not required
(GeminiProperties.refreshPersistenceBundles()).
Here is the issue:
* Launch JUnit plug-in test
* Test runner starts bundle X (static Activator.instance is set)
* Test runner loads test class Y
* Bundle X is stopped (static Activator.instance is clear)
* Bundle X is started again (static Activator.instance is set [1])
* Test class Y method is executed which calls Activator.instance [2]
[1] The issue is that this is actually a new class loaded with a new
class loader (because of the package refresh)
[2] Test fails because Activator.instance is null because of [1].
A possible workaround is to modify the test runner to somehow detect
package refreshes and to re-start the tests. I wonder if that is
possible at all...
Thus, before I go down that path I'm wondering if it's possible to avoid
the package refresh behavior when executing tests.
-Gunnar
--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
|
|
|
|
|
Re: Gemini JPA Package Refresh [message #760789 is a reply to message #759025] |
Mon, 05 December 2011 09:48 |
|
Am 25.11.2011 17:12, schrieb Mike Keith:
> 2) Refreshing will only happen if the persistence bundle was detected to have been resolved before Gemini JPA got started (due to 1). If the bundle is installed/resolved after Gemini JPA then the refreshing will not happen - thus it only happens when the situation warrants refreshing.
That's interesting. In my test bundle I have a "Require-Bundle"
dependency on "org.eclipse.gemini.jpa". Thus, when Equinox starts my
bundle it ensures that "org.eclipse.gemini.jpa" is started first. My
test bundle is still refreshed, though. Should I open a bug to
investigate further?
-Gunnar
--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
|
|
|
Re: Gemini JPA Package Refresh [message #760865 is a reply to message #760789] |
Mon, 05 December 2011 13:29 |
|
Am 05.12.2011 10:48, schrieb Gunnar Wagenknecht:
> That's interesting. In my test bundle I have a "Require-Bundle"
> dependency on "org.eclipse.gemini.jpa". Thus, when Equinox starts my
> bundle it ensures that "org.eclipse.gemini.jpa" is started first. My
> test bundle is still refreshed, though. Should I open a bug to
> investigate further?
I stand corrected. I think it may be a behavior that was the case in the
old (pre-OSGi) world. I did not find any statement regarding this in the
OSGi spec.
-Gunnar
--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02640 seconds