Implemented first SCR component

This commit is contained in:
Willem Cazander 2022-03-02 19:18:47 +01:00
parent 00cb859cd9
commit c6bee21cee
16 changed files with 149 additions and 3 deletions

View file

@ -6,7 +6,22 @@ Final version will be written in HolyC++ on templeOS called VRGEM⁴.
## Project Setup ## Project Setup
Use the AdoptOpenJDK(11++) to run the demo. Requirements;
* Setup [Hyperdrive](https://github.com/hyperspace-org/hyperdrive-service)
* Use an AdoptOpenJDK(11++) to run the demo.
### Project Launch Release
When hyperdrive is running just start the jar file with;
java -jar todo.jar
### Project Launch IDE
Run "mvn package" once before starting.
Append "use-local" to the main launcher to use the local chains.
## Duytschen Code ## Duytschen Code

View file

@ -3,6 +3,7 @@
<properties> <properties>
<entry key="1c2d010066a39d96ace8af0ecc37c72d6f79109f30939e2959befcd9ce25fc8d">../gdxapp4d-chain-sys-engine/src/chain</entry> <entry key="1c2d010066a39d96ace8af0ecc37c72d6f79109f30939e2959befcd9ce25fc8d">../gdxapp4d-chain-sys-engine/src/chain</entry>
<entry key="f8be3b29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41a410b">../gdxapp4d-chain-sys-ocean/src/chain</entry> <entry key="f8be3b29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41a410b">../gdxapp4d-chain-sys-ocean/src/chain</entry>
<entry key="8833aa29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41b58de">../gdxapp4d-chain-dep-osgi-scr/src/chain</entry>
<entry key="ccba3b29da8b1b1cb444f381449beede3cbfd442d158293a4cdffbc3c41a31cc">../gdxapp4d-vrgem4/src/chain</entry> <entry key="ccba3b29da8b1b1cb444f381449beede3cbfd442d158293a4cdffbc3c41a31cc">../gdxapp4d-vrgem4/src/chain</entry>
<entry key="ccba3b29da8b1b1cb444f381449beede3cbfd442d158293a4cdffbc3c41a31cc.gdxapp4d-vrgem4.jar">../gdxapp4d-vrgem4/target/classes</entry> <entry key="ccba3b29da8b1b1cb444f381449beede3cbfd442d158293a4cdffbc3c41a31cc.gdxapp4d-vrgem4.jar">../gdxapp4d-vrgem4/target/classes</entry>
</properties> </properties>

View file

@ -0,0 +1,10 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gdxapp4d-chain-dep-osgi-scr</artifactId>
<packaging>pom</packaging>
</project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<root:ocean xmlns:root="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root"
xmlns:link="http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-link"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root-1.0.xsd">
<link:sea name="DepOSGI SCR" provider="gdxapp4d.system" author="willemtsade">
<link:magic file="bundle/org.osgi.util.function-1.2.0.jar" mime="application/vnd.osgi.bundle"/>
<link:magic file="bundle/org.osgi.util.promise-1.2.0.jar" mime="application/vnd.osgi.bundle"/>
<link:magic file="bundle/org.apache.felix.scr-2.2.0.jar" mime="application/vnd.osgi.bundle"/>
</link:sea>
</root:ocean>

View file

@ -4,6 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root-1.0.xsd"> xsi:schemaLocation="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root-1.0.xsd">
<link:sea name="System Engine" provider="gdxapp4d.system" author="willemtsade"> <link:sea name="System Engine" provider="gdxapp4d.system" author="willemtsade">
<!-- Link dep-osgi-scr -->
<link:chain key="8833aa29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41b58de"/>
<!-- Link vrgem4 --> <!-- Link vrgem4 -->
<link:chain key="ccba3b29da8b1b1cb444f381449beede3cbfd442d158293a4cdffbc3c41a31cc"/> <link:chain key="ccba3b29da8b1b1cb444f381449beede3cbfd442d158293a4cdffbc3c41a31cc"/>
</link:sea> </link:sea>

View file

@ -44,6 +44,11 @@
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

View file

@ -14,12 +14,14 @@ import java.util.function.Consumer;
import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException; import org.osgi.framework.BundleException;
import org.slf4j.LoggerFactory;
import org.x4o.xml.io.X4OConnectionException; import org.x4o.xml.io.X4OConnectionException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBase; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBase;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBootArgs; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpLogger;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpSea; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpSea;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpTerminal; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpTerminal;
@ -138,6 +140,7 @@ public class GDXAppTos4Activator implements BundleActivator {
SystemWarpShipImpl systemWarpShip = new SystemWarpShipImpl(); SystemWarpShipImpl systemWarpShip = new SystemWarpShipImpl();
context.registerService(SystemWarpLogger.class.getName(), new SystemWarpLoggerImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpBase.class.getName(), new SystemWarpBaseImpl(), new Hashtable<String, String>()); context.registerService(SystemWarpBase.class.getName(), new SystemWarpBaseImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpBootArgs.class.getName(), new SystemWarpBootArgsImpl(), new Hashtable<String, String>()); context.registerService(SystemWarpBootArgs.class.getName(), new SystemWarpBootArgsImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpShip.class.getName(), systemWarpShip, new Hashtable<String, String>()); context.registerService(SystemWarpShip.class.getName(), systemWarpShip, new Hashtable<String, String>());
@ -286,4 +289,27 @@ public class GDXAppTos4Activator implements BundleActivator {
return buf.toString(); return buf.toString();
} }
} }
public static class SystemWarpLoggerImpl implements SystemWarpLogger {
@Override
public void infoTag(String tag, String message, Object...args) {
LoggerFactory.getLogger(tag).info(message, args);
}
@Override
public void debugTag(String tag, String message, Object...args) {
LoggerFactory.getLogger(tag).debug(message, args);
}
@Override
public void errorTag(String tag, String message, Object...args) {
LoggerFactory.getLogger(tag).error(message, args);
}
@Override
public void errorTag(String tag, String message, Throwable exception) {
LoggerFactory.getLogger(tag).error(message, exception);
}
}
} }

View file

@ -44,6 +44,7 @@ public class GDXAppTos4Startup {
} }
}; };
Thread framework = new Thread(run); Thread framework = new Thread(run);
framework.setName("boot");
framework.start(); framework.start();
return systemBundle; return systemBundle;

View file

@ -0,0 +1,31 @@
package love.distributedrebirth.gdxapp4d.tos4.service;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public interface SystemWarpLogger {
void infoTag(String tag, String message, Object...args);
void debugTag(String tag, String message, Object...args);
void errorTag(String tag, String message, Object...args);
void errorTag(String tag, String message, Throwable exception);
default void info(Object tag, String message, Object...args) {
infoTag(tag.getClass().getName(), message, args);
}
default void debug(Object tag, String message, Object...args) {
debugTag(tag.getClass().getName(), message, args);
}
default void error(Object tag, String message, Object...args) {
errorTag(tag.getClass().getName(), message, args);
}
default void error(Object tag, String message, Throwable exception) {
errorTag(tag.getClass().getName(), message, exception);
}
}

View file

@ -12,6 +12,7 @@
<groupId>love.distributedrebirth.gdxapp4d</groupId> <groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d-tos4</artifactId> <artifactId>gdxapp4d-tos4</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
@ -21,11 +22,20 @@
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<exportScr>true</exportScr>
<instructions> <instructions>
<_donotcopy>(.git)</_donotcopy> <_donotcopy>(.git)</_donotcopy>
<!-- Enable processing of OSGI DS component annotations -->
<_dsannotations>*</_dsannotations>
<!-- Enable processing of OSGI metatype annotations -->
<_metatypeannotations>*</_metatypeannotations>
<Import-Package> <Import-Package>
love.distributedrebirth.gdxapp4d.tos4.service,
org.osgi.framework, org.osgi.framework,
org.osgi.service.packageadmin,
org.osgi.service.url,
org.osgi.service.startlevel,
org.osgi.util.tracker,
love.distributedrebirth.gdxapp4d.tos4.service,
com.badlogic.gdx, com.badlogic.gdx,
com.badlogic.gdx.assets, com.badlogic.gdx.assets,
com.badlogic.gdx.assets.loaders, com.badlogic.gdx.assets.loaders,

View file

@ -41,6 +41,11 @@ public class GDXAppVrGem4Activator implements BundleActivator {
public void start(final BundleContext context) { public void start(final BundleContext context) {
// LOG.info("GDXAppVrGem4Activator started"); // LOG.info("GDXAppVrGem4Activator started");
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
ServiceReference<SystemWarpTerminal> termRef = context.getServiceReference(SystemWarpTerminal.class); ServiceReference<SystemWarpTerminal> termRef = context.getServiceReference(SystemWarpTerminal.class);
SystemWarpTerminal terminal = context.getService(termRef); SystemWarpTerminal terminal = context.getService(termRef);
@ -162,7 +167,7 @@ public class GDXAppVrGem4Activator implements BundleActivator {
} else { } else {
bootScreen.bootLine("vrGEM4: chains resolved."); bootScreen.bootLine("vrGEM4: chains resolved.");
try { try {
Thread.sleep(5000); Thread.sleep(2000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
} }
Gdx.app.postRunnable(new Runnable() { Gdx.app.postRunnable(new Runnable() {

View file

@ -0,0 +1,28 @@
package love.distributedrebirth.gdxapp4d.vrgem4;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpLogger;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
@Component
public class TestComponent {
@Reference
private SystemWarpLogger log;
@Reference
private SystemWarpShip warpShip;
@Activate
void open() {
log.info(this, "Activated warpEngine: {}", warpShip.getWarpShip().theShip().getEngine());
}
@Deactivate
void close() {
}
}

View file

@ -12,6 +12,7 @@
<module>gdxapp4d-app-notepad</module> <module>gdxapp4d-app-notepad</module>
<module>gdxapp4d-app-tosamp</module> <module>gdxapp4d-app-tosamp</module>
<module>gdxapp4d-boot-desktop</module> <module>gdxapp4d-boot-desktop</module>
<module>gdxapp4d-chain-dep-osgi-scr</module>
<module>gdxapp4d-chain-music-msx</module> <module>gdxapp4d-chain-music-msx</module>
<module>gdxapp4d-chain-music-templeos</module> <module>gdxapp4d-chain-music-templeos</module>
<module>gdxapp4d-chain-sys-engine</module> <module>gdxapp4d-chain-sys-engine</module>