#1035 How to use sys::Service?

Akcelisto Mon 22 Mar 2010

Could anyone give me example for sys::Service?

tactics Mon 22 Mar 2010

I don't think we have any example code (maybe someone can throw something together for the examples directory?)

It's not too hard, though. sys::Service is a mixin. I think the only current implementing class in the standard library is sql::SqlService.

To use a service, you instantiate it and install it:

SqlService("localhost", "admin", "securePa$$word").open.install

Then, anywhere else in your application, you may lookup and make use of the service:

// far away in the code, maybe in a different file
SqlService sql := Service.find(SqlService#)
stmt := sql.sql("select foo from bar where baz is not null")
stmt.queryEach |row|
{
  echo(row->foo)
}

brian Mon 22 Mar 2010

All the web examples illustrate use of the WispService to launch a web server.

Login or Signup to reply.