Reputation: 6925
I would like to add my processor to the lifecycle of a route (or context) and be able to start and stop things when the route starts and stops. I don't really want to create a component for this. I have been researching and I found out I can implement Service
and I can add my service to the context.
However, the only way I find to add it to the context is through the Exchange
. Is there any other cleaner way of doing this?
Upvotes: 2
Views: 1066
Reputation: 22279
You can implement a RoutePolicy which you can specify when setting up the route. It has callbacks for onStart, onStop, onResume, onSuspend, onInit, onRemove, onExchangeBegin, onExchangeDone
Upvotes: 4