UserService dependency injection from portal-spring.xml

thumbnail
490292, modified 18 Years ago. New Member Posts: 10 Join Date: 2/18/08 Recent Posts
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):


	<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
thumbnail
490292, modified 18 Years ago. New Member Posts: 10 Join Date: 2/18/08 Recent Posts
Found another easy way: I used spring's factory-bean and factory-method attributes to retrieve a UserLocalService instance from UserLocalServiceFactory.getService().