How to access deployment parameter from within EJB

前端 未结 1 753
野的像风
野的像风 2020-12-12 01:45

In a Java EE 6 Web application, I would like to access a deployment parameter (a string value) from within an EJB.

I know that I can define a Context Pa

1条回答
  •  不思量自难忘°
    2020-12-12 02:30

    After further research, I have found out the use of env-entry annotation in web.xml.:

    
        myEnvEntry
        java.lang.String
        MyEnvEntryValue
            
    

    The env-entry can be accessed in various ways from an EJB. The simplest is the use of @Resource annotation (requires CDI):

    @Resource(name="myEnvEntry")
    private String myEnvEntry;
    

    Links: Configure your EJB 3 with envirnoment entries using ENC

    0 讨论(0)
提交回复
热议问题