osgi - I wrote a Liferay module. How to make it configurable by administrators? -
i have created liferay 7 module, , works well.
problem: in java source code hard-coded administrators need modify.
question: liferay way externalize settings? don't mind if server has restarted, of course ability modify settings on live running server (via gogo shell?) cool provided these settings survive server restarts.
more specifically, have module able configure api key looks "3g9828hf928rf98"
, module configure list of allowed structures looks "basic-web-content","events","inventory"
.
liferay utilizing standard osgi configuration. it's quite task documenting here, it's laid out in documentation.
in short:
@meta.ocd(id = "com.foo.bar.myappconfiguration") public interface myappconfiguration { @meta.ad( deflt = "blue", required = false ) public string favoritecolor(); @meta.ad( deflt = "red|green|blue", required = false ) public string[] validlanguages(); @meta.ad(required = false) public int itemsperpage(); }
ocd
stands objectclassdefinition. ties configuration class/object configurable object through id/pid.
ad
attributedefinition , provides hints configuration interface, auto-generated of meta type.
and when don't appearance of autogenerated ui, "only" have add localization keys labels see on screen (standard liferay translation).
you'll find lot more details on osgi configuration example on enroute, though examples found bit more complex going after configuration.
Comments
Post a Comment