java 通过xml配置其他MDB Bean中无接口视图Bean的注入

x33g5p2x  于 2023-02-28  发布在  Java
关注(0)|答案(1)|浏览(155)

我有一个MDB,它需要其他无接口视图Bean(无状态会话Bean),不幸的是,我必须通过XML(ejb-jar.xml)进行注入。有人有提示在Java EE 8(EJB 3.2)中实现这一点吗?

@Interceptors(LoggingInterceptor.class)
@MessageDriven(activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/P76MQ$4bd3dc121fdd4ae5a0730e990a4d14c0"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "MandantenId = '4bd3dc121fdd4ae5a0730e990a4d14c0'"),
        @ActivationConfigProperty(propertyName = "maxMessagesPerSessions<", propertyValue = "100"),
        @ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "1000") })
public class Protokollierung implements MessageListener {

    @EJB
    private PersonenIndexRepository personenIndexRepository;

    @EJB
    private BearbeitungsFehlerRepository bearbeitungsFehlerRepository;

    @EJB
    private PersonenIndexStandardisierung personenIndexStandardisierung;

    @EJB
    private ErmittlungFachdatenAenderungen ermittlungFachdatenAenderungen;
    @EJB
    private TransaktionsProtokollRepository transaktionsProtokollRepository;

    @Resource
    private String mandantenId;

    public Protokollierung() {

    }

    @PreDestroy
    public void runterfahren() {
        this.schema = null;
        this.mapper = null;
        MDC.clear();
    }

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void onMessage(Message message) {

    }

}
<message-driven>
How to reference this ejbs ? 
i found something about ejb-local-ref .. how does it work ??
        </message-driven>

问候安德烈

ykejflvf

ykejflvf1#

我找到解决办法了

<ejb-local-ref>
            <ejb-ref-name><classname>/<probertyname>
            </ejb-ref-name>
            <local><classname></local>
            <ejb-link><ejb-refname of linked ejb></ejb-link>
        </ejb-local-ref>

我的错误是我没有声明一个局部标记。。我想。。嘿,我有一个没有接口的bean,为什么我必须另一次声明类型。

相关问题