View Javadoc
1   /*
2    *    Copyright 2009-2022 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.submitted.language;
17  
18  import org.apache.ibatis.executor.parameter.ParameterHandler;
19  import org.apache.ibatis.mapping.BoundSql;
20  import org.apache.ibatis.mapping.MappedStatement;
21  import org.apache.ibatis.mapping.SqlSource;
22  import org.apache.ibatis.parsing.XNode;
23  import org.apache.ibatis.scripting.LanguageDriver;
24  import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
25  import org.apache.ibatis.session.Configuration;
26  
27  /**
28   * Just a test case. Not a real Velocity implementation.
29   */
30  public class VelocityLanguageDriver implements LanguageDriver {
31  
32    @Override
33    public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
34        BoundSql boundSql) {
35      return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
36    }
37  
38    @Override
39    public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType) {
40      return new VelocitySqlSource(configuration, script.getStringBody(""));
41    }
42  
43    @Override
44    public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
45      return new VelocitySqlSource(configuration, script);
46    }
47  }