Currently, @ProxyFor must reference the Entity itself, which, in
2.1.0, required you to put static methods on the entity to do
persistence operations. However, you can use the new Locator and
ServiceLocator in 2.1.1 to move persistence methods out of the entity
into an entity service (perhaps a DAO). I just put up some example
code at http://code.google.com/p/listwidget. It's definitely a work in
progress (== not pretty yet), but the RF stuff there works.
/dmc
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
David Chandler
Developer Programs Engineer, Google Web Toolkit
w: http://code.google.com/
b: http://googlewebtoolkit.blogspot.com/
t: @googledevtools
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Frustratingly, as I know I'm so close, all my entities (both the
implementation and the interface) only contain getter and setter
(simple POJO for use in Hibernate). All my data access methods
currently reside in the entity service, as recommended. Now in the
entity service, I could do a horrible cast from the interface back to
its implementation and send that back to the client. However I have a
custom ServiceLayerDecorator, to use Spring to create my Locators (for
the find method), and hence I can override the following...
@Override
public <T> Class<? extends T> resolveClientType(Class<?>
domainClass, Class<T> clientType, boolean required) {
ProxyFor a = clientType.getAnnotation(ProxyFor.class);
if (a != null && a.value().isAssignableFrom(domainClass)) {
return super.resolveClientType(a.value(), clientType,
required);
This comes in the custom Service Locator that i hooked in via custom
Request Factory Servlet class:
Also see it formatted here: http://pastie.org/1685351
private final static Map<Class<?>, Class<? extends BaseProxy>>
s_proxyTypeCache = new HashMap<Class<?>, Class<? extends
BaseProxy>>();
@SuppressWarnings("unchecked")
@Override
public <T> Class<? extends T> resolveClientType(Class<?> domainClass,
Class<T> clientType, boolean required) {
/*-
* Inspired by
* http://groups.google.com/group/google-web-toolkit/browse_thread/thread/dddd36d0ed4f87be/45af985914ac1780?lnk=gst&q=maitland
* as we mostly use interface type of domain in ProxyFor annotation.
* Assumption:
* Type <T> should be one that is/extends BaseProxy
*/
Class<? extends T> c = null;
ProxyFor p = clientType.getAnnotation(ProxyFor.class);
if (p != null && p.value().isAssignableFrom(domainClass)) {
// job made simple as clientType passed was the real client proxy
// that we defined
c = super.resolveClientType(p.value(), clientType, required);
} else {
// ProxyFor won't be present obviously if clientType param was
// BaseProxy itself
c = super.resolveClientType(domainClass, clientType, required);
if (c != null) {
// we might need/use it later
s_proxyTypeCache.put(domainClass,
(Class<? extends BaseProxy>) c);
} else {
// client type couldn't be retrieved if we had given interface
// type of domain obj in ProxyFor anno and if Locator had
// resolved it to the actual impl type of domain obj and passed
// it as domainClass; See if we already had gotten and stored
// the client type for the same domain's corresponding interface
// type
Set<Class<?>> domainTypes = s_proxyTypeCache.keySet();
for (Iterator<Class<?>> iterator = domainTypes.iterator();
iterator
.hasNext();) {
Class<?> domType = iterator.next();
if (domType.isAssignableFrom(domainClass)) {
// good, we have an entry for domain obj's
// interface/class type
c = (Class<? extends T>) s_proxyTypeCache.get(domType);
break;
}
}
}
}
if (null == c) {
throw new YourApplicationRuntimeException(
"Unable to resolve the client side custom defined proxy class
given the i/p {domain class : "
+ domainClass
+ ", "
+ "client type : "
+ clientType + "}");
}
return c;
}