public CodegenOrchestrator()

in codegen/smithy-ruby-codegen/src/main/java/software/amazon/smithy/ruby/codegen/CodegenOrchestrator.java [56:148]


    public CodegenOrchestrator(PluginContext pluginContext) {

        RubySettings rubySettings =
                RubySettings.from(pluginContext.getSettings());

        // If this fails to load changes, run: ./gradlew --stop
        ServiceLoader<RubyIntegration> integrationServiceLoader = ServiceLoader
                .load(RubyIntegration.class,
                        pluginContext.getPluginClassLoader()
                                .orElse(this.getClass().getClassLoader())
                );

        LOGGER.info("Loading integrations");
        List<RubyIntegration> integrations =
                StreamSupport
                        .stream(integrationServiceLoader.spliterator(), false)
                        .peek((i) -> LOGGER.info(
                                "Loaded RubyIntegration: "
                                        + i.getClass().getName()))
                        .sorted(Comparator.comparing(RubyIntegration::getOrder))
                        .collect(Collectors.toList());
        LOGGER.info("Loaded integrations: " + integrations.size());

        Model resolvedModel = pluginContext.getModel();

        for (RubyIntegration integration : integrations) {
            resolvedModel = integration
                    .preprocessModel(pluginContext, resolvedModel,
                            rubySettings);
        }

        ServiceShape service =
                resolvedModel.expectShape(rubySettings.getService())
                        .asServiceShape().orElseThrow(
                        () -> new CodegenException("Shape is not a service"));

        // Add unique operation input/output shapes
        resolvedModel = ModelTransformer.create()
                .createDedicatedInputAndOutput(resolvedModel, "Input", "Output");

        // Now that service and model are resolved, filter integrations for the service
        Model finalResolvedModel = resolvedModel;
        integrations = integrations.stream()
                .filter((integration) -> integration
                        .includeFor(service, finalResolvedModel))
                .collect(Collectors.toList());

        Set<ShapeId> supportedProtocols = new HashSet<>();
        for (RubyIntegration integration : integrations) {
            supportedProtocols.addAll(
                    integration.getProtocolGenerators()
                            .stream()
                            .map((g) -> g.getProtocol())
                            .peek((s) -> LOGGER.info(
                                    integration.getClass().getSimpleName()
                                            + " registered protocolGenerator "
                                            + "for: "
                                            + s.getName() + " -> "
                                            + s))
                            .collect(Collectors.toSet())
            );
        }

        ShapeId protocol = rubySettings
                .resolveServiceProtocol(service, resolvedModel,
                        supportedProtocols);
        Optional<ProtocolGenerator> protocolGenerator =
                resolveProtocolGenerator(protocol, integrations);

        ApplicationTransport
                applicationTransport; // Java9+ replace with ifPresentOrElse
        if (protocolGenerator.isPresent()) {
            applicationTransport =
                    protocolGenerator.get().getApplicationTransport();
        } else {
            applicationTransport = ApplicationTransport
                    .createDefaultHttpApplicationTransport();
        }

        LOGGER.info(
                "Resolved ApplicationTransport: " + applicationTransport);

        context = new GenerationContext(
                rubySettings,
                pluginContext.getFileManifest(),
                integrations,
                resolvedModel,
                service,
                protocol,
                protocolGenerator,
                applicationTransport
        );
    }