Search code examples
javaosgiipojo

iPOJO: difference between @ServiceProperty and @Property


What's the difference between "service property" and "property" at http://felix.apache.org/site/how-to-use-ipojo-annotations.html#HowtouseiPOJOAnnotations-@ServiceProperty?


Solution

  • A @ServiceProperty is published with the (OSGi) services provided by the component. On the other side, @Property are kept private.

    For example:

    @Component
    @Provides
    public class MyComponent implements MyService {
    
        @Property
        private String hidden;
    
        @ServiceProperty
        private String shown;
    
        [...]
    
    }
    

    This component publishes the MyService 'service' with the 'shown' property. 'hidden' is not published.