JoeGeeky
JoeGeeky

Reputation: 3796

Strongly Typed Configuration Sections for Java

In .NET you can create strongly-typed configuration sections using build-in base classes that do a lot of the mundane heavy lifting with respect to XML Serialization/De-serialization, schema validation, type-casting, etc...

I'm working on a Java application and I'm looking for a similar capability. If there is a built-in facility for this I would prefer to not reinvent the wheel. I don't do a lot of Java so any guidance and links with examples/walk-throughs would be great.

Does anyone have any tips on how I can accomplish this using built-in Java capabilities?

Upvotes: 2

Views: 346

Answers (2)

Bruno Bieth
Bruno Bieth

Reputation: 2387

If you're using Java 8, you can use https://github.com/backuity/p2s It is fail-fast and type-safe with almost no reflection (code is generated with an annotation processor, but plays well with IDE). Note that it is read-only.

Upvotes: 0

Ronald Wildenberg
Ronald Wildenberg

Reputation: 32134

I think the closest you can get to .NET configuration sections is the Preferences API.

This is still a rather low-level approach however. Its intended use is more geared towards user preferences than actual system-wide configuration.

Another option would be Commons Configuration, which provides similar functionality, still not strongly-typed.

Upvotes: 1

Related Questions