Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Can I inject custom module reference in FinderImpl ????
I have a custom module which has some util classes which I need to use in my FinderImpl , is it a good way to inject the util class into FinderImpl, Please do share example if you have.custom module is exporting util class.FinderImpl gradle has dependency added .
but I get reference as null.
@Component(service = SampleFinder.class)
public class SampleFinderImpl extends SampleFinderBaseImpl implements SampleFinder {
//Methods....@Reference
private MathUtil _MathUtil;
}
-----------------------In finder gradle-----------compileOnly project(":modules:abc:com.test.first.util")
------------------------------------------------------in util package - bnd.bnd.Export-Package: com.test.first.util
but I get reference as null.
@Component(service = SampleFinder.class)
public class SampleFinderImpl extends SampleFinderBaseImpl implements SampleFinder {
//Methods....@Reference
private MathUtil _MathUtil;
}
-----------------------In finder gradle-----------compileOnly project(":modules:abc:com.test.first.util")
------------------------------------------------------in util package - bnd.bnd.Export-Package: com.test.first.util
Hi ,You can inject a utility in finder impl , you can refer and try something like journalconverterimpl and journalconverter
https://github.com/liferay/liferay-portal/blob/e3eeacea100fed8f29fa749cd5849d789574cc94/modules/apps/journal/journal-service/src/main/java/com/liferay/journal/internal/util/JournalConverterImpl.java
https://github.com/liferay/liferay-portal/blob/09230c4f8d5d08045c305c359ffb359d509320d0/modules/apps/journal/journal-api/src/main/java/com/liferay/journal/util/JournalConverter.java
This can be referred as
https://github.com/liferay/liferay-portal/blob/e3eeacea100fed8f29fa749cd5849d789574cc94/modules/apps/journal/journal-service/src/main/java/com/liferay/journal/internal/util/JournalConverterImpl.java
https://github.com/liferay/liferay-portal/blob/09230c4f8d5d08045c305c359ffb359d509320d0/modules/apps/journal/journal-api/src/main/java/com/liferay/journal/util/JournalConverter.java
This can be referred as
[code] @Reference
private JournalConverter _journalConverter;
Is your service builder service created using Spring DI or is it created with OSGi DS?
https://help.liferay.com/hc/en-us/articles/360032624732-Migrating-a-Service-Builder-Module-from-Spring-DI-to-OSGi-DS
Given your code, there will be one instantiated by DS, and it will have a non-null reference, but if there is another one instantiated by Spring DI, its reference won't be populated.
https://help.liferay.com/hc/en-us/articles/360032624732-Migrating-a-Service-Builder-Module-from-Spring-DI-to-OSGi-DS
Given your code, there will be one instantiated by DS, and it will have a non-null reference, but if there is another one instantiated by Spring DI, its reference won't be populated.