You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Freeman Fang (JIRA)" <ji...@apache.org> on 2019/08/14 16:28:00 UTC

[jira] [Commented] (KARAF-6380) Karaf does not pass configs with dashes to ManagedService

    [ https://issues.apache.org/jira/browse/KARAF-6380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16907410#comment-16907410 ] 

Freeman Fang commented on KARAF-6380:
-------------------------------------

Hi [~eximius],

This is a known behavior, and it lies in Apache Felix.
{code}
PID strings (symbolic-name syntax) allow hyphens in the OSGI specification. However, hyphens are interpreted by Apache Felix.fileinstall and config:edit shell commands to differentiate a "managed service" and "managed service factory". Therefore, it is recommended to not use hyphens elsewhere in a PID string. 
{code}

So it's not a Karaf problem.

Cheers
Freeman

> Karaf does not pass configs with dashes to ManagedService
> ---------------------------------------------------------
>
>                 Key: KARAF-6380
>                 URL: https://issues.apache.org/jira/browse/KARAF-6380
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>    Affects Versions: 4.2.6
>            Reporter: Kamil
>            Assignee: Freeman Fang
>            Priority: Major
>
> I have a bundle with this code in activator:
>  
> {code:java}
>   @Override
>   public final void start(final BundleContext bundleContext) throws InterruptedException {
> // final String pid = "foo.bar.e35a73c8-f720-4652-83bb-2b9ed79ea51e"; //does not work!
>     final String pid = "foo.bar.e35a73c8f720465283bb2b9ed79ea51e";
>     ServiceRegistration<ManagedService> serviceReg = bundleContext.registerService(ManagedService.class, new ConfigUpdater(), new Hashtable<>(singletonMap(Constants.SERVICE_PID, pid)));
> }
> {code}
> where:
> {code:java}
>   private final class ConfigUpdater implements ManagedService {
>       @Override
>       public void updated(final Dictionary<String, ?> config) throws ConfigurationException {
>         if (config == null) {
>           System.out.println("The config is null!");
>           return;
>         }
>       }
>   }
> {code}
> and two files in $KARAF_HOME/etc:
>  * foo.bar.e35a73c8-f720-4652-83bb-2b9ed79ea51e.cfg
>  * foo.bar.e35a73c8f720465283bb2b9ed79ea51e.cfg
> the first pid gives null as a config, while the second works



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)