Skip to content

Commit

Permalink
Mixins work
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Jul 8, 2024
1 parent b001455 commit 841022e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int offerClassNodeToPlugins(final ILaunchPluginService.Phase phase, final List<I
return flags;
}

void announceLaunch(final TransformingClassLoader transformerLoader, final NamedPath[] specialPaths) {
public void announceLaunch(final TransformingClassLoader transformerLoader, final NamedPath[] specialPaths) {
plugins.forEach((k, p)->p.initializeLaunch((s->transformerLoader.buildTransformedClassNodeFor(s, k)), specialPaths));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public TransformationServicesHandler(TransformStore transformStore, ModuleLayerH
this.layerHandler = layerHandler;
}

public TransformationServicesHandler(TransformStore transformStore, ModuleLayerHandler layerHandler, Environment environment, Collection<ITransformationService> services) {
this.transformStore = transformStore;
this.layerHandler = layerHandler;
setTransformationServices(services, environment);
}

public List<ITransformationService.Resource> initializeTransformationServices(ArgumentHandler argumentHandler, Environment environment) {
loadTransformationServices(environment);
validateTransformationServices();
Expand Down Expand Up @@ -125,14 +131,18 @@ public void discoverServices(final DiscoveryData discoveryData) {
additionalPaths.forEach(np->layerHandler.addToLayer(IModuleLayerManager.Layer.SERVICE, np));
var serviceLayer = layerHandler.buildLayer(IModuleLayerManager.Layer.SERVICE);
earlyDiscoveryServices.forEach(s->s.earlyInitialization(discoveryData.launchTarget(), discoveryData.arguments()));
serviceLookup = ServiceLoaderUtils.streamServiceLoader(()->ServiceLoader.load(serviceLayer.layer(), ITransformationService.class), sce -> LOGGER.fatal(MODLAUNCHER, "Encountered serious error loading transformation service, expect problems", sce))
.collect(Collectors.toMap(ITransformationService::name, TransformationServiceDecorator::new));
setTransformationServices(ServiceLoaderUtils.streamServiceLoader(()->ServiceLoader.load(serviceLayer.layer(), ITransformationService.class), sce -> LOGGER.fatal(MODLAUNCHER, "Encountered serious error loading transformation service, expect problems", sce))
.toList(), Launcher.INSTANCE.environment());
}

private void setTransformationServices(Collection<ITransformationService> services, Environment environment) {
serviceLookup = services.stream().collect(Collectors.toMap(ITransformationService::name, TransformationServiceDecorator::new));
var modlist = serviceLookup.entrySet().stream().map(e->Map.of(
"name", e.getKey(),
"type", "TRANSFORMATIONSERVICE",
"file", ServiceLoaderUtils.fileNameFor(e.getValue().getClass())
)).toList();
Launcher.INSTANCE.environment().getProperty(IEnvironment.Keys.MODLIST.get()).ifPresent(ml->ml.addAll(modlist));
environment.getProperty(IEnvironment.Keys.MODLIST.get()).ifPresent(ml->ml.addAll(modlist));
LOGGER.debug(MODLAUNCHER,"Found transformer services : [{}]", () -> String.join(",",serviceLookup.keySet()));
}

Expand Down

0 comments on commit 841022e

Please sign in to comment.