static XmlCdiBeanFactory with(BeanManager manager, CdiCamelEnvironment environment, CdiCamelExtension extension) { return new XmlCdiBeanFactory(manager, environment, extension); }
if (node instanceof RoutesDefinition) { RoutesDefinition routes = (RoutesDefinition) node; return singleton(routesDefinitionBean(routes, url)); } else if (node instanceof ApplicationContextFactoryBean) { ApplicationContextFactoryBean app = (ApplicationContextFactoryBean) node; Set<SyntheticBean<?>> beans = new HashSet<>(); for (CamelContextFactoryBean factory : app.getContexts()) { SyntheticBean<?> bean = camelContextBean(factory, url, annotatedType); beans.add(bean); beans.addAll(camelContextBeans(factory, bean, url)); beans.add(errorHandlerBean(definition, url)); beans.addAll(beansFrom(base + "/" + definition.getResource(), annotatedType)); beans.add(restContextBean(factory, url)); beans.add(routeContextBean(factory, url)); if (hasId(factory)) { beans.add(camelContextBean(null, factory, url)); CamelContextFactoryBean factory = (CamelContextFactoryBean) node; Set<SyntheticBean<?>> beans = new HashSet<>(); SyntheticBean<?> bean = camelContextBean(factory, url, annotatedType); beans.add(bean); beans.addAll(camelContextBeans(factory, bean, url)); return beans; } else if (node instanceof RestContextDefinition) {
factory.getBeansFactory().stream() .filter(XmlCdiBeanFactory::hasId) .map(bean -> camelContextBean(context, bean, url)) .forEach(beans::add); factory.getEndpoints().stream() .filter(XmlCdiBeanFactory::hasId) .map(endpoint -> camelContextBean(context, endpoint, url)) .forEach(beans::add); factory.getErrorHandlers().stream() .filter(XmlCdiBeanFactory::hasId) .map(handler -> errorHandlerBean(handler, url)) .forEach(beans::add); .map(export -> serviceExporterBean(context, export, url)) .forEach(beans::add); factory.getProxies().stream() .filter(XmlCdiBeanFactory::hasId) .map(proxy -> proxyFactoryBean(context, proxy, url)) .forEach(beans::add); factory.getRedeliveryPolicies().stream() .filter(XmlCdiBeanFactory::hasId) .map(policy -> camelContextBean(context, policy, url)) .forEach(beans::add);
XmlCdiBeanFactory factory = XmlCdiBeanFactory.with(manager, environment, this); ImportResource resource = resources.get(annotatedType); for (String path : resource.value()) { try { extraBeans.addAll(factory.beansFrom(path, annotatedType)); } catch (NoClassDefFoundError cause) { if (cause.getMessage().contains("AbstractCamelContextFactoryBean")) {
hasId(exporter) ? NamedLiteral.of(exporter.getId()) : DEFAULT), type, bean -> "imported bean [" + Objects.toString(exporter.getId(), "export") + "] "
Set<SyntheticBean<?>> beansFrom(String path, AnnotatedType<?> annotatedType) throws JAXBException, IOException { URL url = getResource(path, annotatedType.getJavaClass().getClassLoader()); if (url == null) { logger.warn("Unable to locate resource [{}] for import!", path); return emptySet(); } return beansFrom(url, annotatedType); }
throw attributeNotSupported("deadLetterUri", type, definition.getId()); throw attributeNotSupported("deadLetterHandleNewException", type, definition.getId()); throw attributeNotSupported("transactionTemplateRef", type, definition.getId()); throw attributeNotSupported("transactionManagerRef", type, definition.getId()); throw attributeNotSupported("rollbackLoggingLevel", type, definition.getId()); && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) { throw attributeNotSupported("useOriginalMessage", type, definition.getId()); && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) { throw attributeNotSupported("onRedeliveryRef", type, definition.getId()); && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) { throw attributeNotSupported("onExceptionOccurredRef", type, definition.getId()); || type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) { throw attributeNotSupported("onPrepareFailureRef", type, definition.getId()); && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) { throw attributeNotSupported("retryWhileRef", type, definition.getId());
private SyntheticBean<?> routesDefinitionBean(RoutesDefinition definition, URL url) { return new SyntheticBean<>(manager, // TODO: should be @Named if the id is set new SyntheticAnnotated(RoutesDefinition.class, manager.createAnnotatedType(RoutesDefinition.class).getTypeClosure(), ANY, DEFAULT), RoutesDefinition.class, new SyntheticInjectionTarget<>(() -> definition), bean -> "imported routes definition " + (hasId(definition) ? "[" + definition.getId() + "] " : "") + "from resource [" + url + "]"); }
private SyntheticBean<?> camelContextBean(Bean<?> context, AbstractCamelFactoryBean<?> factory, URL url) { if (factory instanceof BeanManagerAware) { ((BeanManagerAware) factory).setBeanManager(manager); } Set<Annotation> annotations = new HashSet<>(); annotations.add(ANY); // FIXME: should add @ContextName if the Camel context bean has it annotations.add(hasId(factory) ? NamedLiteral.of(factory.getId()) : DEFAULT); // TODO: should that be @Singleton to enable injection points with bean instance type? if (factory.isSingleton()) { annotations.add(APPLICATION_SCOPED); } return new SyntheticBean<>(manager, new SyntheticAnnotated(factory.getObjectType(), manager.createAnnotatedType(factory.getObjectType()).getTypeClosure(), annotations), factory.getObjectType(), new XmlFactoryBeanInjectionTarget<>(manager, factory, context), bean -> "imported bean [" + factory.getId() + "] " + "from resource [" + url + "] " + "with qualifiers " + bean.getQualifiers()); }
private SyntheticBean<?> camelContextBean(CamelContextFactoryBean factory, URL url, AnnotatedType annotatedType) { Set<Annotation> annotations = new HashSet<>(); annotations.add(ANY); if (hasId(factory)) { addAll(annotations, ContextName.Literal.of(factory.getId()), NamedLiteral.of(factory.getId()));