-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Rename Driver to VelocityLanguageDriver
- Loading branch information
Showing
4 changed files
with
90 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/main/java/org/mybatis/scripting/velocity/VelocityLanguageDriver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters