Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up leftovers from removed non-camel-main based runtime #6099

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,13 @@
*/
package org.apache.camel.quarkus.core;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import io.quarkus.arc.runtime.BeanContainer;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import org.apache.camel.CamelContext;
import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.RouteConfigurationsBuilder;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.LambdaRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.builder.endpoint.EndpointRouteBuilder;
import org.apache.camel.builder.endpoint.LambdaEndpointRouteBuilder;
import org.apache.camel.catalog.RuntimeCamelCatalog;
import org.apache.camel.impl.engine.DefaultVariableRepositoryFactory;
import org.apache.camel.spi.CamelContextCustomizer;
Expand Down Expand Up @@ -98,15 +90,6 @@ public void customize(RuntimeValue<CamelContext> context, RuntimeValue<CamelCont
contextCustomizer.getValue().configure(context.getValue());
}

public RuntimeValue<CamelRuntime> createRuntime(BeanContainer beanContainer, RuntimeValue<CamelContext> context) {
final CamelRuntime runtime = new CamelContextRuntime(context.getValue());

// register to the container
beanContainer.beanInstance(CamelProducers.class).setRuntime(runtime);

return new RuntimeValue<>(runtime);
}

public RuntimeValue<CamelContextCustomizer> createNoShutdownStrategyCustomizer() {
return new RuntimeValue<>(context -> context.setShutdownStrategy(new NoShutdownStrategy()));
}
Expand All @@ -115,53 +98,6 @@ public RuntimeValue<CamelContextCustomizer> createSourceLocationEnabledCustomize
return new RuntimeValue<>(context -> context.setSourceLocationEnabled(true));
}

public void addRoutes(RuntimeValue<CamelContext> context, List<String> nonCdiRoutesBuilderClassNames) {
List<RoutesBuilder> allRoutesBuilders = new ArrayList<>();

try {
for (String nonCdiRoutesBuilderClassName : nonCdiRoutesBuilderClassNames) {
Class<RoutesBuilder> nonCdiRoutesBuilderClass = context.getValue().getClassResolver()
.resolveClass(nonCdiRoutesBuilderClassName, RoutesBuilder.class);
allRoutesBuilders.add(context.getValue().getInjector().newInstance(nonCdiRoutesBuilderClass));
}

for (LambdaRouteBuilder builder : context.getValue().getRegistry().findByType(LambdaRouteBuilder.class)) {
allRoutesBuilders.add(new RouteBuilder() {
@Override
public void configure() throws Exception {
builder.accept(this);
}
});
}

for (LambdaEndpointRouteBuilder builder : context.getValue().getRegistry()
.findByType(LambdaEndpointRouteBuilder.class)) {
allRoutesBuilders.add(new EndpointRouteBuilder() {
@Override
public void configure() throws Exception {
builder.accept(this);
}
});
}

allRoutesBuilders.addAll(context.getValue().getRegistry().findByType(RoutesBuilder.class));

// Add RouteConfigurationsBuilders before RoutesBuilders
for (RoutesBuilder routesBuilder : allRoutesBuilders) {
if (routesBuilder instanceof RouteConfigurationsBuilder) {
context.getValue().addRoutesConfigurations((RouteConfigurationsBuilder) routesBuilder);
}
}
for (RoutesBuilder routesBuilder : allRoutesBuilders) {
if (!(routesBuilder instanceof RouteConfigurationsBuilder)) {
context.getValue().addRoutes(routesBuilder);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public void registerLifecycleEventBridge(RuntimeValue<CamelContext> context, Set<String> observedLifecycleEvents) {
context.getValue().addLifecycleStrategy(new CamelLifecycleEventBridge(observedLifecycleEvents));
}
Expand Down

This file was deleted.

Loading