public RoutesBuilder registerRoutes()

in extensions/java-joor-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/java/joor/runtime/JavaJoorDslRecorder.java [38:65]


    public RoutesBuilder registerRoutes(RuntimeValue<CamelContext> context, String className, String location)
            throws Exception {
        Class<?> clazz = Class.forName(className);
        boolean skip = clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())
                || Modifier.isPrivate(clazz.getModifiers());
        // must have a default no-arg constructor to be able to create an instance
        boolean ctr = ObjectHelper.hasDefaultNoArgConstructor(clazz);
        if (ctr && !skip) {
            // create a new instance of the class
            try {
                Object obj = context.getValue().getInjector().newInstance(clazz);
                if (obj instanceof RoutesBuilder builder) {
                    // inject context and resource
                    CamelContextAware.trySetCamelContext(obj, context.getValue());
                    ResourceAware.trySetResource(obj, ResourceHelper.fromString(location, ""));
                    context.getValue().addRoutes(builder);
                    return builder;
                } else {
                    LOG.warn("Ignoring the class {} as it is not of type RoutesBuilder", className);
                }
            } catch (Exception e) {
                throw new RuntimeCamelException("Cannot create instance of class: " + className, e);
            }
        } else {
            LOG.warn("Ignoring the class {} as it cannot be instantiated with the default constructor", className);
        }
        return null;
    }