質問

Rather than manually making configuration changes to OSGi components in Felix, it's good practice to create sling:OsgiConfig nodes in the JCR to make sure that the settings are version controlled, applied the same across environments, etc.

Similarly, I want to disable an out-of-the-box component on each environment. Is there any way to achieve this via configuration? Rather than going to system/console/components and disabling it there?

Anything I've read about this has mentioned making changes internally within the bundle, but since it's one that I don't own, I'd need some external configuration to do this.

役に立ちましたか?

解決

You can do this with the ScrService, which is published by the SCR runtime bundle. API documentation is here.

Note that ScrService is not "standard", i.e. it doesn't come from the OSGi specification. However it is supported by Felix and Equinox and Knopflerfish, so it's pretty much a de facto standard. In fact this service is used by the Web Console when you go to system/console/components.

他のヒント

Try to use attribute policy=ConfigurationPolicy.REQUIRE on @Component.

Then you could prepare a set of packages with configurations for each environment as part of the build. This is also a good practice for having different OSGI configurations for each environment.

So for some of enironments you could just simply not provide a configuration for a particular component. Such component would not run - it would have unsatisfied status.

I believe I've seen this approach in AEM itself.

You can also create a filter to remove current configurations but it still would require to disable the Component at least once. And this solution will work only if this component has mentioned policy.

The other way around is to prepare a Service that would be responsible for disabling other components - it could be configurable. But it doesn't sound like a good solution to me.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top