Extending AbstractSocialComponentFactory for AEM 6.5 with R6 annotations
Hello All,
As part of upgrade from AEM 6.2 to AEM 6.5, I am looking to find a correct way to extend the
This is an example - https://github.com/Adobe-Marketing-Cloud/aem-scf-sample-components-extension/blob/master/bundles/aem-scf-extensions/src/main/java/com/adobe/aem/scf/extensions/IdeaSocialComponentFactory.java similar to which we have our custom implementation working for AEM 6.2. We are also using org.apache.felix.scr.annotations.Component; annotations in 6.2
@Component(name = "Custom Community Component Factory", factory = "com.path.to..CustomCommunityComponentFactory", service = SocialComponentFactory.class, configurationPolicy = ConfigurationPolicy.OPTIONAL)
@Component(name = "Custom Community Component Factory", factory = "com.path.to..CustomCommunityComponentFactory")
and other combinations. But still the class never gets called. The bundle is active and the service class is active too (/system/console/components)
I see that the current custom factory is not registered as SocialComponentFactory but rather as ComponentFactory
Actual : [Custom COmmunity Component Factory,21308, [org.osgi.service.component.ComponentFactory]] ServiceEvent REGISTERED
package path.to.package;
import com.adobe.cq.social.scf.ClientUtilities;
import com.adobe.cq.social.scf.QueryRequestInfo;
import com.adobe.cq.social.scf.SocialComponent;
import com.adobe.cq.social.scf.SocialComponentFactory;
import com.adobe.cq.social.scf.core.AbstractSocialComponentFactory;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
/** Factory Class for Custom Community Component.
* @author Shubham
*
*/
@Component(name = "Custom Community Component", factory = "path.to.current.class.CustomCommunityComponentFactory", service = SocialComponentFactory.class, configurationPolicy = ConfigurationPolicy.OPTIONAL)
public class CustomCommunityComponentFactory extends AbstractSocialComponentFactory implements SocialComponentFactory {
@Override
public SocialComponent getSocialComponent(final Resource resource) {
return new CustomCommunityComponent(resource, this.getClientUtilities(resource.getResourceResolver()));
}
@Override
public SocialComponent getSocialComponent(final Resource resource, final SlingHttpServletRequest request) {
return new CustomCommunityComponent(resource, this.getClientUtilities(request));
}
@Override
public SocialComponent getSocialComponent(Resource resource, ClientUtilities clientUtils, QueryRequestInfo listInfo) {
return new CustomCommunityComponent(resource, clientUtils);
}
@Override
public int getPriority() {
return 1000;
}
@Override
public String getSupportedResourceType() {
return "project/path/to/component";
}
}
I have updated to R6 annotations for other services and servlet class but for this particular one updating to R6 reference and using @Component annotation does not seem to work. The component hbs does not render any thing and there are no errors in any of the logs. During debug as well on component page load I should be able to hit the lines with return statements, but I am unable to. This does work when I use the old annotations. Tried adding immediate=true, socialFactory=true but in vain.
Please help out if there is anything I am missing in terms of binding the custom component with the Social Component Factory class. Not sure if any one has tried this already. Could that be because the OOTB AbstractSocialComponentFactory is still using felix annotations?
cc @aponnusa
