Srs, tenho uma classe anotada num projeto jsf como @Bean.
Como é possivel injeta-la no managed bean.
veja bem fiz o seguinte teste
Criei essa interface
package br.com.c5a.interfaces;
[code]public interface IHello {
public String getHello();
}[/code]
Depois essa implementação
[code]package br.com.c5a.implementacao;
import net.sourceforge.sannotations.annotation.Bean;
import br.com.c5a.interfaces.IHello;
@Bean(name="helloImpl")
public class HelloImpl implements IHello {
public String getHello() {
return "Hello World";
}
}[/code]
AI no managed bean eu anotei com @Bean e criei um set para ~fazer a injeção por set
[code]package br.com.c5a.mb;
import java.util.ArrayList;
import java.util.Collection;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import br.com.c5a.interfaces.IHello;
import net.sourceforge.sannotations.annotation.Bean;
@Bean(name="indexMB")
public class IndexMB {
private String usuario;
private String senha;
private IHello helloImpl;
public void setHelloImpl(IHello helloImpl) {
this.helloImpl = helloImpl;
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = helloImpl.getHello();
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}[/code]
Entretanto não ocorre a injeção pois o valor helloImpl é nulo.
Neste caso usando o @Bean não deveria ocorrer um autowire por nome ?
Este é o web.xml da aplicação
[code]<?xml version=“1.0” encoding=“ISO-8859-1”?>
<web-app xmlns=“http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”
version=“2.4”>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
</web-app>[/code]
Estou usando os .jars
spring-annotation-base-1.1.1.GA.jar e spring-2.0.5.jar.
O caminho que estou seguindo está errado ? não é assim que faz esse tipo de injeção ?