public void contextualize(Context context) throws ContextException {
this.contextFactory.contextualize(context);
try {
this.contextFactory.service(new SimpleServiceManager(this));
} catch (ServiceException se) {
throw new ContextException("Unable to service context factory.", se);
}
try {
// Similar to Excalibur's SourceResolverImpl, and consistent with ContextHelper.CONTEXT_ROOT_URL
if( context.get("context-root") instanceof URL) {
contextBase = ((URL)context.get("context-root")).toExternalForm();
} else {
contextBase = ((File)context.get("context-root")).toURL().toExternalForm();
}
} catch(ContextException ce) {
// set the base URL to the current directory
try {
contextBase = new File(System.getProperty("user.dir")).toURL().toExternalForm();
} catch( MalformedURLException mue) {
throw new ContextException( "Malformed URL for user.dir, and no context-root exists", mue);
}
} catch( MalformedURLException mue) {
throw new ContextException("Malformed URL for context-root", mue);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Base URL set to " + this.contextBase);
}