Create/modify and register filters in OSGI programmatically

40 Views Asked by At

Is it possible to register new filters at runtime in OSGI ?

Use case is the following. We use Adobe AEM CMS with multiple tenants. Now we have a filter that protects access to particular resources based on filter patterns. Here is the header of a filter class that intercepts requests to paths that contain the fragment "protected" for tenant1.

@Component(service = Filter.class,
    property = {
            EngineConstants.SLING_FILTER_SCOPE + "=" + EngineConstants.FILTER_SCOPE_REQUEST,
            EngineConstants.SLING_FILTER_PATTERN + "=" + "/content/dam/tenant1/.*/protected/.*"
    })
 public class ProtectedResourcesFilter implements Filter ....

Now, whenevever we get tenant2 we would like to extend the ProtectedResourcesFilter with another pattern. Is it possible to modify the EngineConstants.SLING_FILTER_PATTERN and reload the filter?

Or is it better to create and register a new filter at runtime in OSGI ?

0

There are 0 best solutions below