public Object get( final Object key )
throws ContextException {
if ( ContextHelper.CONTEXT_OBJECT_MODEL.equals(key)) {
final Environment env = EnvironmentHelper.getCurrentEnvironment();
if ( env == null ) {
throw new ContextException("Unable to locate " + key + " (No environment available)");
}
return env.getObjectModel();
} else if ( ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER.equals(key)) {
final ServiceManager manager = EnvironmentHelper.getSitemapServiceManager();
if ( manager == null ) {
throw new ContextException("Unable to locate " + key + " (No environment available)");
}
return manager;
}
if ( key instanceof String ) {
String stringKey = (String)key;
if ( stringKey.startsWith(OBJECT_MODEL_KEY_PREFIX) ) {
final Environment env = EnvironmentHelper.getCurrentEnvironment();
if ( env == null ) {
throw new ContextException("Unable to locate " + key + " (No environment available)");
}
final Map objectModel = env.getObjectModel();
String objectKey = stringKey.substring(OBJECT_MODEL_KEY_PREFIX.length());
Object o = objectModel.get( objectKey );
if ( o == null ) {
final String message = "Unable to locate " + key;
throw new ContextException( message );
}
return o;
}
}
return super.get( key );