Java .properties files as strongly typed classes -


Is there a way to get properties as strongly typed sections? I think code generators, but with annotation it will be very cool.

What do I mean;

  foo.properties file keyFoo = valuefoo keyBar = valuebar  

  @properties (file = " Foo.properties ") can be class foo {}  

  class foo {string getKeyFoo () {} string getKeyBar () {}} < / Code> 

If I will not start an open source project for that?

In addition to the question;

We think we have a foo.properties file with more than 10 entries; And it seems that this is used as a simple configuration file. I believe that these configuration entries should be provided in the other parts of the design with the getXXX methods as the configuration class. Then the rest of the system reaches the configuration through the provided class instead of dealing with the major names and there is no need to notice when the configuration comes. Then you can change this class with a duplicate when you are testing the caller and the dependency of the file system is removed. On the other hand, it is really nice to get all the entries in a strongly typed fashion.

So this problem is a code generation problem behind the scenario, it's nothing related to runtime, but instead of annotation code generation with an external thing was not good for me though I did more than annotation I do not know, I think it can be achieved (but I will keep in mind that annotation classes can not be produced in the form of McDowell)

Configuration is one of the files that are typed in a fixed way, it needs to declare the interface, but it fills itself in the implementation:

  public interface AppConfig increases config (long getTimeout); URL getURL (); Class getHandlerClass (); }  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -