Thorntail Fraction Loading

March 16, 2020    thorntail wildfly swarm development

Thorntail Fraction Loading

What is a Fraction?

Here's what thorntail says about it…

Thorntail is defined by an unbounded set of capabilities. Each piece of functionality is called a fraction. Some fractions provide only access to APIs, such as JAX-RS or CDI; other fractions provide higher-level capabilities, such as integration with RHSSO (Keycloak).

I guess I can do anything, after all, it's unbounded

Source code

Start it up in debug mode - ~/apps/apache-maven-3.6.3/bin/mvn thorntail:run -Dthorntail.debug.port=5005 -Dswarm.logging=DEBUG -Dthorntail.logging=DEBUG

Swarm

We start in ServerBootstrap. This calls through to the CDI implementation which is weld.

    public Swarm start() throws Exception {
        INSTANCE = this;

        try (AutoCloseable handle = Performance.time("Thorntail.start()")) {

            Module module = Module.getBootModuleLoader().loadModule(CONTAINER_MODULE_NAME);
            Class<?> bootstrapClass = module.getClassLoader().loadClass("org.wildfly.swarm.container.runtime.ServerBootstrapImpl");

            ServerBootstrap bootstrap = (ServerBootstrap) bootstrapClass.newInstance();
            bootstrap
                    .withArguments(this.args)
                    .withBootstrapDebug(this.debugBootstrap)
                    .withExplicitlyInstalledFractions(this.explicitlyInstalledFractions)
                    .withSocketBindings(this.socketBindings)
                    .withOutboundSocketBindings(this.outboundSocketBindings)
                    .withUserComponents(this.userComponentClasses)
                    .withXmlConfig(this.xmlConfig)
                    .withConfigView(this.configView.get(true));

            this.server = bootstrap.bootstrap();

            return this;
        }

org.wildfly.swarm.container.runtime.ServerBootstrapImpl

Eventually, we make it to the bootstrap() method which finally calls weld.initialize();

org.jboss.weld.bootstrap.WeldStartup

Weld's startup class will then fire() against AfterBeanDiscoveryImpl.


        getContainer().setState(ContainerState.DISCOVERED);

        // Flush caches for BeanManager.getBeans() to be usable in ABD (WELD-1729)
        flushCaches();

        tracker.start(Tracker.OP_ABD);
        AfterBeanDiscoveryImpl.fire(deploymentManager, deployment, bdaMapping, contexts);
        tracker.end();

        // Extensions may have registered beans / observers. We need to flush caches.
        flushCaches();

org.wildfly.swarm.container.runtime.cdi.FractionProducingExtension

FractionProducingExtension is an Observer for AfterBeanDiscovery; this grants it an opportunity to add its own beans. In essence, these are Fractions.

Thorntail_Discovery_Fraction

0 = {Class@4134} "class org.wildfly.swarm.mail.MailFraction"
1 = {Class@4135} "class org.wildfly.swarm.request.controller.RequestControllerFraction"
2 = {Class@4136} "class org.wildfly.swarm.io.IOFraction"
3 = {Class@4137} "class org.wildfly.swarm.datasources.DatasourcesFraction"
4 = {Class@4138} "class org.wildfly.swarm.connector.ConnectorFraction"
5 = {Class@4139} "class org.wildfly.swarm.security.SecurityFraction"
6 = {Class@4140} "class org.wildfly.swarm.jaxrs.JAXRSFraction"
7 = {Class@4141} "class org.wildfly.swarm.transactions.TransactionsFraction"
8 = {Class@4142} "class org.wildfly.swarm.jca.JCAFraction"
9 = {Class@4143} "class org.wildfly.swarm.ee.EEFraction"
10 = {Class@4144} "class org.wildfly.swarm.logging.LoggingFraction"
11 = {Class@4145} "class org.wildfly.swarm.naming.NamingFraction"
12 = {Class@4146} "class org.wildfly.swarm.undertow.UndertowFraction"
13 = {Class@4147} "class org.wildfly.swarm.elytron.ElytronFraction"





comments powered by Disqus