You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
This is a question rather than an issue. (I apologize for this.)
I have a spring boot desktop application (Swing).
I want to change a bean which is an instance of JPanel, and reload the class.
(see for full code: https://github.com/bosbeles/spring-swing-deneme)
I am using Intellij. Java 8. Problem 1:
When I change constructor, and add/modify a method name, then Ctrl+Shift+F9, it is working.
But when I change only the constructor, and then Ctrl+Shift+F9; intellij shows a popup for hot code replace. But bean definition is not refreshed.
How can I force to refresh bean definition when I change only the constructor (or probably a method body).
Problem 2
As I said before, if I change method name, it works. But this is a hack.
I have modified your example plugin, and scheduled a timer with 2 seconds delay.
I am holding panel instance in a map. When I change the class, I am fetching the panel bean from the application context (which is statically gotten [a bad design]).
Then an action get panel from the map, and uses it.
It works because of the delay. Normally Spring plugin works after my example plugin. When I put 2 seconds delay, my example plugin works after the spring plugin. Then I can get the new, modified, refreshed bean.
As you see, there are some hacks. Is there a more appropriate way to do this?
`
@OnClassFileEvent(classNameRegexp = MAIN_PANEL, events = {CREATE, MODIFY})
public void changeClassFile(String className) {
scheduler.scheduleCommand(new ReloadClassCommand(appClassLoader, className, mainPanel), 2000);
}
public static void classReloaded(String className, Object mainPanel) {
// this is the main purpose of this class. Finally, we can use typed variables and
// use normal code instead of reflection. Imagine more complex code to reload part of your
// framework - it would be inconvenient to use reflection for each invocation.
EventQueue.invokeLater(() -> {
MainFrame mainFrame = Application.context.getBean(MainFrame.class);
mainFrame.getFactory().put("Window 2", Application.context.getBean(MainPanel.class));
});
}
`
The text was updated successfully, but these errors were encountered:
Hello.
This is a question rather than an issue. (I apologize for this.)
I have a spring boot desktop application (Swing).
I want to change a bean which is an instance of JPanel, and reload the class.
(see for full code: https://github.com/bosbeles/spring-swing-deneme)
I am using Intellij. Java 8.
Problem 1:
When I change constructor, and add/modify a method name, then Ctrl+Shift+F9, it is working.
But when I change only the constructor, and then Ctrl+Shift+F9; intellij shows a popup for hot code replace. But bean definition is not refreshed.
How can I force to refresh bean definition when I change only the constructor (or probably a method body).
Problem 2
As I said before, if I change method name, it works. But this is a hack.
I have modified your example plugin, and scheduled a timer with 2 seconds delay.
I am holding panel instance in a map. When I change the class, I am fetching the panel bean from the application context (which is statically gotten [a bad design]).
Then an action get panel from the map, and uses it.
It works because of the delay. Normally Spring plugin works after my example plugin. When I put 2 seconds delay, my example plugin works after the spring plugin. Then I can get the new, modified, refreshed bean.
As you see, there are some hacks. Is there a more appropriate way to do this?
`
`
The text was updated successfully, but these errors were encountered: