Search code examples
gwtrequestfactory

@Category in AutoBean


Am totally lost trying to understand the @Category annotation of AutoBean. Can somebody please tell me how exactly it can be used?

I went through the example in wiki as well. My doubt is like this.

Say I am having a proxy interface in the client side which extends entity proxy, and I want to insert a non setter/getter method in that interface, how can I do that?

@ProxyFor( value = CacheStrategy.class )
public interface CacheStrategyProxy extends EntityProxy
{
// setters and getters

   CacheStrategyProxy  fetchObject(int id);
}

@Category(CacheStrategyProxyCategory.class)
interface MyFactory extends AutoBeanFactory {
          AutoBean<CacheStrategyProxy> fetchObject();
}

class CacheStrategyProxyCategory {
      public static CacheStrategyProxy fetchObject (AutoBean<CacheStrategyProxy> instance, int id) {
                 // return data
    }
}

Am writing all this in my CacheStrategyProxy file. But I still get the error "Only setters and getters allowed". Pardon me if I have done something silly here. I am totally new to this world.


Solution

  • @Category cannot be used with Request Factory (at least not currently).

    Request Factory makes use of AutoBeans (and your proxies will be AutoBean instances) but the AutoBeanFactory (factories actually) is/are internal to the RequestFactory, and you cannot tweak them.