Enonic version: 6.12.2
OS: Windows 10
I am fiddling around with some stuff in a Java class included in one of my XP Apps. The class is initialized using the OSGi @Component-annotation and I am running an activator-method using the @Activate-annotation to get ahold of the BundleContext. I was looking into context.getServiceReferences() and trying to get the VirtualHostConfigImpl instance, so I could run .getMappings(), but I a bit of a OSGi noob and I am unable to get this “service” without running into problems.
What would the proper way to get the current VirtualHostConfig inside a @Component-class be?
I was hoping to be able to do something like:
@Activate
public void init(BundleContext context) throws Exception {
ServiceReference<VirtualHostConfigImpl> ref = context.getServiceReference(VirtualHostConfigImpl.class);
VirtualHostConfig config = context.getService(ref);
parseMappings(config.getMappings());
}
Unfortunately when I run this on Enonic XP I get a NoClassDefFoundError: com/enonic/xp/web/vhost/impl/config/VirtualHostConfigImpl
.