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

Properties values runtime modifications #31

Closed
lviggiano opened this Issue Jun 5, 2013 · 9 comments

Comments

Projects
None yet
2 participants
@lviggiano
Owner

lviggiano commented Jun 5, 2013

From a private email:

I would say that the main feature I am looking forward to is changing the value of a property at runtime without editing the file.
The reason is that I'm coding a server that is deployed on many environments, each having its own unique values for many properties.
I have :

  • a default value or not, depending if it makes sense for every environment,
  • a specific starting value (per environment) written in the file,
  • a "hot" value, that I sometimes want to apply at runtime (the change may be temporary, so I might want to change it back few minutes/hours later).

This issue is also related to #19 since changing properties values at runtime, it can be nice to have a jmx bean for that too.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 5, 2013

Owner

I will implement this change asap:

I will add an interface like:

interface Mutable {
    // returns the previous value of the specified key in this property list, or null if it did not have one.
    String setProperty(String name, value);
    //the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping
    String removeProperty(String name);
}

so your interface will be declared as:

interface MyConfig extends Config, Mutable {
    @DefaultValue("18")
    Integer minAge();
}

and you can call use it as:

MyConfig cfg = Config.create(MyConfig.class);
cfg.setProperty("minAge", "21"); 

to have it immediately reflected in the object. Of course this will be coordinated by a thread lock, so basically it will wait until all other threads are not reading the property, then update it.
I will test this to make sure it works well in heavy multithreaded environment.

Owner

lviggiano commented Jun 5, 2013

I will implement this change asap:

I will add an interface like:

interface Mutable {
    // returns the previous value of the specified key in this property list, or null if it did not have one.
    String setProperty(String name, value);
    //the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping
    String removeProperty(String name);
}

so your interface will be declared as:

interface MyConfig extends Config, Mutable {
    @DefaultValue("18")
    Integer minAge();
}

and you can call use it as:

MyConfig cfg = Config.create(MyConfig.class);
cfg.setProperty("minAge", "21"); 

to have it immediately reflected in the object. Of course this will be coordinated by a thread lock, so basically it will wait until all other threads are not reading the property, then update it.
I will test this to make sure it works well in heavy multithreaded environment.

@mikeChampagne

This comment has been minimized.

Show comment
Hide comment
@mikeChampagne

mikeChampagne Jun 5, 2013

Thanks for adding this here. :) With that, OWNER api would offer every feature I need at the moment.

Do you plan on adding the jmx bean directly over the Mutable interface? I don't know if that would be significant enough in a jmx beans UI, like jvisualvm... I mean, having only two available operations (set & remove) for all my 80 properties.

And since I don't have direct access to the values, I can't write my own jxm bean, so I have to rely on your implementation. Am I right?

mikeChampagne commented Jun 5, 2013

Thanks for adding this here. :) With that, OWNER api would offer every feature I need at the moment.

Do you plan on adding the jmx bean directly over the Mutable interface? I don't know if that would be significant enough in a jmx beans UI, like jvisualvm... I mean, having only two available operations (set & remove) for all my 80 properties.

And since I don't have direct access to the values, I can't write my own jxm bean, so I have to rely on your implementation. Am I right?

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 5, 2013

Owner

Do you plan on adding the jmx bean directly over the Mutable interface? I don't know if that would be significant enough in a jmx beans UI, like jvisualvm... I mean, having only two available operations (set & remove) for all my 80 properties.

It's in the todo list, after the runtime modification it would be trivial to add this, I suppose.

And since I don't have direct access to the values, I can't write my own jxm bean, so I have to rely on your implementation. Am I right?

You are right, after the Runtime Modification (Mutable interface) implementation you should be able to write the JMX bean, if it isn't available by us.
In that case, we'd appreciate if you'll be so kind to contribute your JMX bean as a patch to our project.

Owner

lviggiano commented Jun 5, 2013

Do you plan on adding the jmx bean directly over the Mutable interface? I don't know if that would be significant enough in a jmx beans UI, like jvisualvm... I mean, having only two available operations (set & remove) for all my 80 properties.

It's in the todo list, after the runtime modification it would be trivial to add this, I suppose.

And since I don't have direct access to the values, I can't write my own jxm bean, so I have to rely on your implementation. Am I right?

You are right, after the Runtime Modification (Mutable interface) implementation you should be able to write the JMX bean, if it isn't available by us.
In that case, we'd appreciate if you'll be so kind to contribute your JMX bean as a patch to our project.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 7, 2013

Owner

Implemented the Mutable interface, see javadocs.

And unit tests here.

Probably I'll add more methods to Mutable interface, as I will do for the new interface Accessible so that all the features available by java.util.Properties methods can be used but only if the user decides that his Config object needs to (less is more, they say).

This feature will be included in the next release, 1.0.4, as soon as I complete all the necessary features, documentation, and things, to make the release ready.

Latest snapshot version (owner-1.0.4-20130607.012115-17) is available here.

Owner

lviggiano commented Jun 7, 2013

Implemented the Mutable interface, see javadocs.

And unit tests here.

Probably I'll add more methods to Mutable interface, as I will do for the new interface Accessible so that all the features available by java.util.Properties methods can be used but only if the user decides that his Config object needs to (less is more, they say).

This feature will be included in the next release, 1.0.4, as soon as I complete all the necessary features, documentation, and things, to make the release ready.

Latest snapshot version (owner-1.0.4-20130607.012115-17) is available here.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 7, 2013

Owner

Things to do before closing this:

  • review the code and the javadoc
  • update documentation (README.md or wiki maybe)
  • get some feedback :)
Owner

lviggiano commented Jun 7, 2013

Things to do before closing this:

  • review the code and the javadoc
  • update documentation (README.md or wiki maybe)
  • get some feedback :)
@mikeChampagne

This comment has been minimized.

Show comment
Hide comment
@mikeChampagne

mikeChampagne Jun 7, 2013

I'll try this soon with your snapshot and let you know if I find any possible improvements.

mikeChampagne commented Jun 7, 2013

I'll try this soon with your snapshot and let you know if I find any possible improvements.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 7, 2013

Owner

👍 feel free to post any thought.

Owner

lviggiano commented Jun 7, 2013

👍 feel free to post any thought.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jun 14, 2013

Owner

some notification mechanism can be good too.

Owner

lviggiano commented Jun 14, 2013

some notification mechanism can be good too.

@lviggiano

This comment has been minimized.

Show comment
Hide comment
@lviggiano

lviggiano Jul 5, 2013

Owner

documented here: http://owner.aeonbits.org/docs/accessible-mutable/

notification mechanism is postponed (if requested in future by somebody)

Owner

lviggiano commented Jul 5, 2013

documented here: http://owner.aeonbits.org/docs/accessible-mutable/

notification mechanism is postponed (if requested in future by somebody)

@lviggiano lviggiano closed this Jul 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment