April 13, 2020
Estimated Post Reading Time ~

@Component (maven scr plugin)

http://felix.apache.org/site/scr-annotations.html

If you are writing an abstract Felix OSGi component, make sure componentAbstract is true:

@Component(componentAbstract=true, ...)
//@Service Abstract component can't be Servicepublic abstract class Foo.
Also, if you want your component to be configurable through Felix Web Console (/system/console/components shows Configure button, little wrench icon), set metatype to true

@Component(metatype=true, ...)
@Servicepublic class Foo ...
Available fields on Felix Web Console can be configured using @Property annotation:

@Property(cardinality=-1000, label="Hosts", description="a list of hosts", value={})private static final String PROP_HOSTS = "my.hosts";This (along with metatype=true) will create a form field on Felix Web Console that has a maximum number of elements of 1000. If you put more than 1000 entries through the form, the 1001st element and on will be truncated.

The document, http://felix.apache.org/site/scr-annotations.html, says that cardinality=Integer.MIN_INT, but it does not work if you specify a variable there. See, https://issues.apache.org/jira/browse/FELIX-2704.
Also, cardinality=-2147483648 won't work. Probably because it's too large. I get NumberFormatException.

To set the type of the property, use longValue, doubleValue...etc instead of value={}.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.