Fórum

Help using Spring with Hooks in Liferay 6.1

Tom Witmer, modificado 11 Anos atrás.

Help using Spring with Hooks in Liferay 6.1

New Member Postagens: 22 Data de Entrada: 27/07/09 Postagens Recentes
I'm building a hook project to override the document library storage, but am running into a problem using Spring in my hook.

I seem to have two options:
  • Let Liferay create my hook object (defined in liferay-hook.xml), or
  • Let the hook project's spring context create my hook object.


How do I create a hook project with Spring that also integrates with Liferay? Most of my attempts so far result in a Spring context with no connection to the Portal, or a Portal object with no connection to my project's spring context.

What I really want is a simple hook object defined in liferay-hook.xml containing references to objects provided by my project's Spring context, but I haven't figured out how to do this. Any help out there?

web.xml excerpt:
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/applicationContext.xml</param-value>
	</context-param>

	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>


applicationContext.xml excerpt:
	<!-- Import UCM services -->
	<import resource="classpath:applicationContext-common-ucm-content-service.xml" />


liferay-hook.xml excerpt:
<hook>
	<portal-properties>portal.properties</portal-properties>
</hook>


portal.properties excerpt:
dl.store.impl=com.testing.liferay.hook.dl.UCMStore
Tom Witmer, modificado 11 Anos atrás.

RE: Help using Spring with Hooks in Liferay 6.1 (Resposta)

New Member Postagens: 22 Data de Entrada: 27/07/09 Postagens Recentes
In hindsight, I'm probably running into precisely this situation: http://www.liferay.com/home/-/blogs/10770905/maximized.

So I think I solved this by letting my Hook class use ClassPathXmlApplicationContext to pull in my custom applicationContext.xml and all its dependencies. This means the hook has to use getBean() to access my Spring beans, but everything works.

Hopefully this will help someone else doing the same thing. If anyone has a better idea, please reply. Thanks!
thumbnail
Jan Geißler, modificado 11 Anos atrás.

RE: Help using Spring with Hooks in Liferay 6.1

Liferay Master Postagens: 735 Data de Entrada: 05/07/11 Postagens Recentes
Here is another approach:

http://www.liferay.com/community/wiki/-/wiki/Main/Adding+Spring+Capabilitites+to+Hook
thumbnail
Sergio Romero Zayas, modificado 10 Anos atrás.

RE: Help using Spring with Hooks in Liferay 6.1

Regular Member Postagens: 151 Data de Entrada: 14/04/08 Postagens Recentes
Jan Geißler:
Here is another approach:

http://www.liferay.com/community/wiki/-/wiki/Main/Adding+Spring+Capabilitites+to+Hook



No run your solution. emoticon