# yulin-codetree

> A framework that shows the chain of method calls

Latest version **0.0.5** (published 2019-03-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install yulin-codetree
pnpm add yulin-codetree
yarn add yulin-codetree
bun add yulin-codetree
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2019-03-25 |
| First published | 2019-03-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | chkch |
| Maintainers | chkch |
| Keywords | SmallOrange |

## Links

- npm: https://www.npmjs.com/package/yulin-codetree
- Repository: https://github.com/chkch/Spring-Project-Tree
- Homepage: https://github.com/chkch/Spring-Project-Tree#readme
- Issues: https://github.com/chkch/Spring-Project-Tree/issues
- npm.io page: https://npm.io/package/yulin-codetree

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2019-03-25

## README

很多新人进入一家新公司后，最头疼的就是如何快速了解公司的业务和项目架构。

因为文档很少，没有文档，或者是文档严重落伍， 根本没法看；如果你碰到一个特别热心的老员工，事无巨细地给你讲，随时在你身边答疑解惑， 那简直是天大的好运气， 现实是大家都很忙，没人给你讲解。

很快就要深入项目做开发了，怎么办呢？

我在加入新公司后，就遇到了悲催的情况。于是，我就做了这款可视化流程分析插件！帮助更多入职新人快速熟悉业务。

演示网址：[http://116.85.23.6:8521/projecttree](http://116.85.23.6:8521/projecttree)

示范工程：[https://gitee.com/zyzpp/Spring-Project-Tree-Demo](https://gitee.com/zyzpp/Spring-Project-Tree-Demo) (版本可能落后)

## Maven依赖

直接在pom.xml引入依赖！

```xml
<dependency>
  <groupId>cn.yueshutong</groupId>
  <artifactId>spring-project-tree</artifactId>
  <version>0.0.5.RELEASE</version>
</dependency>
```

### Spring Boot 项目

如果你的项目是Spring Boot，那么使用会非常简单，只需要一个注解即可。

@EnableProjectTree(value = "")注解参数为[pointcut](https://www.baidu.com/baidu?isource=infinity&iname=baidu&itype=web&tn=98012088_9_dg&ch=7&ie=utf-8&wd=%40pointcut%20%E8%A1%A8%E8%BE%BE%E5%BC%8F)表达式，完整代码如下：

```java
@SpringBootApplication
@EnableProjectTree("execution(* com.example.springboot.demo..*(..))")
public class SpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }

}
```

Project Tree不仅增加了对分布式接口的监控，还增加了pointcut表示式。

### 访问ProjectTree

启动你的项目，首先访问你项目的某个接口，使其执行被监控的方法。然后访问`localhost:8080/projecttree`查看网页。

#### 接口说明

| 接口                         | 说明                 |
| ---------------------------- | -------------------- |
| /projecttree                 | 返回完整调用链视图     |
| /projecttree/all             | 返回全部方法视图     |
| /projecttree/json            | JSON形式的返回结果   |
| /projecttree/{methodId}      | 对某一方法的JSON结果 |

## 注意事项

使用Shiro、Spring Securit等安全框架时，需要注意对此URL的权限控制。

另外，方法调用链分析并不会监控自身对自身的方法调用，因为this.method()并不是调用的代理对象的method()方法。


## 源码亮点

1.如何降低对主流程的性能消耗？

使用多线程实现异步非阻塞模型。

2.为什么使用单例线程池？

只有一个线程的线程池实际是队列+单线程，一个一个的执行任务，完全符合本框架的使需求，多则出错。

3.为什么数据保存到内存？

基于内存的数据读写，基于方法调用链分析进行选择性保存，占用内存极小。理论上说，从接口开始，有多少流程分支，就有多少条数据记录。

4.如何实现方法调用分析？

基于栈数据结构设计算法。

5.如何解决多线程环境对算法的影响？

通过ThreadId加Stack自定义数据结构“线程栈”实现线程隔离。

## 关于作者

博客：[http://www.yueshutong.cn](http://www.yueshutong.cn)

邮箱：yster@foxmail.com

Github：[https://github.com/yueshutong/Spring-Project-Tree](https://github.com/yueshutong/Spring-Project-Tree)

Gitee：[https://gitee.com/zyzpp/Spring-Project-Tree](https://gitee.com/zyzpp/Spring-Project-Tree)

交流QQ群：781927207

---
_Source: https://npm.io/package/yulin-codetree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
