Multi-tenancy in GWT

153 views
Skip to first unread message

Kyle Baley

unread,
Mar 22, 2010, 10:41:08 AM3/22/10
to Google Web Toolkit
I'm new to GWT and the Java world having been in the .NET space for
about 10 years. Our application will be a multi-tenant one (at least,
to the degree that I understand the definition). We'd like customers
to be able to navigate to www.mysite.com/customerName, then log in
from there. I think I have a handle on how to manage this from the GAE
datastore side but am wondering how to manage this URL mapping in
web.xml for GWT.

Also, would like to get some opinions on how to manage the
authentication once it's set up. Here's how I see it working:
- User navigates to www.mysite.com/customerName
- System retrieves company data and stores in session and displays
login page
- User logs in. System authenticates user
- For all RPC calls, system verifies user is logged in *and* checks
that the URL matches the company info in the session

Basically, I want to guard against a user logging into one client
site, then navigating to another.

Thanks
Kyle

dolc...@gmail.com

unread,
Mar 23, 2010, 1:01:53 PM3/23/10
to Google Web Toolkit
So you can just built the ui once and always include it in the login
page for which ever client as the server should be where you filter/
prevent access to data that's not for the current client.

On Mar 22, 10:41 am, Kyle Baley <kyle.ba...@gmail.com> wrote:
> I'm new to GWT and the Java world having been in the .NET space for
> about 10 years. Our application will be a multi-tenant one (at least,
> to the degree that I understand the definition). We'd like customers

> to be able to navigate towww.mysite.com/customerName, then log in

Kyle Baley

unread,
Mar 23, 2010, 9:24:41 PM3/23/10
to Google Web Toolkit
Not sure I understand. I plan to filter data on the server side of
things. But I don't know how to configure GWT to allow me to navigate
to specific client for the entire app.

For example, Acme Hair Salon would navigate to mysite.com/
acmeHairSalon/myapp.html and Generic Dog Collars would navigate to
mysite.com/genericDogCollars/myapp.html. Both URLs should map to the
same instance of the application but in it, I'd check the URL to see
which company was being used and filter all the data in it
accordingly. I know how to do the filtering and can probably figure
out how to check the URL for a company token. But I don't know how to
configure GWT and/or GAE to use a single instance of the application
for multiple (generic) URLs that aren't pre-defined. It sounds to me
like something that should be done in web.xml but again, I don't know
how.

Chad

unread,
Mar 23, 2010, 10:01:13 PM3/23/10
to Google Web Toolkit
Kyle,

While you *may* be able to do that, the general GWT way would be to
have your urls look more like this:

mysite.com/myapp.html#/acmeHairSalon
mysite.com/myapp.html#/genericDogCollars

And you can easily access the tokens via the History class (the
getToken method).

HTH,
Chad

Uros Trebec

unread,
Mar 24, 2010, 10:54:47 AM3/24/10
to Google Web Toolkit
I think the best way to do this is to deploy new instance of client
application for every customer and have one instance of "server"
application that all client applications work with to get their data,
non-client-side business logic, etc.

We're doing it this way when we have different versions of client
application, which tends to change more often than server one. Also
works when you have a development version of client that you need to
test with the same server backend.

Regards,
Uros

Kyle Baley

unread,
Mar 25, 2010, 10:15:03 AM3/25/10
to Google Web Toolkit
Is that possible with GAE?

In any case, I found something that works. I created a JSP page and
dumped the contents of the MyApp.html into it. Then added the
following to my web.xml:

<servlet>
<servlet-name>test</servlet-name>
<jsp-file>/MyApp.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/myApp/clients/*</url-pattern>
</servlet-mapping>

I added /clients in there for now because we're using gwt-dispatch and
I haven't overridden its default of submitting things to /myApp/
dispatch.

Still some kinks to work out (like resource references) but early
results are encouraging.

Muz

unread,
Apr 13, 2010, 11:53:28 AM4/13/10
to Google Web Toolkit
Kyle, I built a similar architecture, but with only one instance of
the app serving all users. When a user authenticates, I look them up
in a global store to figure out which tenant they belong to, and then
use their tenant-specific database for all data persistence for the
session. So all visitors use one instance of the app but each tenant
has their own isolated database...multi-tenancy.

The problem is, true multi-tenancy isn't supported by GAE...they've
been talking about it for almost 2 years now, but it doesn't seem to
be a priority for them. They want you to use a different domain for
every tenant, which means multiple app instances (multiple versions of
your app to deploy & maintain). It also means your customer/tenant has
to be in the loop for all domain administration tasks, which to me
kind of defeats the purpose of customer-focused cloud computing.

I set my multi-tenant app up on Amazon EC2, using 1 tomcat server and
6 mysql databases (6 tenants...each tenant has on average 10 users).
The beauty is if I need to scale or load balance the app, add more
tenants/database instances or just backup one tenant's data, this is
pretty much just a mouse-click or 6 in the EC2 developer console.

Murray

Sripathi Krishnan

unread,
Apr 13, 2010, 1:24:56 PM4/13/10
to google-we...@googlegroups.com
In any case, I found something that works. I created a JSP page and
dumped the contents of the MyApp.html into it. Then added the
following to my web.xml:

       <servlet>
               <servlet-name>test</servlet-name>
               <jsp-file>/MyApp.jsp</jsp-file>
       </servlet>
       <servlet-mapping>
               <servlet-name>test</servlet-name>
               <url-pattern>/myApp/clients/*</url-pattern>
       </servlet-mapping>

I added /clients in there for now because we're using gwt-dispatch and
I haven't overridden its default of submitting things to /myApp/
dispatch.

That is the best way to move forward. Since its unlikely that one client will access the website for another, you don't want the /#customer-name kind of urls. Also, in future, if you want to support a separate domain for each client, it would be easily doable.


-Sri
http://blog.530geeks.com


--
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.


Reply all
Reply to author
Forward
0 new messages