External file to specify DB informationhttps://www.eclipse.org/forums/index.php/mv/msg/164615/521325/#msg_521325
I'm currently developing an application using Springframework, OSGi and EclipseLink. Currently, to store the DB connection information, I have a persistance.xml. I don't want my client to need to re-export the plugin to specify the information about his own DB.

So, perhaps this is a stupid question, but is there a way to specify the information such as eclipselink.jdbc.url, eclipselink.jdbc.user and eclipselink.jdbc.password from "outside" the actual plugin making use of those information?

Ideally I want the client to have a human readable file which he can edit (security issues set aside).

Thanks for helping,
Stefan]]>SMaton 2010-03-17T09:53:10-00:00Re: External file to specify DB informationhttps://www.eclipse.org/forums/index.php/mv/msg/164615/521420/#msg_521420
I have found a solution:

Actually my application has 2 xml files containing information about how to connect to the database. One is the already mentioned persistence.xml, the other one is called jpa.xml.

The jpa.xml file is located in the same bundle as the persistence.xml but within a different folder. While the persistence.xml is directly located in the META-INF folder, the jpa.xml is located under META-INF/spring.

The persistence.xml contains a description for the persistence unit. Initially I had also stored the eclipselink properties such as the driver, the url or the password. Storing those values within the persistence.xml wasn't such a good idea, so (after talking to one of my friends) I decided to pull the eclipselink configuration into the jpa.xml.

The jpa.xml defines my entityManagerFactory bean. One of the properties defines the jpaVendorAdapter (which in my case is set to the eclipselink adapter). My friend suggested to directly embed the properties of the eclipselink adapter into the bean definition. He suggested that, since spring seems to map its own properties to the vendor adapter specific properties, this might be the right place to put them.

Unfortunately I could not find any valid solution to this problem because I could not find any kind of mapping table. So, after some searching, I found that you can also define something called "jpaPropertyMap" within your bean. Fortunately, this map can contain vendor specific properties. So I was able to (more or less directly) copy the properties into this description.

The next step was to enable me to "overload" the property values with settings contained in a property file. This is quite easy because you simply have to replace the map value by a placeholder ( like $(dbuser) ). Finally, I had to tell the bean how to replace the placeholders.