I want to try to limit the places that actually must know they're running in
a multi-site context.  I would also likek to avoid having separate filters
for each site... So, I've been experimenting tonight with a few ways of
doing it.  I have this working - but could you tell me if there may be
Wicket ramifications of doing this that I don't know?

In apache, I proxy site1/app to http://localhost:8081/app/site1 and site2 to
site2, etc...
I use a custom filter that strips the site1 / site2, and sets it on the
Session and my Application Context Factory (which I use throughout the app
to lookup Spring configured services):
public class SiteDifferentiatingFilter extends WicketFilter {

    @Override
    public String getRelativePath(HttpServletRequest request) {
        String path = super.getRelativePath(request);
        for (Site site : Site.values()) {
            if (path.startsWith(site.getKey())) {
                if (RequestCycle.get() != null && Session.get() != null) {
                    ((SiteDifferentiatingWebSession)
Session.get()).setSite(site);
                    ApplicationContextFactory.getFactory().setSite(site);
                }
                path = path.substring(site.getKey().length());
                if (path.startsWith("/")) {
                    path = path.substring(1);
                }
                return path;
            }
        }
        return path;
    }
}

SiteDifferentiatingWebSession.setSite(Site) does this:
    public void setSite(Site site) {
        mSite = site;
        setStyle(site.getKey());
    }

It seems to be working, but there are a lot of unknowns still - maybe
rewriting the path like this messes up some functionality I don't know
about?

Thanks!!
Jeremy
On Sat, Apr 26, 2008 at 2:27 AM, Igor Vaynberg <[EMAIL PROTECTED]>
wrote:

> you can make your entire application url aware, that shouldnt really
> be a problem. i think you will run into interesting things when trying
> to have two spring contexts share a single servlet context though.
>
> -igor
>
>
> On Fri, Apr 25, 2008 at 9:04 PM, Jeremy Thomerson
> <[EMAIL PROTECTED]> wrote:
> > Has anyone done this and might have suggestions?
> >
> >  What I want to be able to do is have multiple applications all running
> >  within one context.  They will basically be different versions of the
> same
> >  site, with some differences in style, and occasionally HTML.  Other
> things,
> >  like sections of the site, could be turned on or off for that site by
> Spring
> >  configuration since I'm using it to configure the middle-tier.
>  Basically, I
> >  want to be able to have something like texashuntfish.com, and also
> >  newmexicohuntfish.com running in the same space, only differentiated by
> the
> >  URL...
> >
> >  So, it will need to support (per site):
> >  - different CSS files / images
> >  - occasionally different HTML
> >  - different Spring contexts
> >
> >  I figure the best way to do this would be early in the request (before
> any
> >  user code is touched), call Session.setStyle("thesitecode");  I believe
> this
> >  gives me all of the CSS / images / HTML differences for free.
>  Somewhere in
> >  there, I will need to set the current site in something like
> >  ApplicationContext.getSite(), using a ThreadLocal, I guess.
> >
> >  Has anyone done something like this or have suggestions before I just
> start
> >  experimenting?  Other considerations?
> >
> >  Thanks,
> >  Jeremy Thomerson
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to