tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aede van der Weij (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENEJB-1103) Inject fields in subclasses that extend class with LocalClient annotation.
Date Mon, 09 Nov 2009 15:19:33 GMT
Inject fields in subclasses that extend class with LocalClient annotation.
--------------------------------------------------------------------------

                 Key: OPENEJB-1103
                 URL: https://issues.apache.org/jira/browse/OPENEJB-1103
             Project: OpenEJB
          Issue Type: Improvement
    Affects Versions: 3.1.2
         Environment: openejb-core 3.1.2
Maven version: 2.0.9
Java version: 1.5.0_12
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
testng 5.8
            Reporter: Aede van der Weij
            Priority: Minor


I am not sure whether this is an improvement or a bug. The method org.apache.openejb.client.inject(Object)
will detect whether a class or super class has the annotation LocalClient. In case only the
super class is annotated the fields of the subclass are not injected.

public abstract class MyBaseClass {
  Context context;

  @BeforeClass
  public void initContainer() {
    //do stuff
    Properties props = new Properties();
    	props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    	context = new InitialContext(props);
  }
}

public class MyTest extends MyBaseClass {
  @EJB
  MyEjbLocal myEjbBean;

  @Test
  public void testMyEjb() {
    Assert.assertNotNull(myEjbBean, "Expected a MyEjbLocal"); 
  }
}

The above test will fail. I am using testng but this will also work with junit 4. My first
though was that this mechanism should be working, but either my assumptions are wrong or the
code could be improved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message