Property in OSGI | Community
Skip to main content
Level 3
October 16, 2015
Solved

Property in OSGI

  • October 16, 2015
  • 2 replies
  • 772 views

Hi everyone,

Can I add a custom property on my OSGI service?

ex.

@Properties({
    @Property(name ="NewValue", intValue = 0, propertyPrivate = false, label="custom value")})
@Service
public class NameClass

 

If I can, How I access to the property in my source code?

 

Thanks,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Lokesh_Shivalingaiah

Yes, You can add and access the same using

ComponentContext.getProperties.get(<property name>)

2 replies

Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
October 16, 2015

Yes, You can add and access the same using

ComponentContext.getProperties.get(<property name>)

avalersAuthor
Level 3
October 16, 2015

Yes, also 

Use this code in the activate method.

Dictionary<?, ?> properties = componentContext.getProperties();

Object propertyObject = properties.get(PROPERTY_NAME);