Package org.apache.camel.model

Examples of org.apache.camel.model.RoutesDefinition


        if (result == null) {
            throw new IOException("Cannot unmarshal to routes using JAXB from input stream: " + is);
        }

        // can either be routes or a single route
        RoutesDefinition answer = null;
        if (result instanceof RouteDefinition) {
            RouteDefinition route = (RouteDefinition) result;
            answer = new RoutesDefinition();
            answer.getRoutes().add(route);
        } else if (result instanceof RoutesDefinition) {
            answer = (RoutesDefinition) result;
        } else {
            throw new IllegalArgumentException("Unmarshalled object is an unsupported type: " + ObjectHelper.className(result) + " -> " + result);
        }
View Full Code Here


     * Returns the routes currently active within this context
     */
    @GET
    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public RoutesDefinition getRouteDefinitions() {
        RoutesDefinition answer = new RoutesDefinition();
        CamelContext camelContext = getCamelContext();
        if (camelContext != null) {
            List<RouteDefinition> list = camelContext.getRouteDefinitions();
            answer.setRoutes(list);
        }
        return answer;
    }
View Full Code Here

  }

  public void stopMetricsRoute() {
    String methodName = "stopMetricsRoute";
    try {
      RoutesDefinition rsd = metricsRouteBuilder.getRouteCollection();
      for (RouteDefinition rd : rsd.getRoutes()) {
        camelContext.stopRoute(rd.getId());
        logger.error(methodName, null, ">>>> Agent Stopped Metrics Publishing");
      }

    } catch (Exception e) {
View Full Code Here

        if (result == null) {
            throw new IOException("Cannot unmarshal to routes using JAXB from input stream: " + is);
        }

        // can either be routes or a single route
        RoutesDefinition answer = null;
        if (result instanceof RouteDefinition) {
            RouteDefinition route = (RouteDefinition) result;
            answer = new RoutesDefinition();
            answer.getRoutes().add(route);
        } else if (result instanceof RoutesDefinition) {
            answer = (RoutesDefinition) result;
        } else {
            throw new IllegalArgumentException("Unmarshalled object is an unsupported type: " + ObjectHelper.className(result) + " -> " + result);
        }
View Full Code Here

        Resource rs = new ClassPathResource("org/apache/camel/itest/jaxb/BarRoute.xml");
        Object value = unmarshaller.unmarshal(rs.getInputStream());

        // it should be a RoutesDefinition (we can have multiple routes in the same XML file)
        RoutesDefinition routes = (RoutesDefinition) value;
        assertNotNull("Should load routes from XML", routes);
        assertEquals(1, routes.getRoutes().size());

        // add the routes to existing CamelContext
        context.addRouteDefinitions(routes.getRoutes());

        assertNotNull("Loaded bar route should be there", context.getRoute("bar"));
        assertEquals(2, context.getRoutes().size());

        // test that loaded route works
View Full Code Here

        if (routes.isEmpty()) {
            return null;
        }

        // use a routes definition to dump the routes
        RoutesDefinition def = new RoutesDefinition();
        def.setRoutes(routes);
        return ModelHelper.dumpModelAsXml(def);
    }
View Full Code Here

    }

    public void addOrUpdateRoutesFromXml(String xml) throws Exception {
        // convert to model from xml
        InputStream is = context.getTypeConverter().mandatoryConvertTo(InputStream.class, xml);
        RoutesDefinition def = context.loadRoutesDefinition(is);
        if (def == null) {
            return;
        }

        // add will remove existing route first
        context.addRouteDefinitions(def.getRoutes());
    }
View Full Code Here

     */
    @GET
    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    @SuppressWarnings("deprecation")
    public RoutesDefinition getRouteDefinitions() {
        RoutesDefinition answer = new RoutesDefinition();
        CamelContext camelContext = getCamelContext();
        if (camelContext != null) {
            List<RouteDefinition> list = camelContext.getRouteDefinitions();
            answer.setRoutes(list);
        }
        return answer;
    }
View Full Code Here

    protected CamelContext camelContext;
    @Test
    public void testCanMarshalRoutes() throws Exception {
        CamelContextResource resource = new CamelContextResource(camelContext);
        RoutesDefinition routes = resource.getRoutesResource().getRouteDefinitions();
        List<RouteDefinition> list = routes.getRoutes();
        System.out.println("Found routes: " + list);

        // now lets marshall to XML
        JAXBContext context = JAXBContext.newInstance(RoutesDefinition.class.getPackage().getName());
        StringWriter out = new StringWriter();
View Full Code Here

        String text = resource.path("routes").accept("application/xml").get(String.class);
        System.out.println("Routes XML: " + text);
        assertNotNull("XML should not be null", text);

        RoutesDefinition routes = resource.path("routes").accept("application/xml").get(RoutesDefinition.class);
        assertNotNull("Should have found routes", routes);
        List<RouteDefinition> routeList = routes.getRoutes();
        assertTrue("Should have at least one route", routeList.size() > 0);
        System.out.println("Have routes: " + routeList);
       
        //call the REST API to remove the first route, then validate that the response page doesn't contain the route
        String routeID = routeList.get(0).getId();
View Full Code Here

TOP

Related Classes of org.apache.camel.model.RoutesDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.