Skip to content

Rename Driver to VelocityLanguageDriver #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 5 additions & 46 deletions src/main/java/org/mybatis/scripting/velocity/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,9 @@
*/
package org.mybatis.scripting.velocity;

import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.parsing.XNode;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
import org.apache.ibatis.session.Configuration;

public class Driver implements LanguageDriver {

/**
* Default constructor.
*/
public Driver() {
this(VelocityLanguageDriverConfig.newInstance());
}

/**
* Constructor.
*
* @param driverConfig
* a language driver configuration
* @since 2.1.0
*/
public Driver(VelocityLanguageDriverConfig driverConfig) {
VelocityFacade.initialize(driverConfig);
}

@Override
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
BoundSql boundSql) {
return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
}

@Override
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterTypeClass) {
return new SQLScriptSource(configuration, script.getNode().getTextContent(),
parameterTypeClass == null ? Object.class : parameterTypeClass);
}

@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterTypeClass) {
return new SQLScriptSource(configuration, script, parameterTypeClass == null ? Object.class : parameterTypeClass);
}

/**
* @deprecated Since 2.1.0, recommend to use the {@link VelocityLanguageDriver}.
*/
@Deprecated
public class Driver extends VelocityLanguageDriver {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mybatis.scripting.velocity;

import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.parsing.XNode;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
import org.apache.ibatis.session.Configuration;

/**
* The {@link LanguageDriver} using Velocity.
* <p>
* This class rename from {@code Driver}.
* </p>
*
* @since 2.1.0
* @author Kazuki Shimizu
*/
public class VelocityLanguageDriver implements LanguageDriver {

/**
* Default constructor.
*/
public VelocityLanguageDriver() {
this(VelocityLanguageDriverConfig.newInstance());
}

/**
* Constructor.
*
* @param driverConfig
* a language driver configuration
*/
public VelocityLanguageDriver(VelocityLanguageDriverConfig driverConfig) {
VelocityFacade.initialize(driverConfig);
}

/**
* {@inheritDoc}
*/
@Override
public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
BoundSql boundSql) {
return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
}

/**
* {@inheritDoc}
*/
@Override
public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterTypeClass) {
return new SQLScriptSource(configuration, script.getNode().getTextContent(),
parameterTypeClass == null ? Object.class : parameterTypeClass);
}

/**
* {@inheritDoc}
*/
@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterTypeClass) {
return new SQLScriptSource(configuration, script, parameterTypeClass == null ? Object.class : parameterTypeClass);
}

}
4 changes: 2 additions & 2 deletions src/site/xdoc/index.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2012-2018 the original author or authors.
Copyright 2012-2019 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,7 +57,7 @@
<configuration>
...
<typeAliases>
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.Driver"/>
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.VelocityLanguageDriver"/>
</typeAliases>
...
</configuration>]]></source>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--

Copyright 2012-2016 the original author or authors.
Copyright 2012-2019 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -27,7 +27,7 @@
</settings>

<typeAliases>
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.Driver"/>
<typeAlias alias="velocity" type="org.mybatis.scripting.velocity.VelocityLanguageDriver"/>
</typeAliases>

<environments default="development">
Expand Down