Created
January 8, 2013 10:37
-
-
Save cpilsworth/4482792 to your computer and use it in GitHub Desktop.
Configurable OSGI Service using Felix SCR 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.sample.osgi; | |
import java.util.Map; | |
import org.apache.felix.scr.annotations.Activate; | |
import org.apache.felix.scr.annotations.Component; | |
import org.apache.felix.scr.annotations.Modified; | |
import org.apache.felix.scr.annotations.Property; | |
@Component(label = "Service Label", description = "Service Description", metatype = true, immediate = true) | |
public class ConfigurableService { | |
@Property(value="default value", label = "Sample Parameter", description = "Example of a component parameter") | |
private static final String SAMPLE_PARAM_NAME = "param.one"; | |
@Activate | |
protected void activate(final Map<String, Object> props) { | |
this.update(props); | |
} | |
@Modified | |
protected void update(final Map<String, Object> props) { | |
System.out.println(props.get(SAMPLE_PARAM_NAME)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and @activate