Skip to content

Instantly share code, notes, and snippets.

@cpilsworth
Created January 8, 2013 10:37
Show Gist options
  • Save cpilsworth/4482792 to your computer and use it in GitHub Desktop.
Save cpilsworth/4482792 to your computer and use it in GitHub Desktop.
Configurable OSGI Service using Felix SCR Annotations
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));
}
}
@vjkohli1
Copy link

when will update method called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment