We have created a BaseEntity with the following fields,

   - primary key
   - version
   - date

I have created an ApplicationEntityLocator to get the getID, getVersion, 
find(Entity) instead of writing them on each entity object. 

public class EntityLocator extends Locator<BaseEntity, Long>
{

    @Override
    public BaseEntity create(Class<? extends BaseEntity> clazz)
    {
        try
        {
            return clazz.newInstance();
        }
        catch (InstantiationException e)
        {
            e.printStackTrace();
        }
        catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public BaseEntity find(Class<? extends BaseEntity> clazz, Long id)
    {
        return null;
    }

    @Override
    public Class<BaseEntity> getDomainType()
    {
        return BaseEntity.class;
    }

    @Override
    public Long getId(BaseEntity domainObject)
    {
        return domainObject.getPrimaryKey();
    }

    @Override
    public Class<Long> getIdType()
    {
        return Long.class;
    }

    @Override
    public Object getVersion(BaseEntity domainObject)
    {
        return domainObject.getEntityVersion();
    }
}

I am not sure of how to use the existing Spring service layer to implement 
the find method on the EntityLocator. How do i locate the service 
implementation from inside EntityLocator, can i do the following in the find 
method

HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
ApplicationContext context = 
WebApplicationContextUtils.getWebApplicationContext(request.getSession()
.getServletContext());
context.getBean(clazz).find(id);

is this a good approach?

-- 
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to