felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Jeschke <matth...@gmail.com>
Subject Re: Question regarding Config Admin
Date Thu, 05 Mar 2015 18:53:25 GMT
Hi,

Here is a small example to create a configuration for a pax-jdbc database
(org.ops4j.datasource is the service factory pid):

@Requires
private ConfigurationAdmin configurationAdmin;

Configuration conf =
configurationAdmin.createFactoryConfiguration("org.ops4j.datasource", "?");
Dictionary<String, String> props = new Hashtable<>();
props.put("osgi.jdbc.driver.name", "mysql");
props.put("databaseName", "ipojotest");
props.put("user", "xxx");
props.put("password", "yyy");
props.put("dataSourceName", "ipojotestsrc");
conf.update(props);

On Thu, Mar 5, 2015 at 7:12 PM, clement escoffier <
clement.escoffier@gmail.com> wrote:

> Hi,
>
> Instead of creating the instance with the @Configuration, you may have to
> create them using 'cfg' files. 'cfg' files are read by Karaf that store the
> configuration into the Config Admin. Then, iPOJO read the configuration
> from the Config Admin.
>
> Cheers,
>
> Clement
>
> 2015-03-05 16:49 GMT+01:00 Andrew Phillips <andyphillips404@gmail.com>:
>
> > I think i figured it out.   Sorry to be trouble.  I figured out that the
> > karat config management can change the configuration, but if there isn’t
> a
> > configuration file set up, it doesn’t show it in the config:list.
> >
> > > On Mar 5, 2015, at 7:19 AM, Andy Phillips <andyphillips404@gmail.com>
> > wrote:
> > >
> > > I appreciate the feedback, not to be a pain, could you give me an
> > example?
> > >
> > >
> > >
> > >> On Mar 5, 2015, at 6:25 AM, Matthias Jeschke <matthjes@gmail.com>
> > wrote:
> > >>
> > >> Hi,
> > >>
> > >> After creating the instances I think you have to create the
> > configuration.
> > >> What I did was to inject the ConfigurationAdmin and then create a new
> > >> configuration (with the respective managed service pid) via
> > >> "createFactoryConfiguration()".
> > >>
> > >> Best regards
> > >>
> > >> Matthias
> > >>
> > >>
> > >> On Thu, Mar 5, 2015 at 1:09 PM, Andrew Phillips <
> > andyphillips404@gmail.com>
> > >> wrote:
> > >>
> > >>> I am using iPojo and trying to create some instances of a component
> > with
> > >>> different configuration and tying the configuration to the Config
> > Admin in
> > >>> karat (so it can be managed with the config commands).
> > >>>
> > >>> No matter what i do, i cannot get the configuration of these
> instances
> > to
> > >>> show up when i do a config:list in karat.   Any help would be greatly
> > >>> appreciated!
> > >>>
> > >>> Here is how i am creating the instances:
> > >>>
> > >>> Instance instance =
> > Instance.instance().of(MapQuestGeocodeProvider.class)
> > >>>
> >  .named("com.hdscores.geocode.mapquest.MapQuetGeocodeOpenProvider")
> > >>>
> > >>>
> >
> .with("managed.service.pid").setto("com.hdscores.geocode.mapquest.MapQuetGeocodeOpenProvider")
> > >>>       .with(MapQuestGeocodeProvider.API_URL).setto("
> > >>> http://open.mapquestapi.com/geocoding/v1/address")
> > >>>
> > >>>
> >
> .with(MapQuestGeocodeProvider.API_KEY).setto("Fmjtd%7Cluur2d6anu%2C7g%3Do5-9ab55u")
> > >>>       .with(Constants.SERVICE_RANKING).setto("10")
> > >>>       .with(GeocodeServiceProperties.USE_IN_MANAGER).setto("true");
> > >>>
> > >>> Instance instance2 =
> > Instance.instance().of(MapQuestGeocodeProvider.class)
> > >>>
> > >>>
> .named("com.hdscores.geocode.mapquest.MapQuetGeocodeLicensedProvider")
> > >>>
> > >>>
> >
> .with("managed.service.pid").setto("com.hdscores.geocode.mapquest.MapQuetGeocodeLicensedProvider")
> > >>>       .with(MapQuestGeocodeProvider.API_URL).setto("
> > >>> http://www.mapquestapi.com/geocoding/v1/address")
> > >>>
> > >>>
> >
> .with(MapQuestGeocodeProvider.API_KEY).setto("Gmjtd%7Cluur2gutnq%2C2l%3Do5-lrasd")
> > >>>       .with(Constants.SERVICE_RANKING).setto("1")
> > >>>       .with(GeocodeServiceProperties.USE_IN_MANAGER).setto("true”);
> > >>>
> > >>> the GeocodeProvider class starts off like this:
> > >>>
> > >>> @Component()
> > >>> @Provides(strategy = “SERVICE")
> > >>> public class MapQuestGeocodeProvider implements GeocodeService {
> > >>>
> > >>>   public static final String API_URL = "apiUrl";
> > >>>   public static final String API_KEY = "apiKey";
> > >>>
> > >>>   private Client client;
> > >>>
> > >>>   @ServiceProperty(name = GeocodeServiceProperties.USE_IN_MANAGER)
> > >>>   private boolean useInManager;
> > >>>
> > >>>   @ServiceProperty(name=API_URL)
> > >>>   private String apiUrl;
> > >>>
> > >>>   @ServiceProperty(name=API_KEY)
> > >>>   private String apiKey;
> > >>>
> > >>>
> > >>> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > >>> For additional commands, e-mail: users-help@felix.apache.org
> > >>>
> > >>>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message