3 Replies Latest reply on Jan 5, 2007 1:58 PM by Sergiu Bivol

    Question about injecting env-entry into interceptor

    Mark Bramnik Newbie

      Hi
      I'm a newbie in the JBOSS world and I've got a problem with env-entry declaration.
      I have an ejb-jar.xml with declared interceptor for EJB3 SLSB.
      I'm trying to inject the environment entry into the interceptor, and it doen't work.
      It seems like jboss merely ignores this declaration- interception mechanism works fine but injection doesn't.
      When I'm trying to inject the same env-entry declaration into SLSB bean everything works just fine.
      As far as I understand xsd allows me to do such an injection into interceptor.

      I'm using JBOSS 4.0.4 GA + EJB3-RC8 on Windows 2000 OS.

      Any help is highly appreciated



      Thanks in advance.

      Mark Bramnik

      The relevant code looks like this:

      ejb-jar.xml

      <?xml version="1.0"?>
       <ejb-jar xmlns="http://http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
       http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
       version="3.0">
       <enterprise-beans>
       <session>
       <ejb-name>SampleDataServiceEJB</ejb-name>
       <ejb-class>xxx.LocalDataServiceEJB</ejb-class>
       <env-entry>
       <env-entry-name>maxExceptions</env-entry-name>
       <env-entry-type>java.lang.Integer</env-entry-type>
       <env-entry-value>15</env-entry-value>
       <injection-target>
       <injection-target-class>xxx.SampleDataServiceEJB</injection-target-class>
       <injection-target-name>maxExceptions</injection-target-name>
       </injection-target>
       </env-entry>
       </session>
       </enterprise-beans>
      
       <interceptors>
       <interceptor>
       <interceptor-class>xxx.SampleLoggingContextInterceptor</interceptor-class>
       <around-invoke>
       <method-name>interceptLog</method-name>
       </around-invoke>
       <env-entry>
       <env-entry-name>minExceptions</env-entry-name>
       <env-entry-type>java.lang.Integer</env-entry-type>
       <env-entry-value>10</env-entry-value>
       <injection-target>
       <injection-target-class>xxx.SampleLoggingContextInterceptor</injection-target-class>
       <injection-target-name>minExceptions</injection-target-name>
       </injection-target>
       </env-entry>
       </interceptor>
       </interceptors>
      
      
       <assembly-descriptor>
       <interceptor-binding>
       <ejb-name>*</ejb-name>
       <interceptor-class>xxx.SampleLoggingContextInterceptor</interceptor-class>
       </interceptor-binding>
       </assembly-descriptor>
       </ejb-jar>
      

      SLSB:
      package xxx;
      
      import javax.ejb.Stateless;
      import javax.ejb.Local;
      import javax.annotation.Resource;
      
      @Stateless
      @Local(SampleDataService.class)
      public class SampleDataServiceEJB implements SampleDataService {
       @Resource(name="maxExceptions")
       private int maxExceptions;
      
       public int getMaxExceptions() {
       return maxExceptions;
       }
      
       public void setMaxExceptions(int maxExceptions) {
       this.maxExceptions = maxExceptions;
       }
      
       public void sampleExecutionMethod() {
       //......
       }
      
      }
      


      The Interceptor


      package xxx;
      
      import javax.annotation.Resource;
      import javax.interceptor.InvocationContext;
      
      public class SampleLoggingContextInterceptor {
       @Resource(name="minExceptions")
       private int minExceptions = 1;
      
       public int getMinExceptions() {
       return minExceptions;
       }
      
       public void setMinExceptions(int minExceptions) {
       this.minExceptions = minExceptions;
       }
      
       public Object interceptLog(InvocationContext inv) throws Exception {
       //......
       }
      }


      P.S. I copied the code above manually (not copy-pasted) so it may contain some insignificant syntax mistakes...