Do install after resolve of oceans.

This commit is contained in:
Willem Cazander 2022-03-03 01:41:24 +01:00
parent b619004477
commit 3e782452aa
3 changed files with 49 additions and 23 deletions

View file

@ -13,7 +13,7 @@ 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.ServiceReference;
import org.slf4j.LoggerFactory; 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;
@ -86,6 +86,7 @@ public class GDXAppTos4Activator implements BundleActivator {
@Override @Override
public void stop(final BundleContext context) { public void stop(final BundleContext context) {
gdxFont.dispose();
} }
@Override @Override
@ -99,7 +100,6 @@ public class GDXAppTos4Activator implements BundleActivator {
File userHome = new File(System.getProperty(SYSTEM_USER_HOME)); File userHome = new File(System.getProperty(SYSTEM_USER_HOME));
hyperdriveHome = new File(userHome, HYPERDRIVE_HOME); hyperdriveHome = new File(userHome, HYPERDRIVE_HOME);
fireMessageEvent("hyper-home: "+hyperdriveHome);
if (!hyperdriveHome.exists()) { if (!hyperdriveHome.exists()) {
fireMessageEvent("ERROR: No Hyperdrive home."); fireMessageEvent("ERROR: No Hyperdrive home.");
return; return;
@ -187,6 +187,28 @@ public class GDXAppTos4Activator implements BundleActivator {
} else { } else {
fireMessageEvent("tos4: chains resolved."); fireMessageEvent("tos4: chains resolved.");
} }
try {
ServiceReference<?>[] refs = context.getServiceReferences( SystemWarpSea.class.getName(), "(warp.sea.name=*)" );
for (int i=0;i<refs.length;i++) {
SystemWarpSea service = (SystemWarpSea) context.getService( refs[i] );
String key = service.getWarpKey();
File waterHome = service.getWarpHome();
for (WaterSeaMagic magic:service.getWarpSea().theWater().getSeaMagics()) {
if ("application/vnd.osgi.bundle".equals(magic.getMime())) {
String overrideBundleKey = key + "." + magic.getFile();
String overrideBundle = localOverrides.getProperty(overrideBundleKey);
if (overrideBundle == null) {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+waterHome.getAbsolutePath()+"/"+magic.getFile());
} else {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+overrideBundle);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
fireMessageEvent("ERROR: "+e.getMessage());
}
} }
private static String getRangeUnicodeUsed() { private static String getRangeUnicodeUsed() {
@ -201,12 +223,26 @@ public class GDXAppTos4Activator implements BundleActivator {
public class SystemWarpSeaImpl implements SystemWarpSea { public class SystemWarpSeaImpl implements SystemWarpSea {
private final String warpKey;
private final File warpHome;
private final WaterOcean warpSea; private final WaterOcean warpSea;
public SystemWarpSeaImpl(WaterOcean warpSea) { public SystemWarpSeaImpl(String warpKey, File warpHome, WaterOcean warpSea) {
this.warpKey = warpKey;
this.warpHome = warpHome;
this.warpSea = warpSea; this.warpSea = warpSea;
} }
@Override
public String getWarpKey() {
return warpKey;
}
@Override
public File getWarpHome() {
return warpHome;
}
@Override @Override
public WaterOcean getWarpSea() { public WaterOcean getWarpSea() {
return warpSea; return warpSea;
@ -259,7 +295,7 @@ public class GDXAppTos4Activator implements BundleActivator {
@Override @Override
public int loadWaterOcean(BundleContext context, String key, Consumer<String> logger) public int loadWaterOcean(BundleContext context, String key, Consumer<String> logger)
throws IOException, InterruptedException, X4OConnectionException, SAXException, BundleException { throws IOException, InterruptedException, X4OConnectionException, SAXException {
File waterHome; File waterHome;
String override = localOverrides.getProperty(key); String override = localOverrides.getProperty(key);
if (override == null) { if (override == null) {
@ -285,20 +321,8 @@ public class GDXAppTos4Activator implements BundleActivator {
Hashtable<String, String> props = new Hashtable<String, String>(); Hashtable<String, String> props = new Hashtable<String, String>();
props.put(SystemWarpSea.NAME_PROPERTY, ocean.theWater().getName()); props.put(SystemWarpSea.NAME_PROPERTY, ocean.theWater().getName());
props.put(SystemWarpSea.PROVIDER_PROPERTY, ocean.theWater().getProvider()); context.registerService(SystemWarpSea.class.getName(), new SystemWarpSeaImpl(key, waterHome, ocean), props);
context.registerService(SystemWarpSea.class.getName(), new SystemWarpSeaImpl(ocean), props);
for (WaterSeaMagic magic:ocean.theWater().getSeaMagics()) {
if ("application/vnd.osgi.bundle".equals(magic.getMime())) {
String overrideBundleKey = key + "." + magic.getFile();
String overrideBundle = localOverrides.getProperty(overrideBundleKey);
if (overrideBundle == null) {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+waterHome.getAbsolutePath()+"/"+magic.getFile());
} else {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+overrideBundle);
}
}
}
int result = 0; int result = 0;
for (WaterSeaChain chain: ocean.theWater().getSeaChains()) { for (WaterSeaChain chain: ocean.theWater().getSeaChains()) {
result += loadWaterOcean(context, chain.getKey(), logger); result += loadWaterOcean(context, chain.getKey(), logger);

View file

@ -1,5 +1,7 @@
package love.distributedrebirth.gdxapp4d.tos4.service; package love.distributedrebirth.gdxapp4d.tos4.service;
import java.io.File;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.warpme.sea.WaterOcean; import love.distributedrebirth.warpme.sea.WaterOcean;
@ -7,7 +9,10 @@ import love.distributedrebirth.warpme.sea.WaterOcean;
public interface SystemWarpSea { public interface SystemWarpSea {
String NAME_PROPERTY = "warp.sea.name"; String NAME_PROPERTY = "warp.sea.name";
String PROVIDER_PROPERTY = "warp.sea.provider";
String getWarpKey();
File getWarpHome();
WaterOcean getWarpSea(); WaterOcean getWarpSea();
} }

View file

@ -28,16 +28,12 @@ import love.distributedrebirth.warpme.ship.WaterShipOcean;
public class GDXAppVrGem4Activator implements BundleActivator { public class GDXAppVrGem4Activator implements BundleActivator {
// private static final Logger LOG = LoggerFactory.getLogger(GDXAppVrGem4Activator.class);
@Override @Override
public void stop(final BundleContext context) { public void stop(final BundleContext context) {
} }
@Override @Override
public void start(final BundleContext context) { public void start(final BundleContext context) {
// LOG.info("GDXAppVrGem4Activator started");
try { try {
Thread.sleep(2000); Thread.sleep(2000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
@ -170,13 +166,14 @@ public class GDXAppVrGem4Activator implements BundleActivator {
} else { } else {
bootScreen.bootLine("vrGEM4: chains resolved."); bootScreen.bootLine("vrGEM4: chains resolved.");
try { try {
Thread.sleep(6000); Thread.sleep(2000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
} }
Gdx.app.postRunnable(new Runnable() { Gdx.app.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
terminal.selectScreen(ScreenDesktop1.class); terminal.selectScreen(ScreenDesktop1.class);
terminal.disposeScreen(bootScreen);
} }
}); });
} }