private void addDependsOnToRouteBuilder(
     Element childElement, ParserContext parserContext, String contextId) {
   // setting the depends-on explicitly is required since Spring 3.0
   String routeBuilderName = childElement.getAttribute("ref");
   if (ObjectHelper.isNotEmpty(routeBuilderName)) {
     // set depends-on to the context for a routeBuilder bean
     try {
       BeanDefinition definition = parserContext.getRegistry().getBeanDefinition(routeBuilderName);
       Method getDependsOn = definition.getClass().getMethod("getDependsOn", new Class[] {});
       String[] dependsOn = (String[]) getDependsOn.invoke(definition);
       if (dependsOn == null || dependsOn.length == 0) {
         dependsOn = new String[] {contextId};
       } else {
         String[] temp = new String[dependsOn.length + 1];
         System.arraycopy(dependsOn, 0, temp, 0, dependsOn.length);
         temp[dependsOn.length] = contextId;
         dependsOn = temp;
       }
       Method method = definition.getClass().getMethod("setDependsOn", String[].class);
       method.invoke(definition, (Object) dependsOn);
     } catch (Exception e) {
       // Do nothing here
     }
   }
 }
 private void registerEndpoint(
     Element childElement, ParserContext parserContext, String contextId) {
   String id = childElement.getAttribute("id");
   // must have an id to be registered
   if (ObjectHelper.isNotEmpty(id)) {
     BeanDefinition definition = endpointParser.parse(childElement, parserContext);
     definition
         .getPropertyValues()
         .addPropertyValue("camelContext", new RuntimeBeanReference(contextId));
     // Need to add this dependency of CamelContext for Spring 3.0
     try {
       Method method = definition.getClass().getMethod("setDependsOn", String[].class);
       method.invoke(definition, (Object) new String[] {contextId});
     } catch (Exception e) {
       // Do nothing here
     }
     parserContext.registerBeanComponent(new BeanComponentDefinition(definition, id));
   }
 }