This commit is contained in:
Shaun Chyxion 2018-06-24 22:58:11 +08:00
parent 096c257112
commit ac55d7891b
113 changed files with 275 additions and 2842 deletions

513
pom.xml
View File

@ -12,22 +12,11 @@
<name>Tigon</name>
<description>Tigon</description>
<parent>
<groupId>me.chyxion</groupId>
<artifactId>maven-parent</artifactId>
<version>0.0.2-RELEASE</version>
</parent>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.version>4.3.8.RELEASE</spring.version>
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
<slf4j.version>1.7.23</slf4j.version>
<log4j.version>2.7</log4j.version>
<shiro.version>1.3.2</shiro.version>
<aspectj.version>1.8.10</aspectj.version>
<main.class>Main</main.class>
<spring.version>5.0.7.RELEASE</spring.version>
<spring-boot.version>2.0.3.RELEASE</spring-boot.version>
</properties>
<scm>
@ -46,7 +35,6 @@
</developers>
<modules>
<!--<module>tigon-lombok</module>-->
<module>tigon-model</module>
<module>tigon-mybatis</module>
<module>tigon-sequence</module>
@ -54,28 +42,17 @@
<module>tigon-mybatis-cache-redis</module>
<module>tigon-shiro-cache</module>
<module>tigon-shiro-cache-redis</module>
<module>tigon-webmvc-core</module>
<module>tigon-webmvc-spring-boot</module>
<module>tigon-webmvc-war</module>
<module>tigon-web</module>
<module>tigon-shiro-core</module>
<module>tigon-shiro-spring-boot</module>
<module>tigon-shiro-war</module>
<module>tigon-service-api</module>
<module>tigon-service-support</module>
<module>tigon-props-config</module>
<module>tigon-extjs</module>
<module>tigon-freemarker-support</module>
<module>tigon-jsp-support</module>
<module>tigon-codegen</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-lombok</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-model</artifactId>
@ -93,17 +70,7 @@
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-spring-boot</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-war</artifactId>
<artifactId>tigon-web</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@ -131,16 +98,6 @@
<artifactId>tigon-shiro-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-spring-boot</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-war</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-service-api</artifactId>
@ -156,112 +113,26 @@
<artifactId>tigon-extjs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-freemarker-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-jsp-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-codegen</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-props-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.14</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.0.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<!-- /mybatis -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.28</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-core -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>${shiro.version}</version>
</dependency>
<dependency>
<artifactId>commons-fileupload</artifactId>
<groupId>commons-fileupload</groupId>
<version>1.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${spring.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Kay-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
@ -269,328 +140,37 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.4</version>
</dependency>
<!-- / Spring Boot -->
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>
<dependency>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- java web -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
target/lib
</outputDirectory>
<excludeScope>provided</excludeScope>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Built-By>Shaun Chyxion</Built-By>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.artifactId}</finalName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${main.class}</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.tooling</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<id>remove-config-file</id>
<goals><goal>clean</goal></goals>
<phase>compile</phase>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>src/main/resources/spring</directory>
<includes>
<include>config.properties</include>
</includes>
</fileset>
<fileset>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
<include>application.yaml</include>
<include>log4j2.xml</include>
</includes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>copy-config-props-file</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>src/main/resources/config_${project.activeProfiles[0].id}.properties</sourceFile>
<destinationFile>src/main/resources/spring/config.properties</destinationFile>
</configuration>
</execution>
<execution>
<id>copy-application-props-file</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>src/main/resources/application_${project.activeProfiles[0].id}.properties</sourceFile>
<destinationFile>src/main/resources/application.properties</destinationFile>
</configuration>
</execution>
<execution>
<id>copy-application-yaml-file</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>src/main/resources/application_${project.activeProfiles[0].id}.yaml</sourceFile>
<destinationFile>src/main/resources/application.yaml</destinationFile>
</configuration>
</execution>
<execution>
<id>copy-log4j2-xml-file</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>src/main/resources/log4j2_${project.activeProfiles[0].id}.xml</sourceFile>
<destinationFile>src/main/resources/log4j2.xml</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<addResources>true</addResources>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
<jvmArguments>
-Xdebug
-Dproject.basedir=${project.basedir}
</jvmArguments>
<!--<skip>false</skip>-->
<!--<fork>true</fork>-->
</configuration>
<executions>
<execution>
@ -600,37 +180,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<versionRange>
[2.6.1,)
</versionRange>
<goals>
<goal>clean</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

View File

@ -17,10 +17,16 @@
<relativePath>../</relativePath>
</parent>
<properties>
<spring-boot.run.main-class>me.chyxion.tigon.codegen.TigonCodeGen</spring-boot.run.main-class>
<mainClass>me.chyxion.tigon.codegen.TigonCodeGen</mainClass>
</properties>
<dependencies>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-freemarker-support</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
@ -28,23 +34,16 @@
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-core</artifactId>
<artifactId>tigon-web</artifactId>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-service-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- mybatis -->
<dependency>
@ -58,14 +57,22 @@
</dependency>
<!-- /mybatis -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>codegen</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,20 @@
package me.chyxion.tigon.codegen;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jun 24, 2018 20:43:36
*/
@SpringBootApplication
public class TigonCodeGen {
/**
* @param args start args
*/
public static void main(String[] args) {
SpringApplication.run(TigonCodeGen.class, args);
}
}

View File

@ -0,0 +1,23 @@
package me.chyxion.tigon.codegen;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jun 24, 2018 20:58:08
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {
/**
* {@inheritDoc}
*/
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/assets/**")
.addResourceLocations("/assets/", "classpath:webapp/assets/");
}
}

View File

@ -9,9 +9,9 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotBlank;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.hibernate.validator.constraints.NotBlank;
import me.chyxion.tigon.codegen.service.CodeGenService;
import me.chyxion.tigon.codegen.service.CodeGenBaseTool;
import org.springframework.web.bind.annotation.RequestParam;

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Scan Code Gen -->
<context:component-scan base-package="me.chyxion.tigon.codegen.controller" />
</beans>

View File

@ -23,7 +23,7 @@ public class FreeMarkerViewResolverExt extends FreeMarkerViewResolver {
@Override
public View resolveViewName(String viewName, Locale locale)
throws Exception {
log.debug("Try To Resolve View Name [{}], Locale [{}] As FreeMarker View.", viewName, locale);
log.debug("Try to resolve view name [{}], locale [{}] as freemarker view.", viewName, locale);
return super.resolveViewName(viewName.replaceAll("(?i)(^\\s*ftl\\:)|(\\.ftl\\s*$)", ""), locale);
}
}

View File

@ -1 +0,0 @@
# tigon-jsp-support

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-jsp-support</artifactId>
<packaging>jar</packaging>
<name>Tigon JSP Support</name>
<description>Tigon JSP Support</description>
<parent>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,59 +0,0 @@
package me.chyxion.tigon.jsp;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletContext;
import java.net.MalformedURLException;
import org.springframework.web.servlet.View;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
/**
* @version 0.0.1
* @since 0.0.1
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Dec 5, 2014 2:33:18 PM
*/
public class InternalResourceViewResolverExt
extends InternalResourceViewResolver {
private static final Logger log =
LoggerFactory.getLogger(InternalResourceViewResolverExt.class);
@Autowired
private ServletContext sc;
/**
* {@inheritDoc}
*/
@Override
public View resolveViewName(String viewName, Locale locale)
throws Exception {
return super.resolveViewName(viewName(viewName), locale);
}
/**
* {@inheritDoc}
*/
@Override
protected boolean canHandle(String viewName, Locale locale) {
try {
// avoid 404
return sc.getResource(getPrefix() + viewName(viewName) + getSuffix()) != null;
}
catch (MalformedURLException e) {
log.warn("InternalResourceViewResolverExt#canHandle Eorror Caused.", e);
return false;
}
}
/**
* Process View Name
* @param name raw name
* @return jsp file name
*/
private String viewName(String name) {
return name.replaceAll("(?i)(^\\s*jsp\\:)|(\\.jsp\\s*$)", "");
}
}

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- JSP View Resolver -->
<bean class="me.chyxion.tigon.jsp.InternalResourceViewResolverExt"
p:prefix="/WEB-INF/views/"
p:suffix=".jsp"
p:contentType="text/html; charset=utf-8"
p:order="32"
/>
</beans>

View File

@ -1,20 +0,0 @@
package me.chyxion.tigon.webmvc.test;
import org.junit.runner.RunWith;
// import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @version 0.0.1
* @since 0.0.1
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jan 27, 2015 3:27:08 PM
*/
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
// @ContextConfiguration("classpath:spring/controller-test.xml")
public class SiteControllerTest {
}

View File

@ -21,10 +21,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@ -39,6 +41,13 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -46,7 +55,7 @@
</dependency>
<!-- For Form Validate -->
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>

View File

@ -24,10 +24,12 @@
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>

View File

@ -26,10 +26,12 @@
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@ -60,11 +62,13 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.28</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<scope>test</scope>
</dependency>
<dependency>
@ -85,6 +89,7 @@
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -1 +0,0 @@
# tigon-props-config

View File

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-props-config</artifactId>
<packaging>jar</packaging>
<name>Tigon Props Config</name>
<parent>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,120 +0,0 @@
package me.chyxion.tigon.propsconfig;
import java.io.File;
import org.slf4j.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.io.FileInputStream;
import org.slf4j.LoggerFactory;
/**
* @version 0.0.1
* @since 0.0.1
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Oct 13, 2015 11:25:55 AM
*/
public class PropsConfig {
private static final Logger log =
LoggerFactory.getLogger(PropsConfig.class);
public static final Properties CONFIG_PROPS =
new Properties();
static { load(); }
/**
* get app (container/tomcat) dir
* @return app dir
*/
public static File getAppDir() {
File file = new File(
// classes
PropsConfig.class.getResource("/").getFile())
// WEB-INF
.getParentFile()
// WebApp
.getParentFile()
// WebApps
.getParentFile()
// App
.getParentFile();
log.info("Get App Dir [{}].", file.getAbsolutePath());
return file;
}
// --
// private methods
/**
* load system config
*/
static void load() {
InputStream configIn = null;
String configPath = "/spring/config.properties";
try {
log.info("Load Classpath Config [{}].", configPath);
configIn = PropsConfig.class
.getResourceAsStream(configPath);
if (configIn != null) {
log.info("Classpath Config [{}] Found.", configPath);
CONFIG_PROPS.load(configIn);
}
else {
log.warn("No Classpath Config [{}] Found.", configPath);
}
}
catch (Exception e) {
log.error("Load Classpath Config [{}] Error Caused.", configPath, e);
}
finally {
if (configIn != null) {
try {
configIn.close();
}
catch (IOException e) {
log.warn("Config Input Stream Close Eroror Caused.");
}
}
}
File appDir = getAppDir();
// load global config
load(appDir.getParentFile());
// load app config
load(appDir);
log.debug("Config Props [{}] Loaded.", CONFIG_PROPS);
}
static void load(File dir) {
// load from custom file
File configFile = new File(dir, "config/config.properties");
String configPath = configFile.getAbsolutePath();
log.info("Load Config From Path [{}].", configPath);
if (configFile.exists()) {
log.info("Config File [{}] Exists.", configPath);
InputStream configIn = null;
try {
configIn = new FileInputStream(configFile);
Properties props = new Properties();
props.load(configIn);
log.debug("Config Props [{}] Found.", props);
CONFIG_PROPS.putAll(props);
}
catch (Exception e) {
log.error("Load Config [{}] Error Caused.", configPath, e);
}
finally {
if (configIn != null) {
try {
configIn.close();
}
catch (IOException e) {
log.warn("Config Input Stream Close Error Caused.");
}
}
}
}
else {
log.info("Config File [{}] Does Not Exist, Ignore.", configPath);
}
}
}

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder properties-ref="configProps" />
</beans>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<util:constant id="configProps"
static-field="me.chyxion.tigon.propsconfig.PropsConfig.CONFIG_PROPS" />
<context:property-placeholder properties-ref="configProps" />
</beans>

View File

@ -1,12 +0,0 @@
package me.chyxion.tigon.propsconfig;
/**
* @version 0.0.1
* @since 0.0.1
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Dec 1, 2016 2:42:36 PM
*/
public class TestDriver {
}

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="encoding" value="utf-8" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%F:%L] %m%n" />
</layout>
</appender>
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="encoding" value="utf-8" />
<param name="MaxFileSize" value="64MB" />
<param name="MaxBackupIndex" value="16" />
<param name="File" value="E:\\Workspaces\\Eclipse\\FlagInfoEChat\\Commons\\echat-db/.log/echat-db-test.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%F:%L] %m%n" />
</layout>
</appender>
<logger name="org.apache">
<level value="warn" />
<appender-ref ref="file" />
</logger>
<logger name="org.springframework">
<level value="warn" />
<appender-ref ref="file" />
</logger>
<root>
<level value="debug" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>
</log4j:configuration>

View File

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:spring/config.properties" />
<import resource="classpath:spring/spring-echat-redis.xml" />
<bean class="cn.com.flaginfo.web.cache.RedisCacheConfig" />
<aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="dataSource"
class="com.alibaba.druid.pool.DruidDataSource"
init-method="init"
destroy-method="close"
p:url="${db.url}"
p:username="${db.user}"
p:password="${db.password}"
/>
<!-- Transaction Manager -->
<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource" />
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- MyBatis SqlSessionFactory -->
<bean id="sqlSessionFactory" class="me.chyxion.tigon.dao.mybatis.SqlSessionFactoryBeanExt"
p:dataSource-ref="dataSource"
p:configLocation="classpath:mybatis/mybatis-config.xml"
p:typeAliasesPackage="${project.groupId}.**.models"
p:mapperLocations="classpath*:mybatis/mappers/**/*-mapper.xml">
<property name="plugins">
<list>
<bean class="me.chyxion.tigon.dao.mybatis.pagination.PaginationIntercepter"
p:dataSource-ref="dataSource" />
</list>
</property>
</bean>
<!-- MyBatis Mapper Auto Scan -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="${project.groupId}.**.mappers"
p:sqlSessionFactoryBeanName="sqlSessionFactory"
/>
</beans>

View File

@ -20,6 +20,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
@ -28,6 +29,7 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<!-- Test -->
<dependency>

View File

@ -21,6 +21,7 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>3.4.2</version>
</dependency>
<!-- Test Dependencies -->
<dependency>

View File

@ -52,11 +52,13 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.28</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<scope>test</scope>
</dependency>
<dependency>
@ -77,6 +79,7 @@
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -20,27 +20,15 @@
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- shiro -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>

View File

@ -23,19 +23,17 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- shiro -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>

View File

@ -3,9 +3,9 @@ package me.chyxion.tigon.shiro.model;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
import lombok.ToString;
import java.util.HashMap;
import java.io.Serializable;
import com.alibaba.fastjson.JSON;
import org.apache.shiro.SecurityUtils;
import org.springframework.util.Assert;
import org.apache.shiro.session.Session;
@ -19,6 +19,7 @@ import org.apache.shiro.session.Session;
*/
@Getter
@Setter
@ToString
public class AuthUser<U> implements Serializable {
private static final long serialVersionUID = 1L;
@ -78,14 +79,6 @@ public class AuthUser<U> implements Serializable {
session.touch();
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return JSON.toJSONString(this);
}
/**
* @param name attr name
* @param value attr value

View File

@ -24,6 +24,7 @@
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
@ -31,7 +32,11 @@
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-core</artifactId>
<artifactId>tigon-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>

View File

@ -58,6 +58,22 @@
<bean factory-bean="authConfigFactory" factory-method="filterRoutings" />
</property>
</bean>
<bean class="org.springframework.boot.web.servlet.FilterRegistrationBean">
<property name="filter">
<bean class="org.springframework.web.filter.DelegatingFilterProxy">
<constructor-arg value="shiroFilter" />
</bean>
</property>
<property name="enabled" value="${shiro.fitler.enabled:true}" />
<property name="initParameters">
<map>
<entry key="targetFilterLifecycle" value="true" />
</map>
</property>
<property name="urlPatterns" value="${shiro.fitler.url-patterns:/*}" />
</bean>
<bean class="me.chyxion.tigon.shiro.AuthExceptionResolver" />
<bean class="me.chyxion.tigon.shiro.service.support.AuthServiceSupport" />
</beans>

View File

@ -1 +0,0 @@
# tigon-shiro

View File

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-shiro-spring-boot</artifactId>
<name>Tigon Shiro Spring Boot</name>
<packaging>jar</packaging>
<parent>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-spring-boot</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,26 +0,0 @@
package me.chyxion.tigon.shiro;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 06, 2017 22:40:11
*/
@Configuration
public class TigonShiroConfig {
@Bean
public FilterRegistrationBean shiroFilterRegistrationBean() {
final FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));
// Servlet container manage filter lifecycle
filterRegistration.addInitParameter("targetFilterLifecycle", "true");
filterRegistration.setEnabled(true);
filterRegistration.addUrlPatterns("/*");
return filterRegistration;
}
}

View File

@ -1,58 +0,0 @@
package me.chyxion.tigon.shiro;
import me.chyxion.tigon.shiro.test.Main;
import me.chyxion.tigon.webmvc.test.ControllerTestTool;
import org.apache.shiro.web.filter.authc.UserFilter;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.HashMap;
import java.util.Map;
/**
* @version 0.0.1
* @since 0.0.1
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jan 27, 2015 3:27:08 PM
*/
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Main.class)
@SpringBootTest
public class SiteControllerTest {
@Autowired
private ControllerTestTool t;
@Autowired
private UserFilter userFilter;
@Test
public void testIndex() {
t.print(t.get("/"));
}
@Test
public void testRaw() {
t.print(t.get("/raw"));
}
@Test
public void testInt() {
t.print(t.get("/int"));
}
@Test
public void testPost() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", "id");
params.put("name", "Shaun Chyxion");
params.put("gender", "");
t.print(t.post("/post", params));
}
}

View File

@ -1,17 +0,0 @@
package me.chyxion.tigon.shiro;
import org.junit.Test;
/**
* @version 0.0.1
* @since 0.0.1
* @author chyxion <br>
* chyxion@163.com <br>
* Mar 14, 2015 3:03:57 PM
*/
public class TestDriver {
@Test
public void test() {
}
}

View File

@ -1,19 +0,0 @@
package me.chyxion.tigon.shiro.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 08, 2017 22:12:05
*/
@ComponentScan("me.chyxion.tigon.shiro.test")
@EnableAutoConfiguration
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}

View File

@ -1,34 +0,0 @@
package me.chyxion.tigon.shiro.test.controller;
import java.util.Map;
import java.util.HashMap;
import org.springframework.stereotype.Controller;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 08, 2017 22:10:53
*/
@Controller
public class SiteController {
@RequestMapping("/")
public void index() {
}
@RequiresUser
@RequestMapping("/raw")
public Map<String, Object> raw() {
Map<String, Object> mapRaw = new HashMap<String, Object>();
mapRaw.put("data", "Hello!");
return mapRaw;
}
@RequestMapping("/int")
public int integer() {
return 99;
}
}

View File

@ -1,3 +0,0 @@
/int=anon
/raw=user
/**=user

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- Scan Controllers -->
<bean class="me.chyxion.tigon.webmvc.test.ControllerTestTool" />
</beans>

View File

@ -1 +0,0 @@
# tigon-shiro

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-shiro-war</artifactId>
<name>Tigon Shiro WAR</name>
<packaging>jar</packaging>
<parent>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-shiro-core</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,6 +0,0 @@
/**
* @author Donghuang <br>
* donghuang@wacai.com <br>
* Mar 07, 2017 13:35
*/
package me.chyxion.tigon.shiro;

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
<name>tigon-webmvc-shiro</name>
<ordering>
<after><others /></after>
</ordering>
<!-- Shiro Filter -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
</web-fragment>

View File

@ -1,17 +0,0 @@
package me.chyxion.tigon.shiro;
import org.junit.Test;
/**
* @version 0.0.1
* @since 0.0.1
* @author chyxion <br>
* chyxion@163.com <br>
* Mar 14, 2015 3:03:57 PM
*/
public class TestDriver {
@Test
public void test() {
}
}

View File

@ -1,103 +0,0 @@
package me.chyxion.tigon.shiro.controller;
import me.chyxion.tigon.format.annotation.EmptyToNull;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.HashMap;
import java.util.Map;
/**
* @version 0.0.1
* @since 0.0.1
* @author chyxion <br>
* chyxion@163.com <br>
* May 31, 2015 3:53:04 PM
*/
@Validated
@Controller
public class SiteController {
@RequestMapping("/")
public void index() {
}
@RequestMapping("/v")
public String index(@RequestParam("v")
// @EmptyToNull
String validate) {
return validate;
}
@RequestMapping("/raw")
public Map<String, Object> raw() {
Map<String, Object> mapRaw = new HashMap<String, Object>();
mapRaw.put("data", "Hello!");
return mapRaw;
}
@RequestMapping("/int")
public int integer() {
return 99;
}
@RequestMapping("/post")
public String post(@Validated Form form) {
return form.getId();
}
public static class Form {
@NotBlank
private String id;
@NotBlank
private String name;
@EmptyToNull
private String gender;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the gender
*/
public String getGender() {
return gender;
}
/**
* @param gender the gender to set
*/
public void setGender(String gender) {
this.gender = gender;
}
}
}

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
<Property name="log.dir">.logs</Property>
<Property name="log.level">DEBUG</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${pattern}" />
</Console>
<RollingFile name="File"
fileName="${log.dir}/log.log"
filePattern="${log.dir}/$${date:yyyy-MM}/log-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="${pattern}" />
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="16 MB" />
</Policies>
<DefaultRolloverStrategy max="32" />
</RollingFile>
<Async name="AsyncFile">
<AppenderRef ref="File" />
</Async>
</Appenders>
<Loggers>
<Logger name="org.springframework" additivity="false">
<AppenderRef ref="AsyncFile" level="INFO" />
</Logger>
<Logger name="org.apache" additivity="false">
<AppenderRef ref="AsyncFile" level="INFO" />
</Logger>
<Root level="DEBUG" additivity="false">
<AppenderRef ref="Console" level="DEBUG" />
</Root>
</Loggers>
</Configuration>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- Scan Controllers -->
<context:component-scan base-package="me.chyxion.tigon.webmvc.test"
use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController" />
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
</context:component-scan>
<bean class="me.chyxion.tigon.webmvc.test.ControllerTestTool" />
</beans>

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>${project.name}</display-name>
<description>${project.description}</description>
<!-- Your Configurations Are Here! -->
</web-app>

View File

@ -5,10 +5,10 @@
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-webmvc-core</artifactId>
<artifactId>tigon-web</artifactId>
<packaging>jar</packaging>
<name>Tigon Web MVC Core</name>
<description>Tigon Web MVC Core</description>
<name>Tigon Web</name>
<description>Tigon Web</description>
<parent>
<groupId>me.chyxion.tigon</groupId>
@ -22,6 +22,10 @@
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-model</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
@ -36,7 +40,8 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<artifactId>spring-test</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
@ -48,20 +53,16 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -1,17 +1,15 @@
package me.chyxion.tigon.webmvc;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import me.chyxion.tigon.webmvc.exception.ExceptionResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import me.chyxion.tigon.webmvc.exception.ExceptionResolver;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* @since 0.0.1
@ -20,7 +18,7 @@ import java.util.List;
* Jul 18, 2014 8:50:17 AM
*/
@Slf4j
@Order(Ordered.LOWEST_PRECEDENCE)
@Order
@ControllerAdvice(annotations = {Controller.class, RestController.class})
public class TigonControllerAdvice {

View File

@ -1,14 +1,13 @@
package me.chyxion.tigon.webmvc;
import java.util.Map;
import java.util.HashMap;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import java.util.HashMap;
import java.util.Map;
import org.aspectj.lang.annotation.AfterReturning;
/**
* process return map
@ -45,7 +44,7 @@ public class TigonControllerAspect {
public void afterReturning(JoinPoint jp, Object result) {
if (result instanceof Map) {
if (log.isDebugEnabled()) {
log.debug("Controller Aspect After Returning, Return Map [{}].", JSON.toJSON(result));
log.debug("Controller aspect after returning, return map [{}].", JSON.toJSON(result));
}
@SuppressWarnings("unchecked")
Map<String, Object> mapRtn = (Map<String, Object>) result;

View File

@ -0,0 +1,95 @@
package me.chyxion.tigon.webmvc;
import java.util.List;
import java.util.Collections;
import java.nio.charset.StandardCharsets;
import org.springframework.http.MediaType;
import org.springframework.context.annotation.Bean;
import org.springframework.format.FormatterRegistry;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.converter.StringHttpMessageConverter;
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 01, 2017 10:35:14
*/
@EnableWebMvc
@Configuration
@EnableAspectJAutoProxy
@ConditionalOnWebApplication
@ImportResource("classpath*:spring/spring-*.xml")
public class TigonWebConfiguration implements WebMvcConfigurer {
/**
* {@inheritDoc}
*/
@Override
public void addFormatters(final FormatterRegistry registry) {
// converters
registry.addConverter(new StringToJSONObjectTypeConverter());
registry.addConverter(new StringToJSONArrayTypeConverter());
// formatters
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
}
/**
* {@inheritDoc}
*/
@Override
public void addReturnValueHandlers(
final List<HandlerMethodReturnValueHandler> returnValueHandlers) {
returnValueHandlers.add(returnValueHandler());
}
@Bean
public HandlerMethodReturnValueHandler returnValueHandler() {
return new TigonReturnValueHandler();
}
/**
* {@inheritDoc}
*/
@Override
public void configurePathMatch(final PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
configurer.setUseRegisteredSuffixPatternMatch(false);
}
/**
* {@inheritDoc}
*/
@Override
public void configureMessageConverters(
List<HttpMessageConverter<?>> converters) {
converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
final FastJsonHttpMessageConverter4 fastJsonMessageConverter =
new FastJsonHttpMessageConverter4();
fastJsonMessageConverter.setSupportedMediaTypes(
Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));
fastJsonMessageConverter.getFastJsonConfig()
.setSerializerFeatures(
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullBooleanAsFalse);
converters.add(fastJsonMessageConverter);
}
}

View File

@ -2,9 +2,8 @@ package me.chyxion.tigon.webmvc.exception;
import java.util.Set;
import java.util.List;
import org.slf4j.Logger;
import java.util.ArrayList;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import javax.validation.ConstraintViolation;
import org.springframework.core.annotation.Order;
import me.chyxion.tigon.webmvc.JSONViewDataModel;
@ -18,16 +17,15 @@ import me.chyxion.tigon.exception.InvalidParamException;
* chyxion@163.com <br>
* Mar 28, 2016 6:39:36 PM
*/
@Slf4j
@Order(10)
public class ConstraintViolationExceptionResolver implements ExceptionResolver {
private static final Logger log =
LoggerFactory.getLogger(ConstraintViolationExceptionResolver.class);
/**
* {@inheritDoc}
*/
@Override
public boolean accept(Throwable ex) {
public boolean accept(final Throwable ex) {
return ex instanceof ConstraintViolationException;
}
@ -40,7 +38,7 @@ public class ConstraintViolationExceptionResolver implements ExceptionResolver {
((ConstraintViolationException) model.getException()).getConstraintViolations();
final List<String> messages = new ArrayList<String>(cvs.size());
for (ConstraintViolation<?> cv : cvs) {
log.info("Constraint Violation [{}] Caused.", cv);
log.info("Constraint violation [{}] Caused.", cv);
messages.add("'" + cv.getPropertyPath() + "' " + cv.getMessage());
}
model.setCode(InvalidParamException.CODE);

View File

@ -22,8 +22,8 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
* chyxion@163.com <br>
* Feb 3, 2015 2:06:58 PM
*/
@Order(64)
@Slf4j
@Order(64)
public class DefaultExceptionResolver implements ExceptionResolver {
@Autowired(required = false)
private ExceptionMessage exceptionMessage;

View File

@ -1,2 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
me.chyxion.tigon.shiro.TigonShiroConfig
me.chyxion.tigon.webmvc.TigonWebConfiguration

View File

@ -15,19 +15,4 @@
<bean class="me.chyxion.tigon.webmvc.exception.DefaultExceptionResolver" />
<bean class="me.chyxion.tigon.webmvc.DefaultViewResolver" p:order="64" />
<!--<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor" />-->
<!--<bean id="mvcValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">-->
<!--<property name="validationMessageSource">-->
<!--<bean class="org.springframework.context.shiro.ReloadableResourceBundleMessageSource"-->
<!--p:fallbackToSystemLocale="true"-->
<!--p:useCodeAsDefaultMessage="false"-->
<!--p:defaultEncoding="UTF-8">-->
<!--<property name="basenames">-->
<!--<list>-->
<!--<value>classpath:i18n/messages</value>-->
<!--</list>-->
<!--</property>-->
<!--</bean>-->
<!--</property>-->
<!--</bean>-->
</beans>

View File

@ -1,29 +0,0 @@
package me.chyxion.tigon.webmvc;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.HandlerInterceptor;
/**
* @version 0.0.2
* @since 0.0.1
* @author Donghuang <br>
* donghuang@wacai.com <br>
* Jul 16, 2014 10:07:52 PM
*/
public interface TigonHandlerInterceptor extends HandlerInterceptor {
/**
* @return include path patterns
*/
String[] includePathPatterns();
/**
* @return exinclude path patterns
*/
String[] excludePathPatterns();
/**
* @return path matcher
*/
PathMatcher pathMatcher();
}

View File

@ -1,175 +0,0 @@
package me.chyxion.tigon.webmvc;
import java.util.List;
import java.util.Locale;
import java.util.Collections;
import java.nio.charset.Charset;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.http.MediaType;
import org.springframework.util.PathMatcher;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.CharEncoding;
import org.springframework.validation.Validator;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.LocaleResolver;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 01, 2017 10:35:14
*/
@Slf4j
public class TigonWebMvcConfiguration extends WebMvcConfigurationSupport {
@Autowired
private Validator validator;
@Autowired
private List<ViewResolver> viewResolvers;
@Autowired(required = false)
private List<TigonHandlerInterceptor> handlerInterceptors;
/**
* {@inheritDoc}
*/
@Override
public void addFormatters(FormatterRegistry registry) {
super.addFormatters(registry);
// converters
registry.addConverter(new StringToJSONObjectTypeConverter());
registry.addConverter(new StringToJSONArrayTypeConverter());
// formatters
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
}
/**
* {@inheritDoc}
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
super.addInterceptors(registry);
// custom interceptors
if (handlerInterceptors != null &&
!handlerInterceptors.isEmpty()) {
for (TigonHandlerInterceptor handlerInterceptor : handlerInterceptors) {
log.info("Re");
final String[] includePathPatterns = handlerInterceptor.includePathPatterns();
Assert.state(includePathPatterns != null && includePathPatterns.length > 0,
"Handler Interceptor 'includePathPatterns' Could Not Be Empty");
final InterceptorRegistration interceptorRegistration =
registry.addInterceptor(handlerInterceptor)
.addPathPatterns(includePathPatterns);
final String[] excludePathPatterns =
handlerInterceptor.excludePathPatterns();
if (excludePathPatterns != null && excludePathPatterns.length > 0) {
interceptorRegistration.excludePathPatterns(excludePathPatterns);
}
final PathMatcher pathMatcher = handlerInterceptor.pathMatcher();
if (pathMatcher != null) {
interceptorRegistration
.pathMatcher(pathMatcher);
}
}
}
}
/**
* {@inheritDoc}
*/
@Override
public void addReturnValueHandlers(
List<HandlerMethodReturnValueHandler> returnValueHandlers) {
returnValueHandlers.add(returnValueHandler());
super.addReturnValueHandlers(returnValueHandlers);
}
@Bean
public HandlerMethodReturnValueHandler returnValueHandler() {
return new TigonReturnValueHandler();
}
/**
* {@inheritDoc}
*/
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
configurer.setUseRegisteredSuffixPatternMatch(false);
super.configurePathMatch(configurer);
}
/**
* {@inheritDoc}
*/
@Override
public void configureMessageConverters(
List<HttpMessageConverter<?>> converters) {
converters.add(new StringHttpMessageConverter(Charset.forName(CharEncoding.UTF_8)));
FastJsonHttpMessageConverter4 fastJsonMessageConverter =
new FastJsonHttpMessageConverter4();
fastJsonMessageConverter.setSupportedMediaTypes(
Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));
fastJsonMessageConverter.getFastJsonConfig()
.setSerializerFeatures(
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullBooleanAsFalse);
converters.add(fastJsonMessageConverter);
super.configureMessageConverters(converters);
}
/**
* {@inheritDoc}
*/
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
for (ViewResolver viewResolver : viewResolvers) {
log.info("Register View Resolver [{}].", viewResolver);
registry.viewResolver(viewResolver);
}
registry.enableContentNegotiation(false);
super.configureViewResolvers(registry);
}
/**
* {@inheritDoc}
*/
@Override
public Validator getValidator() {
return validator;
}
@Bean
public LocaleResolver localeResolver() {
return new CookieLocaleResolver() {
private LocaleResolver acceptHeaderLocaleResolver =
new AcceptHeaderLocaleResolver();
@Override
public Locale resolveLocale(HttpServletRequest request) {
Locale locale = super.determineDefaultLocale(request);
return locale != null ?
locale : acceptHeaderLocaleResolver.resolveLocale(request);
}
};
}
}

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
<Property name="log.dir">.logs</Property>
<Property name="log.level">DEBUG</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${pattern}" />
</Console>
<RollingFile name="File"
fileName="${log.dir}/log.log"
filePattern="${log.dir}/$${date:yyyy-MM}/log-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="${pattern}" />
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="16 MB" />
</Policies>
<DefaultRolloverStrategy max="32" />
</RollingFile>
<Async name="AsyncFile">
<AppenderRef ref="File" />
</Async>
</Appenders>
<Loggers>
<Logger name="org.springframework" additivity="false">
<AppenderRef ref="AsyncFile" level="INFO" />
</Logger>
<Logger name="org.apache" additivity="false">
<AppenderRef ref="AsyncFile" level="INFO" />
</Logger>
<Root level="DEBUG" additivity="false">
<AppenderRef ref="File" level="${log.level}" />
<AppenderRef ref="Console" level="${log.level}" />
</Root>
</Loggers>
</Configuration>

View File

@ -1 +0,0 @@
# tigon-webmvc

View File

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tigon-webmvc-spring-boot</artifactId>
<packaging>jar</packaging>
<name>Tigon Web MVC Spring Boot</name>
<description>Tigon Web MVC Spring Boot</description>
<parent>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-webmvc-core</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-freemarker-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.chyxion.tigon</groupId>
<artifactId>tigon-extjs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,163 +0,0 @@
package me.chyxion.tigon.webmvc.springboot;
import java.util.List;
import java.util.Locale;
import java.util.Collections;
import java.nio.charset.Charset;
import org.springframework.util.Assert;
import org.springframework.http.MediaType;
import org.springframework.util.PathMatcher;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.CharEncoding;
import org.springframework.context.annotation.Bean;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.LocaleResolver;
import me.chyxion.tigon.webmvc.TigonReturnValueHandler;
import me.chyxion.tigon.webmvc.TigonHandlerInterceptor;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.mvc.WebContentInterceptor;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
import me.chyxion.tigon.webmvc.formatter.TrimAnnotationFormatterFactory;
import me.chyxion.tigon.webmvc.converter.StringToJSONArrayTypeConverter;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4;
import me.chyxion.tigon.webmvc.converter.StringToJSONObjectTypeConverter;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import me.chyxion.tigon.webmvc.formatter.EmptyToNullAnnotationFormatterFactory;
import org.springframework.format.number.NumberFormatAnnotationFormatterFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 01, 2017 10:35:14
*/
@EnableWebMvc
@Configuration
@EnableAspectJAutoProxy
@ConditionalOnWebApplication
@ImportResource("classpath*:spring/spring-*.xml")
public class TigonWebMvcSpringBootConfiguration extends WebMvcConfigurerAdapter {
@Autowired(required = false)
private List<TigonHandlerInterceptor> handlerInterceptors;
/**
* {@inheritDoc}
*/
@Override
public void addFormatters(FormatterRegistry registry) {
super.addFormatters(registry);
// converters
registry.addConverter(new StringToJSONObjectTypeConverter());
registry.addConverter(new StringToJSONArrayTypeConverter());
// formatters
registry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new EmptyToNullAnnotationFormatterFactory());
registry.addFormatterForFieldAnnotation(new TrimAnnotationFormatterFactory());
}
/**
* {@inheritDoc}
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
super.addInterceptors(registry);
registry.addInterceptor(new WebContentInterceptor())
.excludePathPatterns("/assets/**", "classpath:webapp/assets/**");
if (handlerInterceptors != null &&
!handlerInterceptors.isEmpty()) {
for (TigonHandlerInterceptor handlerInterceptor : handlerInterceptors) {
final String[] includePathPatterns = handlerInterceptor.includePathPatterns();
Assert.state(includePathPatterns != null && includePathPatterns.length > 0,
"Handler Interceptor 'includePathPatterns' Could Not Be Empty");
final InterceptorRegistration interceptorRegistration =
registry.addInterceptor(handlerInterceptor)
.addPathPatterns(includePathPatterns);
final String[] excludePathPatterns =
handlerInterceptor.excludePathPatterns();
if (excludePathPatterns != null && excludePathPatterns.length > 0) {
interceptorRegistration.excludePathPatterns(excludePathPatterns);
}
final PathMatcher pathMatcher = handlerInterceptor.pathMatcher();
if (pathMatcher != null) {
interceptorRegistration
.pathMatcher(pathMatcher);
}
}
}
}
/**
* {@inheritDoc}
*/
@Override
public void addReturnValueHandlers(
List<HandlerMethodReturnValueHandler> returnValueHandlers) {
returnValueHandlers.add(returnValueHandler());
super.addReturnValueHandlers(returnValueHandlers);
}
@Bean
public HandlerMethodReturnValueHandler returnValueHandler() {
return new TigonReturnValueHandler();
}
/**
* {@inheritDoc}
*/
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false);
configurer.setUseRegisteredSuffixPatternMatch(false);
super.configurePathMatch(configurer);
}
/**
* {@inheritDoc}
*/
@Override
public void configureMessageConverters(
List<HttpMessageConverter<?>> converters) {
converters.add(new StringHttpMessageConverter(Charset.forName(CharEncoding.UTF_8)));
final FastJsonHttpMessageConverter4 fastJsonMessageConverter =
new FastJsonHttpMessageConverter4();
fastJsonMessageConverter.setSupportedMediaTypes(
Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));
fastJsonMessageConverter.getFastJsonConfig()
.setSerializerFeatures(
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullBooleanAsFalse);
converters.add(fastJsonMessageConverter);
super.configureMessageConverters(converters);
}
@Bean
public LocaleResolver localeResolver() {
return new CookieLocaleResolver() {
private final LocaleResolver acceptHeaderLocaleResolver =
new AcceptHeaderLocaleResolver();
/**
* {@inheritDoc}
*/
@Override
public Locale resolveLocale(HttpServletRequest request) {
final Locale locale = super.determineDefaultLocale(request);
return locale != null ?
locale : acceptHeaderLocaleResolver.resolveLocale(request);
}
};
}
}

View File

@ -1,2 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
me.chyxion.tigon.webmvc.springboot.TigonWebMvcSpringBootConfiguration

View File

@ -1,19 +0,0 @@
package me.chyxion.tigon.webmvc.test;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 05, 2017 12:12:56
*/
@ComponentScan("me.chyxion.tigon.webmvc.test")
@EnableAutoConfiguration
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}

View File

@ -1,84 +0,0 @@
package me.chyxion.tigon.webmvc.test;
import java.util.Map;
import org.junit.Test;
import java.util.HashMap;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @version 0.0.1
* @since 0.0.1
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Jan 27, 2015 3:27:08 PM
*/
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Main.class)
@SpringBootTest
public class SiteControllerTest {
@Autowired
private ControllerTestTool t;
@Test
public void testIndex() {
t.print(t.get("/"));
}
@Test
public void testRaw() {
t.print(t.get("/raw"));
}
@Test
public void testInt() {
t.print(t.get("/int"));
}
@Test
public void testFtl() {
t.print(t.get("/test"));
}
@Test
public void testViewModels() {
t.print(t.get("/view-model"));
}
@Test
public void testListResult() {
t.print(t.get("/list-result"));
}
@Test
public void testListResult1() {
t.print(t.get("/list-result1"));
}
@Test
public void testExtJsCommon() {
t.print(t.get("/assets/js/extjs-commons.js"));
}
@Test
public void testPost() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", "id");
params.put("name", "Shaun Chyxion");
params.put("gender", "");
t.print(t.post("/post", params));
}
@Test
public void testRequired() {
Map<String, Object> params = new HashMap<String, Object>();
// params.put("param", "");
t.print(t.post("/required", params));
}
}

View File

@ -1,139 +0,0 @@
package me.chyxion.tigon.webmvc.test.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import me.chyxion.tigon.model.ListResult;
import me.chyxion.tigon.model.ViewModel;
import me.chyxion.tigon.model.ViewModelable;
import org.springframework.stereotype.Controller;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
/**
* @version 0.0.1
* @since 0.0.1
* @author chyxion <br>
* chyxion@163.com <br>
* May 31, 2015 3:53:04 PM
*/
@Validated
@Controller
public class SiteController {
@RequestMapping("/")
public void index() {
}
@RequestMapping("/required")
public String required(
@NotBlank
@RequestParam("param") String param) {
return param;
}
@RequestMapping("/raw")
public Map<String, Object> raw() {
Map<String, Object> mapRaw = new HashMap<String, Object>();
mapRaw.put("data", "Hello!");
return mapRaw;
}
@RequestMapping("/int")
public int integer() {
return 99;
}
@RequestMapping("/test")
public ModelAndView test() {
return new ModelAndView("test").addObject("name", "FreeMarker");
}
@RequestMapping("/view-models")
public List<ViewModel<Integer>> viewModels() {
return Arrays.asList(
new ViewModel<Integer>(1)
.setAttr("name", "foo"),
new ViewModel<Integer>(2)
.setAttr("name", "bar")
.setAttr("other",
new ViewModel<Integer>(3)
.setAttr("name", "foobar")));
}
@RequestMapping("/list-result")
public ViewModelable<List<Integer>> listResult() {
return new ListResult<Integer>().setTotal(10).setData(Arrays.asList(1, 2, 3)).setAttr("attr", "foo");
}
@RequestMapping("/list-result1")
public List<ViewModelable<List<Integer>>> listResult1() {
return Arrays.asList(
new ListResult<Integer>()
.setTotal(10)
.setData(Arrays.asList(1, 2, 3))
.setAttr("attr", "foo"));
}
@RequestMapping("/post")
public String post(@Validated Form form) {
return form.getId();
}
public static class Form {
@NotBlank
private String id;
@NotBlank
private String name;
@NotBlank
private String gender;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the gender
*/
public String getGender() {
return gender;
}
/**
* @param gender the gender to set
*/
public void setGender(String gender) {
this.gender = gender;
}
}
}

View File

@ -1,50 +0,0 @@
package me.chyxion.tigon.webmvc.test.interceptor;
import lombok.extern.slf4j.Slf4j;
import me.chyxion.tigon.webmvc.TigonHandlerInterceptor;
import org.springframework.stereotype.Service;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author Shaun Chyxion <br>
* chyxion@163.com <br>
* Mar 19, 2017 12:48:04
*/
@Slf4j
@Service
public class TimeHandlerInterceptor implements TigonHandlerInterceptor {
@Override
public String[] includePathPatterns() {
return new String[] {"/**"};
}
@Override
public String[] excludePathPatterns() {
return new String[0];
}
@Override
public PathMatcher pathMatcher() {
return null;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
request.setAttribute("Begin", System.currentTimeMillis());
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
System.err.println("Time: " + request.getAttribute("Begin"));
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
}
}

View File

@ -1 +0,0 @@
tigon.webmvc.jsonview.code_key=code

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
<Property name="log.dir">.logs</Property>
<Property name="log.level">DEBUG</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${pattern}" />
</Console>
<RollingFile name="File"
fileName="${log.dir}/log.log"
filePattern="${log.dir}/$${date:yyyy-MM}/log-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="${pattern}" />
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="16 MB" />
</Policies>
<DefaultRolloverStrategy max="32" />
</RollingFile>
<Async name="AsyncFile">
<AppenderRef ref="File" />
</Async>
</Appenders>
<Loggers>
<Logger name="org.springframework" additivity="false">
<AppenderRef ref="AsyncFile" level="INFO" />
</Logger>
<Logger name="org.apache" additivity="false">
<AppenderRef ref="AsyncFile" level="INFO" />
</Logger>
<Root level="DEBUG" additivity="false">
<AppenderRef ref="File" level="${log.level}" />
<AppenderRef ref="Console" level="${log.level}" />
</Root>
</Loggers>
</Configuration>

View File

@ -1,11 +0,0 @@
# Config Dev
# Database
db.url=jdbc:mysql://10.0.0.31/yxt?useUnicode=true&characterEncoding=utf8
db.user=yxt
db.password=yxt402
# Redis
redis.host=127.0.0.1
redis.port=6379
redis.password=0211

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