use of java.util.ArrayList in project camel by apache.
the class BeanIODataFormatComplexTest method createTestData.
private List<Object> createTestData(boolean skipB1header) throws ParseException {
String source = "camel-beanio";
List<Object> body = new ArrayList<Object>();
Date date = new SimpleDateFormat("ddMMyy").parse("030808");
Header hFirst = new Header("A1", date, "PRICE");
Header hSecond = new Header("B1", date, "SECURITY");
Separator headerEnd = new Separator("HEADER END");
A1Record first = new A1Record("0001917", source, 12345.678900);
A1Record second = new A1Record("0002374", source, 59303290.020);
B1Record third = new B1Record("0015219", source, "SECURITY ONE");
Separator sectionEnd = new Separator("END OF SECTION 1");
A1Record fourth = new A1Record("0076647", source, 0.0000000001);
A1Record fifth = new A1Record("0135515", source, 999999999999d);
B1Record sixth = new B1Record("2000815", source, "SECURITY TWO");
B1Record seventh = new B1Record("2207122", source, "SECURITY THR");
body.add(hFirst);
if (!skipB1header) {
body.add(hSecond);
}
body.add(headerEnd);
body.add(first);
body.add(second);
body.add(third);
body.add(sectionEnd);
body.add(fourth);
body.add(fifth);
body.add(sixth);
body.add(seventh);
Trailer trailer = new Trailer(7);
body.add(trailer);
return body;
}
use of java.util.ArrayList in project antlrworks by antlr.
the class XJApplication method performQuit.
public void performQuit() {
delegate.appWillTerminate();
for (XJWindow window : new ArrayList<XJWindow>(windows)) {
if (!window.performClose(false)) {
// cancel quit if any document cannot or don't want to be closed
return;
}
}
XJFrame.closeDesktop();
shutdown();
}
use of java.util.ArrayList in project camel by apache.
the class DefaultCamelContext method shutdownRoute.
public synchronized void shutdownRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception {
RouteService routeService = routeServices.get(routeId);
if (routeService != null) {
List<RouteStartupOrder> routes = new ArrayList<RouteStartupOrder>(1);
RouteStartupOrder order = new DefaultRouteStartupOrder(1, routeService.getRoutes().iterator().next(), routeService);
routes.add(order);
getShutdownStrategy().shutdown(this, routes, timeout, timeUnit);
// must stop route service as well (and remove the routes from management)
stopRouteService(routeService, true);
}
}
use of java.util.ArrayList in project camel by apache.
the class DefaultCamelContext method doSuspend.
@Override
protected void doSuspend() throws Exception {
EventHelper.notifyCamelContextSuspending(this);
log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is suspending");
StopWatch watch = new StopWatch();
// (so when we resume we only resume the routes which actually was suspended)
for (Map.Entry<String, RouteService> entry : getRouteServices().entrySet()) {
if (entry.getValue().getStatus().isStarted()) {
suspendedRouteServices.put(entry.getKey(), entry.getValue());
}
}
// assemble list of startup ordering so routes can be shutdown accordingly
List<RouteStartupOrder> orders = new ArrayList<RouteStartupOrder>();
for (Map.Entry<String, RouteService> entry : suspendedRouteServices.entrySet()) {
Route route = entry.getValue().getRoutes().iterator().next();
Integer order = entry.getValue().getRouteDefinition().getStartupOrder();
if (order == null) {
order = defaultRouteStartupOrder++;
}
orders.add(new DefaultRouteStartupOrder(order, route, entry.getValue()));
}
// suspend routes using the shutdown strategy so it can shutdown in correct order
// routes which doesn't support suspension will be stopped instead
getShutdownStrategy().suspend(this, orders);
// mark the route services as suspended or stopped
for (RouteService service : suspendedRouteServices.values()) {
if (routeSupportsSuspension(service.getId())) {
service.suspend();
} else {
service.stop();
}
}
watch.stop();
if (log.isInfoEnabled()) {
log.info("Apache Camel " + getVersion() + " (CamelContext: " + getName() + ") is suspended in " + TimeUtils.printDuration(watch.taken()));
}
EventHelper.notifyCamelContextSuspended(this);
}
use of java.util.ArrayList in project camel by apache.
the class DefaultCamelContext method createRouteStaticEndpointJson.
public String createRouteStaticEndpointJson(String routeId, boolean includeDynamic) {
List<RouteDefinition> routes = new ArrayList<RouteDefinition>();
if (routeId != null) {
RouteDefinition route = getRouteDefinition(routeId);
if (route == null) {
throw new IllegalArgumentException("Route with id " + routeId + " does not exist");
}
routes.add(route);
} else {
routes.addAll(getRouteDefinitions());
}
StringBuilder buffer = new StringBuilder("{\n \"routes\": {");
boolean firstRoute = true;
for (RouteDefinition route : routes) {
if (!firstRoute) {
buffer.append("\n },");
} else {
firstRoute = false;
}
String id = route.getId();
buffer.append("\n \"").append(id).append("\": {");
buffer.append("\n \"inputs\": [");
// for inputs we do not need to check dynamic as we have the data from the route definition
Set<String> inputs = RouteDefinitionHelper.gatherAllStaticEndpointUris(this, route, true, false);
boolean first = true;
for (String input : inputs) {
if (!first) {
buffer.append(",");
} else {
first = false;
}
buffer.append("\n ");
buffer.append(StringHelper.toJson("uri", input, true));
}
buffer.append("\n ]");
buffer.append(",");
buffer.append("\n \"outputs\": [");
Set<String> outputs = RouteDefinitionHelper.gatherAllEndpointUris(this, route, false, true, includeDynamic);
first = true;
for (String output : outputs) {
if (!first) {
buffer.append(",");
} else {
first = false;
}
buffer.append("\n ");
buffer.append(StringHelper.toJson("uri", output, true));
}
buffer.append("\n ]");
}
if (!firstRoute) {
buffer.append("\n }");
}
buffer.append("\n }\n}\n");
return buffer.toString();
}
Aggregations