Hi,
we would like to integrate GWT 2.1 RequestFactory in our application.
Our application's backend uses JPA and has one database per customer.
So we have to tell our EntityManagerFactory which database it should
use, depending on the customer who did the server request.
Currently we have
http://our-app.com/<unique-customername> as
application URL and we send <unique-customername> to our backend on
each request. That way we can construct an EntityManagerFactory with a
custom properties map which contains a datasource name similar to
"appdatasource-<unique-customername>". So every time we got a new
customer, we just have to add a new JDBC resource and connection pool
which points to the new customers database to our J2EE server.
So we tried this approach with RequestFactory and defined our service
interface like this:
@Service(Person.class)
public interface PersonRequest extends RequestContext {
Request<List<PersonProxy>> findAllPersons(String
uniqueCustomerName);
Request<List<PersonProxy>> findPersonsByAge(int min, int max, String
uniqueCustomerName);
InstanceRequest<PersonProxy, Void> persist(String
uniqueCustomerName);
InstanceRequest<PersonProxy, Void> remove(String
uniqueCustomerName);
Request<PersonProxy> findPerson(Long id);
}
So everything is fine except the method "Request<PersonProxy>
findPerson(Long id)" which is required by the GWT RequestFactory
servlet. So we can't add a second parameter to this method. But this
second parameter is required for our dynamic EntityManagerFactory
configuration.
Are there any plans for a GWT 2.1.x release which supports such a
scenario? It would be nice if the required findEntity method would
support additional custom parameters (maybe via Java5 VarArgs) or if
there is a way to transport additional information from client to
server during a RequestFactory request which can then be accessed
during server side method execution.
Does anybody have an idea for a nasty workaround for that problem that
is possible with the current GWT 2.1 implementation?