Local Repository Init

This commit is contained in:
TerryChang
2016-03-24 04:32:39 +09:00
commit 1ee3249b0b
795 changed files with 359196 additions and 0 deletions

30
.classpath Normal file
View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/target
/src/main/webapp/packageB
/logs

47
.project Normal file
View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>nexacro-egov-javaconfig</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.springframework.ide.eclipse.core.springnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

12
.settings/.jsdtscope Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="nuipattern/|packageB/" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8

View File

@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="${module}">
<wb-resource deploy-path="/WEB-INF/web.xml" source-path="/src/main/webapp/WEB-INF/web.xml"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/${module}/target/classes"/>
<property name="context-root" value="nexacro-egov"/>
</wb-module>
</project-modules>

View File

@@ -0,0 +1,7 @@
<root>
<facet id="jst.jsf">
<node name="libprov">
<attribute name="provider-id" value="jsf-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.jsf" version="1.1"/>
<installed facet="java" version="1.7"/>
</faceted-project>

View File

@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

View File

@@ -0,0 +1 @@
Window

View File

@@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false

View File

@@ -0,0 +1,31 @@
eclipse.preferences.version=1
org.springframework.ide.eclipse.core.builders.enable.beanmetadatabuilder=true
org.springframework.ide.eclipse.core.enable.project.preferences=true
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.boot.bootvalidator=true
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.autowire.autowire-org.springframework.ide.eclipse.beans.core.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.toolAnnotation-org.springframework.ide.eclipse.beans.core.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.AvoidDriverManagerDataSource-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.ImportElementsAtTopRulee-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.ParentBeanSpecifiesAbstractClassRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.RefElementRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.TooManyBeansInFileRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.UnnecessaryValueElementRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.UseBeanInheritance-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.legacyxmlusage.jndiobjectfactory-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.boot.missingConfigurationProcessor-org.springframework.ide.eclipse.boot.bootvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=false

26
.springBeans Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[3.7.0.201506251244-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[true]]></enableImports>
<configs>
<config>java:nexacro.sample.config.root.RootContext</config>
<config>java:nexacro.sample.config.root.ContextCommon</config>
<config>java:nexacro.sample.config.root.ContextCommonException</config>
<config>java:nexacro.sample.config.root.ContextConfiguration</config>
<config>java:nexacro.sample.config.root.ContextDataSource</config>
<config>java:nexacro.sample.config.root.ContextInitialize</config>
<config>java:nexacro.sample.config.root.ContextMapper</config>
<config>java:nexacro.sample.config.root.ContextNexacro</config>
<config>java:nexacro.sample.config.root.ContextSqlMap</config>
<config>java:nexacro.sample.config.root.ContextTransaction</config>
</configs>
<autoconfigs>
<config>src/main/webapp/WEB-INF/config/springmvc/dispatcher-servlet.xml</config>
</autoconfigs>
<configSets>
</configSets>
</beansProjectDescription>

Binary file not shown.

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@@ -0,0 +1,90 @@
Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org)
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.
---------------------------------
This distribution includes cryptographic software. The country in
which you currently reside may have restrictions on the import,
possession, use, and/or re-export to another country, of
encryption software. BEFORE using any encryption software, please
check your country's laws, regulations and policies concerning the
import, possession, or use, and re-export of encryption software, to
see if this is permitted. See http://www.wassenaar.org/ for more
information.
The U.S. Government Department of Commerce, Bureau of Industry and
Security (BIS), has classified this software as Export Commodity
Control Number (ECCN) 5D002.C.1, which includes information security
software using or performing cryptographic functions with asymmetric
algorithms. The form and manner of this distribution makes it
eligible for export under the License Exception ENC Technology
Software Unrestricted (TSU) exception (see the BIS Export
Administration Regulations, Section 740.13) for both object code and
source code.
The following provides more details on the cryptographic software
used (note that this software is not included in the distribution):
* The PBE Encryption facilities require the Java Cryptography
extensions: http://java.sun.com/javase/technologies/security/.
---------------------------------
Distributions of this software may include software developed by
The Apache Software Foundation (http://www.apache.org/).
---------------------------------
ICU License - ICU 1.8.1 and later
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1995-2006 International Business Machines
Corporation and others
All rights reserved.
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so,
provided that the above copyright notice(s) and this
permission notice appear in all copies of the Software and
that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright
holder shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software
without prior written authorization of the copyright holder.

View File

@@ -0,0 +1,14 @@
JASYPT: Java Simplified Encryption
----------------------------------
Jasypt (Java Simplified Encryption) is a java library which allows the
developer to add basic encryption capabilities to his/her projects with
minimum effort, and without the need of having deep knowledge on how
cryptography works.
To learn more and download latest version:
http://www.jasypt.org

View File

@@ -0,0 +1,19 @@
@ECHO OFF
set SCRIPT_NAME=decrypt.bat
set EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI
set EXEC_CLASSPATH=.
if "%JASYPT_CLASSPATH%" == "" goto computeclasspath
set EXEC_CLASSPATH=%EXEC_CLASSPATH%;%JASYPT_CLASSPATH%
:computeclasspath
IF "%OS%" == "Windows_NT" setlocal ENABLEDELAYEDEXPANSION
FOR %%c in (%~dp0..\lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%%c
IF "%OS%" == "Windows_NT" setlocal DISABLEDELAYEDEXPANSION
set JAVA_EXECUTABLE=java
if "%JAVA_HOME%" == "" goto execute
set JAVA_EXECUTABLE="%JAVA_HOME%\bin\java"
:execute
%JAVA_EXECUTABLE% -classpath %EXEC_CLASSPATH% %EXECUTABLE_CLASS% %SCRIPT_NAME% %*

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT_NAME=decrypt.sh
EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI
BIN_DIR=`dirname $0`
DIST_DIR=$BIN_DIR/..
LIB_DIR=$DIST_DIR/lib
EXEC_CLASSPATH="."
if [ -n "$JASYPT_CLASSPATH" ]
then
EXEC_CLASSPATH=$EXEC_CLASSPATH:$JASYPT_CLASSPATH
fi
for a in `find $LIB_DIR -name '*.jar'`
do
EXEC_CLASSPATH=$EXEC_CLASSPATH:$a
done
JAVA_EXECUTABLE=java
if [ -n "$JAVA_HOME" ]
then
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
fi
if [ "$OSTYPE" = "cygwin" ]
then
EXEC_CLASSPATH=`echo $EXEC_CLASSPATH | sed 's/:/;/g' | sed 's/\/cygdrive\/\([a-z]\)/\1:/g'`
JAVA_EXECUTABLE=`cygpath --unix "$JAVA_EXECUTABLE"`
fi
"$JAVA_EXECUTABLE" -classpath $EXEC_CLASSPATH $EXECUTABLE_CLASS $SCRIPT_NAME "$@"

View File

@@ -0,0 +1,19 @@
@ECHO OFF
set SCRIPT_NAME=digest.bat
set EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptStringDigestCLI
set EXEC_CLASSPATH=.
if "%JASYPT_CLASSPATH%" == "" goto computeclasspath
set EXEC_CLASSPATH=%EXEC_CLASSPATH%;%JASYPT_CLASSPATH%
:computeclasspath
IF "%OS%" == "Windows_NT" setlocal ENABLEDELAYEDEXPANSION
FOR %%c in (%~dp0..\lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%%c
IF "%OS%" == "Windows_NT" setlocal DISABLEDELAYEDEXPANSION
set JAVA_EXECUTABLE=java
if "%JAVA_HOME%" == "" goto execute
set JAVA_EXECUTABLE="%JAVA_HOME%\bin\java"
:execute
%JAVA_EXECUTABLE% -classpath %EXEC_CLASSPATH% %EXECUTABLE_CLASS% %SCRIPT_NAME% %*

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT_NAME=digest.sh
EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptStringDigestCLI
BIN_DIR=`dirname $0`
DIST_DIR=$BIN_DIR/..
LIB_DIR=$DIST_DIR/lib
EXEC_CLASSPATH="."
if [ -n "$JASYPT_CLASSPATH" ]
then
EXEC_CLASSPATH=$EXEC_CLASSPATH:$JASYPT_CLASSPATH
fi
for a in `find $LIB_DIR -name '*.jar'`
do
EXEC_CLASSPATH=$EXEC_CLASSPATH:$a
done
JAVA_EXECUTABLE=java
if [ -n "$JAVA_HOME" ]
then
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
fi
if [ "$OSTYPE" = "cygwin" ]
then
EXEC_CLASSPATH=`echo $EXEC_CLASSPATH | sed 's/:/;/g' | sed 's/\/cygdrive\/\([a-z]\)/\1:/g'`
JAVA_EXECUTABLE=`cygpath --unix "$JAVA_EXECUTABLE"`
fi
"$JAVA_EXECUTABLE" -classpath $EXEC_CLASSPATH $EXECUTABLE_CLASS $SCRIPT_NAME "$@"

View File

@@ -0,0 +1,19 @@
@ECHO OFF
set SCRIPT_NAME=encrypt.bat
set EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI
set EXEC_CLASSPATH=.
if "%JASYPT_CLASSPATH%" == "" goto computeclasspath
set EXEC_CLASSPATH=%EXEC_CLASSPATH%;%JASYPT_CLASSPATH%
:computeclasspath
IF "%OS%" == "Windows_NT" setlocal ENABLEDELAYEDEXPANSION
FOR %%c in (%~dp0..\lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%%c
IF "%OS%" == "Windows_NT" setlocal DISABLEDELAYEDEXPANSION
set JAVA_EXECUTABLE=java
if "%JAVA_HOME%" == "" goto execute
set JAVA_EXECUTABLE="%JAVA_HOME%\bin\java"
:execute
%JAVA_EXECUTABLE% -classpath %EXEC_CLASSPATH% %EXECUTABLE_CLASS% %SCRIPT_NAME% %*

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT_NAME=encrypt.sh
EXECUTABLE_CLASS=org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI
BIN_DIR=`dirname $0`
DIST_DIR=$BIN_DIR/..
LIB_DIR=$DIST_DIR/lib
EXEC_CLASSPATH="."
if [ -n "$JASYPT_CLASSPATH" ]
then
EXEC_CLASSPATH=$EXEC_CLASSPATH:$JASYPT_CLASSPATH
fi
for a in `find $LIB_DIR -name '*.jar'`
do
EXEC_CLASSPATH=$EXEC_CLASSPATH:$a
done
JAVA_EXECUTABLE=java
if [ -n "$JAVA_HOME" ]
then
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
fi
if [ "$OSTYPE" = "cygwin" ]
then
EXEC_CLASSPATH=`echo $EXEC_CLASSPATH | sed 's/:/;/g' | sed 's/\/cygdrive\/\([a-z]\)/\1:/g'`
JAVA_EXECUTABLE=`cygpath --unix "$JAVA_EXECUTABLE"`
fi
"$JAVA_EXECUTABLE" -classpath $EXEC_CLASSPATH $EXECUTABLE_CLASS $SCRIPT_NAME "$@"

View File

@@ -0,0 +1,19 @@
@ECHO OFF
set SCRIPT_NAME=listAlgorithms.bat
set EXECUTABLE_CLASS=org.jasypt.intf.cli.AlgorithmRegistryCLI
set EXEC_CLASSPATH=.
if "%JASYPT_CLASSPATH%" == "" goto computeclasspath
set EXEC_CLASSPATH=%EXEC_CLASSPATH%;%JASYPT_CLASSPATH%
:computeclasspath
IF "%OS%" == "Windows_NT" setlocal ENABLEDELAYEDEXPANSION
FOR %%c in (%~dp0..\lib\*.jar) DO set EXEC_CLASSPATH=!EXEC_CLASSPATH!;%%c
IF "%OS%" == "Windows_NT" setlocal DISABLEDELAYEDEXPANSION
set JAVA_EXECUTABLE=java
if "%JAVA_HOME%" == "" goto execute
set JAVA_EXECUTABLE="%JAVA_HOME%\bin\java"
:execute
%JAVA_EXECUTABLE% -classpath %EXEC_CLASSPATH% %EXECUTABLE_CLASS% %SCRIPT_NAME% %*

View File

@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT_NAME=listAlgorithms.sh
EXECUTABLE_CLASS=org.jasypt.intf.cli.AlgorithmRegistryCLI
BIN_DIR=`dirname $0`
DIST_DIR=$BIN_DIR/..
LIB_DIR=$DIST_DIR/lib
EXEC_CLASSPATH="."
if [ -n "$JASYPT_CLASSPATH" ]
then
EXEC_CLASSPATH=$EXEC_CLASSPATH:$JASYPT_CLASSPATH
fi
for a in `find $LIB_DIR -name '*.jar'`
do
EXEC_CLASSPATH=$EXEC_CLASSPATH:$a
done
JAVA_EXECUTABLE=java
if [ -n "$JAVA_HOME" ]
then
JAVA_EXECUTABLE=$JAVA_HOME/bin/java
fi
if [ "$OSTYPE" = "cygwin" ]
then
EXEC_CLASSPATH=`echo $EXEC_CLASSPATH | sed 's/:/;/g' | sed 's/\/cygdrive\/\([a-z]\)/\1:/g'`
JAVA_EXECUTABLE=`cygpath --unix "$JAVA_EXECUTABLE"`
fi
"$JAVA_EXECUTABLE" -classpath $EXEC_CLASSPATH $EXECUTABLE_CLASS $SCRIPT_NAME "$@"

View File

@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Build-Jdk: 1.7.0_79
Built-By: TerryChang
Created-By: Maven Integration for Eclipse

View File

@@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Sun Mar 20 01:39:51 KST 2016
version=1.0.0
groupId=com.nexacro.archetype
m2e.projectName=nexacro-egov-javaconfig
m2e.projectLocation=D\:\\GitRepository\\nexacro-egov-javaconfig\\nexacro-egov-javaconfig
artifactId=nexacro-egov

View File

@@ -0,0 +1,563 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nexacro.archetype</groupId>
<artifactId>nexacro-egov</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>nexacro-egov</name>
<url>http://maven.apache.org</url>
<organization>
<name>nexacro Dev Group</name>
</organization>
<description>Description of nexacro-egov</description>
<properties>
<jdk.version>1.7</jdk.version>
<spring.maven.artifact.version>4.0.9.RELEASE</spring.maven.artifact.version>
<egovframework.rte.version>3.5.0</egovframework.rte.version>
<org.slf4j-version>1.7.5</org.slf4j-version>
<encoding>UTF-8</encoding>
</properties>
<repositories>
<repository>
<id>tobesoft</id>
<url>http://cacao.tobesoft.co.kr/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mvn2</id>
<url>http://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>egovframe</id>
<url>http://www.egovframe.go.kr/maven/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mesir-repo</id>
<url>http://mesir.googlecode.com/svn/trunk/mavenrepo</url>
</repository>
</repositories>
<build>
<defaultGoal>package</defaultGoal>
<!-- Profile 설정 : 순서에 따라 profile source 덮어쓰기가 됨 -->
<resources>
<resource>
<directory>src/main/resources-${environment}</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<directory>${basedir}/target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<pluginManagement>
<plugins>
<!-- Compiler 설정 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<fork>true</fork>
<meminitial>1024m</meminitial>
<maxmem>1024m</maxmem>
<encoding>${encoding}</encoding>
</configuration>
</plugin>
<!-- war 설정 -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<!-- site 생명주기 설정 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<locales>ko</locales>
<inputEncoding>${encoding}</inputEncoding>
<outputEncoding>${encoding}</outputEncoding>
<reportPlugins>
<!-- report 항목 정의 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<configuration>
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<!-- index (Main Information),
scm (Source Repository), plugin-management, mailing-list, issue-tracking,
help, plugins, dependency-convergence, summary (프로젝트 요약), dependency-management,
dependencies, license, modules, project-team, cim (CI서버) -->
<report>index</report>
<report>summary</report>
<report>help</report>
<report>plugins</report>
<report>plugin-management</report>
<report>dependency-convergence</report>
<report>dependency-management</report>
<report>dependencies</report>
<report>modules</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
<!-- Generating JavaDoc Report -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512m</maxmemory>
<encoding>${encoding}</encoding>
<docencoding>${encoding}</docencoding>
<charset>${encoding}</charset>
</configuration>
</plugin>
<!-- Generating Java Source in HTML -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<configuration>
<inputEncoding>${encoding}</inputEncoding>
<outputEncoding>${encoding}</outputEncoding>
<linkJavadoc>true</linkJavadoc>
<!-- <javadocDir>/apidsocs</javadocDir> -->
</configuration>
</plugin>
<!-- PMD manven plugin -->
<!-- PMD ruleset 2.0 은 version 3.0 이상 -->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.5</version>
<configuration>
<rulesets>
<ruleset>${basedir}/EgovInspectionRules_kor-2.7.xml</ruleset>
</rulesets>
<linkXref>true</linkXref>
<sourceEncoding>${encoding}</sourceEncoding>
<minimumTokens>25</minimumTokens>
<targetJdk>${jdk.version}</targetJdk>
</configuration>
</plugin>
-->
</reportPlugins>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<argLine>
-Dsun.jnu.encoding=${encoding}
-Dfile.encoding=${encoding}
</argLine>
<systemPropertyVariables>
<sun.jnu.encoding>${encoding}</sun.jnu.encoding>
<file.encoding>${encoding}</file.encoding>
</systemPropertyVariables>
<skipTests>false</skipTests>
<reportFormat>xml</reportFormat>
<forkMode>once</forkMode>
<!--
"never" : Maven과 같은 process
"once" (default) : 새로운 하나의 jvm process에서 모든 Test 실행
"always" : 각 Test 마다 다른 JVM process 실행
"perthread"
-->
<!-- paralel mode setting -->
<parallel>classes</parallel><!-- classes, methods -->
<threadCount>10</threadCount>
<!--
<excludes>
<exclude>**/Abstract*.java</exclude>
<exclude>**/*Suite.java</exclude>
</excludes>
<includes>
<include>**/*Test.java</include>
</includes>
-->
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.maven.ide.eclipse</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>0.9.9-SNAPSHOT</version>
<configuration>
<mappingId>generic</mappingId>
<configurators></configurators>
<mojoExecutions></mojoExecutions>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<!-- profile 설정 -->
<profiles>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment>
</properties>
</profile>
<profile>
<id>env</id>
<properties>
<environment>env</environment>
</properties>
</profile>
</profiles>
<dependencies>
<!-- spring config -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.maven.artifact.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springmodules</groupId>
<artifactId>spring-modules-jakarta-commons</artifactId>
<version>0.8a</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- xeni -->
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>xmlpull</groupId>
<artifactId>xmlpull</artifactId>
<version>1.1.3.1</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.0</version>
</dependency>
<!-- Configuration jasypt 설정 dependency.. -->
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-spring3</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<!-- 표준프레임워크 실행환경 -->
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.ptl.mvc</artifactId>
<version>${egovframework.rte.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.psl.dataaccess</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.idgnr</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.property</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.maven.artifact.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
<!-- database driver -->
<!-- hsqldb driver -->
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
</dependency>
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<!-- http://hibernate.org/validator/faq/ -->
<!--
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.2.Final</version>
</dependency>
<!-- nexacroplatform X-API -->
<dependency>
<groupId>com.nexacro.xapi</groupId>
<artifactId>nexaxapi</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/nexacro-xapi-1.0.jar
</systemPath>
</dependency>
<!-- XENI API -->
<dependency>
<groupId>com.nexacro.xeni</groupId>
<artifactId>xeniapi</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/nexacro-xeni-1.1.jar
</systemPath>
</dependency>
</dependencies>
</project>

563
pom.xml Normal file
View File

@@ -0,0 +1,563 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nexacro.archetype</groupId>
<artifactId>nexacro-egov</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>nexacro-egov</name>
<url>http://maven.apache.org</url>
<organization>
<name>nexacro Dev Group</name>
</organization>
<description>Description of nexacro-egov</description>
<properties>
<jdk.version>1.7</jdk.version>
<spring.maven.artifact.version>4.0.9.RELEASE</spring.maven.artifact.version>
<egovframework.rte.version>3.5.0</egovframework.rte.version>
<org.slf4j-version>1.7.5</org.slf4j-version>
<encoding>UTF-8</encoding>
</properties>
<repositories>
<repository>
<id>tobesoft</id>
<url>http://cacao.tobesoft.co.kr/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mvn2</id>
<url>http://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>egovframe</id>
<url>http://www.egovframe.go.kr/maven/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mesir-repo</id>
<url>http://mesir.googlecode.com/svn/trunk/mavenrepo</url>
</repository>
</repositories>
<build>
<defaultGoal>package</defaultGoal>
<!-- Profile 설정 : 순서에 따라 profile source 덮어쓰기가 됨 -->
<resources>
<resource>
<directory>src/main/resources-${environment}</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<directory>${basedir}/target</directory>
<finalName>${project.artifactId}-${project.version}</finalName>
<pluginManagement>
<plugins>
<!-- Compiler 설정 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<fork>true</fork>
<meminitial>1024m</meminitial>
<maxmem>1024m</maxmem>
<encoding>${encoding}</encoding>
</configuration>
</plugin>
<!-- war 설정 -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<!-- site 생명주기 설정 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<locales>ko</locales>
<inputEncoding>${encoding}</inputEncoding>
<outputEncoding>${encoding}</outputEncoding>
<reportPlugins>
<!-- report 항목 정의 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<configuration>
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
<reportSets>
<reportSet>
<reports>
<!-- index (Main Information),
scm (Source Repository), plugin-management, mailing-list, issue-tracking,
help, plugins, dependency-convergence, summary (프로젝트 요약), dependency-management,
dependencies, license, modules, project-team, cim (CI서버) -->
<report>index</report>
<report>summary</report>
<report>help</report>
<report>plugins</report>
<report>plugin-management</report>
<report>dependency-convergence</report>
<report>dependency-management</report>
<report>dependencies</report>
<report>modules</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
<!-- Generating JavaDoc Report -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512m</maxmemory>
<encoding>${encoding}</encoding>
<docencoding>${encoding}</docencoding>
<charset>${encoding}</charset>
</configuration>
</plugin>
<!-- Generating Java Source in HTML -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<configuration>
<inputEncoding>${encoding}</inputEncoding>
<outputEncoding>${encoding}</outputEncoding>
<linkJavadoc>true</linkJavadoc>
<!-- <javadocDir>/apidsocs</javadocDir> -->
</configuration>
</plugin>
<!-- PMD manven plugin -->
<!-- PMD ruleset 2.0 은 version 3.0 이상 -->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.5</version>
<configuration>
<rulesets>
<ruleset>${basedir}/EgovInspectionRules_kor-2.7.xml</ruleset>
</rulesets>
<linkXref>true</linkXref>
<sourceEncoding>${encoding}</sourceEncoding>
<minimumTokens>25</minimumTokens>
<targetJdk>${jdk.version}</targetJdk>
</configuration>
</plugin>
-->
</reportPlugins>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<argLine>
-Dsun.jnu.encoding=${encoding}
-Dfile.encoding=${encoding}
</argLine>
<systemPropertyVariables>
<sun.jnu.encoding>${encoding}</sun.jnu.encoding>
<file.encoding>${encoding}</file.encoding>
</systemPropertyVariables>
<skipTests>false</skipTests>
<reportFormat>xml</reportFormat>
<forkMode>once</forkMode>
<!--
"never" : Maven과 같은 process
"once" (default) : 새로운 하나의 jvm process에서 모든 Test 실행
"always" : 각 Test 마다 다른 JVM process 실행
"perthread"
-->
<!-- paralel mode setting -->
<parallel>classes</parallel><!-- classes, methods -->
<threadCount>10</threadCount>
<!--
<excludes>
<exclude>**/Abstract*.java</exclude>
<exclude>**/*Suite.java</exclude>
</excludes>
<includes>
<include>**/*Test.java</include>
</includes>
-->
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.maven.ide.eclipse</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>0.9.9-SNAPSHOT</version>
<configuration>
<mappingId>generic</mappingId>
<configurators></configurators>
<mojoExecutions></mojoExecutions>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<!-- profile 설정 -->
<profiles>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment>
</properties>
</profile>
<profile>
<id>env</id>
<properties>
<environment>env</environment>
</properties>
</profile>
</profiles>
<dependencies>
<!-- spring config -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.maven.artifact.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springmodules</groupId>
<artifactId>spring-modules-jakarta-commons</artifactId>
<version>0.8a</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- xeni -->
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>xmlpull</groupId>
<artifactId>xmlpull</artifactId>
<version>1.1.3.1</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.0</version>
</dependency>
<!-- Configuration jasypt 설정 dependency.. -->
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-spring3</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<!-- 표준프레임워크 실행환경 -->
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.ptl.mvc</artifactId>
<version>${egovframework.rte.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.psl.dataaccess</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.idgnr</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.property</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.maven.artifact.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
<!-- database driver -->
<!-- hsqldb driver -->
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
</dependency>
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<!-- http://hibernate.org/validator/faq/ -->
<!--
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.2.Final</version>
</dependency>
<!-- nexacroplatform X-API -->
<dependency>
<groupId>com.nexacro.xapi</groupId>
<artifactId>nexaxapi</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/nexacro-xapi-1.0.jar
</systemPath>
</dependency>
<!-- XENI API -->
<dependency>
<groupId>com.nexacro.xeni</groupId>
<artifactId>xeniapi</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/nexacro-xeni-1.1.jar
</systemPath>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,39 @@
package com.nexacro.spring;
/**
* <p>상수 데이터
*
* @author Park SeongMin
* @since 08.05.2015
* @version 1.0
* @see
*/
public final class NexacroConstants {
// attribute data
public final class ATTRIBUTE {
public static final String NEXACRO_REQUEST = "NexacroRequest";
public static final String NEXACRO_CACHE_DATA = "NexacroCachedData";
public static final String NEXACRO_PLATFORM_DATA = "NexacroPlatformData";
public static final String NEXACRO_FILE_DATA = "NexacroFileData";
}
// error
public final class ERROR {
public final static int DEFAULT_ERROR_CODE = 0;
public final static String ERROR_CODE = "ErrorCode"; // nexacro 결과 코드값 (ex '0' 이상 일경우 성공)
public final static String ERROR_MSG = "ErrorMsg"; // nexacro 에러 메시지
}
// first row
public final class ERROR_FIRST_ROW {
public final static String ERROR_DATASET = "FirstRowStatus"; // exception after firstrow
public final static String ERROR_CODE = ERROR.ERROR_CODE;
public final static String ERROR_MSG = ERROR.ERROR_MSG;
}
public static final String PERFORMANCE_LOGGER = "com.nexacro.performance";
}

View File

@@ -0,0 +1,113 @@
package com.nexacro.spring;
import com.nexacro.spring.resolve.NexacroMappingExceptionResolver;
/**
*
* nexacro 예외를 의미하는 <code>Exception</code>이다.
*
* <p>nexacro platform으로 전송가능한 에러코드와 에러메시지를 저장한다.
*
* <p><code>NexacroMappingExceptionResolver</code> 설정에 따라 전송되는 에러 메시지 정보는 달라진다.
*
* @author Park SeongMin
* @since 2015. 7. 30.
* @version 1.0
* @see NexacroMappingExceptionResolver
*/
public class NexacroException extends Exception {
/* serialVersionUID */
private static final long serialVersionUID = 4095922735986385233L;
public static final int DEFAULT_ERROR_CODE = -1;
public static final String DEFAULT_MESSAGE = "An Error Occured. check the ErrorCode for detail of error infomation.";
private int errorCode = DEFAULT_ERROR_CODE;
private String errorMsg;
/**
* 기본 생성자이다.
*/
public NexacroException() {
;
}
/**
* 메시지를 가지는 생성자이다.
*
* @param message 메시지
*/
public NexacroException(String message) {
this(message, null);
}
/**
* 메시지와 원천(cause) 예외를 가지는 생성자이다.
*
* @param message 메시지
* @param cause 원천 예외
*/
public NexacroException(String message, Throwable cause) {
super(message, cause);
}
/**
* 메시지와 에러코드, 에러메시지를 가지는 생성자이다.
*
* @param message 메시지
* @param errorCode 에러코드
* @param errorMsg 에러메시지
*/
public NexacroException(String message, int errorCode, String errorMsg) {
this(message, null, errorCode, errorMsg);
}
/**
* 메시지와 원천(cause), 에러코드, 에러메시지 예외를 가지는 생성자이다.
*
* @param message 메시지
* @param cause 원천 예외
* @param errorCode 에러코드
* @param errorMsg 에러메시지
*/
public NexacroException(String message, Throwable cause, int errorCode, String errorMsg) {
super(message, cause);
setErrorCode(errorCode);
setErrorMsg(errorMsg);
}
/**
* 설정 된 에러코드를 반환한다.
* @return errorCode
*/
public int getErrorCode() {
return errorCode;
}
/**
* 에러코드를 설정한다.
*
* @param errorCode 에러코드
*/
public void setErrorCode(int errorCode) {
this.errorCode = errorCode;
}
/**
* 설정 된 에러메시지를 반환한다.
* @return errorMsg
*/
public String getErrorMsg() {
return errorMsg;
}
/**
* 에러메시지를 설정한다.
* @param errorMsg 에러메시지
*/
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}

View File

@@ -0,0 +1,37 @@
package com.nexacro.spring.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p><code>DataSet</code>을 List혹은 POJO형태의 데이터로 변환을 수행하기 위한 annotation이다.
*
* <p>Spring의 Controller내 메서드 파라매터에서 사용가능하다. 아래는 doService 메서드 호출 시 데이터셋 변환 예제이다.
* <blockquote>
* Ex> public void doService(@ParamDataSet(name="dsUnit") List<Map> dsUnits)
* </blockquote>
* @author Park SeongMin
* @since 07.28.2015
* @version 1.0
* @see ParamVariable
*/
@Target({ java.lang.annotation.ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ParamDataSet {
/**
* <code>DataSet</code>의 식별자
* @return dsName
*/
String name();
/**
* Whether the parameter is required.
* <p>Default is {@code true}, leading to an exception thrown in case
* of the parameter missing in the request. Switch this to {@code false}
* if you prefer a {@code null} in case of the parameter missing.
*/
boolean required() default true;
}

View File

@@ -0,0 +1,38 @@
package com.nexacro.spring.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <p><code>Variable</code>을 Primitive 형태의 데이터로 변환을 수행하기 위한 annotation이다.
*
* <p>Spring의 Controller내 메서드 파라매터에서 사용가능하다. 아래는 doService 메서드 호출 시 데이터셋 변환 예제이다.
* <blockquote>
* Ex> public void doService(@ParamVariable(name="varUserName") String userName)
* </blockquote>
* @author Park SeongMin
* @since 07.28.2015
* @version 1.0
* @see ParamDataSet
*/
@Target({ java.lang.annotation.ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ParamVariable {
/**
* <code>Variable</code>식별자
* @return dsName
*/
String name();
/**
* Whether the parameter is required.
* <p>Default is {@code true}, leading to an exception thrown in case
* of the parameter missing in the request. Switch this to {@code false}
* if you prefer a {@code null} in case of the parameter missing.
*/
boolean required() default true;
}

View File

@@ -0,0 +1,28 @@
package com.nexacro.spring.context;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Spring의 ApplicationContext를 제공한다.
*
* @author Park SeongMin
* @since 10.15.2015
* @version 1.0
*
*/
public class ApplicationContextProvider implements ApplicationContextAware {
// 참고 URL
// http://blog.jdevelop.eu/?p=154
// Spring의 Bean들이 로드 된 후 ApplicationContext가 설정된다.
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
// ApplicationContext가 초기화 된 후 호출 된다.
SpringAppContext.getInstance().setApplicationContext(applicationContext);
}
}

View File

@@ -0,0 +1,167 @@
package com.nexacro.spring.context;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nexacro.spring.data.NexacroFirstRowHandler;
import com.nexacro.spring.util.CharsetUtil;
import com.nexacro.xapi.data.PlatformData;
import com.nexacro.xapi.tx.HttpPlatformRequest;
import com.nexacro.xapi.tx.HttpPlatformResponse;
import com.nexacro.xapi.tx.PlatformException;
import com.nexacro.xapi.tx.PlatformType;
import com.nexacro.xapi.util.StringUtils;
/**
* <p>HTTP 요청으로 부터 데이터를 수신받으며, 수신 된 데이터를 저장한다.
* <p>또한 데이터 분할 전송을 위한 NexacroFirstRowHandler를 제공한다.
*
* @author Park SeongMin
* @since 07.28.2015
* @version 1.0
* @see NexacroContextHolder
*/
public class NexacroContext {
/* 데이터 수신시 HTTP GET 데이터 등록 여부의 키 */
private static final String REGISTER_GET_PARAMETER = "http.getparameter.register";
/* HTTP GET 데이터 등록시 Variable 형식으로 변환 여부의 키 */
private static final String GET_PARAMETER_AS_VARIABLE = "http.getparameter.asvariable";
private HttpServletRequest request;
private HttpServletResponse response;
private HttpPlatformRequest platformRequest;
private HttpPlatformResponse platformResponse;
private NexacroFirstRowHandler firstRowHandler;
public NexacroContext(HttpServletRequest request, HttpServletResponse response) throws PlatformException {
parseRequest(request, response);
}
private void parseRequest(HttpServletRequest request, HttpServletResponse response) throws PlatformException {
this.request = request;
this.response = response;
InputStream inputStream = null;
try {
inputStream = request.getInputStream();
} catch (IOException e) {
throw new PlatformException("Could not get HTTP InputStream", e);
}
String charsetOfRequest = CharsetUtil.getCharsetOfRequest(request, PlatformType.DEFAULT_CHAR_SET);
String httpContentType = request.getContentType();
String userAgent = request.getHeader("User-Agent");
String contentType = findContentType(httpContentType, userAgent);
// SSV 자동처리를 위해 inputStream을 사용하도록 한다.
HttpPlatformRequest httpPlatformRequest = new HttpPlatformRequest(inputStream);
if(PlatformType.HTTP_CONTENT_TYPE_BINARY.equals(httpContentType)) {
httpPlatformRequest.setContentType(contentType);
}
try {
httpPlatformRequest.receiveData();
} catch(PlatformException e) {
// ExceptionResolver에서 상세한 로그를 남긴다. 간략로그만을 남기도록 한다.
Logger logger = LoggerFactory.getLogger(getClass());
logger.error("receive platform data failed. e="+e.getMessage());
throw e;
}
// SSV 일 경우에만 contentType 존재. 그 외 처리를 위해 설정.
if(httpPlatformRequest.getContentType() == null) {
httpPlatformRequest.setContentType(contentType);
}
HttpPlatformResponse httpPlatformResponse = new HttpPlatformResponse(response, httpPlatformRequest);
this.platformRequest = httpPlatformRequest;
this.platformResponse = httpPlatformResponse;
}
public HttpPlatformRequest getPlatformRequest() {
return platformRequest;
}
public HttpPlatformResponse getPlatformResponse() {
if(platformResponse != null) {
return platformResponse;
}
platformResponse = new HttpPlatformResponse(response, platformRequest);
return platformResponse;
}
public NexacroFirstRowHandler getFirstRowHandler() {
if(firstRowHandler != null) {
return firstRowHandler;
}
firstRowHandler = new NexacroFirstRowHandler(response, platformRequest);
return firstRowHandler;
}
public boolean isFirstRowFired() {
if(firstRowHandler != null) {
return firstRowHandler.isFirstRowStarted();
}
return false;
}
public PlatformData getPlatformData() {
return this.platformRequest != null ? this.platformRequest.getData(): null;
}
/* HTTP의 ContentType으로부터 송수신 형식을 검색한다. */
String findContentType(String httpContentType, String userAgent) {
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
if (StringUtils.isEmpty(httpContentType)) {
return null;
}
int index = httpContentType.indexOf(';');
String contentType = (index == -1) ? httpContentType : httpContentType.substring(0, index);
if (PlatformType.HTTP_CONTENT_TYPE_XML.equals(contentType)) {
if (isMiPlatform(userAgent)) {
return PlatformType.CONTENT_TYPE_MI_XML;
} else {
return PlatformType.CONTENT_TYPE_XML;
}
} else if (PlatformType.HTTP_CONTENT_TYPE_BINARY.equals(contentType)) {
if (isMiPlatform(userAgent)) {
return PlatformType.CONTENT_TYPE_MI_BINARY;
} else {
return PlatformType.CONTENT_TYPE_BINARY;
}
} else if (PlatformType.HTTP_CONTENT_TYPE_HTML.equals(contentType)) {
return PlatformType.CONTENT_TYPE_HTML;
}
return null;
}
/* MiPlatform 여부 */
private boolean isMiPlatform(String userAgent) {
// MiPlatform 3.1;win32;1400x1050
if (userAgent == null) {
return false;
} else {
return (userAgent.startsWith("MiPlatform"));
}
}
}

View File

@@ -0,0 +1,46 @@
package com.nexacro.spring.context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import com.nexacro.spring.NexacroConstants;
import com.nexacro.xapi.tx.PlatformException;
/**
* <p>HTTP 요청에 대한 <code>NexacroContext</code>를 Thread 단위로 관리한다.
*
* @ClassName : NexacroContextHolder.java
* @author Park SeongMin
* @since 08.11.2015
* @version 1.0
* @see NexacroContext
*/
public abstract class NexacroContextHolder {
public static NexacroContext getNexacroContext(HttpServletRequest request, HttpServletResponse response) throws PlatformException {
NexacroContext nexacroContext = new NexacroContext(request, response);
RequestContextHolder.getRequestAttributes().setAttribute(NexacroConstants.ATTRIBUTE.NEXACRO_REQUEST, NexacroConstants.ATTRIBUTE.NEXACRO_REQUEST, RequestAttributes.SCOPE_REQUEST);
setNexacroContext(nexacroContext);
return nexacroContext;
}
public static void setNexacroContext(NexacroContext context) {
RequestContextHolder.getRequestAttributes().setAttribute(NexacroConstants.ATTRIBUTE.NEXACRO_CACHE_DATA, context, RequestAttributes.SCOPE_REQUEST);
}
public static NexacroContext getNexacroContext() {
Object context = RequestContextHolder.getRequestAttributes().getAttribute(NexacroConstants.ATTRIBUTE.NEXACRO_CACHE_DATA, RequestAttributes.SCOPE_REQUEST);
if(context == null) {
return null;
}
if(context instanceof NexacroContext) {
return (NexacroContext) context;
}
return null;
}
}

View File

@@ -0,0 +1,60 @@
package com.nexacro.spring.context;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.springframework.context.ApplicationContext;
public class SpringAppContext {
/*
* @autowired 자동처리 시에는 아래와 같이 처리 하면 된다.
*
* ApplicationContext ctx = AppContext.getApplicationContext();
* Honeypotbean honey = ctx.getBean(HoneyPotBean.class);
*
*/
public final static SpringAppContext INSTANCE = new SpringAppContext();
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final Lock readLock = lock.readLock();
private final Lock writeLock = lock.writeLock();
private ApplicationContext ctx;
private SpringAppContext() {
}
public static SpringAppContext getInstance() {
return INSTANCE;
}
/**
* Injected from the class “ApplicationContextProvider” which is
* automatically loaded during Spring-Initialization.
*/
public void setApplicationContext(ApplicationContext applicationContext) {
writeLock.lock();
try {
this.ctx = applicationContext;
} finally {
writeLock.unlock();
}
}
/**
* Get access to the Spring ApplicationContext from everywhere in your
* Application.
*
* @return
*/
public ApplicationContext getApplicationContext() {
readLock.lock();
try {
return this.ctx;
} finally {
readLock.unlock();
}
}
}

View File

@@ -0,0 +1,92 @@
package com.nexacro.spring.dao;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.nexacro.xapi.data.datatype.DataType;
import com.nexacro.xapi.data.datatype.DataTypeFactory;
import com.nexacro.xapi.data.datatype.PlatformDataType;
/**
* Dbms를 구현한 추상클래스로서 ResultSetMetaData로부터 데이터셋으로 변환하기 위해 X-API의 DataType을 활용하여 기본형에 대해 데이터 변환을 수행한다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public abstract class AbstractDbms implements Dbms {
/**
* DBMS type handle
*
* @param column
*/
public abstract void handleColumnDataType(DbColumn column);
public List<DbColumn> getDbColumns(ResultSetMetaData resultSetMetaData) throws SQLException {
List<DbColumn> columnList = new ArrayList<DbColumn>();
int columnCount = resultSetMetaData.getColumnCount();
// rs..
for(int i=1; i<=columnCount; i++) {
String columnName = resultSetMetaData.getColumnLabel(i);
if (columnName == null || columnName.equals("")) {
columnName = resultSetMetaData.getColumnName(i);
}
String vendorsTypeName = resultSetMetaData.getColumnTypeName(i);
String typeJavaClassName = resultSetMetaData.getColumnClassName(i);
DataType dataType = DataTypeFactory.getSqlDataType(vendorsTypeName);
if(dataType==null) {
// when dbms vendor's specific column type name
int javaSqlTypeNumber = resultSetMetaData.getColumnType(i);
dataType = DataTypeFactory.getSqlDataType(javaSqlTypeNumber);
}
// find platform datatype
dataType = DataTypeFactory.getPlatformDataType(dataType);
if(dataType == null) {
dataType = PlatformDataType.UNDEFINED;
}
int precision = resultSetMetaData.getPrecision(i);
int scale = resultSetMetaData.getScale(i);
int columnSize = resultSetMetaData.getColumnDisplaySize(i);
DbColumn column = new DbColumn(columnName, dataType, columnSize, vendorsTypeName);
column.setTypeJavaClassName(typeJavaClassName);
column.setPrecision(precision);
column.setScale(scale);
// handle column for dbms
handleColumnDataType(column);
columnList.add(column);
}
return columnList;
}
protected DataType findPlatformDataType(int javaSqlTypeNumber, String vendorsTypeName) {
DataType dataType = DataTypeFactory.getSqlDataType(vendorsTypeName);
if(dataType==null) {
// when dbms vendor's specific column type name
dataType = DataTypeFactory.getSqlDataType(javaSqlTypeNumber);
}
dataType = DataTypeFactory.getPlatformDataType(dataType);
if(dataType == null) {
dataType = PlatformDataType.UNDEFINED;
}
return dataType;
}
}

View File

@@ -0,0 +1,129 @@
package com.nexacro.spring.dao;
import com.nexacro.xapi.data.datatype.DataType;
import com.nexacro.xapi.data.datatype.DataTypeFactory;
/**
* ResultSetMetaData로 부터 획득한 컬럼의 메타데이터 정보를 저장한다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public class DbColumn {
/**
* 컬럼의 기본 크기. 255
*/
public static final int DEFAULT_SIZE = 255;
protected String name = null;
protected DataType dataType = DataTypeFactory.NULL;
protected int size = DEFAULT_SIZE;
protected String vendorsTypeName = null;
// oracle과 같은 경우 float로 생성하면 오로지 java class type으로만 구분이 가능하다. 거참.
protected String typeJavaClassName = null;
protected String decimalDigit = null;
protected int precision;
protected int scale;
public DbColumn(String name, DataType dataType, int size) {
this(name, dataType, size, null);
}
public DbColumn(String name, DataType dataType, int size, String vendorsTypeName) {
setName(name);
setDataType(dataType);
setSize(size);
setVendorsTypeName(vendorsTypeName);
this.vendorsTypeName = vendorsTypeName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DataType getDataType() {
return dataType;
}
public void setDataType(DataType dataType) {
this.dataType = dataType;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public String getVendorsTypeName() {
if(vendorsTypeName!=null) {
return vendorsTypeName;
}
if(dataType!=null) {
return dataType.getTypeName();
}
return null;
}
public void setVendorsTypeName(String vendorsTypeName) {
this.vendorsTypeName = vendorsTypeName;
}
public String getTypeJavaClassName() {
return typeJavaClassName;
}
public void setTypeJavaClassName(String typeJavaClassName) {
this.typeJavaClassName = typeJavaClassName;
}
public String getDecimalDigit() {
return decimalDigit;
}
public void setDecimalDigit(String decimalDigit) {
this.decimalDigit = decimalDigit;
}
/**
* @return the precision
*/
public int getPrecision() {
return precision;
}
/**
* @param precision the precision to set
*/
public void setPrecision(int precision) {
this.precision = precision;
}
/**
* @return the scale
*/
public int getScale() {
return scale;
}
/**
* @param scale the scale to set
*/
public void setScale(int scale) {
this.scale = scale;
}
}

View File

@@ -0,0 +1,45 @@
package com.nexacro.spring.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.util.ClassUtils;
import com.nexacro.spring.data.metadata.NexacroMetaData;
import com.nexacro.spring.data.metadata.support.BeanMetaData;
import com.nexacro.spring.data.metadata.support.MapMetaData;
import com.nexacro.spring.data.metadata.support.UnsupportedMetaData;
import com.nexacro.spring.data.support.NexacroConverterHelper;
import com.nexacro.xapi.data.datatype.DataType;
public abstract class DbMetaDataGathererUtil {
public static NexacroMetaData generateMetaDataFromClass(Class clazz) {
if(!Map.class.isAssignableFrom(clazz)) {
if(ClassUtils.isPrimitiveOrWrapper(clazz)) {
return new UnsupportedMetaData(null);
}
return new BeanMetaData(clazz);
}
return null;
}
public static MapMetaData generateMetaDataFromDbColumns(List<DbColumn> dbColumns) {
Map<String, Object> mapData = new HashMap<String, Object>();
for(DbColumn column: dbColumns) {
String name = column.getName();
DataType dataType = column.getDataType();
// Object defaultValue = NexacroConverterHelper.getDefaultValue(dataType);
// MetaData 생성 시 Map안의 데이터는 타입을 확인할 수 있도록 데이터타입의 기본값을 설정하도록 한다.
Object defaultValue = NexacroConverterHelper.getDefaultMetaDataValue(dataType);
mapData.put(name, defaultValue);
}
return new MapMetaData(mapData);
}
}

View File

@@ -0,0 +1,127 @@
package com.nexacro.spring.dao;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.ibatis.executor.BaseExecutor;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
/**
*
* <p>Dbms 별 데이터 타입 처리를 위한 기본 DbmsProvider 이다.
* <p>아래는 설정 관련 스프링 내 sample 이다.
*
* <pre>
* &lt;bean id="hsqlDbms" class="com.nexacro.spring.dao.dbms.Hsql" /&gt;
* &lt;bean id="oracleDbms" class="com.nexacro.spring.dao.dbms.Oracle" /&gt;
* &lt;bean id="mssqlDbms" class="com.nexacro.spring.dao.dbms.Mssql" /&gt;
* &lt;bean id="mysqlDbms" class="com.nexacro.spring.dao.dbms.Mysql" /&gt;
* &lt;bean id="tiberoDbms" class="com.nexacro.spring.dao.dbms.Tibero" /&gt;
*
* &lt;bean id="dbmsProvider" class="com.nexacro.spring.dao.DbVendorsProvider"&gt;
* &lt;property name="dbvendors"&gt;
* &lt;map&gt;
* &lt;entry key="HSQL Database Engine" value-ref="hsqlDbms"/&gt;
* &lt;entry key="SQL Server" value-ref="mssqlDbms"/&gt;
* &lt;entry key="Oracle" value-ref="oracleDbms"/&gt;
* &lt;/map&gt;
* &lt;/property&gt;
* &lt;/bean&gt;
* </pre>
*
* <p>dbvendors의 key값은 {@link DatabaseMetaData#getDatabaseProductName()} 으로 정의 된다.
* <p>추가적인 타입 처리가 필요한 경우 {@link Dbms}를 구현하여 처리한다.
*
* @author Park SeongMin
* @since 10.11.2015
* @version 1.0
* @see
*
*/
public class DbVendorsProvider implements DbmsProvider {
/*
<bean id="hsqlDbms" class="com.nexacro.spring.dao.dbms.Hsql" />
<bean id="oracleDbms" class="com.nexacro.spring.dao.dbms.Oracle" />
<bean id="mssqlDbms" class="com.nexacro.spring.dao.dbms.Mssql" />
<bean id="mysqlDbms" class="com.nexacro.spring.dao.dbms.Mysql" />
<bean id="tiberoDbms" class="com.nexacro.spring.dao.dbms.Tibero" />
<bean id="dbmsProvider" class="com.nexacro.spring.dao.DbVendorsProvider">
<property name="dbverdors">
<map>
<entry key="SQL Server" value-ref="mssqlDbms"/>
<entry key="Oracle" value-ref="oracleDbms"/>
</map>
</property>
</bean>
*/
// dbms 이름, dbms에 맞는 Dbms class 이름을 list 형태로 받아야 한다.
private static final Log log = LogFactory.getLog(BaseExecutor.class);
private Map<String, Dbms> dbvendors;
public Map<String, Dbms> getDbvendors() {
return dbvendors;
}
public void setDbvendors(Map<String, Dbms> dbvendors) {
this.dbvendors = dbvendors;
}
public Dbms getDbms(Connection conn) {
if (conn == null)
throw new NullPointerException("Connection cannot be null");
try {
String productName = getDataBaseProductName(conn);
if (this.dbvendors != null) {
Dbms dbms = dbvendors.get(productName);
// for (Map.Entry<Object, Object> property : properties.entrySet()) {
// if (productName.contains((String) property.getKey())) {
// return (String) property.getValue();
// }
// }
return dbms; // no match, return null
}
} catch (Exception e) {
log.error("Could not get a Dbms from Connection", e);
}
return null;
}
public Dbms getDbms(DataSource dataSource) {
if (dataSource == null)
throw new NullPointerException("dataSource cannot be null");
Connection connection = null;
try {
connection = dataSource.getConnection();
return getDbms(connection);
} catch (SQLException e) {
log.error("Could not get a Dbms from dataSource", e);
} finally {
if(connection != null) {
try { connection.close(); } catch (SQLException e) { }
}
}
return null;
}
private String getDataBaseProductName(Connection conn) throws SQLException {
DatabaseMetaData metaData = conn.getMetaData();
return metaData.getDatabaseProductName();
}
}

View File

@@ -0,0 +1,27 @@
package com.nexacro.spring.dao;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
/**
* ResultSetMetaData의 컬럼 정보를 토대로 데이터셋으로 변환하기 위한 컬럼정보를 DBMS 별 처리하기 위한 인터페이스이다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public interface Dbms {
/**
* ResultSetMetaData의 컬럼 정보를 토대로 DataSet의 컬럼 정보를 획득한다.
*
* @param resultSetMetaData
* @return dbColumns
* @throws SQLException
*/
List<DbColumn> getDbColumns(ResultSetMetaData resultSetMetaData) throws SQLException;
}

View File

@@ -0,0 +1,21 @@
package com.nexacro.spring.dao;
import java.sql.Connection;
import javax.sql.DataSource;
/**
* 데이터베이스 별 타입처리를 하기 위한 {@code Dbms}를 획득하기 위한 인터페이스이다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public interface DbmsProvider {
Dbms getDbms(DataSource dataSource);
Dbms getDbms(Connection conn);
}

View File

@@ -0,0 +1,20 @@
package com.nexacro.spring.dao;
import com.nexacro.xapi.data.datatype.DataTypeFactory;
/**
* Dbms의 기본 구현체이며, {@link DataTypeFactory}에 명시된 기본형태의 타입 변환을 제공한다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public class DefaultDbms extends AbstractDbms {
@Override
public void handleColumnDataType(DbColumn column) {
}
}

View File

@@ -0,0 +1,36 @@
package com.nexacro.spring.dao;
/**
* DataAccess 데이터 분할 전송시 발생하는 예외를 의미한다.
*
* @author Park SeongMin
* @since 10.05.2015
* @version 1.0
*
*/
public class NexacroFirstRowException extends RuntimeException {
/**
* 메시지를 가지는 생성자이다.
*
* @param message
* 메시지
*/
public NexacroFirstRowException(String message) {
super(message);
}
/**
* 메시지와 원천(cause) 예외를 가지는 생성자이다.
*
* @param message
* 메시지
* @param cause
* 원천 예외
*/
public NexacroFirstRowException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -0,0 +1,22 @@
package com.nexacro.spring.dao.dbms;
import com.nexacro.spring.dao.AbstractDbms;
import com.nexacro.spring.dao.DbColumn;
/**
* <p>Hsql에서 사용되는 데이터 타입과 <code>DataSet</code>의 데이터 타입간의 매핑 정보를 제공한다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public class Hsql extends AbstractDbms {
@Override
public void handleColumnDataType(DbColumn columnInfos) {
}
}

View File

@@ -0,0 +1,43 @@
package com.nexacro.spring.dao.dbms;
import com.nexacro.spring.dao.AbstractDbms;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.xapi.data.datatype.PlatformDataType;
/**
* <p>Mssql에서 사용되는 데이터 타입과 <code>DataSet</code>의 데이터 타입간의 매핑 정보를 제공한다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public class Mssql extends AbstractDbms {
@Override
public void handleColumnDataType(DbColumn column) {
if (column==null) {
return;
}
if ("xml".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
} else if ("image".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.BLOB);
} else if ("int".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.INT);
} else if (column.getVendorsTypeName().endsWith("time")) { //datetime, smalldatetime
column.setDataType(PlatformDataType.DATE_TIME);
} else if (column.getVendorsTypeName().startsWith("time")) { //datetime2, datetimeoffset
column.setDataType(PlatformDataType.DATE_TIME);
} else if (column.getVendorsTypeName().endsWith("money")){ //money, smallmoney
column.setDataType(PlatformDataType.BIG_DECIMAL);
} else if (column.getVendorsTypeName().endsWith("text")){ //text, ntext
column.setDataType(PlatformDataType.STRING);
}
}
}

View File

@@ -0,0 +1,31 @@
package com.nexacro.spring.dao.dbms;
import com.nexacro.spring.dao.AbstractDbms;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.xapi.data.datatype.PlatformDataType;
/**
* <p>Mysql에서 사용되는 데이터 타입과 <code>DataSet</code>의 데이터 타입간의 매핑 정보를 제공한다.
*
* @author Park SeongMin
* @since 08.12.2015
* @version 1.0
*/
public class Mysql extends AbstractDbms {
@Override
public void handleColumnDataType(DbColumn column) {
if (column == null) {
return;
}
if ("MEDIUMINT".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.INT);
} else if ("DATETIME".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.DATE_TIME);
} else if ("YEAR".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.DATE);
}
}
}

View File

@@ -0,0 +1,86 @@
package com.nexacro.spring.dao.dbms;
import com.nexacro.spring.dao.AbstractDbms;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.xapi.data.datatype.PlatformDataType;
/**
* <p>Oracle에서 사용되는 데이터 타입과 <code>DataSet</code>의 데이터 타입간의 매핑 정보를 제공한다.
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public class Oracle extends AbstractDbms {
/*
* @see com.nexacro.spring.dao.Dbms#handleColumnInfo(com.nexacro.spring.dao.DbColumnInfo)
*/
@Override
public void handleColumnDataType(DbColumn column) {
if(column==null) {
return;
}
if("VARCHAR2".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
} else if ("NUMBER".equals(column.getVendorsTypeName())) {
if (Double.class.getName().equals(column.getTypeJavaClassName())){
column.setDataType(PlatformDataType.DOUBLE);
} else if (java.math.BigDecimal.class.getName().equals(column.getTypeJavaClassName())) {
// no option..
if(column.getScale() > 0){
column.setDataType(PlatformDataType.BIG_DECIMAL);
} else {
column.setDataType(PlatformDataType.FLOAT);
}
} else {
column.setDataType(PlatformDataType.INT);
}
} else if ("LONG".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.LONG);
} else if(column.getVendorsTypeName().startsWith("INTERVAL YEAR")) {
column.setDataType(PlatformDataType.DATE_TIME);
} else if(column.getVendorsTypeName().startsWith("INTERVAL DAY")) {
column.setDataType(PlatformDataType.DATE_TIME);
} else if("BFILE".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.BLOB);
} else if("BINARY_FLOAT".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.FLOAT);
} else if("BINARY_DOUBLE".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.DOUBLE);
} else if(column.getVendorsTypeName().startsWith("TIMESTAMP")) {
column.setDataType(PlatformDataType.DATE_TIME);
column.setSize(6);
column.setDecimalDigit(null);
} else if("NVARCHAR2".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
column.setSize(column.getSize()/2);
} else if("NVARCHAR".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
column.setSize(column.getSize()/2);
} else if("NCHAR".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
column.setSize(column.getSize()/2);
} else if("NVARCHAR".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
column.setSize(column.getSize()/2);
} else if("SYS.XMLTYPE".equals(column.getVendorsTypeName())) {
column.setDataType(PlatformDataType.STRING);
} else if(column.getVendorsTypeName().endsWith("ROWID")) { // for ROWID 1111, UROWID 1111
column.setDataType(PlatformDataType.INT);
} else if(column.getVendorsTypeName().endsWith("NCLOB")) { // for NCLOB 1111
column.setDataType(PlatformDataType.STRING);
}
if(column.getVendorsTypeName().indexOf("(")>0) {
column.setVendorsTypeName(column.getVendorsTypeName().replaceAll("\\(.*\\)", ""));
}
}
}

View File

@@ -0,0 +1,50 @@
package com.nexacro.spring.dao.dbms;
import com.nexacro.spring.dao.AbstractDbms;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.xapi.data.datatype.PlatformDataType;
/**
* <p>Tibero에서 사용되는 데이터 타입과 <code>DataSet</code>의 데이터 타입간의 매핑 정보를 제공한다.
*
* @author Park SeongMin
* @since 09.23.2015
* @version 1.0
* @see
*/
public class Tibero extends AbstractDbms {
// Tibero RDBMS JDBC 개발자 안내서
// http://www.tmaxdata.com/img/service/pdf/Tibero%204%20SP1%20JDBC%20Development%20Guide_v2.1.4.pdf
@Override
public void handleColumnDataType(DbColumn column) {
if (column == null) {
return;
}
String vendorsTypeName = column.getVendorsTypeName();
// 모든 numeric 타입이 number로 반환되며, value는 BigDecimal로 처리된다..
if("NUMBER".equals(vendorsTypeName)) {
String typeJavaClassName = column.getTypeJavaClassName();
if("java.math.BigDecimal".equals(typeJavaClassName)) {
column.setDataType(PlatformDataType.BIG_DECIMAL);
}
// int precision = column.getPrecision();
// int scale = column.getScale();
} else if ("GEOMETRY".equals(vendorsTypeName)) {
column.setDataType(PlatformDataType.BLOB);
// } else if ("INTERVAL YEAR TO MONTH".equals(column.getVendorsTypeName())) {
// column.setDataType(PlatformDataType.UNDEFINED);
// } else if ("INTERVAL DAY TO SECOND".equals(column.getVendorsTypeName())) {
// column.setDataType(PlatformDataType.UNDEFINED);
} else if ("ROWID".equals(vendorsTypeName)) {
column.setDataType(PlatformDataType.UNDEFINED);
}
// 그 외 tibero 타입의 경우 자동 변환은 수행하지 않는다.
}
}

View File

@@ -0,0 +1,118 @@
package com.nexacro.spring.dao.ibatis;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.dao.DataAccessException;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.nexacro.spring.dao.Dbms;
import com.nexacro.spring.dao.DbmsProvider;
import com.nexacro.spring.dao.ibatis.NexacroIbatisMetaDataProvider;
import com.nexacro.spring.dao.ibatis.SqlMapClientRowHandler;
import com.nexacro.spring.data.NexacroFirstRowHandler;
import egovframework.rte.psl.dataaccess.EgovAbstractDAO;
import egovframework.rte.psl.orm.ibatis.SqlMapClientTemplate;
/**
* <p>nexacro platform 연동 시 추가적인 기능지원을 위한 EgovAbstractDAO를 확장한 클래스이다.
*
* @author Park SeongMin
* @since 08.06.2015
* @version 1.0
* @see
*/
public class NexacroIbatisAbstractDAO extends EgovAbstractDAO {
// @Resource(name = "ibatisMetaDataProvider")
// private NexacroIbatisMetaDataProvider ibatisMetaDataProvider;
@Resource(name = "dbmsProvider")
private DbmsProvider dbmsProvider;
/**
* 입력받은 값을 batch로 데이터를 삽입한다.
* @param queryId
* @param batchArgs
* @return batch count
* @throws SQLException
*/
public int batch(String queryId, List batchArgs) throws SQLException {
SqlMapClient sqlMapClient = getSqlMapClient();
sqlMapClient.startBatch();
for (Object args : batchArgs) {
sqlMapClient.insert(queryId, args);
}
return sqlMapClient.executeBatch();
}
@Override
public List<?> list(String queryId) {
List<?> list = super.list(queryId);
if (list == null || list.size() == 0) {
list = getNexacroMetaData(queryId, null, list);
}
return list;
}
@Override
public List<?> list(String queryId, Object parameterObject) {
List<?> list = super.list(queryId, parameterObject);
if (list == null || list.size() == 0) {
list = getNexacroMetaData(queryId, parameterObject, list);
}
return list;
}
@Override
public List<?> list(String queryId, int skipResults, int maxResults) {
List<?> list = super.list(queryId, skipResults, maxResults);
if (list == null || list.size() == 0) {
list = getNexacroMetaData(queryId, null, list);
}
return list;
}
@Override
public List<?> list(String queryId, Object parameterObject,
int skipResults, int maxResults) {
List<?> list = super.list(queryId, parameterObject, skipResults, maxResults);
if (list == null || list.size() == 0) {
list = getNexacroMetaData(queryId, parameterObject, list);
}
return list;
}
@Override
public List<?> listWithPaging(String queryId, Object parameterObject,
int pageIndex, int pageSize) {
List<?> listWithPaging = super.listWithPaging(queryId, parameterObject, pageIndex, pageSize);
if (listWithPaging == null || listWithPaging.size() == 0) {
listWithPaging = getNexacroMetaData(queryId, parameterObject, listWithPaging);
}
return listWithPaging;
}
private List<?> getNexacroMetaData(String queryId, Object parameterObject, List originalResult) {
// performance overhead..
// return (List<?>) ibatisMetaDataProvider.doGetQueryMetaData(this, new Object[]{queryId, parameterObject});
return getSqlMapClientTemplateDelegator().queryForList(queryId, parameterObject);
}
public SqlMapClientTemplate getSqlMapClientTemplateDelegator() throws DataAccessException {
SqlMapClientTemplate clientTemplate = super.getSqlMapClientTemplate();
Dbms dbms = dbmsProvider.getDbms(clientTemplate.getDataSource());
return new SqlMapClientTemplateDelegator(clientTemplate, dbms);
}
public void queryWithFirstRowHandler(String queryId, Object parameterObject, NexacroFirstRowHandler firstRowHandler, String sendName, int firstRowCount) {
SqlMapClientRowHandler rowHandler = new SqlMapClientRowHandler(firstRowHandler, sendName, firstRowCount);
getSqlMapClientTemplate().queryWithRowHandler(queryId, parameterObject, rowHandler);
// send remain data..
rowHandler.sendRemainData();
}
}

View File

@@ -0,0 +1,272 @@
package com.nexacro.spring.dao.ibatis;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapExecutor;
import com.ibatis.sqlmap.client.SqlMapSession;
import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
import com.ibatis.sqlmap.engine.mapping.result.ResultMapping;
import com.ibatis.sqlmap.engine.mapping.sql.Sql;
import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;
import com.ibatis.sqlmap.engine.scope.SessionScope;
import com.ibatis.sqlmap.engine.scope.StatementScope;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.spring.dao.DbMetaDataGathererUtil;
import com.nexacro.spring.dao.Dbms;
import com.nexacro.spring.data.metadata.NexacroMetaData;
import com.nexacro.spring.data.metadata.support.MapMetaData;
import com.nexacro.spring.data.metadata.support.UnsupportedMetaData;
import com.nexacro.spring.data.support.NexacroConverterHelper;
import com.nexacro.xapi.data.DataTypes;
import com.nexacro.xapi.data.datatype.DataType;
/**
* <p>SqlMapClientCallback interface implements.. (runtime 시 proxy 처리되어 사용된다.)
* <p>Spring 혹은 egovframework 내에서 사용되는 interface가 다르기 때문에..
*
* @author Park SeongMin
* @since 08.07.2015
* @version 1.0
* @see
*/
public class NexacroIbatisMetaDataGatherer implements InvocationHandler {
//public class SqlMapClientCallbackImpl {
private Dbms dbms;
private SqlMapClient sqlMapClient;
private String statementName;
private Object parameterObject;
public NexacroIbatisMetaDataGatherer(Dbms dbms, SqlMapClient sqlMapClient, String statementName, Object parameterObject) {
this.dbms = dbms;
this.sqlMapClient = sqlMapClient;
this.statementName = statementName;
this.parameterObject = parameterObject;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if("doInSqlMapClient".equals(method.getName())) {
return doInSqlMapClient((SqlMapExecutor) args[0]);
}
return null;
// return method.invoke(this, args);
}
public NexacroMetaData doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
// executor is proxied (for able framework)
NexacroMetaData nexacroMetaData = null;
try {
SqlMapSession session = (SqlMapSession)executor;
Connection currentConnection = session.getCurrentConnection();
Method method = sqlMapClient.getClass().getMethod("getMappedStatement", new Class[]{String.class});
MappedStatement mappedStatement = (MappedStatement) method.invoke(sqlMapClient, new Object[]{statementName});
//ThreadLocal를 통해서 세션을 정의 (sqlMapClient is proxy..)
SessionScope sessionScope = new SessionScope();
// sessionScope.setSqlMapClient(sqlMapClient);
// sessionScope.setSqlMapExecutor(sqlMapClient);
// sessionScope.setSqlMapTxMgr(sqlMapClient);
StatementScope statementScope = new StatementScope(sessionScope);
//다이나믹 쿼리가 적용
mappedStatement.initRequest(statementScope);
//sql을 추출
Sql sql = mappedStatement.getSql();
ParameterMap parameterMap = sql.getParameterMap(statementScope, parameterObject);
// resultMapping의 상세 스펙을 확인하여야 한다.
ResultMap resultMap = mappedStatement.getResultMap();
if(!requireExecuteQuery(resultMap)) {
return DbMetaDataGathererUtil.generateMetaDataFromClass(resultMap.getResultClass());
}
// for only map
statementScope.setParameterMap(parameterMap);
statementScope.setResultMap(resultMap);
Object[] parameters = parameterMap.getParameterObjectValues(statementScope, parameterObject);
String strSql = sql.getSql(statementScope, parameterObject);
// execute query...
nexacroMetaData = executeQuery(statementScope, currentConnection, strSql, parameters);
sql.cleanup(statementScope);
} catch(Exception e) {
Logger logger = LoggerFactory.getLogger(this.getClass());
if(logger.isErrorEnabled()) {
logger.error("failed to query the metadata information. statement="+statementName, e);
}
}
if(nexacroMetaData == null) {
nexacroMetaData = new UnsupportedMetaData(null);
}
return nexacroMetaData;
}
// ibatis SqlExecutor executeQuery code
private MapMetaData executeQuery(StatementScope statementScope, Connection conn, String sqlString, Object[] parameters) throws Exception {
PreparedStatement ps = null;
ResultSet rs = null;
MapMetaData generateMapMetaData = null;
try {
Integer rsType = statementScope.getStatement().getResultSetType();
if (rsType != null) {
ps = prepareStatement(statementScope.getSession(), conn, sqlString, rsType);
} else {
ps = prepareStatement(statementScope.getSession(), conn, sqlString);
}
setStatementTimeout(statementScope.getStatement(), ps);
Integer fetchSize = statementScope.getStatement().getFetchSize();
if (fetchSize != null) {
ps.setFetchSize(fetchSize.intValue());
}
// set parameters..
statementScope.getParameterMap().setParameters(statementScope, ps, parameters);
// execute query
rs = ps.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
// get column information from ResultSetMetaData
List<DbColumn> dbColumns = dbms.getDbColumns(metaData);
ResultMap resultMap = statementScope.getResultMap();
// mapping MetaData and Ibatis ResultMap
mappingDbColumnAndResultMappings(dbColumns, resultMap);
generateMapMetaData = DbMetaDataGathererUtil.generateMetaDataFromDbColumns(dbColumns);
} catch(Exception e) {
throw e;
} finally {
if(rs != null) { try { rs.close(); } catch (SQLException e) {} };
if(ps != null) { try { ps.close(); } catch (SQLException e) {} };
}
return generateMapMetaData;
}
private void mappingDbColumnAndResultMappings(List<DbColumn> dbColumns, ResultMap resultMap) {
ResultMapping[] resultMappings = resultMap.getResultMappings();
if(resultMappings == null) {
return;
}
// ibatis에서 실행된 결과를 cache 해도 resultClass를 선언하지 않을 경우 데이터 타입을 확인할 수 없다.
// 여기서는 ResultMap으로 선언된 경우에만 처리하도록 한다.
int size = dbColumns.size();
for(int i=size-1; i>=0; i--) {
DbColumn dbColumn = dbColumns.get(i);
String name = dbColumn.getName();
boolean existColumn = false;
for(ResultMapping mapping: resultMappings) {
String columnName = mapping.getColumnName(); // db column
String propertyName = mapping.getPropertyName();
if(name.equals(columnName) || name.equals(propertyName)) {
if(propertyName != null) {
dbColumn.setName(propertyName);
}
Class javaType = mapping.getJavaType();
if(javaType != null) {
DataType dataType = NexacroConverterHelper.getDataType(javaType);
if(dataType.getType() != DataTypes.UNDEFINED) {
dbColumn.setDataType(dataType);
}
}
existColumn = true;
break;
}
}
// remove data for result mapping
if(!existColumn) {
dbColumns.remove(i);
}
}
}
private void setStatementTimeout(MappedStatement mappedStatement, Statement statement)
throws SQLException {
if (mappedStatement.getTimeout() != null) {
statement.setQueryTimeout(mappedStatement.getTimeout().intValue());
}
}
private PreparedStatement prepareStatement(SessionScope sessionScope, Connection conn, String sql, Integer rsType) throws SQLException {
// not cached data
PreparedStatement ps = conn.prepareStatement(sql);
return ps;
// SqlMapExecutorDelegate delegate = ((SqlMapClientImpl) sessionScope.getSqlMapExecutor()).getDelegate();
// if (sessionScope.hasPreparedStatementFor(sql)) {
// return sessionScope.getPreparedStatement((sql));
// } else {
// PreparedStatement ps = conn.prepareStatement(sql, rsType.intValue(), ResultSet.CONCUR_READ_ONLY);
// sessionScope.putPreparedStatement(delegate, sql, ps);
// return ps;
// }
}
private PreparedStatement prepareStatement(SessionScope sessionScope, Connection conn, String sql) throws SQLException {
// not cached data
PreparedStatement ps = conn.prepareStatement(sql);
return ps;
}
private boolean requireExecuteQuery(ResultMap resultMap) {
// Map이 아니라면 실행하지 않는다. XML, primitive 등 은 처리하지 않도록 한다.
Class resultClass = resultMap.getResultClass();
if(Map.class.isAssignableFrom(resultClass)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,183 @@
package com.nexacro.spring.dao.ibatis;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.aspectj.lang.JoinPoint.StaticPart;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.nexacro.spring.dao.Dbms;
import com.nexacro.spring.dao.DbmsProvider;
import com.nexacro.spring.util.ReflectionUtil;
/**
* Spring 혹은 EgovFramework의 ibatis 처리 시 메타 데이터를 획득하기 위한 class이다.
* reflection을 이용하여 메타데이터를 획득한다.
*
* @author Park SeongMin
* @since 10.12.2015
* @version 1.0
* @see
*
*/
public class NexacroIbatisMetaDataProvider {
/*
AOP를 사용할 경우 설정
<bean id="ibatisMetaDataProvider" class="com.nexacro.spring.dao.ibatis.NexacroIbatisMetaDataProvider" >
<property name="dbmsProvider" ref="dbmsProvider" />
</bean>
<aop:aspectj-autoproxy proxy-target-class="true"/>
<aop:config >
<aop:pointcut id="ibatisSelectPointCut" expression="execution(* nexacro..service.dao.ibatis..DAO*.list*(..))" />
<aop:aspect ref="ibatisMetaDataProvider" >
<aop:around method="getQueryMetaData" pointcut-ref="ibatisSelectPointCut"/>
</aop:aspect>
</aop:config>
*/
private static String SPRING_INTERFACE_NAME = "org.springframework.orm.ibatis.SqlMapClientCallback";
private static String EGOVFRAMEWORK_INTERFACE_NAME = "egovframework.rte.psl.orm.ibatis.SqlMapClientCallback";
private Logger logger = LoggerFactory.getLogger(NexacroIbatisMetaDataProvider.class);
private DbmsProvider dbmsProvider;
public DbmsProvider getDbmsProvider() {
return dbmsProvider;
}
public void setDbmsProvider(DbmsProvider dbmsProvider) {
this.dbmsProvider = dbmsProvider;
}
/**
* 쿼리를 실행하고 조회 된 결과가 0건일 경우 메타데이터 정보를 획득한다.
* @return
*/
public Object getQueryMetaData(ProceedingJoinPoint pjp) throws Throwable{
Object target = pjp.getTarget();
StaticPart staticPart = pjp.getStaticPart();
Object result = pjp.proceed();
if(result instanceof List) {
List listResult = (List) result;
if(listResult.size() == 0) {
return doGetQueryMetaData(pjp.getTarget(), pjp.getArgs());
}
}
return result;
}
// EgovAbstractDAO를 상속받아 처리 할 경우 superclass 에 정의 된 list 형태는 AOP가 적용되지 않는다.
// framework 별 sample 구성 시 추상 클래스를 제공하도록 하자. spring의 경우 aop를 바로 적용하도록 하자.
public Object doGetQueryMetaData(Object daoObject, Object[] arguments) {
if(arguments == null || arguments.length < 2) {
return new ArrayList();
}
Class<?> daoClass = daoObject.getClass();
String statementName = (String) arguments[0];
Object parameterObject = arguments[1];
// reflection..
Object sqlMapClientTemplate = null;
Object sqlMapClientCallback = null;
Method executeMethod = null;
try {
// TODO 전부 Null 처리 해야 한다.
// find sqlMapClientTemplate in Dao
Method getSqlMapClientTemplateMethod = ReflectionUtil.getMethod(daoClass, "getSqlMapClientTemplate", new Class[]{});
if(getSqlMapClientTemplateMethod == null) {
throw new UnsupportedOperationException("getSqlMapClientTemplate method is null.");
}
sqlMapClientTemplate = getSqlMapClientTemplateMethod.invoke(daoObject, null);
// find dataSource in sqlMapClientTemplate
Method getDataSourceMethod = ReflectionUtil.getMethod(sqlMapClientTemplate.getClass(), "getDataSource", new Class[]{});
if(getDataSourceMethod == null) {
throw new UnsupportedOperationException("getDataSource method is null.");
}
DataSource dataSource = (DataSource) getDataSourceMethod.invoke(sqlMapClientTemplate, null);
// get dbms
Dbms dbms = dbmsProvider.getDbms(dataSource);
// find sqlMapClient in dao
Method getSqlMapClientMethod = ReflectionUtil.getMethod(daoClass, "getSqlMapClient", new Class[]{});
if(getSqlMapClientMethod == null) {
throw new UnsupportedOperationException("getSqlMapClient method is null.");
}
SqlMapClient sqlMapClient = (SqlMapClient) getSqlMapClientMethod.invoke(daoObject, null);
Class<?> findedSqlMapClientCallbackInterface = findSqlMapClientCallbackInterface();
sqlMapClientCallback = createProxiedSqlMapClientCallback(dbms, sqlMapClient, statementName, parameterObject, findedSqlMapClientCallbackInterface);
// find execute method in SqlMapClientTemplate
executeMethod = ReflectionUtil.getMethod(sqlMapClientTemplate.getClass(), "execute", findedSqlMapClientCallbackInterface);
} catch(Throwable e) {
logger.error("unsupported getting metadata. e={}", e.getMessage());
return new ArrayList();
}
// execute..
Object queryMetaData = null;
try {
queryMetaData = executeMethod.invoke(sqlMapClientTemplate, sqlMapClientCallback);
} catch(Throwable e) {
logger.error("an error has occurred while querying the metadata. e={}", e.getMessage());
return new ArrayList();
}
return queryMetaData;
}
private Object createProxiedSqlMapClientCallback(Dbms dbms, SqlMapClient sqlMapClient, String statementName, Object parameterObject, Class<?> findedSqlMapClientCallbackInterface) {
ClassLoader classLoader = this.getClass().getClassLoader();
InvocationHandler sqlMapClientCallbackImpl = new NexacroIbatisMetaDataGatherer(dbms, sqlMapClient, statementName, parameterObject);
return Proxy.newProxyInstance(classLoader, new Class[]{findedSqlMapClientCallbackInterface}, sqlMapClientCallbackImpl);
}
private Class<?> findSqlMapClientCallbackInterface() {
Class<?> sqlMapClient = null;
try {
sqlMapClient = Class.forName(SPRING_INTERFACE_NAME);
} catch (ClassNotFoundException e) {
}
if (sqlMapClient == null) {
try {
sqlMapClient = Class.forName(EGOVFRAMEWORK_INTERFACE_NAME);
} catch (ClassNotFoundException e) {
}
if(sqlMapClient == null) {
throw new UnsupportedOperationException("does not exist SqlMapClientCallback interface. unsupported getting metadata");
}
}
return sqlMapClient;
}
}

View File

@@ -0,0 +1,119 @@
package com.nexacro.spring.dao.ibatis;
import java.util.Map;
import com.ibatis.sqlmap.client.event.RowHandler;
import com.nexacro.spring.dao.NexacroFirstRowException;
import com.nexacro.spring.data.NexacroFirstRowHandler;
import com.nexacro.spring.data.convert.NexacroConvertException;
import com.nexacro.spring.data.support.ObjectToDataSetConverter;
import com.nexacro.xapi.data.DataSet;
import com.nexacro.xapi.tx.PlatformException;
/**
*
* ibatis를 사용하여 nexacro platform으로 대용량 데이터를 전송하려고 할때 사용되는 RowHandler 이다.
* <p>아래와 같은 형식으로 처리하며, 쿼리가 실행한 후 남아 있는 데이터가 존재할 수 있기 때문에 전송되지 않은 데이터를 전송한다.
*
* <pre>
SqlMapClientRowHandler rowHandler = new SqlMapClientRowHandler(firstRowHandler, sendName, firstRowCount);
getSqlMapClientTemplate().queryWithRowHandler("largeDataDAO.selectLargeData", null, rowHandler);
// send remain data..
rowHandler.sendRemainData();
*
* </pre>
*
* @author Park SeongMin
* @since 08.17.2015
* @version 1.0
* @see
*/
public class SqlMapClientRowHandler implements RowHandler {
private static final int DEFAULT_FIRSTROW_COUNT = 1000;
private ObjectToDataSetConverter converter;
private NexacroFirstRowHandler firstRowHandler;
private String resultName;
private int firstRowCount;
private DataSet currentDataSet;
private int currentCount = 0;
public SqlMapClientRowHandler(NexacroFirstRowHandler firstRowHandler, String resultName, int firstRowCount) {
this.firstRowHandler = firstRowHandler;
this.resultName = resultName;
this.firstRowCount = firstRowCount;
if(this.firstRowCount <= 0) {
this.firstRowCount = DEFAULT_FIRSTROW_COUNT;
}
// TODO getting NexacroConverterFactory.getConverter();
this.converter = new ObjectToDataSetConverter();
}
@Override
public void handleRow(Object valueObject) {
try {
prepareDataSet(valueObject);
addRow(valueObject);
currentCount++;
if(currentCount % firstRowCount == 0) {
sendDataSet();
}
} catch (PlatformException e) {
throw new NexacroFirstRowException("could not send data. e="+e.getMessage(), e);
} catch (NexacroConvertException e) {
throw new NexacroFirstRowException("object to dataset convert failed. e="+e.getMessage(), e);
}
}
/**
* 데이터 분할 전송 후 남아 있는 데이터를 전송한다.
*/
public void sendRemainData() {
// send remain data..
DataSet remainDataSet = getDataSet();
if(remainDataSet != null && remainDataSet.getRowCount() > 0) {
try {
firstRowHandler.sendDataSet(remainDataSet);
} catch (PlatformException e) {
// throw new NexacroException("could not send remain data. query="+queryId+" e="+e.getMessage(), e);
throw new NexacroFirstRowException("could not send remain data. e="+e.getMessage(), e);
}
}
}
private void sendDataSet() throws PlatformException {
firstRowHandler.sendDataSet(currentDataSet);
}
private void addRow(Object valueObject) throws NexacroConvertException {
if(valueObject instanceof Map) {
converter.addRowIntoDataSet(currentDataSet, (Map) valueObject);
} else {
converter.addRowIntoDataSet(currentDataSet, valueObject);
}
}
private void prepareDataSet(Object valueObject) throws NexacroConvertException {
if(this.currentDataSet != null) {
return;
}
this.currentDataSet = new DataSet(resultName != null? resultName: "RESULT0");
if(valueObject instanceof Map) {
converter.addColumnIntoDataSet(currentDataSet, (Map) valueObject);
} else {
converter.addColumnIntoDataSet(currentDataSet, valueObject);
}
}
public DataSet getDataSet() {
return this.currentDataSet;
}
}

View File

@@ -0,0 +1,380 @@
package com.nexacro.spring.dao.ibatis;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.support.SQLExceptionTranslator;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.event.RowHandler;
import com.nexacro.spring.dao.Dbms;
import egovframework.rte.psl.orm.ibatis.SqlMapClientCallback;
import egovframework.rte.psl.orm.ibatis.SqlMapClientTemplate;
/**
* <p>SqlMapClientTemplate의 {@code queryForList(...)} 시 메타데이터 정보를 획득하기 위한 Delegator이다.
* <p>Spring의 Callback pattern을 이용하여 처리되며, Runtime시 SqlMapClientCallback interface가 정의된다.
*
* @author Park SeongMin
* @since 08.06.2015
* @version 1.0
* @see
*/
@Deprecated
public class SqlMapClientTemplateDelegator extends SqlMapClientTemplate {
private SqlMapClientTemplate delegator;
private Dbms dbms;
public SqlMapClientTemplateDelegator(SqlMapClientTemplate template, Dbms dbms) {
this.delegator = template;
this.dbms = dbms;
}
public List queryForList(String statementName) throws DataAccessException {
return getNexacroMetaData(statementName, null);
}
public List queryForList(final String statementName, final Object parameterObject) throws DataAccessException {
return getNexacroMetaData(statementName, parameterObject);
}
public List queryForList(String statementName, int skipResults, int maxResults) throws DataAccessException {
return getNexacroMetaData(statementName, null);
}
public List queryForList(String statementName, Object parameterObject, int skipResults, int maxResults)
throws DataAccessException {
return getNexacroMetaData(statementName, parameterObject);
}
public List getNexacroMetaData(final String statementName, final Object parameterObject) throws DataAccessException {
SqlMapClientCallback<?> createProxiedSqlMapClientCallback = createProxiedSqlMapClientCallback(dbms, getSqlMapClient(), statementName, parameterObject, SqlMapClientCallback.class);
return (List) execute(createProxiedSqlMapClientCallback);
}
private SqlMapClientCallback<?> createProxiedSqlMapClientCallback(Dbms dbms, SqlMapClient sqlMapClient, String statementName, Object parameterObject, Class<?> sqlMapClientCallbackInterface) {
ClassLoader classLoader = this.getClass().getClassLoader();
InvocationHandler sqlMapClientCallbackImpl = new NexacroIbatisMetaDataGatherer(dbms, sqlMapClient, statementName, parameterObject);
return (SqlMapClientCallback<?>) Proxy.newProxyInstance(classLoader, new Class[]{sqlMapClientCallbackInterface}, sqlMapClientCallbackImpl);
}
/***************************************************************************************/
/******************************** delegated method ************************************/
/***************************************************************************************/
/**
* @param dataSource
* @see org.springframework.jdbc.support.JdbcAccessor#setDataSource(javax.sql.DataSource)
*/
public void setDataSource(DataSource dataSource) {
delegator.setDataSource(dataSource);
}
/**
* @return
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return delegator.hashCode();
}
/**
* @param dbName
* @see org.springframework.jdbc.support.JdbcAccessor#setDatabaseProductName(java.lang.String)
*/
public void setDatabaseProductName(String dbName) {
delegator.setDatabaseProductName(dbName);
}
/**
* @param exceptionTranslator
* @see org.springframework.jdbc.support.JdbcAccessor#setExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)
*/
public void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator) {
delegator.setExceptionTranslator(exceptionTranslator);
}
/**
* @return
* @see org.springframework.jdbc.support.JdbcAccessor#getExceptionTranslator()
*/
public SQLExceptionTranslator getExceptionTranslator() {
return delegator.getExceptionTranslator();
}
/**
* @param lazyInit
* @see org.springframework.jdbc.support.JdbcAccessor#setLazyInit(boolean)
*/
public void setLazyInit(boolean lazyInit) {
delegator.setLazyInit(lazyInit);
}
/**
* @param obj
* @return
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
return delegator.equals(obj);
}
/**
* @return
* @see org.springframework.jdbc.support.JdbcAccessor#isLazyInit()
*/
public boolean isLazyInit() {
return delegator.isLazyInit();
}
/**
* @param sqlMapClient
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)
*/
public void setSqlMapClient(SqlMapClient sqlMapClient) {
delegator.setSqlMapClient(sqlMapClient);
}
/**
* @return
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#getSqlMapClient()
*/
public SqlMapClient getSqlMapClient() {
return delegator.getSqlMapClient();
}
/**
* @return
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#getDataSource()
*/
public DataSource getDataSource() {
return delegator.getDataSource();
}
/**
*
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#afterPropertiesSet()
*/
public void afterPropertiesSet() {
delegator.afterPropertiesSet();
}
/**
* @param <T>
* @param action
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#execute(org.springframework.orm.ibatis.SqlMapClientCallback)
*/
public <T> T execute(SqlMapClientCallback<T> action) throws DataAccessException {
return delegator.execute(action);
}
/**
* @param action
* @return
* @throws DataAccessException
* @deprecated
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#executeWithListResult(org.springframework.orm.ibatis.SqlMapClientCallback)
*/
public List executeWithListResult(SqlMapClientCallback<List> action) throws DataAccessException {
return delegator.executeWithListResult(action);
}
/**
* @param action
* @return
* @throws DataAccessException
* @deprecated
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#executeWithMapResult(org.springframework.orm.ibatis.SqlMapClientCallback)
*/
public Map executeWithMapResult(SqlMapClientCallback<Map> action) throws DataAccessException {
return delegator.executeWithMapResult(action);
}
/**
* @param statementName
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryForObject(java.lang.String)
*/
public Object queryForObject(String statementName) throws DataAccessException {
return delegator.queryForObject(statementName);
}
/**
* @param statementName
* @param parameterObject
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryForObject(java.lang.String, java.lang.Object)
*/
public Object queryForObject(String statementName, Object parameterObject) throws DataAccessException {
return delegator.queryForObject(statementName, parameterObject);
}
/**
* @return
* @see java.lang.Object#toString()
*/
public String toString() {
return delegator.toString();
}
/**
* @param statementName
* @param parameterObject
* @param resultObject
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryForObject(java.lang.String, java.lang.Object, java.lang.Object)
*/
public Object queryForObject(String statementName, Object parameterObject, Object resultObject)
throws DataAccessException {
return delegator.queryForObject(statementName, parameterObject, resultObject);
}
/**
* @param statementName
* @param rowHandler
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryWithRowHandler(java.lang.String, com.ibatis.sqlmap.client.event.RowHandler)
*/
public void queryWithRowHandler(String statementName, RowHandler rowHandler) throws DataAccessException {
delegator.queryWithRowHandler(statementName, rowHandler);
}
/**
* @param statementName
* @param parameterObject
* @param rowHandler
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryWithRowHandler(java.lang.String, java.lang.Object, com.ibatis.sqlmap.client.event.RowHandler)
*/
public void queryWithRowHandler(String statementName, Object parameterObject, RowHandler rowHandler)
throws DataAccessException {
delegator.queryWithRowHandler(statementName, parameterObject, rowHandler);
}
/**
* @param statementName
* @param parameterObject
* @param keyProperty
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryForMap(java.lang.String, java.lang.Object, java.lang.String)
*/
public Map queryForMap(String statementName, Object parameterObject, String keyProperty) throws DataAccessException {
return delegator.queryForMap(statementName, parameterObject, keyProperty);
}
/**
* @param statementName
* @param parameterObject
* @param keyProperty
* @param valueProperty
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#queryForMap(java.lang.String, java.lang.Object, java.lang.String, java.lang.String)
*/
public Map queryForMap(String statementName, Object parameterObject, String keyProperty, String valueProperty)
throws DataAccessException {
return delegator.queryForMap(statementName, parameterObject, keyProperty, valueProperty);
}
/**
* @param statementName
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#insert(java.lang.String)
*/
public Object insert(String statementName) throws DataAccessException {
return delegator.insert(statementName);
}
/**
* @param statementName
* @param parameterObject
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#insert(java.lang.String, java.lang.Object)
*/
public Object insert(String statementName, Object parameterObject) throws DataAccessException {
return delegator.insert(statementName, parameterObject);
}
/**
* @param statementName
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#update(java.lang.String)
*/
public int update(String statementName) throws DataAccessException {
return delegator.update(statementName);
}
/**
* @param statementName
* @param parameterObject
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#update(java.lang.String, java.lang.Object)
*/
public int update(String statementName, Object parameterObject) throws DataAccessException {
return delegator.update(statementName, parameterObject);
}
/**
* @param statementName
* @param parameterObject
* @param requiredRowsAffected
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#update(java.lang.String, java.lang.Object, int)
*/
public void update(String statementName, Object parameterObject, int requiredRowsAffected)
throws DataAccessException {
delegator.update(statementName, parameterObject, requiredRowsAffected);
}
/**
* @param statementName
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#delete(java.lang.String)
*/
public int delete(String statementName) throws DataAccessException {
return delegator.delete(statementName);
}
/**
* @param statementName
* @param parameterObject
* @return
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#delete(java.lang.String, java.lang.Object)
*/
public int delete(String statementName, Object parameterObject) throws DataAccessException {
return delegator.delete(statementName, parameterObject);
}
/**
* @param statementName
* @param parameterObject
* @param requiredRowsAffected
* @throws DataAccessException
* @see org.springframework.orm.ibatis.SqlMapClientTemplate#delete(java.lang.String, java.lang.Object, int)
*/
public void delete(String statementName, Object parameterObject, int requiredRowsAffected)
throws DataAccessException {
delegator.delete(statementName, parameterObject, requiredRowsAffected);
}
}

View File

@@ -0,0 +1,130 @@
package com.nexacro.spring.dao.jdbc;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.RowCallbackHandler;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.spring.dao.Dbms;
import com.nexacro.spring.dao.NexacroFirstRowException;
import com.nexacro.spring.data.NexacroFirstRowHandler;
import com.nexacro.xapi.data.DataSet;
import com.nexacro.xapi.data.datatype.DataType;
import com.nexacro.xapi.tx.PlatformException;
/**
* jdbc를 사용하여 nexacro platform으로 대용량 데이터를 전송하려고 할때 사용되는 RowHandler 이다.
* <p>아래와 같은 형식으로 처리하며, 쿼리가 실행한 후 남아 있는 데이터가 존재할 수 있기 때문에 전송되지 않은 데이터를 전송한다.
*
* <pre>
DataSource dataSource = getDataSource();
Dbms dbms = dbmsProvider.getDbms(dataSource);
JdbcRowHandler rowHandler = new JdbcRowHandler(dbms, firstRowHandler, sendName, firstRowCount);
getJdbcTemplate().query(sql, args, callbackHandler);
// send remain data..
rowHandler.sendRemainData();
*
* </pre>
*
* @author Park SeongMin
* @since 08.18.2015
* @version 1.0
* @see
*/
public class JdbcRowHandler implements RowCallbackHandler {
private static final int DEFAULT_FIRSTROW_COUNT = 1000;
private Dbms dbms;
private NexacroFirstRowHandler firstRowHandler;
private String resultName;
private int firstRowCount;
private DataSet currentDataSet;
private int currentCount=0;
public JdbcRowHandler(Dbms dbms, NexacroFirstRowHandler firstRowHandler, String resultName, int firstRowCount) {
this.dbms = dbms;
this.firstRowHandler = firstRowHandler;
this.resultName = resultName;
this.firstRowCount = firstRowCount;
if(this.firstRowCount <= 0) {
this.firstRowCount = DEFAULT_FIRSTROW_COUNT;
}
}
@Override
public void processRow(ResultSet rs) throws SQLException {
prepareDataSet(rs);
addRow(rs);
try {
currentCount++;
if(currentCount % firstRowCount == 0) {
sendDataSet();
}
} catch (PlatformException e) {
throw new SQLException("could not send data. e="+e.getMessage());
}
}
/**
* 데이터 분할 전송 후 남아 있는 데이터를 전송한다.
*/
public void sendRemainData() {
// send remain data..
DataSet remainDataSet = getDataSet();
if(remainDataSet != null && remainDataSet.getRowCount() > 0) {
try {
firstRowHandler.sendDataSet(remainDataSet);
} catch (PlatformException e) {
// throw new NexacroException("could not send remain data. query="+queryId+" e="+e.getMessage(), e);
throw new NexacroFirstRowException("could not send remain data. e="+e.getMessage(), e);
}
}
}
private void sendDataSet() throws PlatformException {
firstRowHandler.sendDataSet(currentDataSet);
}
private void addRow(ResultSet rs) throws SQLException {
int newRow = currentDataSet.newRow();
int columnCount = currentDataSet.getColumnCount();
for(int columnIndex=0; columnIndex<columnCount; columnIndex++) {
Object object = rs.getObject(columnIndex+1);
currentDataSet.set(newRow, columnIndex, object);
}
}
private void prepareDataSet(ResultSet rs) throws SQLException {
if(this.currentDataSet != null) {
return;
}
this.currentDataSet = new DataSet(resultName != null? resultName: "RESULT0");
ResultSetMetaData metaData = rs.getMetaData();
// get column information from ResultSetMetaData
List<DbColumn> dbColumns = dbms.getDbColumns(metaData);
for(DbColumn column: dbColumns) {
String name = column.getName();
DataType dataType = column.getDataType();
int size = column.getSize();
currentDataSet.addColumn(name, dataType, size);
}
}
public DataSet getDataSet() {
return this.currentDataSet;
}
}

View File

@@ -0,0 +1,29 @@
package com.nexacro.spring.dao.mybatis;
import org.apache.ibatis.mapping.MappedStatement;
/**
* {@code NexacroMybatisResultSetHandler}에서 메타데이터 조회를 위해 사용되는 정보이며, {@code NexacroMybatisMetaDataProvider}에 의해 제공된다.
*
* @author Park SeongMin
*
*/
class LookupResultSetMetaDataConfig {
private final boolean isSearchMetaData;
private final MappedStatement ms;
LookupResultSetMetaDataConfig(final boolean isSearchMetaData, final MappedStatement ms) {
this.isSearchMetaData = isSearchMetaData;
this.ms = ms;
}
boolean isSearchMetaData() {
return isSearchMetaData;
}
MappedStatement getMappedStatement() {
return ms;
}
}

View File

@@ -0,0 +1,33 @@
package com.nexacro.spring.dao.mybatis;
import org.springframework.core.NamedThreadLocal;
/**
* {@code LookupResultSetMetaDataConfig}를 위한 ThreadLocal holder
* @author Park SeongMin
*
*/
class LookupResultSetMetaDataHolder {
private static final ThreadLocal<LookupResultSetMetaDataConfig> currentMybatisConfig =
new NamedThreadLocal<LookupResultSetMetaDataConfig>("Mybatis lookup Configuration");
static void resetLookupResultSetMetaDataConfig() {
currentMybatisConfig.remove();
}
static void setLookupResultSetMetaDataConfig(LookupResultSetMetaDataConfig config) {
if (config == null) {
resetLookupResultSetMetaDataConfig();
}
else {
currentMybatisConfig.set(config);
}
}
static LookupResultSetMetaDataConfig getLookupResultSetMetaDataConfig() {
return currentMybatisConfig.get();
}
}

View File

@@ -0,0 +1,151 @@
package com.nexacro.spring.dao.mybatis;
import java.util.Map;
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import com.nexacro.spring.dao.NexacroFirstRowException;
import com.nexacro.spring.data.NexacroFirstRowHandler;
import com.nexacro.spring.data.convert.NexacroConvertException;
import com.nexacro.spring.data.support.ObjectToDataSetConverter;
import com.nexacro.xapi.data.DataSet;
import com.nexacro.xapi.tx.PlatformException;
/**
* mybatis를 사용하여 nexacro platform으로 대용량 데이터를 전송하려고 할때 사용되는 RowHandler 이다.
* <p>아래와 같은 형식으로 처리하며, 쿼리가 실행한 후 남아 있는 데이터가 존재할 수 있기 때문에 전송되지 않은 데이터를 전송한다.
*
* <pre>
*
String statement = "nexacro.sample.service.dao.mybatis.LargeDataMybatisMapper.selectLargeData";
Object parameter = null;
SqlSession sqlSession = getSqlSession();
MybatisRowHandler rowHandler = new MybatisRowHandler(firstRowHandler, sendDataSetName, firstRowCount);
sqlSession.select(statement, parameter, rowHandler);
// send remain data..
rowHandler.sendRemainData();
* </pre>
*
* @author Park SeongMin
* @since 10.13.2015
* @version 1.0
* @see
*
*/
public class MybatisRowHandler implements ResultHandler {
/*
다중 DBMS 사용 시 AbstractDAO를 사용하여 처리 하거나 Mapper 인터페이스를 이용한 처리 방법 두가지로 처리 한다.
@Resource(name = "otherSqlSession")
public void setSqlSessionFactory(SqlSessionFactory sqlSession) {
super.setSqlSessionFactory(sqlSession);
}
Mapper 인터페이스를 활용한 방법으로 제시한 가이드에 따라 Mapper인터페이스를 작성해주시고, MapperConfigurer 빈설정 시 아래와 같이 변경해주시면 됩니다.
<bean class="egovframework.rte.psl.dataaccess.mapper.MapperConfigurer">
<property name="basePackage" value="풀패키지명" />
<property name="sqlSessionFactoryBeanName" ref="sqlSession" />
</bean>
<bean class="egovframework.rte.psl.dataaccess.mapper.MapperConfigurer">
<property name="basePackage" value="풀패키지명" />
<property name="sqlSessionFactoryBeanName" ref="otherSqlSession" />
</bean>
*/
private static final int DEFAULT_FIRSTROW_COUNT = 1000;
private ObjectToDataSetConverter converter;
private NexacroFirstRowHandler firstRowHandler;
private String resultName;
private int firstRowCount;
private DataSet currentDataSet;
private int currentCount = 0;
public MybatisRowHandler(NexacroFirstRowHandler firstRowHandler, String resultName, int firstRowCount) {
this.firstRowHandler = firstRowHandler;
this.resultName = resultName;
this.firstRowCount = firstRowCount;
if(this.firstRowCount <= 0) {
this.firstRowCount = DEFAULT_FIRSTROW_COUNT;
}
// TODO getting NexacroConverterFactory.getConverter();
this.converter = new ObjectToDataSetConverter();
}
@Override
public void handleResult(ResultContext context) {
Object valueObject = context.getResultObject();
try {
prepareDataSet(valueObject);
addRow(valueObject);
currentCount++;
if(currentCount % firstRowCount == 0) {
sendDataSet();
}
} catch (PlatformException e) {
throw new NexacroFirstRowException("could not send data. e="+e.getMessage(), e);
} catch (NexacroConvertException e) {
throw new NexacroFirstRowException("object to dataset convert failed. e="+e.getMessage(), e);
}
}
/**
* 데이터 분할 전송 후 남아 있는 데이터를 전송한다.
*/
public void sendRemainData() {
// send remain data..
DataSet remainDataSet = getDataSet();
if(remainDataSet != null && remainDataSet.getRowCount() > 0) {
try {
firstRowHandler.sendDataSet(remainDataSet);
} catch (PlatformException e) {
// throw new NexacroException("could not send remain data. query="+queryId+" e="+e.getMessage(), e);
throw new NexacroFirstRowException("could not send remain data. e="+e.getMessage(), e);
}
}
}
private void sendDataSet() throws PlatformException {
firstRowHandler.sendDataSet(currentDataSet);
}
private void addRow(Object valueObject) throws NexacroConvertException {
if(valueObject instanceof Map) {
converter.addRowIntoDataSet(currentDataSet, (Map) valueObject);
} else {
converter.addRowIntoDataSet(currentDataSet, valueObject);
}
}
private void prepareDataSet(Object valueObject) throws NexacroConvertException {
if(this.currentDataSet != null) {
return;
}
this.currentDataSet = new DataSet(resultName != null? resultName: "RESULT0");
if(valueObject instanceof Map) {
converter.addColumnIntoDataSet(currentDataSet, (Map) valueObject);
} else {
converter.addColumnIntoDataSet(currentDataSet, valueObject);
}
}
public DataSet getDataSet() {
return this.currentDataSet;
}
}

View File

@@ -0,0 +1,187 @@
package com.nexacro.spring.dao.mybatis;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.cache.NullCacheKey;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.transaction.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ClassUtils;
import com.nexacro.spring.data.metadata.NexacroMetaData;
import com.nexacro.spring.data.metadata.support.BeanMetaData;
import com.nexacro.spring.data.metadata.support.UnsupportedMetaData;
/**
* <p>Mybatis의 {@link Executor#query(MappedStatement, Object, RowBounds, ResultHandler)} plugin으로,
* 쿼리 실행 시 ({@code List} 형태의 select) 데이터가 0건일 경우 컬럼의 메타데이터 정보를 획득한다.
*
* @author Park SeongMin
* @since 10.13.2015
* @version 1.0
* @see
*/
@Intercepts({ @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
public class NexacroMybatisMetaDataProvider implements Interceptor {
private static Logger logger = LoggerFactory.getLogger(NexacroMybatisMetaDataProvider.class);
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
// To change body of implemented methods use File | Settings | File
// Templates.
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object intercept(Invocation invocation) throws Throwable {
Object proceed = invocation.proceed();
if(proceed instanceof List) {
List list = (List) proceed;
if(list.size() == 0) {
return getNexacroMetaData(invocation);
}
}
return proceed;
}
private Object getNexacroMetaData(Invocation invocation) {
Object[] args = invocation.getArgs();
MappedStatement ms = (MappedStatement) args[0];
List<ResultMap> resultMaps = ms.getResultMaps();
for(ResultMap resultMap: resultMaps) {
if(!requireExecuteQuery(resultMap)) {
return generateMetaDataFromClass(resultMap.getType());
}
}
// return doGetMetaData(executor, ms, param, rowBounds, resultHandler);
// ResultSetHandler를 등록해 두고, 여기서 실행 하는 경우에만 상태값을 저장하여 처리하도록 하자.
LookupResultSetMetaDataConfig config = new LookupResultSetMetaDataConfig(true, ms);
LookupResultSetMetaDataHolder.setLookupResultSetMetaDataConfig(config);
try {
// used cache..
// proceed = invocation.proceed();
Executor executor = (Executor) invocation.getTarget();
Object parameter = args[1];
RowBounds rowBounds = (RowBounds) args[2];
ResultHandler resultHandler = (ResultHandler) args[3];
BoundSql boundSql = ms.getBoundSql(parameter);
CacheKey cacheKey = new NullCacheKey(); // or create cache key. msId, parameter,
return executor.query(ms, parameter, rowBounds, resultHandler, cacheKey, boundSql);
} catch(Throwable e) {
// ignore
Logger logger = LoggerFactory.getLogger(getClass());
logger.warn("failed to query the metadata information. statement="+ms.getId(), e);
} finally {
LookupResultSetMetaDataHolder.resetLookupResultSetMetaDataConfig();
}
return new ArrayList();
}
private List doGetMetaData(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler) {
// http://zgundam.tistory.com/34 참고..
BoundSql boundSql = ms.getBoundSql(parameter);
Executor wrapper = executor;
Configuration configuration = ms.getConfiguration();
StatementHandler handler = configuration.newStatementHandler(wrapper, ms, parameter, rowBounds, resultHandler, boundSql);
// log 처리 하지 않음
// Statement stmt = prepareStatement(handler, ms.getStatementLog());
Statement stmt = null;
try {
Transaction transaction = executor.getTransaction();
Connection connection = null;
try {
connection = transaction.getConnection();
} catch (SQLException e) {
logger.warn("getting connection failed for MetaData.", e);
return new ArrayList();
}
stmt = handler.prepare(connection);
handler.parameterize(stmt);
} catch(SQLException e) {
logger.warn("create statement and parameterize failed.", e);
return new ArrayList();
}
// handler 별 호출을 처리 할 까?
try {
handler.query(stmt, resultHandler);
} catch (SQLException e) {
logger.error("failed to query the metadata information. statement="+ms.getId(), e);
}
return new ArrayList();
}
private boolean requireExecuteQuery(ResultMap resultMap) {
// Map이 아니라면 실행하지 않는다. XML, primitive 등 은 처리하지 않도록 한다.
Class resultClass = resultMap.getType();
Boolean autoMapping = resultMap.getAutoMapping();
if(Map.class.isAssignableFrom(resultClass)) {
return true;
}
return false;
}
private NexacroMetaData generateMetaDataFromClass(Class clazz) {
if(!Map.class.isAssignableFrom(clazz)) {
if(ClassUtils.isPrimitiveOrWrapper(clazz)) {
return new UnsupportedMetaData(null);
}
return new BeanMetaData(clazz);
}
return null;
}
}

View File

@@ -0,0 +1,244 @@
package com.nexacro.spring.dao.mybatis;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.ibatis.executor.resultset.ResultSetHandler;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.ResultMapping;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import com.nexacro.spring.context.SpringAppContext;
import com.nexacro.spring.dao.DbColumn;
import com.nexacro.spring.dao.DbMetaDataGathererUtil;
import com.nexacro.spring.dao.DbVendorsProvider;
import com.nexacro.spring.dao.Dbms;
import com.nexacro.spring.dao.DbmsProvider;
import com.nexacro.spring.data.metadata.support.MapMetaData;
import com.nexacro.spring.data.support.NexacroConverterHelper;
import com.nexacro.xapi.data.DataTypes;
import com.nexacro.xapi.data.datatype.DataType;
/**
* <p>Mybatis의 {@link ResultSetHandler#handleResultSets(Statement)} plugin으로 {@link NexacroMybatisMetaDataProvider}에서 메타데이터 요청시에만 실행되며,
* 쿼리를 수행하고 <code>ResultSet</code>으로 부터 {@link DbmsProvider}를 이용하여 메타데이터 정보를 획득한다.
*
* @author Park SeongMin
* @since 10.13.2015
* @version 1.0
* @see
*/
@Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})})
public class NexacroMybatisResultSetHandler implements Interceptor {
private static DbmsProvider dbmsProvider;
@Override
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
@Override
public void setProperties(Properties properties) {
}
@Override
public Object intercept(Invocation invocation) throws Throwable {
LookupResultSetMetaDataConfig config = LookupResultSetMetaDataHolder.getLookupResultSetMetaDataConfig();
if(config != null && config.isSearchMetaData()) {
// search metadata
Object[] args = invocation.getArgs();
Statement statement = (Statement) args[0];
return getMetaDataFromResultSet(config, statement);
} else {
return invocation.proceed();
}
}
private Object getMetaDataFromResultSet(LookupResultSetMetaDataConfig config, Statement statement) {
initDbmsProvider();
MapMetaData generateMapMetaData = null;
MappedStatement mappedStatement = config.getMappedStatement();
try {
ResultSet rs = statement.getResultSet();
ResultSetMetaData metaData = rs.getMetaData();
Connection connection = statement.getConnection();
Dbms dbms = dbmsProvider.getDbms(connection);
// get column information from ResultSetMetaData
List<DbColumn> dbColumns = dbms.getDbColumns(metaData);
List<ResultMap> resultMaps = mappedStatement.getResultMaps();
if(validResultMaps(resultMaps)) {
// mapping MetaData and Ibatis ResultMap
ResultMap resultMap = resultMaps.get(0);
// auto mappings..
// AutoMappingBehavior.NONE.equals(mappedStatement.getConfiguration().getAutoMappingBehavior())
// NONE - 자동매핑을 사용하지 않는다. 오직 수동으로 매핑한 프로퍼티만을 설정할것이다.
// PARTIAL - 조인 내부에 정의한 내포된 결과매핑을 제외하고 자동매핑한다.
// FULL - 모든것을 자동매핑한다.
// DefaultResultSetHandler Code.. getRowValue(). AutoMapping
// if (!shouldApplyAutomaticMappings(resultMap, !AutoMappingBehavior.NONE.equals(mappedStatement.getConfiguration().getAutoMappingBehavior()))) {
// if (!shouldApplyAutomaticMappings(resultMap, !AutoMappingBehavior.NONE.equals(mappedStatement.getConfiguration().getAutoMappingBehavior()))) {
mappingDbColumnAndResultMappings(dbColumns, resultMap);
// }
}
generateMapMetaData = DbMetaDataGathererUtil.generateMetaDataFromDbColumns(dbColumns);
} catch (Exception e) {
Logger logger = LoggerFactory.getLogger(this.getClass());
if(logger.isErrorEnabled()) {
logger.error("failed to query the metadata information.", e);
}
}
return generateMapMetaData;
}
private void mappingDbColumnAndResultMappings(List<DbColumn> dbColumns, ResultMap resultMap) {
Class<?> resultType = resultMap.getType();
if(resultType != Map.class) {
// resultSetMetaData columns
return;
}
// Map 만을 대상으로 하기 때문에 PropertyMappings만을 사용한다. (getConstructorResultMappings는 사용하지 않는다.)
final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
// propertyMappings length가 0인 경우 auto mapping 으로 처리 한다.
if(propertyMappings.size() == 0) {
return;
}
int size = dbColumns.size();
for(int i=size-1; i>=0; i--) {
DbColumn dbColumn = dbColumns.get(i);
String name = dbColumn.getName();
boolean existColumn = false;
// Map의 Automapping이 아니다. 일반 Mapping이다.
// Boolean autoMapping = resultMap.getAutoMapping();
// if(autoMapping != null && Boolean.TRUE.equals(autoMapping)) {
// existColumn = true;
// }
for (ResultMapping propertyMapping: propertyMappings) {
String columnName = propertyMapping.getColumn();
String propertyName = propertyMapping.getProperty();
if(name.equals(columnName) || name.equals(propertyName)) {
if(propertyName != null) {
dbColumn.setName(propertyName);
}
// javaType이 선언되지 않았을 경우 기본적으로 Object 형식으로 반환된다.
// NexacroConverterHelper.getDataType 의 Object는 undefined 이기 때문에 ResultSetMetaData의 타입으로 처리가 된다.
Class javaType = propertyMapping.getJavaType();
if(javaType != null) {
DataType dataType = NexacroConverterHelper.getDataType(javaType);
if(dataType.getType() != DataTypes.UNDEFINED) {
dbColumn.setDataType(dataType);
}
}
existColumn = true;
break;
}
}// end resultMappings
// remove data for result mapping
if(!existColumn) {
dbColumns.remove(i);
}
} // end dbColumns
}
private boolean validResultMaps(List<ResultMap> resultMaps) {
if(resultMaps == null || resultMaps.size() < 1) {
return false;
}
return true;
}
private boolean shouldApplyAutomaticMappings(ResultMap resultMap, boolean def) {
return resultMap.getAutoMapping() != null ? resultMap.getAutoMapping(): def;
}
private void initDbmsProvider() {
if (dbmsProvider != null) {
return;
}
ApplicationContext applicationContext = SpringAppContext.getInstance().getApplicationContext();
if (applicationContext != null) {
dbmsProvider = (DbmsProvider) applicationContext.getBean("dbmsProvider");
}
if (dbmsProvider == null) {
dbmsProvider = new DbVendorsProvider();
}
}
protected Class<?> resolveInterface(Class<?> type) {
// only list..
Class<?> classToCreate;
if (type == List.class || type == Collection.class || type == Iterable.class) {
classToCreate = ArrayList.class;
} else if (type == Map.class) {
classToCreate = HashMap.class;
} else if (type == SortedSet.class) { // issue #510 Collections Support
classToCreate = TreeSet.class;
} else if (type == Set.class) {
classToCreate = HashSet.class;
} else {
classToCreate = type;
}
return classToCreate;
}
}

View File

@@ -0,0 +1,41 @@
package com.nexacro.spring.data;
import com.nexacro.xapi.data.DataSet;
/**
* <p>데이터 변환 시 <code>DataSet</code>의 행(row)의 형식(type)을 처리하기 위한 인터페이스이다.
*
* @author Park SeongMin
* @since 07.31.2015
* @version 1.0
* @see DataSet#getRowType(int)
*/
public interface DataSetRowTypeAccessor {
/**
* <code>Map</code>으로 데이터 변환 시 행의 타입을 획득하기 위한 식별자(key)이다.
*/
static final String NAME = "DataSetRowType";
/**
* 행(row)의 형식(type)을 반환한다.
* @return rowType 행의 형식
* @see DataSet#ROW_TYPE_NORMAL
* @see DataSet#ROW_TYPE_INSERTED
* @see DataSet#ROW_TYPE_UPDATED
* @see DataSet#ROW_TYPE_DELETED
*/
int getRowType();
/**
* 행(row)의 형식(type)을 설정한다.
* @param rowType 행의 형식
* @see DataSet#ROW_TYPE_NORMAL
* @see DataSet#ROW_TYPE_INSERTED
* @see DataSet#ROW_TYPE_UPDATED
* @see DataSet#ROW_TYPE_DELETED
*/
void setRowType(int rowType);
}

View File

@@ -0,0 +1,29 @@
package com.nexacro.spring.data;
/**
* <p>데이터 변환 시 <code>DataSet</code>의 원본데이터를 처리하기 위한 인터페이스이다.
*
* @author Park SeongMin
* @since 07.31.2015
* @version 1.0
*/
public interface DataSetSavedDataAccessor<T> {
/**
* <code>Map</code>으로 데이터 변환 시 원본데이터를 획득하기 위한 식별자(key)이다.
*/
static final String NAME = "DataSetSavedData";
/**
* 데이터 변경시 저장된 원본데이터를 반환한다.
* @return t 원본데이터
*/
T getData();
/**
* 데이터 변경시 저장되는 원본데이터를 설정한다.
* @param t 원본데이터
*/
void setData(T t);
}

Some files were not shown because too many files have changed in this diff Show More