public Object exec()

in src/main/java/org/apache/sling/scripting/freemarker/internal/AdaptToMethod.java [55:68]


    public Object exec(final List arguments) throws TemplateModelException {
        if (arguments.size() != 2) {
            throw new TemplateModelException("wrong number of arguments, expecting 2 (adaptable and adapter type).");
        }
        try {
            final String classname = arguments.get(1).toString();
            final Class<?> clazz = dynamicClassLoaderManager.getDynamicClassLoader().loadClass(classname);
            final TemplateModel templateModel = (TemplateModel) arguments.get(0);
            final Object adaptable = DeepUnwrap.unwrap(templateModel);
            return adapterManager.getAdapter(adaptable, clazz);
        } catch (Exception e) {
            throw new TemplateModelException(e);
        }
    }