Skip to content

Commit

Permalink
17.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FirokOtaku committed Oct 18, 2022
1 parent 83a0e56 commit 2d5c75e
Show file tree
Hide file tree
Showing 22 changed files with 349 additions and 49 deletions.
15 changes: 14 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@

<groupId>firok.spring</groupId>
<artifactId>mvci</artifactId>
<version>17.5.0</version>
<version>17.6.0</version>
<description>An annotation processing tool to generate MVC code from JavaBean(s).</description>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.23</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.7.4</version>
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
Expand Down
24 changes: 21 additions & 3 deletions readme-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@ Except default replacing-key-value-pairs, you could create custom ones by editin

After version _17.2.0_ MVCI would generate some classes under `firok.spring.mvci.runtime` package,
which contains information about all bean-classes marked with `@MVCIntrospective` and related structures.
( After 17.6.0, MVCI module no longer contains package `firok.spring.mvci.runtime`.
All its contents are moved to package `firok.spring.mvci.comment`
to provide support of Java module system)

`Current XXX Names` store full qualified names of related classes;
`Current XXX Classes` store Class instances of related classes.
`Current XXX s` store all instances of related structures help you
quickly get all of them rather than read them via Spring Context api.
If needed, you should set `firok.spring.mvci.runtime.enable-xxx-config` to `true`
in your config file and add `@ComponentScan` annotation.

> **Why we store information in two different ways**
>
Expand All @@ -93,10 +100,16 @@ which contains information about all bean-classes marked with `@MVCIntrospective

### Code template

**MVCI itself** is not based on SpringBoot and MybatisPlus. But **the default templates used by MVCI** is based on SpringBoot and MybatisPlus.
By default, you should import them as dependencies, or the project will not pass the compilation.
**MVCI itself** has very limited amount of dependencies.

In addition, you need to properly import dependencies such as database drivers, or your project may not work properly.
Only a few Spring components have been referenced
to provide enhancements.

But **the default templates used by MVCI**
is based on SpringBoot and MybatisPlus and so on.

By default, you should import them as dependencies,
or the project will not pass the compilation.

### Runtime information classes

Expand All @@ -117,6 +130,11 @@ MVCI has only passed testing under **Java17**. It may work in lower version of J

## Changelog

### 17.6.0

* add more runtime helper class
* add Java module support

### 17.5.0

* now source files would be included when compiling
Expand Down
36 changes: 18 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,26 @@

_17.2.0_ 版本之后的 MVCI 在参与编译时会在 `firok.spring.mvci.runtime` 包下生成数个类,
操作这些类可以获取本项目中所有标注了 `@MVCIntrospective` 注解并生成了相应结构的实体信息.
( 17.6.0 版本开始, 为了兼容 Java 模块化,
`firok.spring.mvci` 模块不再直接包含
`firok.spring.mvci.runtime` 包.
这些辅助类的结构和注释都转移到了 `firok.spring.mvci.comment` 包 )

`Current XXX Names` 以字符串方式储存了对应结构的完整限定名;
`Current XXX Names` 以字符串方式储存了对应结构的完整限定名.
`Current XXX Classes` 储存了对应结构的 Class 对象.

> **为什么要以两种方式储存信息**
>
> 根据 [虚拟机规范(Java SE 17)对类初始化的描述](https://docs.oracle.com/javase/specs/jls/se17/html/jls-12.html#:~:text=12.4.1.%C2%A0-,When%20Initialization%20Occurs,-A%20class%20or),
> 某个类初次实例化之前或其静态字段初次被主动引用之前,
> 此类一定会先进行类初始化.
> GraalVM 下经测试,
> 仅是访问某个类的 Class 对象不会触发其类加载.
>
> 为了避免不同编译器或解释器实现可能出现的不同实现,
> MVCI 仍储存了一份字符串类型的信息,
> 以完全避免期望之外的类加载.
`Current XXX s` 是一个包含了各结构的 Spring Config 类,
默认情况下此 Config 不会注入到 Spring Context,
需要将 `firok.spring.mvci.runtime.enable-xxx-config` 设为 `true` 并使用 `@ComponentScan` 手动设置 Spring 组件扫描,
或自行创建一个子类并注入到 Spring Context.

## 注意

### 关于代码生成模板

**MVCI 本身** 不基于 SpringBoot 和 MybatisPlus,
但是 **MVCI 默认的结构代码模板** 基于 SpringBoot 和 MybatisPlus.
所以默认情况下需为编译环境引入相关依赖, 否则项目无法通过编译.

此外, 还需要正确提供数据库驱动等依赖, 否则项目可能无法正常运行.
**MVCI 本身** 的依赖非常有限,
仅引入了少数几个 Spring 组件用于提供增强功能.
但是 **MVCI 默认的结构代码模板** 基于 SpringBoot 和 MybatisPlus,
所以默认情况下需在编译环境引入相关依赖, 否则项目无法通过编译.

### 关于运行时数据类

Expand All @@ -124,6 +119,11 @@ MVCI 17.x 仅于 **Java17 环境** 下通过测试.

## 变动记录

### 17.6.0

* 新增运行时数据类用于收集 mapper, service, service impl, controller
* 新增 Java 模块化支持

### 17.5.0

* 现在打包时会附带源码等内容
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/firok/spring/mvci/comment/CurrentControllers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package firok.spring.mvci.comment;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;

/**
* 当前项目中所有的 controller
* @implNote 此类会在编译期填充内容 this class will be filled during compiling phase
* @since 17.6.0
* */
@Configuration
@ConditionalOnExpression("${firok.spring.mvci.runtime.enable-controller-config:false}")
public class CurrentControllers
{
/**
* <p>获取某个实体类对应的 controller 实例</p>
* <p>Get controller instance of a bean</p>
*
* @param fullQualifiedBeanName 类完整限定名
* @return controller 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object getByFullQualifiedBeanName(String fullQualifiedBeanName)
{
return switch (fullQualifiedBeanName)
{
default -> null;
};
}

/**
* <p>获取所有 controller 实例</p>
* <p>Get all controller instances of a bean</p>
*
* @return controller 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object[] getAllInstances()
{
return new Object[] {
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/firok/spring/mvci/comment/CurrentMappers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package firok.spring.mvci.comment;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;

/**
* 当前项目中所有的 mapper
* @implNote 此类会在编译期填充内容 this class will be filled during compiling phase
* @since 17.6.0
* */
@Configuration
@ConditionalOnExpression("${firok.spring.mvci.runtime.enable-mapper-config:false}")
public class CurrentMappers
{
/**
* <p>获取某个实体类对应的 mapper 实例</p>
* <p>Get mapper instance of a bean</p>
*
* @param fullQualifiedBeanName 类完整限定名
* @return mapper 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object getByFullQualifiedBeanName(String fullQualifiedBeanName)
{
return switch (fullQualifiedBeanName)
{
default -> null;
};
}


/**
* <p>获取所有 mapper 实例</p>
* <p>Get all mapper instances of a bean</p>
*
* @return mapper 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object[] getAllInstances()
{
return new Object[] {
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/firok/spring/mvci/comment/CurrentServiceImpls.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package firok.spring.mvci.comment;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;

/**
* 当前项目中所有的 service impl
* @implNote 此类会在编译期填充内容 this class will be filled during compiling phase
* @since 17.6.0
* */
@Configuration
@ConditionalOnExpression("${firok.spring.mvci.runtime.enable-service-impl-config:false}")
public class CurrentServiceImpls
{
/**
* <p>获取某个实体类对应的 service impl 实例</p>
* <p>Get service impl instance of a bean</p>
*
* @param fullQualifiedBeanName 类完整限定名
* @return service impl 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object getByFullQualifiedBeanName(String fullQualifiedBeanName)
{
return switch (fullQualifiedBeanName)
{
default -> null;
};
}


/**
* <p>获取所有 service impl 实例</p>
* <p>Get all service impl instances of a bean</p>
*
* @return service 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object[] getAllInstances()
{
return new Object[] {
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package firok.spring.mvci.runtime;
package firok.spring.mvci.comment;

/**
* @since 17.2.0
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/firok/spring/mvci/comment/CurrentServices.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package firok.spring.mvci.comment;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;

/**
* 当前项目中所有的 service
* @implNote 此类会在编译期填充内容 this class will be filled during compiling phase
* @since 17.6.0
* */
@Configuration
@ConditionalOnExpression("${firok.spring.mvci.runtime.enable-service-config:false}")
public class CurrentServices
{
/**
* <p>获取某个实体类对应的 service 实例</p>
* <p>Get service instance of a bean</p>
*
* @param fullQualifiedBeanName 类完整限定名
* @return service 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object getByFullQualifiedBeanName(String fullQualifiedBeanName)
{
return switch (fullQualifiedBeanName)
{
default -> null;
};
}

/**
* <p>获取所有 service 实例</p>
* <p>Get all service instances of a bean</p>
*
* @return service 实例
* @implNote 此方法会在编译期填充内容 this method will be filled during compiling phase
*/
public Object[] getAllInstances()
{
return new Object[] {
};
}
}
7 changes: 7 additions & 0 deletions src/main/java/firok/spring/mvci/comment/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* MVCI 会在编译时向 firok.spring.mvci.runtime 包生成数个辅助运行时操作的类,
* 这些辅助类的 API 和注释可以在这里找到.
*
* @since 17.2.0
*/
package firok.spring.mvci.comment;
Loading

0 comments on commit 2d5c75e

Please sign in to comment.