Пример #1
0
 public String dumpRouteAsXml() throws Exception {
   String id = route.getId();
   RouteDefinition def = context.getRouteDefinition(id);
   if (def != null) {
     return ModelHelper.dumpModelAsXml(def);
   }
   return null;
 }
Пример #2
0
  public String dumpRoutesAsXml() throws Exception {
    List<RouteDefinition> routes = context.getRouteDefinitions();
    if (routes.isEmpty()) {
      return null;
    }

    // use a routes definition to dump the routes
    RoutesDefinition def = new RoutesDefinition();
    def.setRoutes(routes);
    return ModelHelper.dumpModelAsXml(context, def);
  }
Пример #3
0
  public void updateRouteFromXml(String xml) throws Exception {
    // convert to model from xml
    RouteDefinition def = ModelHelper.createModelFromXml(xml, RouteDefinition.class);
    if (def == null) {
      return;
    }

    // if the xml does not contain the route-id then we fix this by adding the actual route id
    // this may be needed if the route-id was auto-generated, as the intend is to update this route
    // and not add a new route, adding a new route, use the MBean operation on ManagedCamelContext
    // instead.
    if (ObjectHelper.isEmpty(def.getId())) {
      def.setId(getRouteId());
    } else if (!def.getId().equals(getRouteId())) {
      throw new IllegalArgumentException(
          "Cannot update route from XML as routeIds does not match. routeId: "
              + getRouteId()
              + ", routeId from XML: "
              + def.getId());
    }

    // add will remove existing route first
    context.addRouteDefinition(def);
  }