Bom dia a todos,
Estou usando vRaptor já algum tempo, não tive problema com ele.
Agora estou implementando o Spring conforme a Apostila fj28, mas na classe Criador de Session dá o seguinte erro:
código
@PostConstruct
public void abre() {
this.session = proxifier.proxify(Session.class, new MethodInvocation<Session>() {
public Object intercept(Session proxy, Method method, Object[] args, SuperMethod superMethod) {
Session sessionDoSpring = SessionFactoryUtils.doGetSession(factory, true);
return new Mirror().on(sessionDoSpring).invoke().method(method).withArgs(args);
}
});
}
na 3ª linha: The type new MethodInvocation(){} must implement the inherited abstract method MethodInvocation.intercept(Session, Method, Object[], SuperMethod)
na 4ª linha: Method cannot be resolved to a type
segue a classe completa:
package br.com.siagh.infra;
import net.vidageek.mirror.dsl.Mirror;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.ComponentFactory;
import br.com.caelum.vraptor.proxy.MethodInvocation;
import br.com.caelum.vraptor.proxy.Proxifier;
import br.com.caelum.vraptor.proxy.SuperMethod;
@Component
public class CriadorDeSession implements ComponentFactory<Session> {
private final SessionFactory factory;
private final Proxifier proxifier;
private Session session;
public CriadorDeSession(SessionFactory factory, Proxifier proxifier) {
this.factory = factory;
this.proxifier = proxifier;
}
@PostConstruct
public void abre() {
//this.session = factory.openSession();
this.session = proxifier.proxify(Session.class, new MethodInvocation<Session>() {
public Object intercept(Session proxy, Method method, Object[] args, SuperMethod superMethod) {
Session sessionDoSpring = SessionFactoryUtils.doGetSession(factory, true);
return new Mirror().on(sessionDoSpring).invoke().method(method).withArgs(args);
}
});
}
public Session getInstance() {
//return factory.openSession();
return this.session;
}
@PreDestroy
public void fecha() {
this.session.close();
}
}
Desde já agradeço…