Skip to content

Commit 5d84546

Browse files
Structure Modification
1 parent 2d7af0b commit 5d84546

File tree

250 files changed

+210
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+210
-15
lines changed

pom.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
<modelVersion>4.0.0</modelVersion>
1111
<packaging>pom</packaging>
1212
<artifactId>zero-entry</artifactId>
13-
<name>Zero.Core.Entry.POM.${zero.version}</name>
13+
<name>Zero.Entry.POM.${zero.version}</name>
1414
<modules>
15-
<module>zero-focus</module>
16-
<module>zero-import</module>
17-
<module>zero-mini</module>
15+
<module>zero-entry-bootstrap-core</module>
16+
<module>zero-entry-bootstrap-extension</module>
17+
<module>zero-entry-bootstrap-osgi</module>
18+
<module>zero-entry-bootstrap-import</module>
1819
</modules>
1920
<build>
2021
<plugins>
File renamed without changes.

zero-mini/pom.xml zero-entry-bootstrap-core/pom.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
<artifactId>zero-entry</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010
</parent>
11-
12-
<name>Zero.Entry.Stack.Mini</name>
13-
<artifactId>zero-mini</artifactId>
11+
<name>Zero.Entry.BootStrap.Core</name>
12+
<artifactId>zero-entry-bootstrap-core</artifactId>
1413
<dependencies>
1514
<dependency>
1615
<groupId>io.netty</groupId>
@@ -20,7 +19,7 @@
2019
<!-- Switch to Up -->
2120
<dependency>
2221
<groupId>io.zerows</groupId>
23-
<artifactId>zero-core-entry-standalone</artifactId>
22+
<artifactId>zero-core-entry-facade</artifactId>
2423
</dependency>
2524
</dependencies>
2625
</project>

zero-focus/pom.xml zero-entry-bootstrap-extension/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>zero-focus</artifactId>
13-
<name>Zero.Entry.Stack.Scaffold</name>
12+
<artifactId>zero-entry-bootstrap-extension</artifactId>
13+
<name>Zero.Entry.BootStrap.Extension</name>
1414

1515
<dependencies>
1616
<dependency>
File renamed without changes.

zero-import/pom.xml zero-entry-bootstrap-import/pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<version>1.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
11-
<artifactId>zero-import</artifactId>
11+
<artifactId>zero-entry-bootstrap-import</artifactId>
1212
<packaging>pom</packaging>
13-
<name>Zero.Entry.Stack.Import</name>
13+
<name>Zero.Entry.BootStrap.Import</name>
1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<java.version>17</java.version>
@@ -21,7 +21,7 @@
2121
<!-- Switch to Up -->
2222
<dependency>
2323
<groupId>io.zerows</groupId>
24-
<artifactId>zero-core-entry-standalone</artifactId>
24+
<artifactId>zero-core-entry-facade</artifactId>
2525
</dependency>
2626
</dependencies>
2727
<dependencyManagement>
@@ -62,12 +62,12 @@
6262
<!-- Business Scaffold -->
6363
<dependency>
6464
<groupId>io.zerows</groupId>
65-
<artifactId>zero-focus</artifactId>
65+
<artifactId>zero-entry-bootstrap-extension</artifactId>
6666
<version>${zero.version}</version>
6767
</dependency>
6868
<dependency>
6969
<groupId>io.zerows</groupId>
70-
<artifactId>zero-mini</artifactId>
70+
<artifactId>zero-entry-bootstrap-core</artifactId>
7171
<version>${zero.version}</version>
7272
</dependency>
7373
</dependencies>

zero-entry-bootstrap-osgi/pom.xml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.zerows</groupId>
8+
<artifactId>zero-entry</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>zero-entry-bootstrap-osgi</artifactId>
13+
<name>Zero.Entry.BootStrap.OSGI</name>
14+
<packaging>bundle</packaging>
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.zerows</groupId>
18+
<artifactId>zero-core-runtime-metadata</artifactId>
19+
</dependency>
20+
</dependencies>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.felix</groupId>
25+
<artifactId>maven-bundle-plugin</artifactId>
26+
<extensions>true</extensions>
27+
<configuration>
28+
<instructions>
29+
<Export-Package>
30+
<!-- SPI Required -->
31+
io.zerows.core.metadata.osgi.spi.*;-split-package:=merge-first,
32+
33+
io.zerows.core.entry.module.*,
34+
</Export-Package>
35+
<Import-Package>
36+
*;resolution:=optional,
37+
</Import-Package>
38+
<Embed-Transitive>true</Embed-Transitive>
39+
<!--
40+
在 JDK 9 之后,OSGI的打包会引起部分警告信息:
41+
[WARNING] Osgi io.zerows:zero-ams:bundle:1.0-SNAPSHOT :
42+
Classes found in the wrong directory: {META-INF/versions/9/module-info.class=module-info.class}
43+
此错误信息在编译的时候不会有问题,但在IDEA识别时会阻拦IDEA的运行,如直接导致IDEA中无法启动应用,因此,
44+
需要在打包的时候忽略此错误信息,具体配置如下:
45+
-->
46+
<_fixupmessages>
47+
"Classes found in the wrong directory";restrict:=error;is:=ignore
48+
</_fixupmessages>
49+
</instructions>
50+
</configuration>
51+
</plugin>
52+
<plugin>
53+
<artifactId>maven-compiler-plugin</artifactId>
54+
<version>${maven.plugin.compiler}</version>
55+
<configuration>
56+
<source>${java.version}</source>
57+
<target>${java.version}</target>
58+
<!--<compilerArgs>
59+
<arg>-verbose</arg>
60+
<arg>-Xlint:all,-options,-path</arg>
61+
</compilerArgs>-->
62+
</configuration>
63+
</plugin>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-dependency-plugin</artifactId>
67+
<executions>
68+
<execution>
69+
<id>copy-dependencies</id>
70+
<phase>package</phase>
71+
<goals>
72+
<goal>copy-dependencies</goal>
73+
</goals>
74+
<configuration>
75+
<!-- <includeScope>compile</includeScope> -->
76+
<type>jar</type>
77+
<includeTypes>jar</includeTypes>
78+
<!-- 存放服务依赖的jar包,存放在服务相同目录的lib文件夹下 -->
79+
<outputDirectory>
80+
target/lib
81+
</outputDirectory>
82+
</configuration>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.zerows.core.entry.osgi;
2+
3+
import org.apache.felix.dm.DependencyActivatorBase;
4+
import org.apache.felix.dm.DependencyManager;
5+
import org.osgi.framework.Bundle;
6+
import org.osgi.framework.BundleContext;
7+
8+
/**
9+
* @author lang : 2024-04-17
10+
*/
11+
public abstract class AbstractContainerBundle extends DependencyActivatorBase {
12+
13+
@Override
14+
public void init(final BundleContext context, final DependencyManager dm) throws Exception {
15+
final Bundle bundle = context.getBundle();
16+
// 依赖服务必须启动,否则此处的内容会不生效
17+
OEnvironment.initialize(bundle);
18+
19+
// 子类处理
20+
this.initModule(context, dm);
21+
}
22+
23+
@Override
24+
public void destroy(final BundleContext context, final DependencyManager dm) throws Exception {
25+
// 子类可重写此方法实现销毁
26+
this.destroyModule(context, dm);
27+
}
28+
29+
protected void initModule(final BundleContext context, final DependencyManager dm) throws Exception {
30+
// 子类可重写此方法实现初始化
31+
}
32+
33+
protected void destroyModule(final BundleContext context, final DependencyManager dm) throws Exception {
34+
// 子类可重写此方法实现销毁
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package io.zerows.core.entry.osgi;
2+
3+
import io.horizon.eon.VMessage;
4+
import io.horizon.eon.em.Environment;
5+
import io.horizon.eon.em.app.OsType;
6+
import io.horizon.eon.spec.VBoot;
7+
import io.horizon.runtime.Macrocosm;
8+
import io.horizon.util.HUt;
9+
import io.vertx.up.util.Ut;
10+
import org.osgi.framework.Bundle;
11+
12+
import java.util.Properties;
13+
import java.util.concurrent.ConcurrentMap;
14+
15+
/**
16+
* @author lang : 2024-04-17
17+
*/
18+
public class OEnvironment {
19+
/**
20+
* 环境变量初始化验证,内置启动会被直接调用
21+
*/
22+
public static void initialize(final Bundle bundle) {
23+
/*
24+
* 判断是否开启了开发环境,如果开启了开发环境,那么就会读取 .env.development 文件
25+
* 加载文件中的环境变量到系统层(只适用于开发)
26+
*/
27+
if (HUt.ioExist(VBoot._ENV_DEVELOPMENT)) {
28+
// 1. 环境变量设置
29+
final OsType os = HUt.envOs();
30+
Ut.Log.boot(OEnvironment.class).warn(VMessage.KEnvironment.DEVELOPMENT,
31+
os.name(), VBoot._ENV_DEVELOPMENT);
32+
final Properties properties = HUt.ioProperties(VBoot._ENV_DEVELOPMENT);
33+
// 1.1. 环境变量注入
34+
if (!properties.containsKey(Macrocosm.ZERO_ENV)) {
35+
properties.put(Macrocosm.ZERO_ENV, Environment.Development.name());
36+
}
37+
/*
38+
* 开发环境需要带上启动参数,否则会报错,这里是为了解决 JDK 9 以上版本的问题
39+
* --add-opens java.base/java.util=ALL-UNNAMED
40+
* --add-opens java.base/java.lang=ALL-UNNAMED
41+
*/
42+
final ConcurrentMap<String, String> written = HUt.envOut(properties);
43+
44+
// 2. 环境变量打印
45+
final String environments = HUt.envString(written);
46+
Ut.Log.boot(OEnvironment.class).warn(VMessage.KEnvironment.ENV, environments);
47+
}
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.zerows.core.metadata.osgi.spi.HorizonIoLoad
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# 检查环境变量 ZERO_HOME
3+
if [ -z "$ZERO_HOME" ]; then
4+
echo "ZERO_HOME 环境变量未设置!"
5+
exit 1
6+
fi
7+
mvn clean package install -Dquickly -DskipTests=true -Dmaven.javadoc.skip=true -Dmaven.compile.fork=true -T 1C

zero-entry-bootstrap-osgi/zoc-dev.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
./zoc-build.sh
3+
echo "Zero OSGI Development..."
4+
cp -rf target/*.jar $ZERO_HOME/develop/libs/bundles/

zero-entry-bootstrap-osgi/zoc.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
./zoc-build.sh
3+
echo "Zero OSGI Dispatch..."
4+
if [ "core" == "$1" ]; then
5+
cp -rf target/*.jar $ZERO_HOME/bundles/infix
6+
elif [ "extension" == "$1" ]; then
7+
cp -rf target/*.jar $ZERO_HOME/bundles/extension
8+
else
9+
cp -rf target/*.jar $ZERO_HOME/bundles/core
10+
fi

0 commit comments

Comments
 (0)