JavaEE @Specializes继承中的注释用法

时间:2016-10-13 05:14:41

标签: cdi

我的项目中有以下情况。

@Named("a")

class A{ }

@Specializes

class B extends A{ }

@Specializes

class C extends B{ }

class Test{

    @Inject
    A a1;
}

在测试类中,我想将c类实例注入引用变量a1。我试过,它总是注射B.

怎么做?

Some more information:

I also want to mentioned that each of  these 3 classes are in defferent projects. I'm tring to access the method from xhtml file not from Test class I'm using EL .

project1---> A

@Named("links")

@ApplicationScoped

 class A{


 public String getMethod1(){
 }

 }

project2(dependency to project1)----> B

@Specializes

class B extends A{

@Override
public String getMethod1(){
 }

}

project3(dependency to project1,project2)---->C

@Specializes

class C extends B{

@Override
public String getMethod1(){
 }

}

project4(dependency to project1,project2,project3)---> 

MyPage.xhtm



    <ui:include src="#{links.method1()}">

        </ui:include>

当我尝试使用EL'链接'来访问时,总是指向B类。

请在这里建议我。

0 个答案:

没有答案