-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
173 additions
and
2,686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,9 @@ | |
/** | ||
* @Author [email protected] | ||
* @Date 2022-07-12 | ||
* 让docean用起来像spring | ||
* Make Docean feel like Spring. | ||
* <p> | ||
* 适配spring 的注解(Service Repository Component Autowired PreDestroy PostConstruct) | ||
* Annotations compatible with Spring(Service Repository Component Autowired PreDestroy PostConstruct) | ||
*/ | ||
@DOceanPlugin | ||
@Slf4j | ||
|
@@ -80,15 +80,15 @@ public void putBean(String name, Bean bean) { | |
public String getInitMethodName(Object obj, Class clazz) { | ||
return Arrays.stream(clazz.getMethods()) | ||
.map(it -> Arrays.stream(it.getAnnotations()).filter(anno -> anno instanceof PostConstruct) | ||
.findAny().map(it2->it.getName()).orElse(Cons.INIT)) | ||
.findAny().map(it2 -> it.getName()).orElse(Cons.INIT)) | ||
.filter(name -> !Cons.INIT.equals(name)).findAny().orElse(Cons.INIT); | ||
} | ||
|
||
@Override | ||
public String getDestoryMethodName(Object obj, Class clazz) { | ||
return Arrays.stream(clazz.getMethods()) | ||
.map(it -> Arrays.stream(it.getAnnotations()).filter(anno -> anno instanceof PreDestroy) | ||
.findAny().map(it2->it.getName()).orElse(Cons.DESTORY)) | ||
.findAny().map(it2 -> it.getName()).orElse(Cons.DESTORY)) | ||
.filter(name -> !Cons.DESTORY.equals(name)).findAny().orElse(Cons.DESTORY); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>run.mone</groupId> | ||
<artifactId>jcommon</artifactId> | ||
<version>1.4-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>docean-spring-starter</artifactId> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<springboot.version>2.7.15</springboot.version> | ||
<spring.version>5.3.29</spring.version> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<version>${springboot.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>run.mone</groupId> | ||
<artifactId>docean</artifactId> | ||
<version>1.4-java20-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.11.0</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>--add-modules=jdk.incubator.concurrent</arg> | ||
<arg>--enable-preview</arg> | ||
</compilerArgs> | ||
<compilerVersion>20</compilerVersion> | ||
<source>20</source> | ||
<target>20</target> | ||
</configuration> | ||
</plugin> | ||
|
||
|
||
</plugins> | ||
|
||
|
||
</build> | ||
|
||
|
||
|
||
</project> |
61 changes: 61 additions & 0 deletions
61
...ocean-spring-starter/src/main/java/run/mone/docean/spring/config/DoceanAutoConfigure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package run.mone.docean.spring.config; | ||
|
||
import com.google.common.base.Splitter; | ||
import com.xiaomi.youpin.docean.Ioc; | ||
import com.xiaomi.youpin.docean.common.Safe; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import run.mone.docean.spring.extension.Extensions; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.Resource; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author [email protected] | ||
* @date 2023/9/19 13:46 | ||
*/ | ||
@Configuration | ||
@Slf4j | ||
public class DoceanAutoConfigure { | ||
|
||
private Ioc ioc; | ||
|
||
@Resource | ||
private ApplicationContext ac; | ||
|
||
@Value("${extensions:}") | ||
private String extensionsConfig; | ||
|
||
public static Map<String, String> extensionMap = new HashMap<>(); | ||
|
||
|
||
@PostConstruct | ||
public void initConfig() { | ||
List<String> list = Splitter.on(":").splitToList(extensionsConfig); | ||
if (list.size() == 3) { | ||
extensionMap.put(list.get(0), list.get(1)); | ||
ioc = Ioc.ins().name("extension").setContextFunction(name -> { | ||
if (ac.containsBean(name)) { | ||
return ac.getBean(name); | ||
} | ||
return Safe.callAndLog(() -> ac.getBean(Class.forName(name)), null); | ||
}).init(list.get(2), "run.mone.docean.plugin.spring"); | ||
} | ||
} | ||
|
||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public Extensions extensions() { | ||
Extensions extensions = new Extensions(ioc); | ||
return extensions; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
jcommon/docean-spring-starter/src/main/java/run/mone/docean/spring/extension/Extensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package run.mone.docean.spring.extension; | ||
|
||
import com.xiaomi.youpin.docean.Ioc; | ||
import run.mone.docean.spring.config.DoceanAutoConfigure; | ||
|
||
/** | ||
* @author [email protected] | ||
* @date 2023/9/19 14:20 | ||
*/ | ||
public class Extensions { | ||
|
||
private Ioc ioc; | ||
|
||
public Extensions(Ioc ioc) { | ||
this.ioc = ioc; | ||
} | ||
|
||
public <T> T get(String name) { | ||
String key = DoceanAutoConfigure.extensionMap.get(name); | ||
return ioc.getBean(key); | ||
} | ||
|
||
|
||
} |
1 change: 1 addition & 0 deletions
1
jcommon/docean-spring-starter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=run.mone.docean.spring.config.DoceanAutoConfigure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ | |
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ | |
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
</project> |
61 changes: 0 additions & 61 deletions
61
ozhera-all/opentelemetry-java-instrumentation/examples/distro/README.md
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
ozhera-all/opentelemetry-java-instrumentation/examples/distro/agent/build.gradle
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.