package com.qianwen.core.tool.beans;
|
|
import java.security.ProtectionDomain;
|
import org.springframework.asm.ClassVisitor;
|
import org.springframework.cglib.beans.BeanMap;
|
import org.springframework.cglib.core.AbstractClassGenerator;
|
import org.springframework.cglib.core.ReflectUtils;
|
|
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/beans/BladeBeanMap.class */
|
public abstract class BladeBeanMap extends BeanMap {
|
/* renamed from: newInstance */
|
public abstract BladeBeanMap m4newInstance(Object o);
|
|
protected BladeBeanMap() {
|
}
|
|
protected BladeBeanMap(Object bean) {
|
super(bean);
|
}
|
|
public static BladeBeanMap create(Object bean) {
|
BladeGenerator gen = new BladeGenerator();
|
gen.setBean(bean);
|
return gen.create();
|
}
|
|
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/beans/BladeBeanMap$BladeGenerator.class */
|
public static class BladeGenerator extends AbstractClassGenerator {
|
private static final AbstractClassGenerator.Source SOURCE = new AbstractClassGenerator.Source(BladeBeanMap.class.getName());
|
private Object bean;
|
private Class beanClass;
|
private int require;
|
|
public BladeGenerator() {
|
super(SOURCE);
|
}
|
|
public void setBean(Object bean) {
|
this.bean = bean;
|
if (bean != null) {
|
this.beanClass = bean.getClass();
|
}
|
}
|
|
public void setBeanClass(Class beanClass) {
|
this.beanClass = beanClass;
|
}
|
|
public void setRequire(int require) {
|
this.require = require;
|
}
|
|
protected ClassLoader getDefaultClassLoader() {
|
return this.beanClass.getClassLoader();
|
}
|
|
protected ProtectionDomain getProtectionDomain() {
|
return ReflectUtils.getProtectionDomain(this.beanClass);
|
}
|
|
public BladeBeanMap create() {
|
if (this.beanClass == null) {
|
throw new IllegalArgumentException("Class of bean unknown");
|
}
|
setNamePrefix(this.beanClass.getName());
|
BladeBeanMapKey key = new BladeBeanMapKey(this.beanClass, this.require);
|
return (BladeBeanMap) super.create(key);
|
}
|
|
public void generateClass(ClassVisitor v) throws Exception {
|
new BladeBeanMapEmitter(v, getClassName(), this.beanClass, this.require);
|
}
|
|
protected Object firstInstance(Class type) {
|
return ((BeanMap) ReflectUtils.newInstance(type)).newInstance(this.bean);
|
}
|
|
protected Object nextInstance(Object instance) {
|
return ((BeanMap) instance).newInstance(this.bean);
|
}
|
}
|
}
|