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

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

View file

@ -14,12 +14,14 @@ import java.util.function.Consumer;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.slf4j.LoggerFactory;
import org.x4o.xml.io.X4OConnectionException;
import org.xml.sax.SAXException;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBase;
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.SystemWarpShip;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpTerminal;
@ -138,6 +140,7 @@ public class GDXAppTos4Activator implements BundleActivator {
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(SystemWarpBootArgs.class.getName(), new SystemWarpBootArgsImpl(), 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();
}
}
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);
framework.setName("boot");
framework.start();
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);
}
}