简体   繁体   中英

How can i know when CamelContext was started?

I want to know when CamelContext was started. As i see, DefaultCamelContext has private Date startDate field. There is no getter or other methods to get information from this field. All can i get is getUptimeMillis() that returns uptime, but this is not what I am looking for.

I know that I can get field value using reflection:

Class clazz = context.getClass();
Field field = clazz.getDeclaredField("startDate");
field.setAccessible(true);
Date date = (Date) field.get(context);

But I dont think this is good way.

Is there any another way to get this information (may be use another CamelContext, some camel components or services)?

Thank you.

Yeah we can make that as a public API. I created a ticket https://issues.apache.org/jira/browse/CAMEL-14266

Otherwise you should do as suggested to calculate the start date via the uptime and minus the current time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM