Re: [Simpleweb-Support] Need help with Simple 3.1.3
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2006-05-25 12:41:18
|
Hi Vincent,
Here is the simplest possible way to do this:
public class Server {
public static void main(String[] list) throws
Exception{
Context context = new FileContext();
LoaderEngine engine = new LoaderEngine(context);
engine.load("attributes",
"my.package.AttributeService");
engine.load("default",
"my.package.FileService");
engine.link("*", "default");
engine.link("/attibute/*", "attributes");
ConnectionFactory.getConnection(engine).connect(new
ServerSocket(8080));
}
}
public class FileService extends Service {
public FileService(Context context){
super(context);
}
public void process(Request req, Response resp)
throws Exception{
String target = req.getURI();
File file = context.getFile(target);
// work with file
}
}
public class AttributeService extends Service {
public AttributeService(Context context) {
super(context);
}
public void process(Request req, Response
resp)throws Exception{
//work with attributes here
}
}
Hope this helps,
Niall
--- Vincent Etter <vin...@gm...> wrote:
> Hello !
>
> I was using Simple 3.0 and I saw this morning that
> there were a few new
> versions. I decided to use the latest, but I have
> some problems. I looked at
> the demo and tried to do my own little server, but
> I'm not sure what is
> useful...
>
> Could someone give me the minimal architecture
> needed to have a server that
> :
> - has a few services mapped on specific urls
> (/attributes =>
> AttributeService, ...)
> - acts like an http server for "unmapped" urls (ie
> /index.html loads the
> file name index.html located in a given directory).
>
> I saw that all mapping stuff and server config can
> be done in xml files, and
> I must say that this is a great thing ! I think I
> understood how Mapper.xmland
> Content.xml work (but I really don't know where I
> have to say in the code
> that I want these files to be used...), but
> Server.xml is a little more
> complicated... Can someone explain me who this file
> works ?
>
> Thanks a lot !
>
> Vincent
>
Niall Gallagher
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|