-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to easily call a bean method after camel has started #324
Comments
Wonder if we should do this through @BindToRegistry
OnStart doOnStart() {
return context -> doSomething(context);
} so we can use the same thing also for groovy/kotlin beans {
bean<OnStart>("doOnStart") {
doSomething(it)
}
} |
Yeah possible. I was also considering something even easier, with just a special method name or something. As otherwise you have to juggle with all that lambda and annotations. When all you wanted was just to have a method on RouteBuilder that camel-k would call.
|
Maybe having an interface to extend ? I'm more keen to have a proper type to have better support for tooling so i.e. for plain Java you can do something like class MyRoute extends RouteBuilder implements OnStartup {
public void onStartup() {
}
} This would also allow the runtime to easily detect what to do without having to rely on reflection to access methods so when a route is added, the camel-k runtime can do something like: if (route instanceof OnStartup) {
context.addLifecycleStrategy(...);
} and for scripting context {
onStartup {
...
// this would directly add this closure body as handler
// for the event by invoking context.addLifecycleStrategy(...)
}
} |
The |
Or maybe we can just enrich the RouteBuilder DSL to have a public void configure() {
onStartup(this::doOnStartup);
} That would be agnostic of the runtime |
Fixed on came by apache/camel#3850 |
so you dont have to do the timer:foo?repeatCount=1 trick.
Some kind of annotation or convention method name or something. We do have some event listeners we can hook into. But lets consider making this easy for end users writing their camel k in a source file in java / groovy etc.
The text was updated successfully, but these errors were encountered: