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
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
Solved! Go to Solution.
Please remove the factory attribute. It will resolve the issue and the component will be registered using SocialComponentFactory.
@Component(name = "Custom Community Component Factory", configurationPolicy = ConfigurationPolicy.OPTIONAL, service = SocialComponentFactory.class)
public class CustomCommunityComponentFactory extends AbstractSocialComponentFactory {
// Rest of the Code.
}
[Custom Community Component Factory,23947, [com.adobe.cq.social.scf.SocialComponentFactory]] ServiceEvent REGISTERED
Hope this helps!
Thanks
Please remove the factory attribute. It will resolve the issue and the component will be registered using SocialComponentFactory.
@Component(name = "Custom Community Component Factory", configurationPolicy = ConfigurationPolicy.OPTIONAL, service = SocialComponentFactory.class)
public class CustomCommunityComponentFactory extends AbstractSocialComponentFactory {
// Rest of the Code.
}
[Custom Community Component Factory,23947, [com.adobe.cq.social.scf.SocialComponentFactory]] ServiceEvent REGISTERED
Hope this helps!
Thanks
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
SCR inheritance (which is supported by the Felix SCR annotations) is no longer possible with the OSGI annotations, and that's by design. IIRC Carsten Ziegeler (of the OSGI alliance) wrote that it caused more problems can benefits, so it was not included into the OSGI annotations
Views
Likes
Replies