Created
May 25, 2017 20:36
-
-
Save nateyolles/5b92320d2efff785d4c4c0d066a3bcee to your computer and use it in GitHub Desktop.
OSGi Declarative Services Annotations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nateyolles.aem.osgiannotationdemo.core.services.impl; | |
import org.apache.commons.lang3.StringUtils; | |
import org.osgi.service.metatype.annotations.AttributeDefinition; | |
import org.osgi.service.metatype.annotations.AttributeType; | |
import org.osgi.service.metatype.annotations.ObjectClassDefinition; | |
import org.osgi.service.metatype.annotations.Option; | |
@ObjectClassDefinition(name = "Annotation Demo Service - OSGi") | |
public @interface Configuration { | |
@AttributeDefinition( | |
name = "Boolean Property", | |
description = "Sample boolean value", | |
type = AttributeType.BOOLEAN | |
) | |
boolean servicename_propertyname_boolean() default true; | |
@AttributeDefinition( | |
name = "String Property", | |
description = "Sample String property", | |
type = AttributeType.STRING | |
) | |
String servicename_propertyname_string() default "foo"; | |
@AttributeDefinition( | |
name = "Dropdown property", | |
description = "Sample dropdown property", | |
options = { | |
@Option(label = "DAYS", value = "DAYS"), | |
@Option(label = "HOURS", value = "HOURS"), | |
@Option(label = "MILLISECONDS", value = "MILLISECONDS"), | |
@Option(label = "MINUTES", value = "MINUTES"), | |
@Option(label = "SECONDS", value = "SECONDS") | |
} | |
) | |
String servicename_propertyname_dropdown() default StringUtils.EMPTY; | |
@AttributeDefinition( | |
name = "String Array Property", | |
description = "Sample String array property", | |
type = AttributeType.STRING | |
) | |
String[] servicename_propertyname_string_array() default {"foo", "bar"}; | |
/* | |
* To create password field, either set the AttributeType or have the | |
* property name end with "*.password" (or both). | |
*/ | |
@AttributeDefinition( | |
name = "Password Property", | |
description = "Sample password property", | |
type = AttributeType.PASSWORD | |
) | |
String servicename_propertyname_password() default StringUtils.EMPTY; | |
@AttributeDefinition( | |
name = "Long Property", | |
description = "Sample long property", | |
type = AttributeType.LONG | |
) | |
long servicename_propertyname_long() default 0L; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @AquilaVasc, it's a bit late for this comment, but perhaps you forgot to use `@Designate´ to indicate to which component the config should be bound?
Any configs declared with
@ObjectClassDefinition
will be ignored unless they are bound to at least one component using `@Designate´. For a practical example, check out AEM Core Component's FormHandlerImpl component