diff --git a/docs/spring/csac685e64-930e-11ee-83ff-acde48001122.java b/docs/spring/csac685e64-930e-11ee-83ff-acde48001122.java new file mode 100644 index 00000000..bd16750d --- /dev/null +++ b/docs/spring/csac685e64-930e-11ee-83ff-acde48001122.java @@ -0,0 +1,19 @@ +package com.huifer.aop.advice; + +/** + * 描述: + * + * @author huifer + * @date 2019-03-02 + */ +public class Person implements BaseAopPointCutInAdvice { + @Override + public void eat() { + System.out.println("吃饭了"); + } + + @Override + public void wc() { + System.out.println("上厕所了"); + } +} diff --git a/docs/spring/csac96ad3c-930e-11ee-83ff-acde48001122.java b/docs/spring/csac96ad3c-930e-11ee-83ff-acde48001122.java new file mode 100644 index 00000000..8a1769b9 --- /dev/null +++ b/docs/spring/csac96ad3c-930e-11ee-83ff-acde48001122.java @@ -0,0 +1,42 @@ +/** + * Copyright 2009-2015 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ibatis.binding; + +import org.apache.ibatis.exceptions.PersistenceException; + +/** + * @author Clinton Begin + */ +public class BindingException extends PersistenceException { + + private static final long serialVersionUID = 4300802238789381562L; + + public BindingException() { + super(); + } + + public BindingException(String message) { + super(message); + } + + public BindingException(String message, Throwable cause) { + super(message, cause); + } + + public BindingException(Throwable cause) { + super(cause); + } +} diff --git a/docs/spring/csacc4b22c-930e-11ee-83ff-acde48001122.java b/docs/spring/csacc4b22c-930e-11ee-83ff-acde48001122.java new file mode 100644 index 00000000..70f2b7a0 --- /dev/null +++ b/docs/spring/csacc4b22c-930e-11ee-83ff-acde48001122.java @@ -0,0 +1,46 @@ +/** + * Copyright 2009-2015 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ibatis.submitted.lazyload_common_property; + +public class Father { + private Integer id; + private String name; + private GrandFather grandFather; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public GrandFather getGrandFather() { + return grandFather; + } + + public void setGrandFather(GrandFather grandFather) { + this.grandFather = grandFather; + } +} diff --git a/docs/spring/csacf2dd46-930e-11ee-83ff-acde48001122.java b/docs/spring/csacf2dd46-930e-11ee-83ff-acde48001122.java new file mode 100644 index 00000000..6c638e0f --- /dev/null +++ b/docs/spring/csacf2dd46-930e-11ee-83ff-acde48001122.java @@ -0,0 +1,162 @@ +/** + * Copyright 2009-2018 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ibatis.reflection.wrapper; + +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.SystemMetaObject; +import org.apache.ibatis.reflection.factory.ObjectFactory; +import org.apache.ibatis.reflection.property.PropertyTokenizer; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * java map 的包装对象, 本质操作为map的操作, get-> map.get() set->map.put() + * @author Clinton Begin + */ +public class MapWrapper extends BaseWrapper { + + private final Map map; + + public MapWrapper(MetaObject metaObject, Map map) { + super(metaObject); + this.map = map; + } + + @Override + public Object get(PropertyTokenizer prop) { + // 是否有索引 + if (prop.getIndex() != null) { + Object collection = resolveCollection(prop, map); + // 嗲用 BaseWrapper + return getCollectionValue(prop, collection); + } else { + // 获取 + return map.get(prop.getName()); + } + } + + @Override + public void set(PropertyTokenizer prop, Object value) { + if (prop.getIndex() != null) { + Object collection = resolveCollection(prop, map); + setCollectionValue(prop, collection, value); + } else { + map.put(prop.getName(), value); + } + } + + @Override + public String findProperty(String name, boolean useCamelCaseMapping) { + return name; + } + + @Override + public String[] getGetterNames() { + return map.keySet().toArray(new String[map.keySet().size()]); + } + + @Override + public String[] getSetterNames() { + return map.keySet().toArray(new String[map.keySet().size()]); + } + + @Override + public Class getSetterType(String name) { + PropertyTokenizer prop = new PropertyTokenizer(name); + if (prop.hasNext()) { + MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName()); + if (metaValue == SystemMetaObject.NULL_META_OBJECT) { + return Object.class; + } else { + return metaValue.getSetterType(prop.getChildren()); + } + } else { + if (map.get(name) != null) { + return map.get(name).getClass(); + } else { + return Object.class; + } + } + } + + @Override + public Class getGetterType(String name) { + PropertyTokenizer prop = new PropertyTokenizer(name); + if (prop.hasNext()) { + MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName()); + if (metaValue == SystemMetaObject.NULL_META_OBJECT) { + return Object.class; + } else { + return metaValue.getGetterType(prop.getChildren()); + } + } else { + if (map.get(name) != null) { + return map.get(name).getClass(); + } else { + return Object.class; + } + } + } + + @Override + public boolean hasSetter(String name) { + return true; + } + + @Override + public boolean hasGetter(String name) { + PropertyTokenizer prop = new PropertyTokenizer(name); + if (prop.hasNext()) { + if (map.containsKey(prop.getIndexedName())) { + MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName()); + if (metaValue == SystemMetaObject.NULL_META_OBJECT) { + return true; + } else { + return metaValue.hasGetter(prop.getChildren()); + } + } else { + return false; + } + } else { + return map.containsKey(prop.getName()); + } + } + + @Override + public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) { + HashMap map = new HashMap<>(); + set(prop, map); + return MetaObject.forObject(map, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(), metaObject.getReflectorFactory()); + } + + @Override + public boolean isCollection() { + return false; + } + + @Override + public void add(Object element) { + throw new UnsupportedOperationException(); + } + + @Override + public void addAll(List element) { + throw new UnsupportedOperationException(); + } + +} diff --git a/docs/spring/csad2065e0-930e-11ee-83ff-acde48001122.java b/docs/spring/csad2065e0-930e-11ee-83ff-acde48001122.java new file mode 100644 index 00000000..a05bb240 --- /dev/null +++ b/docs/spring/csad2065e0-930e-11ee-83ff-acde48001122.java @@ -0,0 +1,76 @@ +/** + * Copyright 2009-2016 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ibatis.submitted.global_variables_defaults; + +import org.apache.ibatis.cache.Cache; +import org.apache.ibatis.cache.impl.PerpetualCache; +import org.apache.ibatis.reflection.factory.DefaultObjectFactory; + +import java.lang.reflect.Field; +import java.util.Properties; + +public class SupportClasses { + + public static class CustomObjectFactory extends DefaultObjectFactory { + private static final long serialVersionUID = 4576592418878031661L; + private Properties properties; + + public Properties getProperties() { + return properties; + } + + @Override + public void setProperties(Properties properties) { + this.properties = properties; + } + } + + public static class CustomCache extends PerpetualCache { + private String name; + + public CustomCache(String id) { + super(id); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + static class Utils { + static SupportClasses.CustomCache unwrap(Cache cache) { + Field field; + try { + field = cache.getClass().getDeclaredField("delegate"); + } catch (NoSuchFieldException e) { + throw new IllegalStateException(e); + } + try { + field.setAccessible(true); + return (SupportClasses.CustomCache) field.get(cache); + } catch (IllegalAccessException e) { + throw new IllegalStateException(e); + } finally { + field.setAccessible(false); + } + } + } + +}