1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.scripting.velocity;
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
29
30
31
32
33
34
35
36
37 public class VelocityLanguageDriver implements LanguageDriver {
38
39
40
41
42 public VelocityLanguageDriver() {
43 this(VelocityLanguageDriverConfig.newInstance());
44 }
45
46
47
48
49
50
51
52 public VelocityLanguageDriver(VelocityLanguageDriverConfig driverConfig) {
53 VelocityFacade.initialize(driverConfig);
54 }
55
56
57
58
59 @Override
60 public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
61 BoundSql boundSql) {
62 return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
63 }
64
65
66
67
68 @Override
69 public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterTypeClass) {
70 return new SQLScriptSource(configuration, script.getNode().getTextContent(),
71 parameterTypeClass == null ? Object.class : parameterTypeClass);
72 }
73
74
75
76
77 @Override
78 public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterTypeClass) {
79 return new SQLScriptSource(configuration, script, parameterTypeClass == null ? Object.class : parameterTypeClass);
80 }
81
82 }