QuestionQ12

Given a scenario, identify how to implement OSGi services and servlets

An AEM application needs to implement multi-tenancy using Adobe-recommended best practices and associate multiple configurations with it.

Which option is recommended?

  • A import org.apache.felix.scr.annotations.Component;@Component(label = “My configuration”, metatype = true, factory= true)
  • B import org.osgi.service.component.annotations.Component;@Component(service = ConfigurationFactory.class)
  • C import org.osgi.service.metatype.annotations.AttributeDefinition; import org.osgi.service.metatype.annotations.ObjectClassDefinition;@ObjectClassDefinition(name = “My configuration”)
  • D import org.osgi.service.component.annotations.Component;import org.osgi.service.metatype.annotations.Designate;@Component(service = ConfigurationFactory.class)@Designate(ocd = ConfigurationFactorylmpl.Config.class, factory=true)
Explanation

OSGi factory configurations allow multiple independently identified configuration instances to be bound to the same component or service. The modern OSGi annotation pattern uses @Component together with @Designate(ocd = ..., factory = true); factory = true enables the factory-configuration behavior needed for multiple instances. Adobe’s OSGi best-practices material shows this @Designate factory pattern, and AEM documentation describes factory configurations as creating distinct instances with persistent identities.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!