Skip to content

Instantly share code, notes, and snippets.

@athiththan11
Created July 6, 2019 08:24
Show Gist options
  • Save athiththan11/160a16cfbb4fe09261d8033cb7a725b9 to your computer and use it in GitHub Desktop.
Save athiththan11/160a16cfbb4fe09261d8033cb7a725b9 to your computer and use it in GitHub Desktop.
Fabricator OSGi service component implementation containing the activation with the Bundle Context
@Component(name = "com.sample.athiththan.fabricator.internal.service", immediate = true)
public class FabricatorServiceComponent {
private static final Logger LOGGER = Logger.getLogger(FabricatorServiceComponent.class.getName());
@Activate
protected void activate(ComponentContext context) {
/**
* create a new instance inside the activate method and register the service
*/
// create an instance and register
context.getBundleContext().registerService(FactFabricator.class.getName(), new FactFabricator(), null);
LOGGER.info("OSGI Fabricator :: Fabricator bundle is activated");
}
@Deactivate
protected void deactivate(ComponentContext context) {
LOGGER.info("OSGI Fabricator :: Fabricator bundle is deactivated");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment