Re: [Simpleweb-Support] How to combine a LoaderEngine with a FileEngine ?
Brought to you by:
niallg
From: Hugo W. <ug...@li...> - 2007-06-06 21:29:26
|
Here is what I did... I extend simple.http.load.Service and put a FileEngine in it. Then map = all that is not a service to this class. 1st) make a mapping like: <?xml version=3D"1.0"?> <!DOCTYPE mapper SYSTEM "http://www.simpleframework.org/dtd/mapper.dtd"> <mapper> <lookup> <service name=3D"files" type=3D"mypackage.FileService"/> <service name=3D"service1" type=3D"mypackage.MyService"/>=20=20=20= =20=20=20=20=20=20=20=20=20=20=20 </lookup> =20=20=20=20 <resolve> <match name=3D"files" path=3D"/*"/> <match name=3D"service1" path=3D"/service1"/> </resolve> =20=20=20=20 </mapper> 2nd) extend Service and make it work with files: public class FileService extends Service { private FileEngine engine; =20=20=20=20=20=20=20=20 public FileService(Context context){ super(context);=20=20=20=20=20=20=20=20=20=20=20 engine =3D new FileEngine(context);=20=20 }=20=20=20=20=20=20=20=20 =09 public void process(Request req, Response resp) throws Exception{ engine.resolve(req.getURI()).handle(req, resp); }=20=20=20=20=20=20=20=20 } By the way, it also work with instances of Redirect... public Resource redirect(Request req, Response resp) throws Exception{ return engine.resolve(req.getURI()); }=20=20=20=20=20=20=20=20 Hugo. =3D --=20 Powered by Outblaze |