Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » SessionCustomizer in OSGi environments(Small? change to get SessionCustomizer working in OSGi environments)
icon14.gif  SessionCustomizer in OSGi environments [message #657055] Tue, 01 March 2011 13:27 Go to next message
Caspar MacRae is currently offline Caspar MacRae
Messages: 12
Registered: March 2011
Location: London
Junior Member
I was going to pop this on bugzilla but thought I'd see if anyone has any better ideas or workarounds first..


The SessionCustomizer is unusable in an OSGi environment without first modifying the org.eclipse.persistence.core bundle to add dynamic import..

The EntityManagerSetupImp could be modified to be more OSGi aware (via a class/instance loading fa├žade) and lookup the client SessionCustomizer from the OSGi registry - using the class name from the "eclipselink.session.customizer" property as a filter parameter.

This would ensure the correct SessionCustomizer is found without any need to know the specific client's implementation class (so no nasty workarounds).

Re: SessionCustomizer in OSGi environments [message #657173 is a reply to message #657055] Tue, 01 March 2011 19:32 Go to previous messageGo to next message
Shaun Smith is currently offline Shaun Smith
Messages: 197
Registered: July 2009
Senior Member
SessionCustomizer works for me in OSGi. The trick is to ensure that EclipseLink can load the class you name either in your persistence.xml or that you pass in the properties you use to create your EntityManagerFactory.

E.g.
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("eclipselink.classloader", this.getClass().getClassLoader());
properties.put("eclipselink.session.customizer", "my.Customizer");                  
emf = new PersistenceProvider()	.createEntityManagerFactory("comics", properties);


--Shaun
Re: SessionCustomizer in OSGi environments [message #657343 is a reply to message #657173] Wed, 02 March 2011 14:02 Go to previous message
Caspar MacRae is currently offline Caspar MacRae
Messages: 12
Registered: March 2011
Location: London
Junior Member
Thanks Shaun, works perfectly.

A case of RTFM Embarrassed
Previous Topic:SequenceGenerator
Next Topic:[JPA-Newbie] -- JPA 2 for dynamic/custom entity types (database schemas)?
Goto Forum:
  


Current Time: Thu Oct 23 06:06:30 GMT 2014

Powered by FUDForum. Page generated in 0.02220 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software