Hi Erick,

 

It is possible to dynamically update the virtual hosts without restarting
the whole component. There is a Component#updateHosts() method that you can
invoke for this purpose.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~  <http://www.restlet.org/>
http://www.restlet.org
Noelios Technologies ~  <http://www.noelios.com/> http://www.noelios.com

 

 

 

 

De : Erick Fleming [mailto:[email protected]] 
Envoyé : dimanche 24 janvier 2010 03:34
À : [email protected]
Objet : Serving multiple hosts

 

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=2449705

Reply via email to