Hi All,
i created a configuration factory service to bind multiple config for different type mail accounts ? im using @Reference(target ="service.label="") but it's not working as reference is shown as unsatisfied.. im using ds annotations.
Solved! Go to Solution.
I created a sample service with factory config, please check for reference
aem63app-repo/java/r6/factory at master · arunpatidar02/aem63app-repo · GitHub
Views
Replies
Total Likes
I created a sample service with factory config, please check for reference
aem63app-repo/java/r6/factory at master · arunpatidar02/aem63app-repo · GitHub
Did not work for me.
I did the following
Service code (in the first bundle)
public interface GodaDataServiceFactory {
List<GodaDataBean> getData();
}
Service Impl Code (Another bundle - Second bundle, Note its a factory)
@Component(
service = GodaDataServiceFactory.class,
factory = "GodaDataServiceFactory",
configurationPolicy = ConfigurationPolicy.REQUIRE
)
@Designate(ocd = GodaDataServiceFactoryConfig.class, factory = true)
public class GodaDataServiceFactoryJcrImpl implements GodaDataServiceFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(GodaDataServiceFactoryJcrImpl.class);
@Override
public List<GodaDataBean> getData() {
return null;
}
}
Snaps of the configs
Reference
Option 1 (Direct reference):
@Reference(target = "(sample=test)")
private GodaDataServiceFactory godaDataServiceFactory;
Option 2 (Indirect using bind and unbind)
@Reference(
name = "godaDataServiceFactory",
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
bind = "bindGodaDataServiceFactory",
unbind = "unbindGodaDataServiceFactory")
List<GodaDataServiceFactory> godaDataServiceFactoryList = new ArrayList<>();
protected synchronized void bindGodaDataServiceFactory(final GodaDataServiceFactory config) {
LOGGER.info("Goda config factory: {}", config);
godaDataServiceFactoryList.add(config);
}
protected synchronized void unbindGodaDataServiceFactory(final GodaDataServiceFactory config) {
godaDataServiceFactoryList.remove(config);
}
None of this seems to work. In the first case godaDataServiceFactory, it is null. The second case, the list is always empty. Note that the consumer is a servlet.
My GitHub Repos
Consumer -> https://github.com/GodaProjects/aem646
API -> https://github.com/GodaProjects/api
API IMPL -> https://github.com/GodaProjects/apiImplJcr
Update 1:
For option 1, The servlet remains unsatisfied.
Reference godaDataServiceFactory | Unsatisfied |
For the second option,the list remains empty
Update 2
Consumer project is created using Archetype 13 (has the servlet which consumes the factory service) -> https://github.com/GodaProjects/aem646
API project is created using Archetype 18 (has the API interface for the factory) -> https://github.com/GodaProjects/api
API IMPL project is created using Archetype 18 (has the implementation for the API which is in the API project) -> https://github.com/GodaProjects/apiImplJcr
Views
Replies
Total Likes
Views
Likes
Replies