See http://code.google.com/p/google-web-toolkit/issues/detail?id=6794

On Thursday, June 14, 2012 5:57:46 PM UTC+2, thiago borges martins wrote:
>
> I have a problem of inheritance and generics in the RequestContext and 
> could not solve it. Based on the documentation of this site: 'http:// 
> www.aceevo.com/requestcontext-inheritance-coming-to-client-in-gwt-2-4/' 
> in version 2.4 of GWT is already permitted to use generics in 
> interfaces mapping service. 
> Only after following the documentation and after several tests I could 
> not use inheritance and generics. The compilation is successful, the 
> problem is when I call eg the Save method that receives the type 'T' 
> that is generic, so it is done the method call is released this 
> exception: "In RequestContext for operation 21ta4sO_AJ6TM $ 
> y1q6TcANUXPyQ = ". 
>
> What I did to solve the problem is to create a RequestContext that 
> implements the service of the object that I'm persisting with all 
> methods that are generic, but tipando attributes and returns the proxy 
> that handles the service. 
>
> Would anyone explain to me how do I use a generic interface with the 
> RequestContext? 
>
> Below follows the generic classes and interfaces that you may have a 
> vision of how implemented and accepted suggestions on how to implement 
> too. 
>
> Interface Generics: 
> package br.com.lri.shared.server; 
>
>
> import java.util.List; 
>
> import br.com.lri.business.BusinessBO; 
> import br.com.lri.server.BeanLocator; 
> import br.com.tbm.framework.business.TransactionException; 
>
> import com.google.web.bindery.requestfactory.shared.EntityProxy; 
> import com.google.web.bindery.requestfactory.shared.Request; 
> import com.google.web.bindery.requestfactory.shared.RequestContext; 
> import com.google.web.bindery.requestfactory.shared.Service; 
>
>
> /** 
>  * @author Thiago 
>  * 
>  */ 
> @Service( value = BusinessBO.class, locator = BeanLocator.class ) 
> public interface ServiceRequestContext< T extends EntityProxy > 
> extends RequestContext { 
>
>     /** 
>      * Metódo responsável por buscar o objeto por id. 
>      * 
>      * @param <T> 
>      * 
>      * @param id 
>      *            parametro {@link Long} que é o id do objeto que será 
>      *            pesquisado. 
>      * @return O tipo da classe que é passada para o objeto. 
>      */ 
>     Request< T > buscarPorId( Long id ); 
>
>
>     /** 
>      * Método responsável por buscar o objeto através dos filtros do 
> próprio 
>      * objeto. 
>      * 
>      * @param object 
>      *            parametro {@link Object} que é filtro da consulta. 
>      * @return O tipo da classe que é passada para o objeto. 
>      */ 
>     Request< T > buscarPorObject( T object ); 
>
>
>     /** 
>      * Método responsável por buscar todos os objetos. 
>      * 
>      * @return {@link List}<T> lista de de objetos do tipo da classe. 
>      */ 
>     Request< List< T >> buscarTodos(); 
>
>
>     /** 
>      * Método responsável por buscar todos todos os objetos através do 
> filtros 
>      * do próprio objeto. 
>      * 
>      * @param object 
>      *            parametro {@link Object} que é o filtro da consulta. 
>      * @return {@link List}<T> lista de de objetos do tipo da classe. 
>      */ 
>     Request< List< T >> buscarTodosPorObject( T object ); 
>
>
>     /** 
>      * Método responsável por salvar ou alterar o objeto no banco de 
> dados. 
>      * 
>      * @param domain 
>      *            paramentro {@link Object} que será persistido no 
> banco. 
>      * @return O tipo da classe que é passada para o objeto. 
>      * @throws TransactionException 
>      */ 
>     Request< T > salvar( T domain ); 
>
>
>     /** 
>      * Método responsável por excluir o objeto do banco de dados. 
>      * 
>      * @param domain 
>      *            paramentro {@link Object} que é o dominio a ser 
> excluido. 
>      * @return {@link Boolean} 
>      * @throws TransactionException 
>      */ 
>     Request< Boolean > excluir( T domain ); 
>
> } 
>
> @Service( value = PaisBOImpl.class, locator = BeanLocator.class ) 
> public interface PaisBOImplServiceRequest extends 
> ServiceRequestContext<PaisProxy>{} 
>
> Class and Interfaces side backbean: 
> package br.com.lri.business; 
>
>
> import java.util.List; 
>
> import javax.ejb.EJB; 
>
> import br.com.lri.persistence.impl.BusinessDAOImpl; 
> import br.com.tbm.framework.business.TransactionException; 
> import br.com.tbm.framework.business.ValidationException; 
>
>
> /** 
>  * @author Thiago 
>  * 
>  */ 
> public interface Business< T > { 
>
>     /** 
>      * Metódo responsável por buscar o objeto por id. 
>      * 
>      * @param id 
>      *            parametro {@link Long} que é o id do objeto que será 
>      *            pesquisado. 
>      * @return O tipo da classe que é passada para o objeto. 
>      */ 
>     T buscarPorId( Long id ); 
>
>
>     /** 
>      * Método responsável por buscar o objeto através dos filtros do 
> próprio 
>      * objeto. 
>      * 
>      * @param object 
>      *            parametro {@link Object} que é filtro da consulta. 
>      * @return O tipo da classe que é passada para o objeto. 
>      */ 
>     T buscarPorObject( T object ); 
>
>
>     /** 
>      * Método responsável por buscar todos os objetos. 
>      * 
>      * @return {@link List}<T> lista de de objetos do tipo da classe. 
>      */ 
>     List< T > buscarTodos(); 
>
>
>     /** 
>      * Método responsável por buscar todos todos os objetos através do 
> filtros 
>      * do próprio objeto. 
>      * 
>      * @param object 
>      *            parametro {@link Object} que é o filtro da consulta. 
>      * @return {@link List}<T> lista de de objetos do tipo da classe. 
>      */ 
>     List< T > buscarTodosPorObject( T object ); 
>
>
>     /** 
>      * Método responsável por realizar as validações antes de salvar o 
> objeto no 
>      * banco. 
>      * 
>      * @throws ValidationException 
>      */ 
>     void antesSalvar() throws ValidationException; 
>
>
>     /** 
>      * Método responsável por realizar ações após salvar o objeto no 
> banco. 
>      * 
>      * @throws ValidationException 
>      */ 
>     void depoisSalvar() throws ValidationException; 
>
>
>     /** 
>      * @throws ValidationException 
>      */ 
>     void antesExcluir() throws ValidationException; 
>
>
>     /** 
>      * Método responsável por verificar se o objeito foi excluido do 
> banco e 
>      * realizar outras ações após a exclusão. 
>      * 
>      * @param domain 
>      *            paramentro {@link Object} que é o dominio da 
> exclusão. 
>      * @return {@link Boolean} verdadeiro quando o objeto for 
> excluido. 
>      * @throws ValidationException 
>      */ 
>     Boolean depoisExcluir( T domain ) throws ValidationException; 
>
>
>     /** 
>      * Método responsável por salvar ou alterar o objeto no banco de 
> dados. 
>      * 
>      * @param domain 
>      *            paramentro {@link Object} que será persistido no 
> banco. 
>      * @return O tipo da classe que é passada para o objeto. 
>      * @throws TransactionException 
>      */ 
>     T salvar( T domain ) throws TransactionException; 
>
>
>     /** 
>      * Método responsável por excluir o objeto do banco de dados. 
>      * 
>      * @param domain 
>      *            paramentro {@link Object} que é o dominio a ser 
> excluido. 
>      * @return {@link Boolean} 
>      * @throws TransactionException 
>      */ 
>     Boolean excluir( T domain ) throws TransactionException; 
>
>
>     /** 
>      * Método responsável por retornar o {@link EJB} de acesso ao 
> banco. 
>      * 
>      * @return {@link BusinessDAOImpl} 
>      */ 
>     BusinessDAOImpl getBusinessDAOImpl(); 
> } 
>
> package br.com.lri.business; 
>
>
> import java.io.Serializable; 
> import java.util.List; 
>
> import javax.ejb.Stateless; 
>
> import br.com.lri.persistence.impl.BusinessDAOImpl; 
> import br.com.tbm.framework.business.TransactionException; 
> import br.com.tbm.framework.business.ValidationException; 
>
>
> /** 
>  * @author Thiago 
>  * 
>  */ 
> @Stateless 
> public class BusinessBO< T > implements Business< T >, Serializable { 
>
>     private static final long serialVersionUID = 
> -1782467852719269251L; 
>
>
>     /** 
>      * @see br.com.lri.business.Business#buscarPorId(java.lang.Long) 
>      */ 
>     @Override 
>     public T buscarPorId( Long id ) { 
>
>         return null; 
>     } 
>
>
>     /** 
>      * @see 
> br.com.lri.business.Business#buscarPorObject(java.lang.Object) 
>      */ 
>     @Override 
>     public T buscarPorObject( T object ) { 
>
>         return null; 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#buscarTodos() 
>      */ 
>     @Override 
>     public List< T > buscarTodos() { 
>
>         return null; 
>     } 
>
>
>     /** 
>      * @see 
> br.com.lri.business.Business#buscarTodosPorObject(java.lang.Object) 
>      */ 
>     @Override 
>     public List< T > buscarTodosPorObject( T object ) { 
>
>         return null; 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#antesSalvar() 
>      */ 
>     @Override 
>     public void antesSalvar() throws ValidationException { 
>
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#depoisSalvar() 
>      */ 
>     @Override 
>     public void depoisSalvar() throws ValidationException { 
>
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#antesExcluir() 
>      */ 
>     @Override 
>     public void antesExcluir() throws ValidationException { 
>
>     } 
>
>
>     /** 
>      * @see 
> br.com.lri.business.Business#depoisExcluir(java.lang.Object) 
>      */ 
>     @Override 
>     public Boolean depoisExcluir( T domain ) throws 
> ValidationException { 
>
>         return null; 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#salvar(java.lang.Object) 
>      */ 
>     @Override 
>     @SuppressWarnings( "unchecked" ) 
>     public T salvar( T domain ) throws TransactionException { 
>
>         try { 
>             antesSalvar(); 
>             T returns = (T) 
> getBusinessDAOImpl().saveOrUpdate( domain ); 
>             depoisSalvar(); 
>             return returns; 
>         } 
>         catch ( Exception e ) { 
>             throw new TransactionException( e ); 
>         } 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#excluir(java.lang.Object) 
>      */ 
>     @Override 
>     @SuppressWarnings( "unchecked" ) 
>     public Boolean excluir( T domain ) throws TransactionException { 
>
>         try { 
>             antesExcluir(); 
>             getBusinessDAOImpl().delete( domain ); 
>             return depoisExcluir( domain ); 
>         } 
>         catch ( Exception e ) { 
>             throw new TransactionException( e ); 
>         } 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.Business#getBusinessDAOImpl() 
>      */ 
>     @Override 
>     public BusinessDAOImpl getBusinessDAOImpl() { 
>
>         return null; 
>     } 
> } 
>
> package br.com.lri.business.impl; 
>
>
> import java.util.List; 
>
> import javax.ejb.EJB; 
> import javax.ejb.Stateless; 
>
> import br.com.lri.business.BusinessBO; 
> import br.com.lri.domain.enderecos.Pais; 
> import br.com.lri.persistence.impl.BusinessDAOImpl; 
> import br.com.tbm.framework.business.TransactionException; 
> import br.com.tbm.framework.business.ValidationException; 
> import br.com.tbm.framework.persistence.PersistenceException; 
> import br.com.tbm.framework.persistence.Sort; 
>
>
> /** 
>  * @author Thiago 
>  * 
>  */ 
> @Stateless 
> public class PaisBOImpl extends BusinessBO< Pais > { 
>
>     private static final long serialVersionUID = 2165217381632483592L; 
>
>     @EJB 
>     private BusinessDAOImpl businessDAOImpl; 
>
>
>     /** 
>      * @see br.com.lri.business.BusinessBO#buscarPorId(java.lang.Long) 
>      */ 
>     @Override 
>     @SuppressWarnings( "unchecked" ) 
>     public Pais buscarPorId( Long id ) { 
>
>         try { 
>             return (Pais) businessDAOImpl.findById( Pais.class, id, 
> new String[] { "" } ); 
>         } 
>         catch ( PersistenceException e ) { 
>             e.printStackTrace(); 
>             return null; 
>         } 
>     } 
>
>
>     /** 
>      * @see 
> br.com.lri.business.BusinessBO#buscarPorObject(java.lang.Object) 
>      */ 
>     @Override 
>     @SuppressWarnings( "unchecked" ) 
>     public Pais buscarPorObject( Pais object ) { 
>
>         try { 
>             return (Pais) businessDAOImpl.findByExample( 
>                 object, 
>                 null, 
>                 Sort.ASC( new String[] { "nmPais" } ), 
>                 new String[] { "" } ).get( 0 ); 
>         } 
>         catch ( PersistenceException e ) { 
>             e.printStackTrace(); 
>             return null; 
>         } 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.BusinessBO#buscarTodos() 
>      */ 
>     @Override 
>     @SuppressWarnings( "unchecked" ) 
>     public List< Pais > buscarTodos() { 
>
>         try { 
>             return businessDAOImpl.findAll( Pais.class ); 
>         } 
>         catch ( PersistenceException e ) { 
>             e.printStackTrace(); 
>             return null; 
>         } 
>     } 
>
>
>     /** 
>      * @see 
> br.com.lri.business.BusinessBO#buscarPorObject(java.lang.Object) 
>      */ 
>     @Override 
>     @SuppressWarnings( "unchecked" ) 
>     public List< Pais > buscarTodosPorObject( Pais object ) { 
>
>         try { 
>             return businessDAOImpl.findByExample( 
>                 object, 
>                 null, 
>                 Sort.ASC( new String[] { "nmPais" } ), 
>                 new String[] { "" } ); 
>         } 
>         catch ( PersistenceException e ) { 
>             e.printStackTrace(); 
>             return null; 
>         } 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.BusinessBO#antesSalvar() 
>      */ 
>     @Override 
>     public void antesSalvar() throws ValidationException { 
>
>     } 
>
>
>     /** 
>      * @param domain 
>      * @return 
>      * @throws TransactionException 
>      */ 
>     @Override 
>     public Pais salvar( Pais domain ) throws TransactionException { 
>
>         return super.salvar( domain ); 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.BusinessBO#depoisSalvar() 
>      */ 
>     @Override 
>     public void depoisSalvar() throws ValidationException { 
>
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.BusinessBO#antesExcluir() 
>      */ 
>     @Override 
>     public void antesExcluir() throws ValidationException { 
>
>     } 
>
>
>     /** 
>      * @see 
> br.com.lri.business.BusinessBO#depoisExcluir(java.lang.Object) 
>      */ 
>     @Override 
>     public Boolean depoisExcluir( Pais domain ) throws 
> ValidationException { 
>
>         return null; 
>     } 
>
>
>     /** 
>      * @see br.com.lri.business.BusinessBO#getBusinessDAOImpl() 
>      */ 
>     @Override 
>     public BusinessDAOImpl getBusinessDAOImpl() { 
>
>         return this.businessDAOImpl; 
>     } 
>
> } 
>
> I thank everyone's help.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/4NBX9jsTQlUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to