Better cold classes management #175
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 |
This comment has been minimized.
This comment has been minimized.
fcamblor
commented on restx-common/src/main/java/restx/common/processor/RestxAbstractProcessor.java
in ad583cc
Mar 31, 2015
Wow this seems really weird case ! :-) Since the Last note : why not |
This comment has been minimized.
This comment has been minimized.
Oh .. didn't noticed the code was already here before... Thus, my remarks might concern @xhanin as well :) |
This comment has been minimized.
This comment has been minimized.
Yes, this is for me. Here it's not javadoc, it's just comment, and considering the amount of comment I put in code usually people read it when there is some :) And I name the file variable, so I don't think adding an additional variable is really worth it. But if you prefer I won't object :) |
|
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"
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.
AutoStartable
ones) 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@Cold
will be added to the resource file (thanks to a new annotation processor).