I am implementing some unit tests and if things go wrong I just want
to shutdown ASAP without regard for inconsistent
states, etc.  There's no easy hook in DefaultShutDownStrategy to do
that because you need to know the route
startup order, so I ended up with this convoluted code (that I kick
off in a separate thread). It doesn't work, BTW.

                    DefaultRouteStartupOrder rsuo = null;
                    int startOrder = 0;
                    List<RouteStartupOrder> suo = new
ArrayList<RouteStartupOrder>();
                    List<Route> routes = context.getRoutes();
                    for (Route route : routes) {
                        List<Service> services = route.getServices();
                        for (Service service : services) {
                            if (service instanceof RouteService) {
                                rsuo = new
DefaultRouteStartupOrder(startOrder, route, (RouteService) service);
                                suo.add(rsuo);
                            }
                        }
                        startOrder++;
                    }
                    ShutdownStrategy sds = context.getShutdownStrategy();
                    sds.shutdownForced(context, suo);

I know there must be an easier way, but I haven't found such.  Any ideas?

Thanks,

Chris

Reply via email to