My problem is that I create all users urls when I start my server. With a lot of users this takes time and I want to minimize my startup time to be able to deploy faster.
My url is;
http://server.com/user_id/user_files_goes_here
Code;
public synchronized Restlet createInboundRoot() {
// for every client do;
addClientDirectories(client);
}
private void addClientDirectories(Client aUser) {
Router guardedRouter = new Router(context);
// Attach a guard to secure access to the directory
SaltedClientGuard guard = new SaltedClientGuard(context, ChallengeScheme.HTTP_BASIC, "user: " + aUser.userID);
guard.setRechallengeEnabled(false);
guard.getSecrets().put(aUser.userID, aUser.mPassword.toCharArray());
guard.setNext(guardedRouter);
// Create a directory able to expose a hierarchy of files
Directory directory = new Directory(context, rooturi+ aUser.userID + "/");
directory.setListingAllowed(true);
directory.setDeeplyAccessible(true);
directory.setModifiable(true);
directory.setTargetClass(UserDirectory.class);
guardedRouter.attach(rooturl, directory);
rootRouter.attach(userurl + "/" + aUser.userID+"/", guard);
}
Above makes sure a user has to login with basic auth and then UserDirectory.class handles what data should be transfered up or down. Each user has own login and his own file area under his own url(with suburls depending on users file structure).
Instead of creating all users when starting the servlet, can I somehow hook into the login/first access(to the same url as described above) with Restlet framework and attach the user directories then?
So, it turns out, its not harder then calling my addClientDirectories() when a user logs in.