0 Replies Latest reply on Nov 15, 2005 12:43 PM by fang

    How to declare environment entries using annotations?

    fang

      The EJB3 specification (15.2.3) says:


      Environment entries may be declared by the use of annotations, without need for any deployment
      descriptor entries. Environment entries may also be declared by deployment descriptor entries, without
      need for any annotations. The same environment entry may be declared using both an annotation and a
      deployment descriptor entry. In this case, the information in the deployment descriptor entry may be
      used to override some of the information provided in the annotation. This approach may be used by an
      Application Assembler to override information provided by the Bean Provider.

      I know how to declare an environment entry using deployment descriptor like this:

       <env-entry>
       <env-entry-name>myConfigUrl</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value><![CDATA[resource:myconfig.xml]]></env-entry-value>
       </env-entry>
      


      But I have no idea and couldn't find in our forums how to declare the same entry using EJB3 annotation such that I can use use annotation to access this entry from stateless session bean like the following way:
      private @Resource(name="myConfigURL", type=java.lang.String.class)
       String myConfigURL;
      




      I guess the only way is to use full deployment descriptor instead of any EJB3 annotation, but the problem is that I do need EJB3 annotations.


      Any ideas? Thanks

      FY