I'm building a system with Restlet 2.0 that I want a set of applications to
respond differently based on set of configurations attached to domain names.
One technique is to use VirtualHosts, but I'd like to be able to add new
domains dynamically. (Scala code):
val listOfHosts = List(
HostConfig("foo", "foo.com|foo.net", "foo_db"),
HostConfig("bar", "bar.com|bar.net", "bar_db"),
)
for(host <- listOfHosts) {
val aHost = new VirtualHost(getContext)
aHost.setHostDomain(host.domains)
aHost.attachDefault(new WebsiteApplication(webdir, host.dbname))
aHost.attach("/lib", aLibApplication)
aHost.attach("/api", new ApiApplication(webdir, host.dbname))
aHost.attach("/admin", new AdminApplication(webdir, host.dbname))
getHosts.add(aHost)
}
Another technique is to use one set of application, but have internal logic
for each request. Since the applications are the same except for the
database back-end would this be more appropriate?
class BaseResource extends ServerResource {
var config = _
override def doInit() {
config = db.getConfigurationFor(getReference.getHostDomain)
}
}
I'm looking for anyone how has experience solving a similar problem.
Thanks for any feedback
--
Erick Fleming
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2441472