Hi,
Yes you can register whatever instance class you want in the service
registry with related properties.
For example, you can register a ShiroFilter as an osgi service in the
service registry:
Dictionary shiroProps = new Hashtable();
String[] urls = {"/*"};
String[] servlets = {restServlet.getServletConfig().getServletName()};
shiroProps.put("filter-name", "Shiro Filter");
shiroProps.put("urlPatterns", urls);
shiroProps.put("servletNames", servlets);
ShiroFilter shiroFilter = new ShiroFilter();
ServiceRegistration filterRegistration =
componentContext
.getBundleContext()
.registerService(Filter.class.getName(),
shiroFilter, shiroProps);
So you could registrer a WebEnvironment the same way.
regards,
François
On 07/03/2024 18:24, Steinar Bang wrote:
What's the easiest way to find the Shiro WebEnvironment from a
Declarative Services component running in karaf?
Does anyone know?
Can the WebEnvironment be injected as an OSGi service?
Or may there be multiple WebEnvironments inside a karaf instance if
there are multiple web applications each with their own shiro realm?
Thanks!
- Steinar