Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
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
UserService dependency injection from portal-spring.xml
Hi,
I'd like to write a customized UserService for my portlet application. The service needs Liferay's UserService or UserLocalService. To autowire the dependencies I need a bean for it in my applicationContext. I found out that UserService is described in Liferay's portal-spring.xml, so Spring should resolve it with the following config in my web.xml (have not tried it yet):
I think this will cause multiple contexts (the liferay context and my context). In other forum messages SpringUtil is used to retrieve the liferay context.
So what's recommend?
Regards
Dennis
I'd like to write a customized UserService for my portlet application. The service needs Liferay's UserService or UserLocalService. To autowire the dependencies I need a bean for it in my applicationContext. I found out that UserService is described in Liferay's portal-spring.xml, so Spring should resolve it with the following config in my web.xml (have not tried it yet):
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/my-web-context.xml,classpath:my-service-context.xml,
classpath:portal-spring.xml</param-value>
</context-param>
<listener>
<description>Spring initialization</description>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
I think this will cause multiple contexts (the liferay context and my context). In other forum messages SpringUtil is used to retrieve the liferay context.
So what's recommend?
Regards
Dennis
Found another easy way: I used spring's factory-bean and factory-method attributes to retrieve a UserLocalService instance from UserLocalServiceFactory.getService().
Community
Company
Feedback