Re: OWNER : runtime modifications

48 views
Skip to first unread message

Luigi R. Viggiano

unread,
Jun 5, 2013, 11:21:13 AM6/5/13
to Michaël Champagne, owne...@googlegroups.com
Hi Michäel 

1. I know your implementation loads the properties from the file only once, and not everytime a method of the interface is called, because you talked about doing a "hot reaload" feature. Is it kept somewhere in a "dark private secret" class? Where?


Yes.

Loading the file all the times would be a performance issue. 
 
 

 

2. If the value are kept somewhere, can't we have MBeans to access them and modify them from outside the program? :D

I am talking about javax.management.MBeanServer and org.softee.management.annotation.ManagedAttribute here.


That would be nice. There is an open issue #19 for that. It's nice to have, but I am mostly working on this thing alone. If you like to contribute some patch, I will integrate very happily if the code (and tests) meets the standards of the project.
 

 

3. In the "hot reload" implementation you are thinking of,  we need to modify the file and save it before "triggering" the reloading of modified values, if there are, right?

If we do that, the previous file values are lost. I would rather modify the "loaded" value with MBeans, but since we only have an interface with your annotations (which I like very much), we can't.


JMX bean is a different thing, but related to the hot reload. 
you change things on JMX if you don't want your changes to be persistent. If you want to alter your configuration permanently on that server, then you may want to change the file and have it reloaded automagically.
 

 

4. It would be nice to have something to support validations on values. I mean, whether the value is the default or loaded from the properties file, have some validation code attached to when the value is loaded or changed. Have you thought about that, or you'd rather let the user implement it's validation code himself? Maybe use some other annotations for validation...


Yes, this is definitely an awesome idea, and we'll implement the "Mandatory" request as a variant of the Validation, something like `@Validate(Mandatory.class)`.
 

 

5. Are we forced to match the name of the interface with the name of the properties file? It would be cool to annotate the interface with the properties file name, for more flexibility, don't you think?


No, you are not forced to do so. @Sources allows you to specify most of URL resources as source for your properties.

Plus, you can "wrap" your properties into a Config object, see "Importing properties". 
You can have several sources for a Config object as @Sources can specify many sources and @LoadPolicy can specify how those properties should be used, the importing properties also works together with this: properties will be loaded by default using the class name, then by @Sources and you can also specify properties to import programmatically. 
Properties imported have lower priority over properties loaded by `@Sources`, this means that if maxAge is specified in the imported properties AND by a file specified in @Sources, the one coming from the file will prevail over the one specified as "imported properties".

About runtime changes, this is an interesting example about imported properties, I think:

    public interface ReloadImportConfig extends Config, Reloadable {
        Integer minimumAge();
    }

    @Test
    public void testReloadWithImportedProperties() throws Throwable {
        Properties props = new Properties() {{
           setProperty("minimumAge", "18");
        }};

        ReloadImportConfig cfg = ConfigFactory.create(ReloadImportConfig.class, props);
        assertEquals(Integer.valueOf(18), cfg.minimumAge());

        props.setProperty("minimumAge", "21"); // changing props doesn't reflect to cfg immediately
        assertEquals(Integer.valueOf(18), cfg.minimumAge());

        cfg.reload(); // the config gets reloaded, so the change in props gets reflected
        assertEquals(Integer.valueOf(21), cfg.minimumAge());
    }


Know that I enjoy your OWNER project and i am very enthusiastic about it.

I'm glad to hear that. 

I might try to wrap it with my own classes to use it inside our java project at work, but I like to discuss with you about all that.

 

ps - english isn't my native language, so I hope I am not misunderstood too often  :)

Same here, no worries.

Any question, would be better to be posed via github issues (there is a question label), or on the mailing list which can be found here (and in CC):

 

Thanks and best regards,
Luigi.

Luigi Viggiano

unread,
Jun 5, 2013, 11:37:05 AM6/5/13
to owne...@googlegroups.com, Michaël Champagne, luigi.v...@newinstance.it


On Wednesday, June 5, 2013 5:21:13 PM UTC+2, Luigi R. Viggiano wrote:
Hi Michäel 

1. I know your implementation loads the properties from the file only once, and not everytime a method of the interface is called, because you talked about doing a "hot reaload" feature. Is it kept somewhere in a "dark private secret" class? Where?

I forgot to mention where: 


in the properties member instance at line #43

Luigi.
Reply all
Reply to author
Forward
0 new messages