parameter) {
21 | return mapper.selectList(parameter);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/AngularJS/web/angluar-phonecat/step-9-practice.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | angular 内置过滤器演示
10 |
11 | uppercase: {{ "lower cap string" | uppercase }}
12 |
13 |
14 | json: {{ {foo: "bar", baz: 23} | json }}
15 |
16 |
17 | date: {{ 1304375948024 | date }}
18 |
19 |
20 | date:"MM/dd/yyyy @ h:mma": {{ 1304375948024 | date:"MM/dd/yyyy @ h:mma" }}
21 |
22 |
23 |
--------------------------------------------------------------------------------
/junit4/src/test/java/com/github/loafer/junit/AssertTests.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.junit;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Ignore;
5 | import org.junit.Test;
6 |
7 | /**
8 | * Date Created 14-3-17
9 | *
10 | * @author zjh
11 | */
12 | public class AssertTests {
13 |
14 | @Test
15 | public void testAssertArrayEquals(){
16 | byte[] expected = "trial".getBytes();
17 | byte[] actual = "trial".getBytes();
18 | Assert.assertArrayEquals("failure - byte arrays not same", expected, actual);
19 | }
20 |
21 | @Test
22 | @Ignore
23 | public void testAssertEquals(){
24 | Assert.assertEquals("failure - strings not same", 51, 52);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AngularJS/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.github.loafer
8 | AngularJS
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
13 | javax.servlet
14 | javax.servlet-api
15 | 3.1.0
16 |
17 |
18 |
--------------------------------------------------------------------------------
/logback/src/main/java/com/github/loafer/logback/HelloWorld2.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.logback;
2 |
3 | import ch.qos.logback.classic.LoggerContext;
4 | import ch.qos.logback.core.util.StatusPrinter;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | /**
9 | * Date Created 14-3-17
10 | *
11 | * @author zjh
12 | */
13 | public class HelloWorld2 {
14 | public static void main(String[] args){
15 | Logger logger = LoggerFactory.getLogger("com.github.loafer.logback.HelloWorld2");
16 | logger.debug("Hello World.");
17 |
18 | //print internal state
19 | LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
20 | StatusPrinter.print(lc);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/reactor-spring/src/main/java/com/github/loafer/hello/HelloApplication.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.hello;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.ComponentScan;
5 | import org.springframework.context.annotation.Configuration;
6 | import reactor.core.Environment;
7 | import reactor.core.Reactor;
8 | import reactor.core.spec.Reactors;
9 | import reactor.spring.context.config.EnableReactor;
10 |
11 | /**
12 | * @author zhaojh
13 | */
14 | @Configuration
15 | @EnableReactor
16 | @ComponentScan
17 | public class HelloApplication {
18 | @Bean
19 | public Reactor rootReactor(Environment env){
20 | return Reactors.reactor().env(env).get();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring4-mvc-exception-handling/web/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | examples
8 | org.springframework.web.servlet.DispatcherServlet
9 | 1
10 |
11 |
12 | examples
13 | /
14 |
15 |
--------------------------------------------------------------------------------
/spring4-mvc-xml-complex/src/main/webapp/WEB-INF/views/user/index.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Created by IntelliJ IDEA.
3 | User: zjh
4 | Date: 14-5-22
5 | Time: 下午2:33
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 | <%
10 | String path = request.getContextPath();
11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
12 | %>
13 |
14 |
15 |
16 |
17 |
18 |
19 | User List
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/AngularJS/web/custom-directive/isolate-fun-bind-directive-01/script.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by zjh on 14-5-16.
3 | */
4 | angular.module('docsIsoFnBindExample', [])
5 | .controller('Controller', ['$scope', '$timeout', function($scope, $timeout){
6 | $scope.name = 'Tobias';
7 | $scope.hideDialog = function(){
8 | $scope.dialogIsHidden = true;
9 | $timeout(function(){
10 | $scope.dialogIsHidden = false;
11 | }, 2000);
12 | }
13 | }])
14 | .directive('myDialogClose', function(){
15 | return {
16 | restrict: 'E',
17 | transclude: true,
18 | scope: {
19 | close: '&onClose'
20 | },
21 | templateUrl: 'my-dialog-close.html'
22 | }
23 | });
--------------------------------------------------------------------------------
/reactor-spring/src/main/java/com/github/loafer/hello/consumer/HelloConsumer.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.hello.consumer;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import org.springframework.stereotype.Component;
6 | import reactor.event.Event;
7 | import reactor.function.Consumer;
8 |
9 | /**
10 | * @author zhaojh
11 | */
12 | @Component
13 | public class HelloConsumer implements Consumer>{
14 | private static final Logger logger = LoggerFactory.getLogger(HelloConsumer.class);
15 |
16 | @Override
17 | public void accept(Event event) {
18 | logger.info("{} handler accept: {}", event.getKey(), event.getData());
19 | event.setData("Hello " + event.getData());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spring4-mybatis/src/test/resources/simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/AngularJS/web/angluar-phonecat/step-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/spring4-mybatis/src/test/resources/generics.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/AngularJS/web/custom-directive/tabs-example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Hello
11 | Lorem ipsum dolor sit amet
12 |
13 |
14 | World
15 | Mauris elementum elementum enim at suscipit.
16 | counter: {{i || 0}}
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/core-java-annotation/src/main/java/com/github/loafer/annotation/AnnotationExample.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.annotation;
2 |
3 | import com.github.loafer.annotation.declaration.NullValueValidate;
4 | import com.github.loafer.annotation.processor.NullValueValidateProcessor;
5 |
6 | /**
7 | * Created by zhaojh on 2014/6/9.
8 | */
9 | public class AnnotationExample {
10 | @NullValueValidate(fieldName = "testVar1")
11 | private String testVar1;
12 |
13 | @NullValueValidate(fieldName = "testVar2")
14 | private String testVar2 = "hello world";
15 |
16 | public AnnotationExample(){
17 | NullValueValidateProcessor.process(this);
18 | }
19 |
20 | public static void main(String[] args){
21 | AnnotationExample annotationExample = new AnnotationExample();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/jasig-cas-client-custom-login/src/main/webapp/WEB-INF/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/mybatis-simple-common-mapper/src/test/java/com/github/quick4j/mybatis/mapper/builder/assistant/MappedStatementAssistant.java:
--------------------------------------------------------------------------------
1 | package com.github.quick4j.mybatis.mapper.builder.assistant;
2 |
3 | import org.apache.ibatis.mapping.MappedStatement;
4 | import org.apache.ibatis.session.SqlSession;
5 |
6 | /**
7 | * @author zhaojh.
8 | */
9 | public class MappedStatementAssistant {
10 | private MappedStatementAssistant(){}
11 |
12 | public static boolean hasStatementInSqlSession(String statementName, SqlSession sqlSession){
13 | return sqlSession.getConfiguration().hasStatement(statementName, false);
14 | }
15 |
16 | public static MappedStatement getMappedStatement(String statementName, SqlSession sqlSession){
17 | return sqlSession.getConfiguration().getMappedStatement(statementName);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/spring4-mvc-xml-complex/src/main/webapp/WEB-INF/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/reactor-spring/src/main/java/com/github/loafer/hello/consumer/HandlerBean.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.hello.consumer;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import reactor.event.Event;
6 | import reactor.spring.context.annotation.Consumer;
7 | import reactor.spring.context.annotation.Selector;
8 |
9 | /**
10 | * @author zhaojh
11 | */
12 | @Consumer
13 | public class HandlerBean {
14 | private static final Logger logger = LoggerFactory.getLogger(HandlerBean.class);
15 |
16 | @Selector(value = "english", reactor = "@rootReactor")
17 | public void english(String s){
18 | logger.info("Hello, {}", s);
19 | }
20 |
21 | @Selector(value = "chinese", reactor = "@rootReactor")
22 | public void chinese(Event event){
23 | logger.info("你好, {}", event.getData());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/reactor-spring/src/main/java/com/github/loafer/hello/consumer/ResultHandlerBean.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.hello.consumer;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import reactor.spring.context.annotation.Consumer;
6 | import reactor.spring.context.annotation.Selector;
7 |
8 | /**
9 | * @author zhaojh
10 | */
11 | @Consumer
12 | public class ResultHandlerBean {
13 | private static final Logger logger = LoggerFactory.getLogger(ResultHandlerBean.class);
14 |
15 | @Selector(value = "replyInEnglish", reactor = "@rootReactor")
16 | public void speakEnglish(String value){
17 | logger.info("Hello, {}", value);
18 | }
19 |
20 | @Selector(value = "replyInChinese", reactor = "@rootReactor")
21 | public void speakChinese(String value){
22 | logger.info("你好,{}", value);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/mybatis-sqlbuilder/src/main/java/com/github/quick4j/core/repository/mybaits/sqlbuilder/EntityAssistant.java:
--------------------------------------------------------------------------------
1 | package com.github.quick4j.core.repository.mybaits.sqlbuilder;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | /**
7 | * @author zhaojh.
8 | */
9 | public class EntityAssistant {
10 | private static Map entityPersistentInfoMap = new HashMap();
11 |
12 | public static EntityPersistentInfo parse(Class entityClass){
13 | if(entityPersistentInfoMap.containsKey(entityClass)){
14 | return entityPersistentInfoMap.get(entityClass);
15 | }
16 |
17 | EntityPersistentInfo persistentInfo = new EntityPersistentInfo(entityClass);
18 | entityPersistentInfoMap.put(entityClass, persistentInfo);
19 | return persistentInfo;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/reactor-spring/src/test/resources/spring-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/mybatis-simple-common-mapper/src/test/java/com/github/quick4j/mybatis/mapper/builder/assistant/EntityAssistant.java:
--------------------------------------------------------------------------------
1 | package com.github.quick4j.mybatis.mapper.builder.assistant;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | /**
7 | * @author zhaojh.
8 | */
9 | public class EntityAssistant {
10 | private static Map entityPersistentInfoMap = new HashMap();
11 |
12 | public static EntityPersistentInfo parse(Class entityClass){
13 | if(entityPersistentInfoMap.containsKey(entityClass)){
14 | return entityPersistentInfoMap.get(entityClass);
15 | }
16 |
17 | EntityPersistentInfo persistentInfo = new EntityPersistentInfo(entityClass);
18 | entityPersistentInfoMap.put(entityClass, persistentInfo);
19 | return persistentInfo;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spring-security-web/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 | springSecurityFilterChain
9 | org.springframework.web.filter.DelegatingFilterProxy
10 |
11 |
12 |
13 | springSecurityFilterChain
14 | /*
15 |
16 |
17 |
18 | org.springframework.web.context.ContextLoaderListener
19 |
20 |
--------------------------------------------------------------------------------
/jasig-cas-client-custom-login/src/main/webapp/success.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Created by IntelliJ IDEA.
3 | User: zhaojh
4 | Date: 2014/5/30
5 | Time: 17:14
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 | <%
10 | String path = request.getContextPath();
11 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
12 | %>
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Welcome !!!
21 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/mybatis-simple-common-mapper/src/test/java/com/github/quick4j/mybatis/mapper/builder/MapperBuilder.java:
--------------------------------------------------------------------------------
1 | package com.github.quick4j.mybatis.mapper.builder;
2 |
3 | import javassist.ClassPool;
4 | import javassist.CtClass;
5 |
6 | /**
7 | * @author zhaojh.
8 | */
9 | public class MapperBuilder {
10 | private ClassPool pool = ClassPool.getDefault();
11 |
12 | public Class build(String className, Class superInterface){
13 | Class mapper = null;
14 | try{
15 | CtClass superclass = pool.get(superInterface.getName());
16 | CtClass ctMapper = pool.makeInterface(className, superclass);
17 | mapper = ctMapper.toClass();
18 | }catch (Exception e){
19 | String message = String.format("创建[%s]失败。", className);
20 | throw new RuntimeException(message, e);
21 | }
22 | return mapper;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/spring4-mybatis/src/main/java/com/github/loafer/mybatis/simple/UserService.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.mybatis.simple;
2 |
3 | import com.github.loafer.mybatis.simple.mapper.UserMapper;
4 | import com.github.loafer.mybatis.simple.model.User;
5 |
6 | import javax.annotation.Resource;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | /**
11 | * @author zhaojh
12 | */
13 | public class UserService implements IUserService {
14 |
15 | private UserMapper userMapper;
16 |
17 | @Resource
18 | public void setUserMapper(UserMapper userMapper) {
19 | this.userMapper = userMapper;
20 | }
21 |
22 | @Override
23 | public User find(String id) {
24 | return userMapper.selectOne(id);
25 | }
26 |
27 | @Override
28 | public List find(Map parameter) {
29 | return userMapper.selectList(parameter);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/core-java-annotation/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.github.loafer
6 | core-java-annotation
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | core-java-annotation
11 | http://maven.apache.org
12 |
13 |
14 | UTF-8
15 |
16 |
17 |
18 |
19 | junit
20 | junit
21 | 4.11
22 | test
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/xml/src/test/resources/example.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/AngularJS/web/angluar-phonecat/js/controllers.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by zjh on 14-5-12.
3 | */
4 | //'use strict';
5 | var phonecatControllers = angular.module('phonecatControllers', []);
6 |
7 | phonecatControllers.controller('PhoneListCtrl', ['$scope', '$http', function($scope, $http){
8 | $http.get('phones/phones.json').success(function(data){
9 | $scope.phones = data.splice(0, 5);
10 | $scope.orderPro = 'age';
11 | });
12 | }]);
13 |
14 | phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams', '$http', function($scope, $routeParams, $http){
15 | // $scope.phoneId = $routeParams.phoneId;
16 | $http.get('phones/' + $routeParams.phoneId + '.json').success(function(data){
17 | $scope.phone = data;
18 | $scope.mainImageUrl = data.images[0]
19 | });
20 |
21 | $scope.setImage = function(imgUrl){
22 | $scope.mainImageUrl = imgUrl;
23 | }
24 | }]);
25 |
26 |
--------------------------------------------------------------------------------
/mybatis-sqlbuilder/src/main/java/com/github/quick4j/core/repository/mybaits/sqlbuilder/MapperRegistry.java:
--------------------------------------------------------------------------------
1 | package com.github.quick4j.core.repository.mybaits.sqlbuilder;
2 |
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | /**
8 | * @author zhaojh.
9 | */
10 | public class MapperRegistry {
11 | private final Map knownMappers = new HashMap();
12 |
13 | public void addMapper(Class entityClass, Class entityMapperClass){
14 | String entityClassName = entityClass.getName();
15 | if(!knownMappers.containsKey(entityClassName)){
16 | knownMappers.put(entityClassName, entityMapperClass);
17 | }
18 | }
19 |
20 | public Class getMapper(Class entityClass){
21 | return knownMappers.get(entityClass.getName());
22 | }
23 |
24 | public boolean exist(Class entityClass){
25 | return knownMappers.containsKey(entityClass.getName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/mybatis-sqlbuilder/src/test/java/com/github/loafer/MapperTest.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.mybatis.spring.SqlSessionTemplate;
6 | import org.springframework.test.context.ContextConfiguration;
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import javax.annotation.Resource;
11 |
12 | /**
13 | * @author zhaojh.
14 | */
15 | @RunWith(SpringJUnit4ClassRunner.class)
16 | @ContextConfiguration({"/spring-config.xml", "/spring-mybatis-config.xml"})
17 | public class MapperTest {
18 | @Resource
19 | private SqlSessionTemplate sqlSessionTemplate;
20 |
21 | @Test
22 | @Transactional
23 | public void test1(){
24 | sqlSessionTemplate.selectOne("com.github.loafer.entity.StudentMapper.findOne", String.valueOf(System.currentTimeMillis()));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AngularJS/web/angluar-phonecat/partials/phone-list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Search:
6 | Sort By:
7 |
11 |
12 |
21 |
22 |
--------------------------------------------------------------------------------
/mybatis-sqlbuilder/src/main/java/com/github/quick4j/core/repository/mybaits/sqlbuilder/mapper/Mapper.java:
--------------------------------------------------------------------------------
1 | package com.github.quick4j.core.repository.mybaits.sqlbuilder.mapper;
2 |
3 | import com.github.quick4j.core.repository.mybaits.support.OurSqlBuilder;
4 | import org.apache.ibatis.annotations.*;
5 |
6 | /**
7 | * @author zhaojh.
8 | */
9 | public interface Mapper {
10 | @SelectProvider(type = OurSqlBuilder.class, method = OurSqlBuilder.BUILD_FIND_BY_KEY_SQL)
11 | T findOne(@Param("type") Class entityClass, @Param("id") String id);
12 |
13 | @InsertProvider(type = OurSqlBuilder.class, method = OurSqlBuilder.BUILD_INSERT_SQL)
14 | void insert(T entity);
15 |
16 | @UpdateProvider(type = OurSqlBuilder.class, method = OurSqlBuilder.BUILD_UPDATE_SQL)
17 | void update(T entity);
18 |
19 | @DeleteProvider(type = OurSqlBuilder.class, method = OurSqlBuilder.BUILD_DELETE_BY_KEY_SQL)
20 | void delete(Class entityClass, @Param("id") String id);
21 | }
22 |
--------------------------------------------------------------------------------
/jasig-cas-client/src/main/java/com/github/loafer/examples/user/UserService.java:
--------------------------------------------------------------------------------
1 | package com.github.loafer.examples.user;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | import java.util.ArrayList;
6 | import java.util.HashMap;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | /**
11 | * Created by zhaojh on 14-5-28.
12 | */
13 | @Component(value = "userService")
14 | public class UserService implements IUserService {
15 | private static List