当我使用liferay 6.1时,我创建了一个收到消息的应用程序。
Java类:
public class MailMessageBus implements MessageListener
\ src \ main \ webapp \ WEB-INF \ src \ META-INF \ messaging-spring.xml文件:
<beans
default-destroy-method="destroy"
default-init-method="afterPropertiesSet"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<bean id="messagingConfigurator" class="com.liferay.portal.kernel.messaging.config.PluginMessagingConfigurator">
<property name="messageListeners">
<map key-type="java.lang.String" value-type="java.util.List">
<entry key="mail-send-message">
<list value-type="com.liferay.portal.kernel.messaging.MessageListener">
<ref bean="messageListener.mail_listener" />
</list>
</entry>
</map>
</property>
<property name="destinations">
<list>
<ref bean="destination.mail"/>
</list>
</property>
</bean>
<!-- Destination class -->
<bean id="destination.mail" class="com.liferay.portal.kernel.messaging.ParallelDestination">
<property name="name" value="mail-send-message" />
</bean>
<!-- Listener class -->
<bean id="messageListener.mail_listener" class="customportlet.AMessageBusListener.MailMessageBus" />
和\ src \ main \ webapp \ WEB-INF \ web.xml文件:
...
<context-param>
<param-name>portalContextConfigLocation</param-name>
<param-value>/WEB-INF/src/META-INF/messaging-spring.xml</param-value>
</context-param>
...
如何在OSGi模块中为liferay 7做同样的事情? OSGi模块没有web.xml文件。 非常感谢你!
答案 0 :(得分:0)
我试图完成同样的事情,并且基于我迄今为止发现的内容,web.xml是不必要的。根据这个资源,OSGi模块似乎自动检测弹簧配置:
https://docs.spring.io/spring-osgi/docs/current/reference/html/app-deploy.html
只需将配置放在位于META-INF / spring
的xml文件中