Class SpringBootServiceFactory

java.lang.Object
com.gigaspaces.internal.services.ServiceFactory
com.gigaspaces.internal.services.SpringBootServiceFactory
Direct Known Subclasses:
DiManagerServiceFactory, GraphqlServiceFactory, McpServiceFactory, RestV3ServiceFactory

public abstract class SpringBootServiceFactory extends ServiceFactory
Common base for ServiceFactory implementations that boot an in-process, embedded Spring Boot fat-jar application via reflection over org.springframework.boot.loader.launch.* (currently McpServiceFactory and RestV3ServiceFactory; GraphqlServiceFactory once re-enabled). Extracted from what was, before PIC-6253, near-identical duplicated code in each of those classes.

The single behavioral change this base class makes versus the pre-PIC-6253 per-class copies: each service's ChildFirstURLClassLoader is now parented on the shared SpringBootClassLoader singleton instead of directly on the thread's context classloader (which, in practice, was always the plain system classloader - see ServiceFactory.createService()). This lets the shared library layer's classes resolve via ordinary parent-first delegation, while ChildFirstURLClassLoader's existing child-first override (scoped to org.springframework.boot.loader.*) continues to guarantee each service's own bundled Launcher/JarLauncher wins over anything above it.

Since:
18.0.0
Author:
Niv Ingberg
  • Constructor Details

    • SpringBootServiceFactory

      public SpringBootServiceFactory()
  • Method Details

    • getBootJarPath

      protected abstract Path getBootJarPath()
      Path to this service's own Spring Boot fat jar.
    • buildLaunchArgs

      protected String[] buildLaunchArgs()
      Arguments passed to Spring Boot's Launcher.launch(String[]); empty by default.
    • logger

      protected abstract org.slf4j.Logger logger()
      Logger used for the "service terminated" message on shutdown.
    • parentClassLoader

      protected ClassLoader parentClassLoader()
      Parent classloader for this service's ChildFirstURLClassLoader. Defaults to the shared SpringBootClassLoader singleton (PIC-6253), so the shared library layer's classes resolve via ordinary parent-first delegation. A service whose own fat jar bundles its complete stack and gets no benefit from that layer may override this to return ClassLoader.getSystemClassLoader() instead for full isolation from the shared layer - see DiManagerServiceFactory's own override for the tradeoffs this carries (logging-system auto-detection in particular).
    • getServiceClassName

      protected final String getServiceClassName()
      Specified by:
      getServiceClassName in class ServiceFactory
    • initializeClasspath

      protected void initializeClasspath(ClasspathBuilder classpath)
      Specified by:
      initializeClasspath in class ServiceFactory
    • createService

      public final Closeable createService()
      Overrides:
      createService in class ServiceFactory