class MVELObjectModelResolver implements ObjectModelResolver {

	@Override
	public Object getInstance(ObjectModel model, ClassLoader cl, Map<String, Object> contextParams) {
		Object instance = null;
		InternalRuntimeManager manager = null;
		if (contextParams.containsKey("runtimeManager")) {
			manager = (InternalRuntimeManager) contextParams.get("runtimeManager");
			instance = manager.getCacheManager().get(model.getIdentifier());
			if (instance != null) {
				return instance;
			}
		}
		ParserConfiguration config = new ParserConfiguration();
        config.setClassLoader(cl);
        ParserContext ctx = new ParserContext(config);
        if (contextParams != null) {
            for (Map.Entry<String, Object> entry : contextParams.entrySet()) {
                ctx.addVariable(entry.getKey(), entry.getValue().getClass());
            }
        }

        Object compiledExpression = MVEL.compileExpression(model.getIdentifier(), ctx);
        instance = MVELSafeHelper.getEvaluator().executeExpression( compiledExpression, contextParams );
        
        if (manager != null && instance instanceof Cacheable) {
			manager.getCacheManager().add(model.getIdentifier(), instance);
		}
        return instance;
	}

}