use of act.util.ClassNode in project actframework by actframework.
the class FullStackAppBootstrapClassLoader method cache.
private synchronized ClassNode cache(Class<?> c) {
String cname = canonicalName(c);
if (null == cname) {
return null;
}
String name = c.getName();
ClassInfoRepository repo = (ClassInfoRepository) classInfoRepository();
if (repo.has(cname)) {
return repo.node(name, cname);
}
actClasses.add(c);
ClassNode node = repo.node(name);
node.modifiers(c.getModifiers());
Class[] ca = c.getInterfaces();
for (Class pc : ca) {
if (pc == Object.class)
continue;
String pcname = canonicalName(pc);
if (null != pcname) {
cache(pc);
node.addInterface(pcname);
}
}
Class pc = c.getSuperclass();
if (null != pc && Object.class != pc) {
String pcname = canonicalName(pc);
if (null != pcname) {
cache(pc);
node.parent(pcname);
}
}
return node;
}
use of act.util.ClassNode in project actframework by actframework.
the class ActionMethodMetaInfo method mergeFromWithList.
private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) {
C.Set<String> withClasses = this.withList;
if (withClasses.isEmpty()) {
return;
}
ClassInfoRepository repo = app.classLoader().classInfoRepository();
for (final String withClass : withClasses) {
String curWithClass = withClass;
ControllerClassMetaInfo withClassInfo = infoBase.controllerMetaInfo(curWithClass);
while (null == withClassInfo && !"java.lang.Object".equals(curWithClass)) {
ClassNode node = repo.node(curWithClass);
if (null != node) {
node = node.parent();
}
if (null == node) {
break;
}
curWithClass = node.name();
withClassInfo = infoBase.controllerMetaInfo(curWithClass);
}
if (null != withClassInfo) {
withClassInfo.merge(infoBase, app);
interceptors.mergeFrom(withClassInfo.interceptors);
}
}
}
use of act.util.ClassNode in project actframework by actframework.
the class ControllerClassMetaInfo method mergeFromWithList.
private void mergeFromWithList(final ControllerClassMetaInfoManager infoBase, final App app) {
C.Set<String> withClasses = C.newSet();
getAllWithList(withClasses, infoBase);
final ControllerClassMetaInfo me = this;
ClassInfoRepository repo = app.classLoader().classInfoRepository();
for (final String withClass : withClasses) {
String curWithClass = withClass;
ControllerClassMetaInfo withClassInfo = infoBase.controllerMetaInfo(curWithClass);
while (null == withClassInfo && !"java.lang.Object".equals(curWithClass)) {
ClassNode node = repo.node(curWithClass);
if (null != node) {
node = node.parent();
}
if (null == node) {
break;
}
curWithClass = node.name();
withClassInfo = infoBase.controllerMetaInfo(curWithClass);
}
if (null != withClassInfo) {
withClassInfo.merge(infoBase, app);
if (isMyAncestor(withClassInfo)) {
interceptors.mergeFrom(withClassInfo.interceptors, me);
} else {
interceptors.mergeFrom(withClassInfo.interceptors);
}
}
}
}
use of act.util.ClassNode in project actframework by actframework.
the class JobMethodMetaInfo method extendedJobMethodMetaInfoList.
public List<JobMethodMetaInfo> extendedJobMethodMetaInfoList(App app) {
E.illegalStateIf(!classInfo().isAbstract(), "this job method meta info is not abstract");
final List<JobMethodMetaInfo> list = new ArrayList<>();
final JobClassMetaInfo clsInfo = classInfo();
String clsName = clsInfo.className();
ClassNode node = app.classLoader().classInfoRepository().node(clsName);
if (null == node) {
return list;
}
final JobMethodMetaInfo me = this;
node.visitTree(new Osgl.Visitor<ClassNode>() {
@Override
public void visit(ClassNode classNode) throws Osgl.Break {
if (!classNode.isAbstract() && classNode.isPublic()) {
JobClassMetaInfo subClsInfo = new JobClassMetaInfo().className(classNode.name());
JobMethodMetaInfo subMethodInfo = new JobMethodMetaInfo(subClsInfo, JobMethodMetaInfo.this);
if (me.isStatic()) {
subMethodInfo.invokeStaticMethod();
} else {
subMethodInfo.invokeInstanceMethod();
}
subMethodInfo.name(me.name());
subMethodInfo.returnType(me.returnType());
list.add(subMethodInfo);
}
}
});
return list;
}
use of act.util.ClassNode in project actframework by actframework.
the class MetricMetaInfoRepo method mergeFromParents.
private void mergeFromParents(ClassInfoRepository classInfoRepository) {
// sort class names so that super class always be processed before extended class
SortedSet<String> sortedClassNames = new TreeSet<>(classInfoRepository.parentClassFirst);
sortedClassNames.addAll(contexts.keySet());
for (String className : sortedClassNames) {
String context = contexts.get(className);
if (context.startsWith("/")) {
context = calibrate(context);
} else {
ClassNode node = classInfoRepository.node(className);
if (null != node) {
ClassNode parentNode = node.parent();
if (null != parentNode) {
String parentContext = contexts.get(parentNode.name());
context = concat(parentContext, context);
}
}
}
contexts.put(className, context);
}
}
Aggregations