Hi, I'm currently experimenting with Karaf / Aries blueprint to find out if there are suitable ways to provide some functions for my application. One of this is to dynamically create DataSources (and then Providers) based on properties stored in a file. So the use case would be: 1. Create a property file with, e.g., the database driver, url, password etc. and Aries JNDI specifier 2. Drop this file into karaf/etc 3. A new DataSource service is created with the service property " osgi.jndi.service.name" set to the value specified in the property file. 4. In the persistence.xml the appropriate data source is used (it also has a configurable unit name) 5. A provider is created based on the persistence.xml
So basically I have an "applications" running in the container that use JPA to write/read data to a database. A new application (with a new data source) is initialized when a new configuration file is dropped into the karaf/etc folder. Furthermore, it is somehow difficult to find a good documentation about blueprint (e.g. property-placeholder, cm:properties, cm:config). Do you know a good reference? On Tue, Dec 2, 2014 at 7:16 AM, jbonofre [via Karaf] < [email protected]> wrote: > Hi, > > why do you need managed service factory ? > > A simple cm:config is not enough (it can be provided by a feature) ? > > Just to understand your use case. > > Regards > JB > > On 12/02/2014 06:24 AM, matthjes wrote: > > > Hi, > > > > I have the following managed-service-factory: > > > > <cm:managed-service-factory factory-pid="DataSource" > > interface="javax.sql.DataSource"> > > <service-properties> > > <entry key="osgi.jndi.service.name" value="${dbname}"/> > > </service-properties> > > <cm:managed-component > > class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> > > <property name="driverClassName" value=""/> > > <property name="url" value=""/> > > <property name="username" value=""/> > > <property name="password" value=""/> > > </cm:managed-component> > > </cm:managed-service-factory> > > > > Now I'd like to set ${dbname} to a value specified in a configuration > file > > so that every time I put a new config file into karaf/etc a new > DataSource > > service with a specific osgi.jndi.service.name is created. > > > > I've tried using property-placeholder, however, this did not work. The > only > > method that currently works ist the following: > > > > <cm:managed-service-factory factory-pid="DataSource" > > interface="javax.sql.DataSource"> > > <service-properties> > > <cm:cm-properties persistent-id="DataSource"/> > > </service-properties> > > <cm:managed-component > > class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> > > <property name="driverClassName" value=""/> > > <property name="url" value=""/> > > <property name="username" value=""/> > > <property name="password" value=""/> > > </cm:managed-component> > > </cm:managed-service-factory> > > > > So using cm-properties inside the service-properties element. However, > this > > uses *all* properties defined in the config file for the > service-properties, > > which is not intended. > > > > Is there some way to have a config file with several properties but only > use > > one of them as a service property for a managed service? > > > > > > > > -- > > View this message in context: > http://karaf.922171.n3.nabble.com/managed-service-factory-how-to-set-service-properties-from-config-file-tp4036836.html > > Sent from the Karaf - User mailing list archive at Nabble.com. > > > > -- > Jean-Baptiste Onofré > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4036837&i=0> > http://blog.nanthrax.net > Talend - http://www.talend.com > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://karaf.922171.n3.nabble.com/managed-service-factory-how-to-set-service-properties-from-config-file-tp4036836p4036837.html > To unsubscribe from managed-service-factory: how to set > service-properties from config file, click here > <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4036836&code=bWF0dGhqZXNAZ21haWwuY29tfDQwMzY4MzZ8LTk5NjI4MTMwNQ==> > . > NAML > <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://karaf.922171.n3.nabble.com/managed-service-factory-how-to-set-service-properties-from-config-file-tp4036836p4036840.html Sent from the Karaf - User mailing list archive at Nabble.com.
