Skip to content

Commit

Permalink
write a line into test.file
Browse files Browse the repository at this point in the history
  • Loading branch information
huifer committed Dec 5, 2023
1 parent 8830282 commit cbb260b
Show file tree
Hide file tree
Showing 5 changed files with 345 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/spring/csac685e64-930e-11ee-83ff-acde48001122.java
Original file line number Diff line number Diff line change
@@ -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("上厕所了");
}
}
42 changes: 42 additions & 0 deletions docs/spring/csac96ad3c-930e-11ee-83ff-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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);
}
}
46 changes: 46 additions & 0 deletions docs/spring/csacc4b22c-930e-11ee-83ff-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}
}
162 changes: 162 additions & 0 deletions docs/spring/csacf2dd46-930e-11ee-83ff-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/**
* Copyright 2009-2018 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<String, Object> map;

public MapWrapper(MetaObject metaObject, Map<String, Object> 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<String, Object> 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 <E> void addAll(List<E> element) {
throw new UnsupportedOperationException();
}

}
76 changes: 76 additions & 0 deletions docs/spring/csad2065e0-930e-11ee-83ff-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Copyright 2009-2016 the original author or authors.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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);
}
}
}

}

0 comments on commit cbb260b

Please sign in to comment.