4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * AutoIgnore 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoIgnore {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * ApplicationListener 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoListener {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/common/AotAutoType.java:
--------------------------------------------------------------------------------
1 | package net.dreamlu.mica.auto.common;
2 |
3 | import lombok.Getter;
4 | import lombok.RequiredArgsConstructor;
5 | import net.dreamlu.mica.auto.annotation.AotBeanFactoryInitialization;
6 | import net.dreamlu.mica.auto.annotation.AotBeanRegistration;
7 | import net.dreamlu.mica.auto.annotation.AotRuntimeHintsRegistrar;
8 |
9 | /**
10 | * aot
11 | *
12 | * @author L.cm
13 | */
14 | @Getter
15 | @RequiredArgsConstructor
16 | public enum AotAutoType {
17 |
18 | /**
19 | * RuntimeHintsRegistrar 添加到 aot.factories
20 | */
21 | RUNTIME_HINTS_REGISTRAR(AotRuntimeHintsRegistrar.class.getName(), "org.springframework.aot.hint.RuntimeHintsRegistrar"),
22 | /**
23 | * BeanRegistrationAotProcessor 添加到 aot.factories
24 | */
25 | BEAN_REGISTRATION(AotBeanRegistration.class.getName(), "org.springframework.beans.factory.aot.BeanRegistrationAotProcessor"),
26 | /**
27 | * BeanFactoryInitializationAotProcessor 添加到 aot.factories
28 | */
29 | BEAN_FACTORY_INITIALIZATION(AotBeanFactoryInitialization.class.getName(), "org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor");
30 |
31 | private final String annotation;
32 | private final String configureKey;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoFailureAnalyzer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * FailureAnalyzer 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoFailureAnalyzer {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoConfigDataLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * ConfigDataLoader
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoConfigDataLoader {
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoRunListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * SpringApplicationRunListener 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoRunListener {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoEnvPostProcessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * EnvironmentPostProcessor 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoEnvPostProcessor {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoLoggingSystemFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * LoggingSystemFactory 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoLoggingSystemFactory {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoTemplateProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * TemplateAvailabilityProvider 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoTemplateProvider {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoConfigImportFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * AutoConfigurationImportFilter 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoConfigImportFilter {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoContextInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * ApplicationContextInitializer 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoContextInitializer {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoEnableCircuitBreaker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * EnableCircuitBreaker
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoEnableCircuitBreaker {
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoConfigDataLocationResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * ConfigDataLocationResolver
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoConfigDataLocationResolver {
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoDatabaseInitializerDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * DatabaseInitializerDetector 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoDatabaseInitializerDetector {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AotBeanRegistration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * org.springframework.beans.factory.aot.BeanRegistrationAotProcessor
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AotBeanRegistration {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AotRuntimeHintsRegistrar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * aot org.springframework.aot.hint.RuntimeHintsRegistrar
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AotRuntimeHintsRegistrar {
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AotBeanFactoryInitialization.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * aot org.springframework.beans.factory.aot.BeanRegistrationAotProcessor
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AotBeanFactoryInitialization {
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoDependsOnDatabaseInitializationDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.Documented;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | import static java.lang.annotation.ElementType.TYPE;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * DependsOnDatabaseInitializationDetector 处理
28 | *
29 | * @author L.cm
30 | */
31 | @Documented
32 | @Retention(SOURCE)
33 | @Target(TYPE)
34 | public @interface AutoDependsOnDatabaseInitializationDetector {
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/resources/test/MyProcessor.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import net.dreamlu.mica.auto.annotation.AutoService;
4 |
5 | import javax.annotation.processing.Completion;
6 | import javax.annotation.processing.ProcessingEnvironment;
7 | import javax.annotation.processing.Processor;
8 | import javax.annotation.processing.RoundEnvironment;
9 | import javax.lang.model.SourceVersion;
10 | import javax.lang.model.element.AnnotationMirror;
11 | import javax.lang.model.element.Element;
12 | import javax.lang.model.element.ExecutableElement;
13 | import javax.lang.model.element.TypeElement;
14 | import java.util.Set;
15 |
16 | @AutoService(Processor.class)
17 | public class MyProcessor implements Processor {
18 |
19 | @Override
20 | public Set getSupportedOptions() {
21 | return null;
22 | }
23 |
24 | @Override
25 | public Set getSupportedAnnotationTypes() {
26 | return null;
27 | }
28 |
29 | @Override
30 | public SourceVersion getSupportedSourceVersion() {
31 | return null;
32 | }
33 |
34 | @Override
35 | public void init(ProcessingEnvironment processingEnv) {
36 |
37 | }
38 |
39 | @Override
40 | public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
41 | return false;
42 | }
43 |
44 | @Override
45 | public Iterable extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
46 | return null;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/net/dreamlu/mica/auto/service/AutoServiceProcessorTest.java:
--------------------------------------------------------------------------------
1 | package net.dreamlu.mica.auto.service;
2 |
3 | import com.google.testing.compile.Compilation;
4 | import com.google.testing.compile.Compiler;
5 | import com.google.testing.compile.JavaFileObjects;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.junit.runners.JUnit4;
9 |
10 | import javax.tools.StandardLocation;
11 |
12 | import static com.google.testing.compile.CompilationSubject.assertThat;
13 |
14 | /**
15 | * use google compile-testing Tests the {@link AutoServiceProcessor}.
16 | *
17 | * @author L.cm
18 | */
19 | @RunWith(JUnit4.class)
20 | public class AutoServiceProcessorTest {
21 |
22 | @Test
23 | public void autoService() {
24 | Compilation compilation =
25 | Compiler.javac()
26 | // 选择注解处理器
27 | .withProcessors(new AutoServiceProcessor())
28 | // 选择需要处理的代码
29 | .compile(JavaFileObjects.forResource("test/MyProcessor.java"));
30 | // 断言是否成功
31 | assertThat(compilation).succeededWithoutWarnings();
32 | // 断言生成的内容, compile-testing 默认是生成到了内存中
33 | assertThat(compilation)
34 | // 选择生成的配置文件,如果是生成 java 文件可以使用 generatedSourceFile 方法
35 | .generatedFile(StandardLocation.CLASS_OUTPUT, "META-INF/services/javax.annotation.processing.Processor")
36 | // 转换成 utf-8 字符串然后进行比较
37 | .contentsAsUtf8String()
38 | // 由于生成的文件尾部有个 writer.newLine() 在各个平台不一样,所以采用 startsWith
39 | .contains("test.MyProcessor");
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/annotation/AutoService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 Google LLC
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.annotation;
18 |
19 | import java.lang.annotation.*;
20 |
21 | /**
22 | * An annotation for service providers as described in {@link java.util.ServiceLoader}. The {@link
23 | * net.dreamlu.mica.auto.service.AutoServiceProcessor} generates the configuration files which
24 | * allows service providers to be loaded with {@link java.util.ServiceLoader#load(Class)}.
25 | *
26 | *
Service providers assert that they conform to the service provider specification.
27 | * Specifically, they must:
28 | *
29 | *
30 | *
be a non-inner, non-anonymous, concrete class
31 | *
have a publicly accessible no-arg constructor
32 | *
implement the interface type returned by {@code value()}
33 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.service;
18 |
19 | import lombok.experimental.UtilityClass;
20 |
21 | import javax.lang.model.util.Elements;
22 | import javax.tools.FileObject;
23 | import java.io.*;
24 | import java.nio.charset.Charset;
25 | import java.nio.charset.StandardCharsets;
26 | import java.util.*;
27 |
28 | /**
29 | * A helper class for reading and writing Services files.
30 | *
31 | * @author L.cm
32 | */
33 | @UtilityClass
34 | class ServicesFiles {
35 | private static final Charset UTF_8 = StandardCharsets.UTF_8;
36 |
37 | /**
38 | * Reads the set of service classes from a service file.
39 | *
40 | * @param fileObject not {@code null}. Closed after use.
41 | * @return a not {@code null Set} of service class names.
42 | * @throws IOException
43 | */
44 | protected static Set readServiceFile(FileObject fileObject, Elements elementUtils) throws IOException {
45 | HashSet serviceClasses = new HashSet<>();
46 | try (
47 | InputStream input = fileObject.openInputStream();
48 | InputStreamReader isr = new InputStreamReader(input, UTF_8);
49 | BufferedReader r = new BufferedReader(isr)
50 | ) {
51 | String line;
52 | while ((line = r.readLine()) != null) {
53 | // 跳过注释行
54 | int commentStart = line.indexOf('#');
55 | if (commentStart >= 0) {
56 | continue;
57 | }
58 | line = line.trim();
59 | // 校验是否删除文件
60 | if (!line.isEmpty() && Objects.nonNull(elementUtils.getTypeElement(line))) {
61 | serviceClasses.add(line);
62 | }
63 | }
64 | return serviceClasses;
65 | }
66 | }
67 |
68 | /**
69 | * Writes the set of service class names to a service file.
70 | *
71 | * @param output not {@code null}. Not closed after use.
72 | * @param services a not {@code null Collection} of service class names.
73 | * @throws IOException
74 | */
75 | protected static void writeServiceFile(Collection services, OutputStream output) throws IOException {
76 | BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8));
77 | List serviceList = new ArrayList<>(services);
78 | Collections.sort(serviceList);
79 | for (String service : serviceList) {
80 | writer.write(service);
81 | writer.newLine();
82 | }
83 | writer.flush();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/common/MultiSetMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.common;
18 |
19 | import java.util.*;
20 |
21 | /**
22 | * MultiSetMap
23 | *
24 | * @author L.cm
25 | */
26 | public class MultiSetMap {
27 | private transient final Map> map;
28 |
29 | public MultiSetMap() {
30 | map = new HashMap<>();
31 | }
32 |
33 | private Set createSet() {
34 | return new HashSet<>();
35 | }
36 |
37 | /**
38 | * put to MultiSetMap
39 | *
40 | * @param key 键
41 | * @param value 值
42 | * @return boolean
43 | */
44 | public boolean put(K key, V value) {
45 | Set set = map.get(key);
46 | if (set == null) {
47 | set = createSet();
48 | if (set.add(value)) {
49 | map.put(key, set);
50 | return true;
51 | } else {
52 | throw new AssertionError("New set violated the set spec");
53 | }
54 | } else {
55 | return set.add(value);
56 | }
57 | }
58 |
59 | /**
60 | * 是否包含某个key
61 | *
62 | * @param key key
63 | * @return 结果
64 | */
65 | public boolean containsKey(K key) {
66 | return map.containsKey(key);
67 | }
68 |
69 | /**
70 | * 是否包含 value 中的某个值
71 | *
72 | * @param value value
73 | * @return 是否包含
74 | */
75 | public boolean containsVal(V value) {
76 | Collection> values = map.values();
77 | return values.stream().anyMatch(vs -> vs.contains(value));
78 | }
79 |
80 | /**
81 | * key 集合
82 | *
83 | * @return keys
84 | */
85 | public Set keySet() {
86 | return map.keySet();
87 | }
88 |
89 | /**
90 | * put list to MultiSetMap
91 | *
92 | * @param key 键
93 | * @param set 值列表
94 | * @return boolean
95 | */
96 | public boolean putAll(K key, Set set) {
97 | if (set == null) {
98 | return false;
99 | }
100 | Set vSet = map.computeIfAbsent(key, k -> createSet());
101 | vSet.addAll(set);
102 | return true;
103 | }
104 |
105 | /**
106 | * put MultiSetMap to MultiSetMap
107 | *
108 | * @param data MultiSetMap
109 | * @return boolean
110 | */
111 | public boolean putAll(MultiSetMap data) {
112 | if (data == null || data.isEmpty()) {
113 | return false;
114 | } else {
115 | for (K k : data.keySet()) {
116 | this.putAll(k, data.get(k));
117 | }
118 | return true;
119 | }
120 | }
121 |
122 | /**
123 | * get List by key
124 | *
125 | * @param key 键
126 | * @return List
127 | */
128 | public Set get(K key) {
129 | return map.get(key);
130 | }
131 |
132 | /**
133 | * clear MultiSetMap
134 | */
135 | public void clear() {
136 | map.clear();
137 | }
138 |
139 | /**
140 | * isEmpty
141 | *
142 | * @return isEmpty
143 | */
144 | public boolean isEmpty() {
145 | return map.isEmpty();
146 | }
147 |
148 | @Override
149 | public String toString() {
150 | return map.toString();
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/src/main/java/net/dreamlu/mica/auto/aot/FactoriesFiles.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
3 | *
4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.gnu.org/licenses/lgpl.html
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package net.dreamlu.mica.auto.aot;
18 |
19 | import lombok.experimental.UtilityClass;
20 | import net.dreamlu.mica.auto.common.MultiSetMap;
21 |
22 | import javax.lang.model.util.Elements;
23 | import javax.tools.FileObject;
24 | import java.io.*;
25 | import java.nio.charset.Charset;
26 | import java.nio.charset.StandardCharsets;
27 | import java.util.*;
28 | import java.util.stream.Collectors;
29 |
30 | /**
31 | * spring boot 自动化配置工具类
32 | *
33 | * @author L.cm
34 | */
35 | @UtilityClass
36 | class FactoriesFiles {
37 | private static final Charset UTF_8 = StandardCharsets.UTF_8;
38 |
39 | /**
40 | * 读取 spring.factories 文件
41 | *
42 | * @param fileObject FileObject
43 | * @return MultiSetMap
44 | * @throws IOException 异常信息
45 | */
46 | protected static MultiSetMap readFactoriesFile(FileObject fileObject, Elements elementUtils) throws IOException {
47 | // 读取 spring.factories 内容
48 | Properties properties = new Properties();
49 | try (InputStream input = fileObject.openInputStream()) {
50 | properties.load(input);
51 | }
52 | MultiSetMap multiSetMap = new MultiSetMap<>();
53 | Set> entrySet = properties.entrySet();
54 | for (Map.Entry