0

当我使用 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 文件。非常感谢!

4

1 回答 1

0

我正在尝试完成同样的事情,并且根据我目前发现的 web.xml 是不必要的。根据此资源,OSGi 模块似乎自动检测弹簧配置:

https://docs.spring.io/spring-osgi/docs/current/reference/html/app-deploy.html

只需将您的配置放在位于 META-INF/spring 的 xml 文件中

于 2018-02-26T18:10:10.753 回答