-
Notifications
You must be signed in to change notification settings - Fork 78
Better cold classes management #175
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
Conversation
This method recursively analyse a class to get all its super classes, and all its interfaces
Instead of just adding the component class, also adds its inherited classes.
This property contains a string with all FQCN of cold classes, separated by ':'.
This property might be specified using System.properties like that:
```
System.setProperty("restx.cold.classes", "foo.ColdClass1:bar.ColdClass2");
```
It meant that `foo.ColdClass1` and `bar.ColdClass2` must be ignored by hot-reload
mechanism.
As cold classes are supposed to be used by components, they must be loaded with the same classloader
as the one used for components, that's why the classloader used to initialize the factory's components
is kept, and re-used to transform cold classes FQCN into real classes.
Currently only one method is defined, a method to extract cold classes from a string. The string needs to contain fqcn separated by the ':' character.
Using a resource `META-INF/cold-classes.list` permits to declare a list of cold classes. The file must contain a fqcn per line. Mind that this file will be read only once, so new cold classes declaration will requires a restart of the application.
This annotation permits to declare the class as cold. Once declared the class will not be part of the hot-reloading mechanism.
In factory annotation processor a class was used to generate the machine service file. This process use from now on the abstract class ResourceDeclaration defined in RestxAbstractProcessor. Like this other processors having the same need, might also use the ResourceDeclaration class.
This annotation processor will produces a "cold-classes.list" file, containing the list of all classes annotated with @Cold.
|
Sounds good to me. One question: is there any reason you use |
|
No reason, I just use to much ux systems :) So I will change to |
|
Separator changed, if it's okay for you I will merge this tomorrow. |
|
Fine for me |
|
👍 with some delay (sorry) |
As a trim is done of tokens of the splitted string, property might be defined like that: restx.cold.classes="foo.bar.MyFxirColdClass, foo.bar.MySecondColdClass,or.whithout.Spaces"
8653257 to
5f66923
Compare
|
I changed the trim, according to Xavier's remark (thanks to "push -f" :)). |
Better cold classes management. fix #160
|
@a-peyrard Just 1 simple question about I'm facing some weird classloader issue and tried to fix it with |
|
I just checked the code, and it should work for any classes, not only If it's not working you can try to add the property "restx.cold.classes" to On Fri, Oct 23, 2015 at 5:07 PM Frédéric Camblor notifications@github.com
|
|
Yep, tried with the But no worries, my problem may not be related to hot reload (I only tried to fix it with cold classes but it didn't helped) |
|
Fred, I think it would be interesting to diagnose your issue more closely to see if it's not a problem with the new cold classes approach. I will try to check that with you next week or more probably the week after, since I won't be at the office next week. |
|
I just created this repo reproducing my case (needs current restx version to compile well as it requires if you run If you retry it in |
|
I just cloned your repo, and I will try to explain what I understood. The App.class is loaded a first time by the main classloader (being AppClassLoader), and after that the I manage to make it work by commenting the line: I don't know why I used this classloader to load the cold classes, I don't know what would be the impact, to use the original classloader instead of the one creating the main restx factory. HTH |
This PR permits to manage several new things about cold classes.
AutoStartableones) in cold classes list.restx.cold.classes. The property value is a list of fqcn separated by:.META-INF/cold-classes.list. Resources will be loaded from the classloader, and every classes listed will be added to the cold classes list. The file must contains a list of fqcn, one per line.@Cold. So every classes annotated with@Coldwill be added to the resource file (thanks to a new annotation processor).