Skip to content

Commit 15d7040

Browse files
authored
Merge pull request #74 from kazuki43zoo/gh-65
Rename Driver to VelocityLanguageDriver
2 parents 9a1f0cc + d176ffd commit 15d7040

File tree

4 files changed

+90
-50
lines changed

4 files changed

+90
-50
lines changed

src/main/java/org/mybatis/scripting/velocity/Driver.java

+5-46
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,9 @@
1515
*/
1616
package org.mybatis.scripting.velocity;
1717

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-
public class Driver implements LanguageDriver {
28-
29-
/**
30-
* Default constructor.
31-
*/
32-
public Driver() {
33-
this(VelocityLanguageDriverConfig.newInstance());
34-
}
35-
36-
/**
37-
* Constructor.
38-
*
39-
* @param driverConfig
40-
* a language driver configuration
41-
* @since 2.1.0
42-
*/
43-
public Driver(VelocityLanguageDriverConfig driverConfig) {
44-
VelocityFacade.initialize(driverConfig);
45-
}
46-
47-
@Override
48-
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
49-
BoundSql boundSql) {
50-
return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
51-
}
52-
53-
@Override
54-
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterTypeClass) {
55-
return new SQLScriptSource(configuration, script.getNode().getTextContent(),
56-
parameterTypeClass == null ? Object.class : parameterTypeClass);
57-
}
58-
59-
@Override
60-
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterTypeClass) {
61-
return new SQLScriptSource(configuration, script, parameterTypeClass == null ? Object.class : parameterTypeClass);
62-
}
63-
18+
/**
19+
* @deprecated Since 2.1.0, recommend to use the {@link VelocityLanguageDriver}.
20+
*/
21+
@Deprecated
22+
public class Driver extends VelocityLanguageDriver {
6423
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Copyright 2012-2019 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+
* http://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.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+
* The {@link LanguageDriver} using Velocity.
29+
* <p>
30+
* This class rename from {@code Driver}.
31+
* </p>
32+
*
33+
* @since 2.1.0
34+
* @author Kazuki Shimizu
35+
*/
36+
public class VelocityLanguageDriver implements LanguageDriver {
37+
38+
/**
39+
* Default constructor.
40+
*/
41+
public VelocityLanguageDriver() {
42+
this(VelocityLanguageDriverConfig.newInstance());
43+
}
44+
45+
/**
46+
* Constructor.
47+
*
48+
* @param driverConfig
49+
* a language driver configuration
50+
*/
51+
public VelocityLanguageDriver(VelocityLanguageDriverConfig driverConfig) {
52+
VelocityFacade.initialize(driverConfig);
53+
}
54+
55+
/**
56+
* {@inheritDoc}
57+
*/
58+
@Override
59+
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
60+
BoundSql boundSql) {
61+
return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
62+
}
63+
64+
/**
65+
* {@inheritDoc}
66+
*/
67+
@Override
68+
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterTypeClass) {
69+
return new SQLScriptSource(configuration, script.getNode().getTextContent(),
70+
parameterTypeClass == null ? Object.class : parameterTypeClass);
71+
}
72+
73+
/**
74+
* {@inheritDoc}
75+
*/
76+
@Override
77+
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterTypeClass) {
78+
return new SQLScriptSource(configuration, script, parameterTypeClass == null ? Object.class : parameterTypeClass);
79+
}
80+
81+
}

src/site/xdoc/index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2012-2018 the original author or authors.
4+
Copyright 2012-2019 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
5757
<configuration>
5858
...
5959
<typeAliases>
60-
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.Driver"/>
60+
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.VelocityLanguageDriver"/>
6161
</typeAliases>
6262
...
6363
</configuration>]]></source>

src/test/resources/org/mybatis/scripting/velocity/use/MapperConfig.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<!--
33
4-
Copyright 2012-2016 the original author or authors.
4+
Copyright 2012-2019 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
2727
</settings>
2828

2929
<typeAliases>
30-
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.Driver"/>
30+
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.VelocityLanguageDriver"/>
3131
</typeAliases>
3232

3333
<environments default="development">

0 commit comments

Comments
 (0)