I am developing a component based game engine in java, right now when i have changes to the components I need to rebuild and restart the editor for the changes to take effect (or i can use some limited hot code injection if the application is running in debug mode).
I am looking for a way to allow the user to modify the source of the components and reload them without having to restart the application (maybe just exit and enter game mode instead). Also a important feature that I need is that the final exported code should be native Java code(so no interpreter should be used in the final result)).
Can you give me any pointers on how to integrate the beanshell interpreter in the project? I can manually monitor the source folder for changes and feed the updated java classes to it, but how is the hotswap going to occur really?
BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript.
BeanShell is an open-source embeddable Java source interpreter which has object scripting language features developed in Java. Developed by Patrick Niemeyer, BeanShell runs in the Java Runtime Environment and makes use of a variation of the Java syntax.
BeanShell vars.Create a sampler to request a product from the Amazon website. Then add a Post CSS/JQuery Extractor and extract the buying price. Whenever this request is executed, JMeter will create a variable on memory with the “Reference Name.” This variable is only available during that test.
First of all, the title is a bit confusing. You don't need to integrate a BeanShell. What you actually need are:
Architecture
Let's say you have an object graph. There are lots of objects, references, etc. So it will be really a tricky task to replace some instance with the new one. Instead of solving this problem you can hide dynamic part behind a "static" proxy. Proxy will handle all reloading stuff (including source folder monitoring).
Before reload:
After reload:
Having that done you can easily track changes and update dynamic part when needed.
Java Compiler API
Instead of using interpreted languages you can use Java, compiling it on the fly and loading using 'Class.forName()'. There are a lot of different examples due to the fact this approach was there for a while.
Here are some details:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With