class Bar<T> { private final Foo<T> foo; private List<T> list; Bar(Baz baz) { // Since baz cannot be changed, you will have to // unsafe cast Foo<?> to Foo<T> here. foo = (Foo<T>) baz.getFoo(); } void putBar() { list.add(foo.bar()); } void callFoo() { foo.foo(list.get(0)); } }
@Test(groups = INTEGRATION) @SpecAssertion(section = INJECTION_POINT, id = "aaa") public void testNonContextualEjbInjectionPointGetBean() throws Exception { Bar bar = (Bar) new InitialContext().lookup("java:module/Bar"); Bean<?> bean = bar.getFoo().getInjectionPoint().getBean(); assertNull(bean); }
@Test(groups = INTEGRATION) @SpecAssertion(section = INJECTION_POINT, id = "aa") public void testContextualEjbInjectionPointGetBean() throws Exception { Bean<?> bean = baz.get().getFoo().getInjectionPoint().getBean(); assertNotNull(bean); assertEquals(bean.getBeanClass(), Baz.class); }
class Bar { private final Foo<Object> foo; private List<Object> list; Bar(Baz baz) { // Since baz cannot be changed, you will have to // unsafe cast Foo<?> to Foo<Object> here. foo = (Foo<Object>) baz.getFoo(); } void putBar() { list.add(foo.bar()); } void callFoo() { foo.foo(list.get(0)); } }